Add function to update summary. Fix compiler warnings
authorSrinivasa Ragavan <sragavan@novell.com>
Mon, 28 Jul 2008 09:33:57 +0000 (09:33 +0000)
committerSrinivasa Ragavan <sragavan@src.gnome.org>
Mon, 28 Jul 2008 09:33:57 +0000 (09:33 +0000)
2008-07-28  Srinivasa Ragavan  <sragavan@novell.com>

* camel/camel-folder.c: Add function to update summary.
* camel/camel-vtrash-folder.c: Fix compiler warnings

svn path=/trunk/; revision=9206

camel/ChangeLog
camel/camel-folder.c
camel/camel-vtrash-folder.c

index 7fc8612..58ddd3a 100644 (file)
@@ -1,5 +1,10 @@
 2008-07-28  Srinivasa Ragavan  <sragavan@novell.com>
 
+       * camel/camel-folder.c: Add function to update summary.
+       * camel/camel-vtrash-folder.c: Fix compiler warnings
+
+2008-07-28  Srinivasa Ragavan  <sragavan@novell.com>
+
        * camel/camel-folder-summary.c: Kick off debug lines.
 
 2008-07-27  Srinivasa Ragavan  <sragavan@novell.com>
index 27a4153..1feda1a 100644 (file)
@@ -387,8 +387,6 @@ folder_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
 
                        #warning "Add a better base class function to get counts specific to normal/vee folder."
                        if (unread == -1) {
-                               int j;
-                               CamelMessageInfo *info;
 
                                if (!CAMEL_IS_VEE_FOLDER (folder)) {
                                        /* TODO: Locking? */
@@ -701,6 +699,42 @@ append_message (CamelFolder *folder, CamelMimeMessage *message,
 
 }
 
+static void
+update_summary (CamelMessageInfoBase *info)
+{
+       int unread=0, deleted=0, junk=0;
+       guint32 flags = info->flags;
+
+       d(printf("Updating summary of %s\n", info->summary->folder->full_name));
+       if (flags & CAMEL_MESSAGE_SEEN)
+               unread = 1;
+       
+       if (flags & CAMEL_MESSAGE_DELETED)
+               deleted = 1;
+
+       if (flags & CAMEL_MESSAGE_JUNK)
+               junk = 1;
+       
+       info->flags |= CAMEL_MESSAGE_FOLDER_FLAGGED;
+       info->dirty = TRUE;
+
+       if (info->summary) {
+               camel_folder_summary_touch(info->summary);
+
+               if (unread)
+                       info->summary->unread_count += unread;
+               if (deleted)
+                       info->summary->deleted_count += deleted;
+               if (junk)
+                       info->summary->junk_count += junk;
+               if (junk && !deleted)
+                       info->summary->junk_not_deleted_count += junk;
+               if (junk ||  deleted) 
+                       info->summary->visible_count -= junk ? junk : deleted;
+               info->summary->saved_count++;
+
+       }
+}
 
 /**
  * camel_folder_append_message:
@@ -723,9 +757,7 @@ camel_folder_append_message (CamelFolder *folder, CamelMimeMessage *message,
        g_return_if_fail (CAMEL_IS_FOLDER (folder));
 
        CAMEL_FOLDER_REC_LOCK(folder, lock);
-
        CF_CLASS (folder)->append_message (folder, message, info, appended_uid, ex);
-
        CAMEL_FOLDER_REC_UNLOCK(folder, lock);
 }
 
index 0924f3b..8935a5b 100644 (file)
@@ -331,7 +331,7 @@ vtrash_search_by_expression(CamelFolder *folder, const char *expression, CamelEx
                                vuid = g_malloc(strlen(uid)+9);
                                memcpy(vuid, hash, 8);
                                strcpy(vuid+8, uid);
-                               g_ptr_array_add(result, camel_pstring_strdup(vuid));
+                               g_ptr_array_add(result, (gpointer) camel_pstring_strdup(vuid));
                                g_free (vuid);
                        }
                        camel_folder_search_free(f, matches);
@@ -343,7 +343,7 @@ vtrash_search_by_expression(CamelFolder *folder, const char *expression, CamelEx
        camel_folder_free_summary (folder, infos);
        CAMEL_VEE_FOLDER_UNLOCK(folder, subfolder_lock);
 
-       g_ptr_array_foreach (uids, camel_pstring_free, NULL);
+       g_ptr_array_foreach (uids, (GFunc) camel_pstring_free, NULL);
        g_ptr_array_free(uids, TRUE);
 
        return result;
@@ -394,7 +394,7 @@ vtrash_search_by_uids(CamelFolder *folder, const char *expression, GPtrArray *ui
                                vuid = g_malloc(strlen(uid)+9);
                                memcpy(vuid, hash, 8);
                                strcpy(vuid+8, uid);
-                               g_ptr_array_add(result, camel_pstring_strdup(vuid));
+                               g_ptr_array_add(result, (gpointer) camel_pstring_strdup(vuid));
                                g_free (vuid);
                        }
                        camel_folder_search_free(f, matches);
@@ -438,7 +438,7 @@ vtrash_uid_added(CamelVTrashFolder *vf, const char *uid, CamelFolderSummary *ssu
        vinfo = (CamelVeeMessageInfo *)camel_folder_summary_uid(((CamelFolder *)vf)->summary, vuid);
        if (vinfo == NULL) {
                CamelMessageInfo *tinfo;
-               tinfo = camel_vee_summary_add((CamelVeeSummary *)((CamelFolder *)vf)->summary, ssummary, uid, hash);
+               tinfo = (CamelMessageInfo *) camel_vee_summary_add((CamelVeeSummary *)((CamelFolder *)vf)->summary, ssummary, uid, hash);
                if (tinfo) {
                        camel_folder_change_info_add_uid(((CamelVeeFolder *)vf)->changes, vuid);
                        camel_message_info_free (tinfo);
@@ -532,12 +532,11 @@ vtrash_add_folder(CamelVeeFolder *vf, CamelFolder *sub)
        }
        
        for (i=0;i<infos->len;i++) {
-               CamelMessageInfo *info;
                char *uid = infos->pdata[i];
                vtrash_uid_added((CamelVTrashFolder *)vf, uid, sub->summary, hash);
        }
        
-       g_ptr_array_foreach (infos, camel_pstring_free, NULL);
+       g_ptr_array_foreach (infos, (GFunc) camel_pstring_free, NULL);
        g_ptr_array_free (infos, TRUE);
 
        if (camel_folder_change_info_changed(vf->changes)) {