2005-12-30 [colin] 1.9.100cvs115
authorColin Leroy <colin@colino.net>
Fri, 30 Dec 2005 17:36:08 +0000 (17:36 +0000)
committerColin Leroy <colin@colino.net>
Fri, 30 Dec 2005 17:36:08 +0000 (17:36 +0000)
* src/mh.c
Implement copy_msgs for a little optimization
* src/imap.c
Finish yesterday's fix

ChangeLog
PATCHSETS
configure.ac
src/imap.c
src/mh.c

index 80a4468980527f1af9b94a4d1e41abd3a7216402..f0ec38b5cefec180131d11240e74271360295afb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-12-30 [colin]     1.9.100cvs115
+
+       * src/mh.c
+               Implement copy_msgs for a little optimization
+       * src/imap.c
+               Finish yesterday's fix
+
 2005-12-29 [colin]     1.9.100cvs114
 
        * src/imap.c
 2005-12-29 [colin]     1.9.100cvs114
 
        * src/imap.c
index 612adeee4d521655c51276d3edbd5d33b0c7d798..e07892782a46920fa3254014649ee41b828ca6df 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.395.2.152 -r 1.395.2.153 src/summaryview.c;  ) > 1.9.100cvs112.patchset
 ( cvs diff -u -r 1.382.2.211 -r 1.382.2.212 src/compose.c;  ) > 1.9.100cvs113.patchset
 ( cvs diff -u -r 1.179.2.85 -r 1.179.2.86 src/imap.c;  ) > 1.9.100cvs114.patchset
 ( cvs diff -u -r 1.395.2.152 -r 1.395.2.153 src/summaryview.c;  ) > 1.9.100cvs112.patchset
 ( cvs diff -u -r 1.382.2.211 -r 1.382.2.212 src/compose.c;  ) > 1.9.100cvs113.patchset
 ( cvs diff -u -r 1.179.2.85 -r 1.179.2.86 src/imap.c;  ) > 1.9.100cvs114.patchset
+( cvs diff -u -r 1.79.2.21 -r 1.79.2.22 src/mh.c;  cvs diff -u -r 1.179.2.86 -r 1.179.2.87 src/imap.c;  ) > 1.9.100cvs115.patchset
index a94b03e120666ce5feb109e71ad5c2fe61b1bd33..10fda3c29ad8317551c77617530ed8ebd488da2a 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=100
 INTERFACE_AGE=0
 BINARY_AGE=0
 MICRO_VERSION=100
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=114
+EXTRA_VERSION=115
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index e02a2fad77e61928ae9f9b6dfda2b769daa15831..1c61729f6faa14a919c98e9bff5f588d10ca158e 100644 (file)
@@ -3118,8 +3118,9 @@ gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list,
 
        /* If old uid_next matches new uid_next we can be sure no message
           was added to the folder */
 
        /* If old uid_next matches new uid_next we can be sure no message
           was added to the folder */
-       if (( selected_folder && !session->folder_content_changed) ||
-           (!selected_folder && uid_next == item->uid_next)) {
+       debug_print("uid_next is %d and item->uid_next %d \n", 
+               uid_next, item->uid_next);
+       if (uid_next == item->uid_next) {
                nummsgs = g_slist_length(item->uid_list);
 
                /* If number of messages is still the same we
                nummsgs = g_slist_length(item->uid_list);
 
                /* If number of messages is still the same we
index 635019bb67453498125e4c7151b694ac4c318661..092d5b5421a19c96567fe6693fd8b19a1c83295b 100644 (file)
--- a/src/mh.c
+++ b/src/mh.c
@@ -81,6 +81,10 @@ static gint     mh_add_msgs          (Folder         *folder,
 static gint     mh_copy_msg            (Folder         *folder,
                                         FolderItem     *dest,
                                         MsgInfo        *msginfo);
 static gint     mh_copy_msg            (Folder         *folder,
                                         FolderItem     *dest,
                                         MsgInfo        *msginfo);
+static gint    mh_copy_msgs            (Folder         *folder, 
+                                        FolderItem     *dest, 
+                                        MsgInfoList    *msglist, 
+                                        GRelation      *relation);
 static gint     mh_remove_msg          (Folder         *folder,
                                         FolderItem     *item,
                                         gint            num);
 static gint     mh_remove_msg          (Folder         *folder,
                                         FolderItem     *item,
                                         gint            num);
@@ -154,6 +158,7 @@ FolderClass *mh_get_class(void)
                mh_class.add_msg = mh_add_msg;
                mh_class.add_msgs = mh_add_msgs;
                mh_class.copy_msg = mh_copy_msg;
                mh_class.add_msg = mh_add_msg;
                mh_class.add_msgs = mh_add_msgs;
                mh_class.copy_msg = mh_copy_msg;
+               mh_class.copy_msgs = mh_copy_msgs;
                mh_class.remove_msg = mh_remove_msg;
                mh_class.remove_all_msg = mh_remove_all_msg;
                mh_class.is_msg_changed = mh_is_msg_changed;
                mh_class.remove_msg = mh_remove_msg;
                mh_class.remove_all_msg = mh_remove_all_msg;
                mh_class.is_msg_changed = mh_is_msg_changed;
@@ -421,14 +426,33 @@ static gint mh_add_msgs(Folder *folder, FolderItem *dest, GSList *file_list,
 }
 
 static gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
 }
 
 static gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
+{
+       GSList msglist;
+
+       g_return_val_if_fail(msginfo != NULL, -1);
+
+       msglist.data = msginfo;
+       msglist.next = NULL;
+
+       return mh_copy_msgs(folder, dest, &msglist, NULL);      
+}
+
+static gint mh_copy_msgs(Folder *folder, FolderItem *dest, MsgInfoList *msglist, 
+                        GRelation *relation)
 {
        gboolean dest_need_scan = FALSE;
        gchar *srcfile;
        gchar *destfile;
        gint filemode = 0;
        FolderItemPrefs *prefs;
 {
        gboolean dest_need_scan = FALSE;
        gchar *srcfile;
        gchar *destfile;
        gint filemode = 0;
        FolderItemPrefs *prefs;
-
+       MsgInfo *msginfo = NULL;
+       gboolean remove_special_headers = FALSE;
+       MsgInfoList *cur = NULL;
        g_return_val_if_fail(dest != NULL, -1);
        g_return_val_if_fail(dest != NULL, -1);
+       g_return_val_if_fail(msglist != NULL, -1);
+       
+       msginfo = (MsgInfo *)msglist->data;
+
        g_return_val_if_fail(msginfo != NULL, -1);
 
        if (msginfo->folder == dest) {
        g_return_val_if_fail(msginfo != NULL, -1);
 
        if (msginfo->folder == dest) {
@@ -441,60 +465,69 @@ static gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
                if (dest->last_num < 0) return -1;
        }
 
                if (dest->last_num < 0) return -1;
        }
 
-       prefs = dest->prefs;
-
-       srcfile = procmsg_get_message_file(msginfo);
-       destfile = mh_get_new_msg_filename(dest);
-       if (!destfile) {
-               g_free(srcfile);
-               return -1;
-       }
-       
-       debug_print("Copying message %s%c%d to %s ...\n",
-                   msginfo->folder->path, G_DIR_SEPARATOR,
-                   msginfo->msgnum, dest->path);
-       
-
        if ((MSG_IS_QUEUED(msginfo->flags) || MSG_IS_DRAFT(msginfo->flags))
        && !folder_has_parent_of_type(dest, F_QUEUE)
        && !folder_has_parent_of_type(dest, F_DRAFT)) {
        if ((MSG_IS_QUEUED(msginfo->flags) || MSG_IS_DRAFT(msginfo->flags))
        && !folder_has_parent_of_type(dest, F_QUEUE)
        && !folder_has_parent_of_type(dest, F_DRAFT)) {
-               if (procmsg_remove_special_headers(srcfile, destfile) !=0) {
-                       g_free(srcfile);
-                       g_free(destfile);
-                       return -1;
-               }
+               /* as every msginfo comes from the same folder, it is supposed they
+                * will either match the preceding condition either all or none.
+                */
+               remove_special_headers = TRUE;
        } else if (!(MSG_IS_QUEUED(msginfo->flags) || MSG_IS_DRAFT(msginfo->flags))
        && (folder_has_parent_of_type(dest, F_QUEUE)
         || folder_has_parent_of_type(dest, F_DRAFT))) {
        } else if (!(MSG_IS_QUEUED(msginfo->flags) || MSG_IS_DRAFT(msginfo->flags))
        && (folder_has_parent_of_type(dest, F_QUEUE)
         || folder_has_parent_of_type(dest, F_DRAFT))) {
-               g_free(srcfile);
-               g_free(destfile);
                return -1;
                return -1;
-       } else if (copy_file(srcfile, destfile, TRUE) < 0) {
-               FILE_OP_ERROR(srcfile, "copy");
+       } 
+
+       prefs = dest->prefs;
+
+       for (cur = msglist; cur; cur = cur->next) {
+               msginfo = (MsgInfo *)cur->data;
+               if (!msginfo)
+                       continue;
+               srcfile = procmsg_get_message_file(msginfo);
+               destfile = mh_get_new_msg_filename(dest);
+               if (!destfile) {
+                       g_free(srcfile);
+                       continue;
+               }
+
+               debug_print("Copying message %s%c%d to %s ...\n",
+                           msginfo->folder->path, G_DIR_SEPARATOR,
+                           msginfo->msgnum, dest->path);
+
+
+               if (remove_special_headers) {
+                       if (procmsg_remove_special_headers(srcfile, destfile) !=0) {
+                               g_free(srcfile);
+                               g_free(destfile);
+                               continue;
+                       }
+               } else if (copy_file(srcfile, destfile, TRUE) < 0) {
+                       FILE_OP_ERROR(srcfile, "copy");
+                       g_free(srcfile);
+                       g_free(destfile);
+                       continue;
+               }
+               if (prefs && prefs->enable_folder_chmod && prefs->folder_chmod) {
+                       if (chmod(destfile, prefs->folder_chmod) < 0)
+                               FILE_OP_ERROR(destfile, "chmod");
+
+                       /* for mark file */
+                       filemode = prefs->folder_chmod;
+                       if (filemode & S_IRGRP) filemode |= S_IWGRP;
+                       if (filemode & S_IROTH) filemode |= S_IWOTH;
+               }
+               if (relation)
+                       g_relation_insert(relation, msginfo, GINT_TO_POINTER(dest->last_num+1));
                g_free(srcfile);
                g_free(destfile);
                g_free(srcfile);
                g_free(destfile);
-               return -1;
+               dest->last_num++;
        }
 
        dest_need_scan = mh_scan_required(dest->folder, dest);
        if (!dest_need_scan)
                dest->mtime = time(NULL);
 
        }
 
        dest_need_scan = mh_scan_required(dest->folder, dest);
        if (!dest_need_scan)
                dest->mtime = time(NULL);
 
-
-       if (prefs && prefs->enable_folder_chmod && prefs->folder_chmod) {
-               if (chmod(destfile, prefs->folder_chmod) < 0)
-                       FILE_OP_ERROR(destfile, "chmod");
-
-               /* for mark file */
-               filemode = prefs->folder_chmod;
-               if (filemode & S_IRGRP) filemode |= S_IWGRP;
-               if (filemode & S_IROTH) filemode |= S_IWOTH;
-       }
-
-       g_free(srcfile);
-       g_free(destfile);
-       dest->last_num++;
-
        return dest->last_num;
 }
 
        return dest->last_num;
 }