Changeset 1845

Show
Ignore:
Timestamp:
04/27/07 13:44:14
Author:
pvanhoof
Message:

unread and read counts of folders

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libtinymail-camel/camel-lite/camel/camel-folder.c

    r1706 r1845  
    320320        int unread = -1, deleted = 0, junked = 0, visible = 0, count = -1; 
    321321 
    322         for (i=0;i<args->argc;i++) { 
    323                 CamelArgGet *arg = &args->argv[i]; 
    324  
    325                 tag = arg->tag; 
    326  
    327                 switch (tag & CAMEL_ARG_TAG) { 
    328                         /* CamelObject args */ 
     322        for (i=0; i < args->argc; i++)  
     323        { 
     324          CamelArgGet *arg = &args->argv[i]; 
     325 
     326          tag = arg->tag; 
     327 
     328          switch (tag & CAMEL_ARG_TAG)  
     329          { 
     330                /* CamelObject args */ 
    329331                case CAMEL_OBJECT_ARG_DESCRIPTION: 
    330332                        if (folder->description == NULL) 
     
    351353                case CAMEL_FOLDER_ARG_UNREAD: 
    352354                case CAMEL_FOLDER_ARG_DELETED: 
    353                         /* This is so we can get the values atomically, and also so we can calculate them only once */ 
     355 
     356                        /* This is so we can get the values atomically, and also  
     357                         * so we can calculate them only once */ 
     358 
    354359                        if (unread == -1) { 
    355360                                int j; 
     
    358363                                /* TODO: Locking? */ 
    359364                                unread = 0; 
    360                                 count = camel_folder_summary_count(folder->summary); 
    361                                 for (j=0; j<count; j++)  
     365                                count = camel_folder_summary_count (folder->summary); 
     366                                for (j=0; j < count; j++)  
    362367                                { 
    363                                         info = camel_folder_summary_index(folder->summary, j); 
     368                                        info = camel_folder_summary_index (folder->summary, j); 
    364369                                        if (info)  
    365370                                        { 
    366                                                 guint32 flags = camel_message_info_flags(info); 
    367  
    368                                                 if ((flags & CAMEL_MESSAGE_SEEN) == 0) 
    369                                                         unread++; 
     371                                                guint32 flags = camel_message_info_flags (info); 
     372 
    370373                                                if (flags & CAMEL_MESSAGE_DELETED) 
    371374                                                        deleted++; 
     375                                                else 
     376                                                        if ((flags & CAMEL_MESSAGE_SEEN) == 0) 
     377                                                                unread++; 
     378 
    372379                                                camel_message_info_free(info); 
    373380                                        } 
     
    410417                default: 
    411418                        continue; 
    412                
    413  
    414                arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE; 
     419         
     420 
     421          arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE; 
    415422        } 
    416423 
  • trunk/libtinymail-camel/tny-camel-folder.c

    r1836 r1845  
    173173                { 
    174174                        guint32 flags = camel_message_info_flags(info); 
    175                         if ((flags & CAMEL_MESSAGE_SEEN) == 0
     175                        if ((flags & CAMEL_MESSAGE_DELETED) && (flags & CAMEL_MESSAGE_SEEN)
    176176                                priv->unread_length++; 
    177177                        priv->cached_length++; 
     
    213213                           unread messages (yes I know it sucks, but get_unread_msg_cnt 
    214214                           walks the entire summary to count the unread ones). 
    215  
    216215                           TNY TODO: a better solution for this */ 
    217  
    218216                        priv->unread_length = camel_folder_get_unread_message_count (priv->folder); 
    219217                        priv->unread_sync = 0; 
     
    711709        GError *err; 
    712710        TnySessionCamel *session; 
    713         guint oldlen, oldurlen; 
    714711} RefreshFolderInfo; 
    715712 
     
    740737        TnyFolder *self = info->self; 
    741738        TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 
     739        TnyFolderChange *change = tny_folder_change_new (self); 
    742740 
    743741        if (info->callback) 
    744742                info->callback (info->self, info->cancelled, &info->err, info->user_data); 
    745743 
    746         if (info->oldlen != priv->cached_length || info->oldurlen != priv->unread_length) 
    747         { 
    748                 TnyFolderChange *change = tny_folder_change_new (self); 
    749                 if (info->oldlen != priv->cached_length) 
    750                         tny_folder_change_set_new_all_count (change, priv->cached_length); 
    751                 if (info->oldurlen != priv->unread_length) 
    752                         tny_folder_change_set_new_unread_count (change, priv->unread_length); 
    753                 notify_folder_observers_about (self, change); 
    754                 g_object_unref (change); 
    755         } 
     744        tny_folder_change_set_new_all_count (change, priv->cached_length); 
     745        tny_folder_change_set_new_unread_count (change, priv->unread_length); 
     746        notify_folder_observers_about (self, change); 
     747        g_object_unref (change); 
    756748 
    757749        return FALSE; 
     
    970962 
    971963        info = g_slice_new (RefreshFolderInfo); 
    972         info->oldlen = priv->cached_length; 
    973         info->oldurlen = priv->unread_length; 
    974964        info->session = TNY_FOLDER_PRIV_GET_SESSION (priv); 
    975965        info->err = NULL; 
     
    10311021        priv->cached_length = camel_folder_get_message_count (priv->folder);     
    10321022        if (G_LIKELY (priv->folder) && CAMEL_IS_FOLDER (priv->folder) && G_LIKELY (priv->has_summary_cap)) 
    1033                 priv->unread_length = (guint)camel_folder_get_unread_message_count (priv->folder); 
     1023                priv->unread_length = (guint) camel_folder_get_unread_message_count (priv->folder); 
    10341024 
    10351025        if (camel_exception_is_set (&ex)) 
     
    10901080        tny_list_prepend (headers, (GObject*)header); 
    10911081 
    1092         if ((flags & CAMEL_MESSAGE_SEEN) == 0) 
    1093                 priv->unread_length++; 
    1094  
    10951082        g_object_unref (G_OBJECT (header)); 
    1096  
    1097         priv->cached_length++; 
    10981083 
    10991084        return; 
     
    11131098        CamelException ex = CAMEL_EXCEPTION_INITIALISER; 
    11141099        FldAndPriv *ptr = NULL; 
    1115         guint oldlen = priv->cached_length; 
    1116         guint oldurlen = priv->unread_length; 
    11171100 
    11181101        g_assert (TNY_IS_LIST (headers)); 
     
    11531136 
    11541137        if (priv->folder && CAMEL_IS_FOLDER (priv->folder)) 
    1155         { 
    1156                 priv->cached_length = 0; 
    1157                 priv->unread_length = 0; 
    1158                 g_ptr_array_foreach (priv->folder->summary->messages, add_message_with_uid, ptr); 
    1159         } 
     1138                g_ptr_array_foreach (priv->folder->summary->messages,  
     1139                        add_message_with_uid, ptr); 
    11601140 
    11611141        g_slice_free (FldAndPriv, ptr); 
     
    11631143        g_object_unref (G_OBJECT (headers)); 
    11641144        g_static_rec_mutex_unlock (priv->folder_lock); 
    1165  
    1166         if (oldlen != priv->cached_length || oldurlen != priv->unread_length) 
    1167         { 
    1168                 TnyFolderChange *change = tny_folder_change_new (self); 
    1169                 if (oldlen != priv->cached_length) 
    1170                         tny_folder_change_set_new_all_count (change, priv->cached_length); 
    1171                 if (oldurlen != priv->unread_length) 
    1172                         tny_folder_change_set_new_unread_count (change, priv->unread_length); 
    1173                 notify_folder_observers_about (self, change); 
    1174                 g_object_unref (change); 
    1175         } 
    11761145 
    11771146        _tny_session_stop_operation (TNY_FOLDER_PRIV_GET_SESSION (priv)); 
     
    28432812        TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 
    28442813        guint newlen, newurlen; 
     2814        TnyFolderChange *change; 
     2815 
     2816 
     2817        /* TODO: This causes a memory peak at the application's startup. 
     2818         * We can improve this by only reading the unread and read counts 
     2819         * from the summary.mmap file (in camel-lite). */ 
    28452820 
    28462821        g_static_rec_mutex_lock (priv->folder_lock); 
    2847  
    28482822        if (!priv->folder || !priv->loaded || !CAMEL_IS_FOLDER (priv->folder)) 
    28492823                if (!load_folder_no_lock (priv))  
     
    28522826                        return; 
    28532827                } 
    2854  
    28552828        newurlen = camel_folder_get_unread_message_count (priv->folder); 
    28562829        newlen = camel_folder_get_message_count (priv->folder); 
    2857  
    28582830        g_static_rec_mutex_unlock (priv->folder_lock); 
    28592831 
    2860  
    2861         if (newlen != priv->cached_length || newurlen != priv->unread_length) 
    2862         { 
    2863                 TnyFolderChange *change = tny_folder_change_new (self); 
    2864  
    2865                 if (newlen != priv->cached_length)  
    2866                 { 
    2867                         priv->cached_length = newlen; 
    2868                         tny_folder_change_set_new_all_count (change, priv->cached_length); 
    2869                 } 
    2870  
    2871  
    2872                 if (newurlen != priv->unread_length)  
    2873                 { 
    2874                         priv->unread_length = newurlen; 
    2875                         tny_folder_change_set_new_unread_count (change, priv->unread_length); 
    2876                 } 
    2877  
    2878                 notify_folder_observers_about (self, change); 
    2879                 g_object_unref (change); 
    2880         } 
    2881  
     2832        change = tny_folder_change_new (self); 
     2833        priv->cached_length = newlen; 
     2834        tny_folder_change_set_new_all_count (change, priv->cached_length); 
     2835        priv->unread_length = newurlen; 
     2836        tny_folder_change_set_new_unread_count (change, priv->unread_length); 
     2837        notify_folder_observers_about (self, change); 
     2838        g_object_unref (change); 
     2839 
     2840        _tny_camel_folder_check_uncache ((TnyCamelFolder*)self, priv); 
    28822841 
    28832842        return FALSE; 
  • trunk/libtinymailui-gtk/tny-gtk-folder-store-tree-model.c

    r1788 r1845  
    8686                        folder, -1); 
    8787 
     88                /* TODO: This causes a memory peak at the application's startup. 
     89                *Also look at tny-camel-folder:c:2818... for more information */ 
     90 
     91                tny_folder_poke_status (TNY_FOLDER (folder)); 
     92 
    8893                recurse_folders_async (hlrp->self, folder, tree_iter); 
    8994 
     
    163168 
    164169                recurse_folders_sync (self, folder, &tree_iter); 
     170 
     171 
     172                /* TODO: This causes a memory peak at the application's startup. 
     173                *Also look at tny-camel-folder:c:2818... for more information */ 
     174 
     175                tny_folder_poke_status (TNY_FOLDER (folder)); 
    165176 
    166177                g_object_unref (G_OBJECT (folder));