0.8.10claws81
authorChristoph Hohmann <reboot@gmx.ch>
Tue, 4 Mar 2003 22:48:28 +0000 (22:48 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Tue, 4 Mar 2003 22:48:28 +0000 (22:48 +0000)
* src/folder.c
        o fix moving and copying when folder returns 0 for new
          message number
        o remove some code for single message copy and move
          operations and use functions for multiple messages

* src/news.c
        remove unused include

ChangeLog.claws
configure.ac
src/folder.c
src/news.c

index c55377b9b918f61a2a6d74b5031feb9f48c90935..e411893e97331b045a66b4b39eca9966c17559f7 100644 (file)
@@ -1,3 +1,14 @@
+2003-03-04 [christoph] 0.8.10claws81
+
+       * src/folder.c
+               o fix moving and copying when folder returns 0 for new
+                 message number
+               o remove some code for single message copy and move
+                 operations and use functions for multiple messages
+
+       * src/news.c
+               remove unused include
+
 2003-03-04 [paul]      0.8.10claws80
 
        * src/gtk/about.c
@@ -5,7 +16,7 @@
 
 2003-03-03 [christoph] 0.8.10claws79
 
-       * src/news.c
+       * src/news.[ch]
                have to multiply the percentage of the current fetch with
                the percentage that it has of the total fetch operation
                for correct values
index 7603ae0ef1bfab4604f8c46d008cc643e68eabb2..5690f3fb79812e5a720d8ce08e56865a7c1db60b 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=10
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws80
+EXTRA_VERSION=claws81
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index d6a88986ef97749f21f8d937599a05d34d1cfee9..3a6535cc95577f4a69e3b454ab9000b1114ae96a 100644 (file)
@@ -1684,72 +1684,14 @@ gint folder_item_move_to(FolderItem *src, FolderItem *dest, FolderItem **new_ite
 
 gint folder_item_move_msg(FolderItem *dest, MsgInfo *msginfo)
 {
-       Folder *folder;
-       gint num;
-       Folder *src_folder;
-
-       g_return_val_if_fail(dest != NULL, -1);
-       g_return_val_if_fail(msginfo != NULL, -1);
-
-       folder = dest->folder;
-
-       g_return_val_if_fail(folder->remove_msg != NULL, -1);
-       g_return_val_if_fail(folder->copy_msg != NULL, -1);
-
-       if (!dest->cache) folder_item_read_cache(dest);
-
-       src_folder = msginfo->folder->folder;
-
-       num = folder->copy_msg(folder, dest, msginfo);
-       
-       if (num > 0) {
-               MsgInfo *newmsginfo;
-    
-               /* Add new msginfo to dest folder */
-               if (NULL != (newmsginfo = folder->get_msginfo(folder, dest, num))) {
-                       newmsginfo->flags.perm_flags = msginfo->flags.perm_flags;
-                       
-                       if (dest->stype == F_OUTBOX || dest->stype == F_QUEUE  ||
-                           dest->stype == F_DRAFT  || dest->stype == F_TRASH)
-                               MSG_UNSET_PERM_FLAGS(newmsginfo->flags,
-                                                    MSG_NEW|MSG_UNREAD|MSG_DELETED);
-                       msgcache_add_msg(dest->cache, newmsginfo);
-
-                       if (MSG_IS_NEW(newmsginfo->flags))
-                               dest->new++;
-                       if (MSG_IS_UNREAD(newmsginfo->flags))
-                               dest->unread++;
-                       if (MSG_IS_UNREAD(newmsginfo->flags) && procmsg_msg_has_marked_parent(newmsginfo))
-                               dest->unreadmarked++;
-                       if (procmsg_msg_has_flagged_parent(newmsginfo, MSG_IGNORE_THREAD))
-                               procmsg_msginfo_set_flags(newmsginfo, MSG_IGNORE_THREAD, 0);
-                       dest->total++;
-                       folder_item_update(dest, F_ITEM_UPDATE_MSGCNT | F_ITEM_UPDATE_CONTENT);
-
-                       procmsg_msginfo_free(newmsginfo);
-               }
-
-               /* remove source message from it's folder */
-               if (src_folder->remove_msg) {
-                       src_folder->remove_msg(src_folder, msginfo->folder,
-                                              msginfo->msgnum);
-                       msgcache_remove_msg(msginfo->folder->cache, msginfo->msgnum);
+       GSList *list = NULL;
+       gint ret;
 
-                       if (MSG_IS_NEW(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
-                               msginfo->folder->new--;
-                       if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
-                               msginfo->folder->unread--;
-                       if (MSG_IS_UNREAD(msginfo->flags) && procmsg_msg_has_marked_parent(msginfo))
-                               msginfo->folder->unreadmarked--;
-                       msginfo->folder->total--;
-                       folder_item_update(dest, F_ITEM_UPDATE_MSGCNT | F_ITEM_UPDATE_CONTENT);
-               }
-       }
+       list = g_slist_append(list, msginfo);
+       ret = folder_item_move_msgs_with_dest(dest, list);
+       g_slist_free(list);
        
-       if (folder->finished_copy)
-               folder->finished_copy(folder, dest);
-
-       return num;
+       return ret;
 }
 
 /*
@@ -1778,7 +1720,8 @@ gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
        FolderItem *item;
        GSList *newmsgnums = NULL;
        GSList *l, *l2;
-       gint num;
+       gint num, lastnum = -1;
+       gboolean folderscan = FALSE;
 
        g_return_val_if_fail(dest != NULL, -1);
        g_return_val_if_fail(msglist != NULL, -1);
@@ -1805,7 +1748,7 @@ gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
 
        /* Read cache for dest folder */
        if (!dest->cache) folder_item_read_cache(dest);
-       
+
        /* 
         * Fetch new MsgInfos for new messages in dest folder,
         * add them to the msgcache and update folder message counts
@@ -1815,36 +1758,60 @@ gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
                MsgInfo *msginfo = (MsgInfo *) l->data;
 
                num = GPOINTER_TO_INT(l2->data);
+               l2 = g_slist_next(l2);
 
-               if (num > 0) {
+               if (num >= 0) {
                        MsgInfo *newmsginfo;
 
-                       newmsginfo = folder->get_msginfo(folder, dest, num);
-                       if (newmsginfo) {
-                               newmsginfo->flags.perm_flags = msginfo->flags.perm_flags;
-                               if (dest->stype == F_OUTBOX ||
-                                   dest->stype == F_QUEUE  ||
-                                   dest->stype == F_DRAFT  ||
-                                   dest->stype == F_TRASH)
-                                       MSG_UNSET_PERM_FLAGS(newmsginfo->flags,
-                                                            MSG_NEW|MSG_UNREAD|MSG_DELETED);
-                               msgcache_add_msg(dest->cache, newmsginfo);
-
-                               if (MSG_IS_NEW(newmsginfo->flags))
-                                       dest->new++;
-                               if (MSG_IS_UNREAD(newmsginfo->flags))
-                                       dest->unread++;
-                               if (MSG_IS_UNREAD(newmsginfo->flags) && procmsg_msg_has_marked_parent(newmsginfo))
-                                       dest->unreadmarked++;
-                               if (procmsg_msg_has_flagged_parent(newmsginfo, MSG_IGNORE_THREAD))
-                                       procmsg_msginfo_set_flags(newmsginfo, MSG_IGNORE_THREAD, 0);
-                               dest->total++;
-                               folder_item_update(dest, F_ITEM_UPDATE_MSGCNT | F_ITEM_UPDATE_CONTENT);
-
-                               procmsg_msginfo_free(newmsginfo);
+                       if (num == 0) {
+                               gchar *file;
+
+                               if (!folderscan) {
+                                       folder_item_scan(dest);
+                                       folderscan = TRUE;
+                               }
+                               file = folder_item_fetch_msg(msginfo->folder, msginfo->msgnum);
+                               num = folder_item_get_msg_num_by_file(dest, file);
+                               g_free(file);
+                       }
+
+                       if (num > lastnum)
+                               lastnum = num;
+
+                       if (num == 0)
+                               continue;
+
+                       if (!folderscan) {
+                               newmsginfo = folder->get_msginfo(folder, dest, num);
+                               if (newmsginfo) {
+                                       newmsginfo->flags.perm_flags = msginfo->flags.perm_flags;
+                                       if (dest->stype == F_OUTBOX ||
+                                           dest->stype == F_QUEUE  ||
+                                           dest->stype == F_DRAFT  ||
+                                           dest->stype == F_TRASH)
+                                               MSG_UNSET_PERM_FLAGS(newmsginfo->flags,
+                                                                    MSG_NEW|MSG_UNREAD|MSG_DELETED);
+                                       msgcache_add_msg(dest->cache, newmsginfo);
+
+                                       if (MSG_IS_NEW(newmsginfo->flags))
+                                               dest->new++;
+                                       if (MSG_IS_UNREAD(newmsginfo->flags))
+                                               dest->unread++;
+                                       if (MSG_IS_UNREAD(newmsginfo->flags) && procmsg_msg_has_marked_parent(newmsginfo))
+                                               dest->unreadmarked++;
+                                       if (procmsg_msg_has_flagged_parent(newmsginfo, MSG_IGNORE_THREAD))
+                                               procmsg_msginfo_set_flags(newmsginfo, MSG_IGNORE_THREAD, 0);
+                                       dest->total++;
+                                       folder_item_update(dest, F_ITEM_UPDATE_MSGCNT | F_ITEM_UPDATE_CONTENT);
+
+                                       procmsg_msginfo_free(newmsginfo);
+                               }
+                       } else {
+                               newmsginfo = msgcache_get_msg(dest->cache, num);
+                               procmsg_msginfo_unset_flags(newmsginfo, ~0, ~0);
+                               procmsg_msginfo_set_flags(newmsginfo, msginfo->flags.perm_flags, 0);
                        }
                }
-               l2 = g_slist_next(l2);
        }
 
        /*
@@ -1857,8 +1824,9 @@ gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
                MsgInfo *msginfo = (MsgInfo *) l->data;
 
                num = GPOINTER_TO_INT(l2->data);
+               l2 = g_slist_next(l2);
                
-               if (num > 0) {
+               if (num >= 0) {
                        item->folder->remove_msg(item->folder,
                                                 msginfo->folder,
                                                 msginfo->msgnum);
@@ -1875,8 +1843,6 @@ gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
                        msginfo->folder->total--;                       
                        folder_item_update(msginfo->folder, F_ITEM_UPDATE_MSGCNT | F_ITEM_UPDATE_CONTENT);
                }
-
-               l2 = g_slist_next(l2);
        }
 
 
@@ -1884,7 +1850,7 @@ gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
                folder->finished_copy(folder, dest);
 
        g_slist_free(newmsgnums);
-       return dest->last_num;
+       return lastnum;
 }
 
 /*
@@ -1908,51 +1874,14 @@ gint folder_item_copy_msg(FolderItem *dest, MsgInfo *msginfo)
 
 gint folder_item_copy_msg(FolderItem *dest, MsgInfo *msginfo)
 {
-       Folder *folder;
-       gint num;
-
-       g_return_val_if_fail(dest != NULL, -1);
-       g_return_val_if_fail(msginfo != NULL, -1);
-
-       folder = dest->folder;
-
-       g_return_val_if_fail(folder->copy_msg != NULL, -1);
+       GSList *list = NULL;
+       gint ret;
 
-       if (!dest->cache) folder_item_read_cache(dest);
+       list = g_slist_append(list, msginfo);
+       ret = folder_item_copy_msgs_with_dest(dest, list);
+       g_slist_free(list);
        
-       num = folder->copy_msg(folder, dest, msginfo);
-       if (num > 0) {
-               MsgInfo *newmsginfo;
-
-               if (NULL != (newmsginfo = folder->get_msginfo(folder, dest, num))) {
-                       newmsginfo->flags.perm_flags = msginfo->flags.perm_flags;
-                       if (dest->stype == F_OUTBOX ||
-                           dest->stype == F_QUEUE  ||
-                           dest->stype == F_DRAFT  ||
-                           dest->stype == F_TRASH)
-                               MSG_UNSET_PERM_FLAGS(newmsginfo->flags,
-                                                    MSG_NEW|MSG_UNREAD|MSG_DELETED);
-                       msgcache_add_msg(dest->cache, newmsginfo);
-
-                       if (MSG_IS_NEW(newmsginfo->flags))
-                               dest->new++;
-                       if (MSG_IS_UNREAD(newmsginfo->flags))
-                               dest->unread++;
-                       if (MSG_IS_UNREAD(newmsginfo->flags) && procmsg_msg_has_marked_parent(newmsginfo))
-                               dest->unreadmarked++;
-                       if (procmsg_msg_has_flagged_parent(newmsginfo, MSG_IGNORE_THREAD))
-                               procmsg_msginfo_set_flags(newmsginfo, MSG_IGNORE_THREAD, 0);
-                       dest->total++;
-                       folder_item_update(dest, F_ITEM_UPDATE_MSGCNT | F_ITEM_UPDATE_CONTENT);
-
-                       procmsg_msginfo_free(newmsginfo);
-               }                       
-       }
-
-       if (folder->finished_copy)
-               folder->finished_copy(folder, dest);
-
-       return num;
+       return ret;
 }
 
 /*
@@ -1978,9 +1907,10 @@ gint folder_item_copy_msgs_with_dest(FolderItem *dest, GSList *msglist)
 gint folder_item_copy_msgs_with_dest(FolderItem *dest, GSList *msglist)
 {
        Folder *folder;
-       gint num;
+       gint num, lastnum = -1;
        GSList *newmsgnums = NULL;
        GSList *l, *l2;
+       gboolean folderscan = FALSE;
 
        g_return_val_if_fail(dest != NULL, -1);
        g_return_val_if_fail(msglist != NULL, -1);
@@ -2012,36 +1942,60 @@ gint folder_item_copy_msgs_with_dest(FolderItem *dest, GSList *msglist)
                MsgInfo *msginfo = (MsgInfo *) l->data;
 
                num = GPOINTER_TO_INT(l2->data);
+               l2 = g_slist_next(l2);
 
-               if (num > 0) {
+               if (num >= 0) {
                        MsgInfo *newmsginfo;
 
-                       newmsginfo = folder->get_msginfo(folder, dest, num);
-                       if (newmsginfo) {
-                               newmsginfo->flags.perm_flags = msginfo->flags.perm_flags;
-                               if (dest->stype == F_OUTBOX ||
-                                   dest->stype == F_QUEUE  ||
-                                   dest->stype == F_DRAFT  ||
-                                   dest->stype == F_TRASH)
-                                       MSG_UNSET_PERM_FLAGS(newmsginfo->flags,
-                                                            MSG_NEW|MSG_UNREAD|MSG_DELETED);
-                               msgcache_add_msg(dest->cache, newmsginfo);
-
-                               if (MSG_IS_NEW(newmsginfo->flags))
-                                       dest->new++;
-                               if (MSG_IS_UNREAD(newmsginfo->flags))
-                                       dest->unread++;
-                               if (MSG_IS_UNREAD(newmsginfo->flags) && procmsg_msg_has_marked_parent(newmsginfo))
-                                       dest->unreadmarked++;
-                               if (procmsg_msg_has_flagged_parent(newmsginfo, MSG_IGNORE_THREAD))
-                                       procmsg_msginfo_set_flags(newmsginfo, MSG_IGNORE_THREAD, 0);
-                               dest->total++;
-                               folder_item_update(dest, F_ITEM_UPDATE_MSGCNT | F_ITEM_UPDATE_CONTENT);
-
-                               procmsg_msginfo_free(newmsginfo);
+                       if (num == 0) {
+                               gchar *file;
+
+                               if (!folderscan) {
+                                       folder_item_scan(dest);
+                                       folderscan = TRUE;
+                               }
+                               file = folder_item_fetch_msg(msginfo->folder, msginfo->msgnum);
+                               num = folder_item_get_msg_num_by_file(dest, file);
+                               g_free(file);
+                       }
+       
+                       if (num > lastnum)
+                               lastnum = num;
+
+                       if (num == 0)
+                               continue;
+
+                       if (!folderscan) {
+                               newmsginfo = folder->get_msginfo(folder, dest, num);
+                               if (newmsginfo) {
+                                       newmsginfo->flags.perm_flags = msginfo->flags.perm_flags;
+                                       if (dest->stype == F_OUTBOX ||
+                                           dest->stype == F_QUEUE  ||
+                                           dest->stype == F_DRAFT  ||
+                                           dest->stype == F_TRASH)
+                                               MSG_UNSET_PERM_FLAGS(newmsginfo->flags,
+                                                                    MSG_NEW|MSG_UNREAD|MSG_DELETED);
+                                       msgcache_add_msg(dest->cache, newmsginfo);
+
+                                       if (MSG_IS_NEW(newmsginfo->flags))
+                                               dest->new++;
+                                       if (MSG_IS_UNREAD(newmsginfo->flags))
+                                               dest->unread++;
+                                       if (MSG_IS_UNREAD(newmsginfo->flags) && procmsg_msg_has_marked_parent(newmsginfo))
+                                               dest->unreadmarked++;
+                                       if (procmsg_msg_has_flagged_parent(newmsginfo, MSG_IGNORE_THREAD))
+                                               procmsg_msginfo_set_flags(newmsginfo, MSG_IGNORE_THREAD, 0);
+                                       dest->total++;
+                                       folder_item_update(dest, F_ITEM_UPDATE_MSGCNT | F_ITEM_UPDATE_CONTENT);
+
+                                       procmsg_msginfo_free(newmsginfo);
+                               }
+                       } else {
+                               newmsginfo = msgcache_get_msg(dest->cache, num);
+                               procmsg_msginfo_unset_flags(newmsginfo, ~0, ~0);
+                               procmsg_msginfo_set_flags(newmsginfo, msginfo->flags.perm_flags, 0);
                        }
                }
-               l2 = g_slist_next(l2);
        }
        
        if (folder->finished_copy)
index c3a10cf929253b7be432a555d80445e484c943ae..246a3b871f125ff9a9865b1f85affa69f81146f9 100644 (file)
@@ -46,7 +46,6 @@
 #include "prefs_common.h"
 #include "prefs_account.h"
 #include "inputdialog.h"
-#include "alertpanel.h"
 #include "log.h"
 #include "progressindicator.h"
 #if USE_OPENSSL