0.9.3claws64
authorChristoph Hohmann <reboot@gmx.ch>
Mon, 28 Jul 2003 15:47:24 +0000 (15:47 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Mon, 28 Jul 2003 15:47:24 +0000 (15:47 +0000)
* src/folder.[ch]
* src/imap.c
* src/mh.c
        return new message numbers as a GRelation instead of a GSList
        that has to be in the same order as the input list. A list
        would make it hard for IMAP to optimize oepration by sorting
        the input list. The returned list would have to be reordered
        to match the same order that input list has.

* src/gtk/gtkaspell.c
        fix missing return value, could cause a crash when garbage is
        on the stack that is used as the expected return value

ChangeLog.claws
configure.ac
src/folder.c
src/folder.h
src/gtk/gtkaspell.c
src/imap.c
src/mh.c

index 584328f92418c3943b291931f8de84fd265a29ee..f2a62cfd67d4321a357bcb79fa0a47552539ad31 100644 (file)
@@ -1,3 +1,18 @@
+2003-07-28 [christoph] 0.9.3claws64
+
+       * src/folder.[ch]
+       * src/imap.c
+       * src/mh.c
+               return new message numbers as a GRelation instead of a GSList
+               that has to be in the same order as the input list. A list
+               would make it hard for IMAP to optimize oepration by sorting
+               the input list. The returned list would have to be reordered
+               to match the same order that input list has.
+
+       * src/gtk/gtkaspell.c
+               fix missing return value, could cause a crash when garbage is
+               on the stack that is used as the expected return value
+
 2003-07-28 [paul]      0.9.3claws63
 
        * sync with 0.9.4cvs1
index a34674badc6a287dc6a5b5ce890a722dfdfb784f..169c30cc11c005e27c921d41e437f3f5f9229b11 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=3
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=62
+EXTRA_VERSION=64
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
index 10b2444ac6e71a33fe6dd0261b6fc877be463bb8..8b5eb74c3d6258cba243ade3fd2f21cb7c25f2eb 100644 (file)
@@ -1684,7 +1684,7 @@ gint folder_item_add_msgs(FolderItem *dest, GSList *file_list,
         Folder *folder;
         gint ret, num, lastnum = -1;
        GSList *file_cur;
-       MsgNumberList *newnum_list = NULL, *newnum_cur = NULL;
+       GRelation *relation;
        MsgFileInfo *fileinfo = NULL;
        gboolean folderscan = FALSE;
 
@@ -1694,10 +1694,13 @@ gint folder_item_add_msgs(FolderItem *dest, GSList *file_list,
 
         folder = dest->folder;
 
+       relation = g_relation_new(2);
+       g_relation_index(relation, 0, g_direct_hash, g_direct_equal);
+
        if (folder->klass->add_msgs != NULL) {
-               ret = folder->klass->add_msgs(folder, dest, file_list, &newnum_list);
+               ret = folder->klass->add_msgs(folder, dest, file_list, relation);
                if (ret < 0) {
-                       g_slist_free(newnum_list);
+                       g_relation_destroy(relation);
                        return ret;
                }
        } else {
@@ -1706,19 +1709,20 @@ gint folder_item_add_msgs(FolderItem *dest, GSList *file_list,
 
                        ret = folder->klass->add_msg(folder, dest, fileinfo->file, fileinfo->flags);
                        if (ret < 0) {
-                               g_slist_free(newnum_list);
+                               g_relation_destroy(relation);
                                return ret;
                        }
-                       newnum_list = g_slist_append(newnum_list, GINT_TO_POINTER(ret));
+                       g_relation_insert(relation, fileinfo, GINT_TO_POINTER(ret));
                }
        }
 
-       for (newnum_cur = newnum_list, file_cur = file_list;
-            newnum_cur != NULL && file_cur != NULL;
-            newnum_cur = g_slist_next(newnum_cur), file_cur = g_slist_next(file_cur)) {
+       for (file_cur = file_list; file_cur != NULL; file_cur = g_slist_next(file_cur)) {
+               GTuples *tuples;
 
-               num = GPOINTER_TO_INT(newnum_cur->data);
                fileinfo = (MsgFileInfo *) file_cur->data;
+               tuples = g_relation_select(relation, fileinfo, 0);
+               num = GPOINTER_TO_INT(g_tuples_index(tuples, 0, 1));
+               g_tuples_destroy(tuples);
 
                if (num >= 0) {
                        MsgInfo *newmsginfo;
@@ -1753,7 +1757,7 @@ gint folder_item_add_msgs(FolderItem *dest, GSList *file_list,
                }
        }
 
-       g_slist_free(newnum_list);
+       g_relation_destroy(relation);
 
         return lastnum;
 }
@@ -1948,10 +1952,10 @@ gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
 gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
 {
        Folder *folder;
-       GSList *newmsgnums = NULL;
-       GSList *l, *l2;
+       GSList *l;
        gint num, lastnum = -1;
        gboolean folderscan = FALSE;
+       GRelation *relation;
 
        g_return_val_if_fail(dest != NULL, -1);
        g_return_val_if_fail(msglist != NULL, -1);
@@ -1960,13 +1964,16 @@ gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
 
        g_return_val_if_fail(folder->klass->copy_msg != NULL, -1);
 
+       relation = g_relation_new(2);
+       g_relation_index(relation, 0, g_direct_hash, g_direct_equal);
+
        /* 
         * Copy messages to destination folder and 
         * store new message numbers in newmsgnums
         */
        if (folder->klass->copy_msgs != NULL) {
-               if (folder->klass->copy_msgs(folder, dest, msglist, &newmsgnums) < 0) {
-                       g_slist_free(newmsgnums);
+               if (folder->klass->copy_msgs(folder, dest, msglist, relation) < 0) {
+                       g_relation_destroy(relation);
                        return -1;
                }
        } else {
@@ -1974,7 +1981,7 @@ gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
                        MsgInfo * msginfo = (MsgInfo *) l->data;
 
                        num = folder->klass->copy_msg(folder, dest, msginfo);
-                       newmsgnums = g_slist_append(newmsgnums, GINT_TO_POINTER(num));
+                       g_relation_insert(relation, msginfo, GINT_TO_POINTER(num));
                }
        }
 
@@ -1985,12 +1992,13 @@ gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
         * Fetch new MsgInfos for new messages in dest folder,
         * add them to the msgcache and update folder message counts
         */
-       for (l = msglist, l2 = newmsgnums; 
-            l != NULL && l2 != NULL;
-            l = g_slist_next(l), l2 = g_slist_next(l2)) {
+       for (l = msglist; l != NULL; l = g_slist_next(l)) {
                MsgInfo *msginfo = (MsgInfo *) l->data;
+                GTuples *tuples;
 
-               num = GPOINTER_TO_INT(l2->data);
+                tuples = g_relation_select(relation, msginfo, 0);
+                num = GPOINTER_TO_INT(g_tuples_index(tuples, 0, 1));
+                g_tuples_destroy(tuples);
 
                if (num >= 0) {
                        MsgInfo *newmsginfo;
@@ -2029,14 +2037,14 @@ gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
         * copying was successfull and update folder
         * message counts
         */
-       l2 = newmsgnums;
-       for (l = msglist, l2 = newmsgnums;
-            l != NULL && l2 != NULL;
-            l = g_slist_next(l), l2 = g_slist_next(l2)) {
+       for (l = msglist; l != NULL; l = g_slist_next(l)) {
                MsgInfo *msginfo = (MsgInfo *) l->data;
                FolderItem *item = msginfo->folder;
+                GTuples *tuples;
 
-               num = GPOINTER_TO_INT(l2->data);
+                tuples = g_relation_select(relation, msginfo, 0);
+                num = GPOINTER_TO_INT(g_tuples_index(tuples, 0, 1));
+                g_tuples_destroy(tuples);
 
                if ((num >= 0) && (item->folder->klass->remove_msg != NULL)) {
                        item->folder->klass->remove_msg(item->folder,
@@ -2046,11 +2054,10 @@ gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
                }
        }
 
-
        if (folder->klass->finished_copy)
                folder->klass->finished_copy(folder, dest);
 
-       g_slist_free(newmsgnums);
+       g_relation_destroy(relation);
        return lastnum;
 }
 
@@ -2110,9 +2117,9 @@ gint folder_item_copy_msgs_with_dest(FolderItem *dest, GSList *msglist)
 {
        Folder *folder;
        gint num, lastnum = -1;
-       GSList *newmsgnums = NULL;
-       GSList *l, *l2;
+       GSList *l;
        gboolean folderscan = FALSE;
+       GRelation *relation;
 
        g_return_val_if_fail(dest != NULL, -1);
        g_return_val_if_fail(msglist != NULL, -1);
@@ -2121,13 +2128,16 @@ gint folder_item_copy_msgs_with_dest(FolderItem *dest, GSList *msglist)
  
        g_return_val_if_fail(folder->klass->copy_msg != NULL, -1);
 
+        relation = g_relation_new(2);
+        g_relation_index(relation, 0, g_direct_hash, g_direct_equal);
+
        /*
         * Copy messages to destination folder and 
         * store new message numbers in newmsgnums
         */
        if (folder->klass->copy_msgs != NULL) {
-               if (folder->klass->copy_msgs(folder, dest, msglist, &newmsgnums) < 0) {
-                       g_slist_free(newmsgnums);
+               if (folder->klass->copy_msgs(folder, dest, msglist, relation) < 0) {
+                       g_relation_destroy(relation);
                        return -1;
                }
        } else {
@@ -2135,7 +2145,7 @@ gint folder_item_copy_msgs_with_dest(FolderItem *dest, GSList *msglist)
                        MsgInfo * msginfo = (MsgInfo *) l->data;
 
                        num = folder->klass->copy_msg(folder, dest, msginfo);
-                       newmsgnums = g_slist_append(newmsgnums, GINT_TO_POINTER(num));
+                       g_relation_insert(relation, msginfo, GINT_TO_POINTER(num));
                }
        }
 
@@ -2146,12 +2156,13 @@ gint folder_item_copy_msgs_with_dest(FolderItem *dest, GSList *msglist)
         * Fetch new MsgInfos for new messages in dest folder,
         * add them to the msgcache and update folder message counts
         */
-       for (l = msglist, l2 = newmsgnums;
-            l != NULL && l2 != NULL;
-            l = g_slist_next(l), l2 = g_slist_next(l2)) {
+       for (l = msglist; l != NULL; l = g_slist_next(l)) {
                MsgInfo *msginfo = (MsgInfo *) l->data;
+                GTuples *tuples;
 
-               num = GPOINTER_TO_INT(l2->data);
+                tuples = g_relation_select(relation, msginfo, 0);
+                num = GPOINTER_TO_INT(g_tuples_index(tuples, 0, 1));
+                g_tuples_destroy(tuples);
 
                if (num >= 0) {
                        MsgInfo *newmsginfo;
@@ -2189,7 +2200,8 @@ gint folder_item_copy_msgs_with_dest(FolderItem *dest, GSList *msglist)
        if (folder->klass->finished_copy)
                folder->klass->finished_copy(folder, dest);
 
-       g_slist_free(newmsgnums);
+       g_relation_destroy(relation);
+
        return lastnum;
 }
 
index 21bdfb248556d1e53ec4695dda7dd7d22c200af0..6e3aaf33708666416921b8568399199c6ee2bd5c 100644 (file)
@@ -223,14 +223,14 @@ struct _FolderClass
        gint            (*add_msgs)             (Folder         *folder,
                                                 FolderItem     *dest,
                                                 GSList         *file_list,
-                                                MsgNumberList **newnum_list);
+                                                GRelation      *relation);
        gint            (*copy_msg)             (Folder         *folder,
                                                 FolderItem     *dest,
                                                 MsgInfo        *msginfo);
        gint            (*copy_msgs)            (Folder         *folder,
                                                 FolderItem     *dest,
                                                 MsgInfoList    *msglist,
-                                                MsgNumberList **newnum_list);
+                                                GRelation      *relation);
        gint            (*remove_msg)           (Folder         *folder,
                                                 FolderItem     *item,
                                                 gint            num);
index fc3bbb927a7241a82ae0f506fadefd620d846ceb..edfae15792f0dcef067eab4191e300020fa07a08 100644 (file)
@@ -303,7 +303,7 @@ static void gtkaspell_checkers_error_message (gchar *message)
 
 const char *gtkaspell_checkers_strerror(void)
 {
-       g_return_if_fail(gtkaspellcheckers);
+       g_return_val_if_fail(gtkaspellcheckers, "");
        return gtkaspellcheckers->error_message;
 }
 
index 82a523f61acf638226f8b4ca1423cdfdea69ea04..0df7e4318a27bb1af2cb067225e8c3ea2a94c685 100644 (file)
@@ -166,7 +166,7 @@ static gint imap_add_msg(Folder * folder,
                         const gchar * file, MsgFlags * flags);
 static gint imap_add_msgs(Folder * folder, FolderItem * dest,
                          GSList * file_list,
-                         MsgNumberList **newnum_list);
+                         GRelation *relation);
 
 static gint imap_copy_msg(Folder * folder,
                          FolderItem * dest, MsgInfo * msginfo);
@@ -793,7 +793,6 @@ gint imap_add_msg(Folder *folder, FolderItem *dest, const gchar *file, MsgFlags
        gint ret;
        GSList file_list;
        MsgFileInfo fileinfo;
-       MsgNumberList *msgnum_list = NULL;
 
        g_return_val_if_fail(file != NULL, -1);
 
@@ -802,13 +801,12 @@ gint imap_add_msg(Folder *folder, FolderItem *dest, const gchar *file, MsgFlags
        file_list.data = &fileinfo;
        file_list.next = NULL;
 
-       ret = imap_add_msgs(folder, dest, &file_list, &msgnum_list);
-       g_slist_free(msgnum_list);
+       ret = imap_add_msgs(folder, dest, &file_list, NULL);
        return ret;
 }
 
 gint imap_add_msgs(Folder *folder, FolderItem *dest, GSList *file_list,
-                  MsgNumberList **newnum_list)
+                  GRelation *relation)
 {
        gchar *destdir;
        IMAPSession *session;
@@ -854,7 +852,8 @@ gint imap_add_msgs(Folder *folder, FolderItem *dest, GSList *file_list,
                        return -1;
                }
 
-               *newnum_list = g_slist_append(*newnum_list, GINT_TO_POINTER(newnum));
+               if (relation != NULL)
+                       g_relation_insert(relation, fileinfo, GINT_TO_POINTER(newnum));
                if (newnum > last_uid)
                        last_uid = newnum;
        }
index dcdb58988759fc5268432751ed7cfacd4924b2d7..95cd75f1ccaaa63b6e6a97f1ced641208a4dd1bb 100644 (file)
--- a/src/mh.c
+++ b/src/mh.c
@@ -56,7 +56,7 @@ static gint mh_add_msg(Folder * folder,
                       const gchar * file,
                       MsgFlags * flags);
 static gint mh_add_msgs(Folder * folder,
-                FolderItem * dest, GSList * file_list, MsgNumberList **newnum_list);
+                FolderItem * dest, GSList * file_list, GRelation *relation);
 static gint mh_copy_msg(Folder * folder,
                        FolderItem * dest, MsgInfo * msginfo);
 static gint mh_remove_msg(Folder * folder, FolderItem * item, gint num);
@@ -316,7 +316,6 @@ gint mh_add_msg(Folder *folder, FolderItem *dest, const gchar *file, MsgFlags *f
        gint ret;
        GSList file_list;
        MsgFileInfo fileinfo;
-       MsgNumberList *newnum_list = NULL;
 
        g_return_val_if_fail(file != NULL, -1);
 
@@ -325,13 +324,12 @@ gint mh_add_msg(Folder *folder, FolderItem *dest, const gchar *file, MsgFlags *f
        file_list.data = &fileinfo;
        file_list.next = NULL;
 
-        ret = mh_add_msgs(folder, dest, &file_list, &newnum_list);
-       g_slist_free(newnum_list);
+        ret = mh_add_msgs(folder, dest, &file_list, NULL);
        return ret;
 } 
  
 gint mh_add_msgs(Folder *folder, FolderItem *dest, GSList *file_list, 
-                 MsgNumberList **newnum_list) 
+                 GRelation *relation)
 { 
        gchar *destfile;
        GSList *cur;
@@ -359,7 +357,8 @@ gint mh_add_msgs(Folder *folder, FolderItem *dest, GSList *file_list,
                                return -1;
                        }
                }
-               *newnum_list = g_slist_append(*newnum_list, GINT_TO_POINTER(dest->last_num + 1));
+               if (relation != NULL)
+                       g_relation_insert(relation, fileinfo, GINT_TO_POINTER(dest->last_num + 1));
 
                g_free(destfile);
                dest->last_num++;