0.9.5claws24
authorChristoph Hohmann <reboot@gmx.ch>
Sun, 21 Sep 2003 20:32:33 +0000 (20:32 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Sun, 21 Sep 2003 20:32:33 +0000 (20:32 +0000)
* src/alertpanel.c
        remove unneeded include

* src/folder.c
        clean up copy/move mess with duplicated code

* src/imap.c
        fix problem that sometimes the folder was not scanned
        also it was changed

ChangeLog.claws
configure.ac
src/alertpanel.c
src/folder.c
src/imap.c

index 048d3c5..8e04fd3 100644 (file)
@@ -1,3 +1,15 @@
+2003-09-21 [christoph] 0.9.5claws24
+
+       * src/alertpanel.c
+               remove unneeded include
+
+       * src/folder.c
+               clean up copy/move mess with duplicated code
+
+       * src/imap.c
+               fix problem that sometimes the folder was not scanned
+               also it was changed
+
 2003-09-21 [christoph] 0.9.5claws23
 
        * src/Makefile.am
index 8b3357d..3a9abf9 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=23
+EXTRA_VERSION=24
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
index 811b401..d456ea4 100644 (file)
@@ -31,7 +31,6 @@
 #include "utils.h"
 #include "gtkutils.h"
 #include "inc.h"
-#include "log.h"
 #include "logwindow.h"
 
 #define TITLE_FONT     "-*-helvetica-medium-r-normal--17-*-*-*-*-*-*-*," \
index ea9c6bf..c87d558 100644 (file)
@@ -1966,45 +1966,11 @@ gint folder_item_move_to(FolderItem *src, FolderItem *dest, FolderItem **new_ite
        return F_MOVE_OK;
 }
 
-gint folder_item_move_msg(FolderItem *dest, MsgInfo *msginfo)
-{
-       GSList *list = NULL;
-       gint ret;
-
-       list = g_slist_append(list, msginfo);
-       ret = folder_item_move_msgs(dest, list);
-       g_slist_free(list);
-       
-       return ret;
-}
-
-/*
-gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
-{
-       Folder *folder;
-       gint num;
-
-       g_return_val_if_fail(dest != NULL, -1);
-       g_return_val_if_fail(msglist != NULL, -1);
-
-       folder = dest->folder;
-       if (dest->last_num < 0) folder->scan(folder, dest);
-
-       num = folder->move_msgs_with_dest(folder, dest, msglist);
-       if (num > 0) dest->last_num = num;
-       else dest->op_count = 0;
-
-       return num;
-}
-*/
-
 /**
- * Copy a list of messages to a new folder.
- *
- * \param dest Destination folder
- * \param msglist List of messages
+ * Copy a list of message to a new folder and remove
+ * source messages if wanted
  */
-gint folder_item_move_msgs(FolderItem *dest, GSList *msglist)
+static gint do_copy_msgs(FolderItem *dest, GSList *msglist, gboolean remove_source)
 {
        Folder *folder;
        GSList *l;
@@ -2087,177 +2053,101 @@ gint folder_item_move_msgs(FolderItem *dest, GSList *msglist)
                }
        }
 
-       /*
-        * Remove source messages from their folders if
-        * copying was successfull and update folder
-        * message counts
-        */
-       for (l = msglist; l != NULL; l = g_slist_next(l)) {
-               MsgInfo *msginfo = (MsgInfo *) l->data;
-               FolderItem *item = msginfo->folder;
-                GTuples *tuples;
-
-                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,
-                                                       msginfo->folder,
-                                                       msginfo->msgnum);
-                       remove_msginfo_from_cache(item, msginfo);
+       if (remove_source) {
+               /*
+                * Remove source messages from their folders if
+                * copying was successfull and update folder
+                * message counts
+                */
+               for (l = msglist; l != NULL; l = g_slist_next(l)) {
+                       MsgInfo *msginfo = (MsgInfo *) l->data;
+                       FolderItem *item = msginfo->folder;
+                       GTuples *tuples;
+
+                       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,
+                                                               msginfo->folder,
+                                                               msginfo->msgnum);
+                               remove_msginfo_from_cache(item, msginfo);
+                       }
                }
        }
 
        if (folder->klass->finished_copy)
-               folder->klass->finished_copy(folder, dest);
+               folder->klass->finished_copy(folder, dest);
 
        g_relation_destroy(relation);
        return lastnum;
 }
 
-/*
-gint folder_item_copy_msg(FolderItem *dest, MsgInfo *msginfo)
+/**
+ * Move a message to a new folder.
+ *
+ * \param dest Destination folder
+ * \param msginfo The message
+ */
+gint folder_item_move_msg(FolderItem *dest, MsgInfo *msginfo)
 {
-       Folder *folder;
-       gint num;
+       GSList list;
 
        g_return_val_if_fail(dest != NULL, -1);
        g_return_val_if_fail(msginfo != NULL, -1);
 
-       folder = dest->folder;
-       if (dest->last_num < 0) folder->scan(folder, dest);
+       list.data = msginfo;
+       list.next = NULL;
 
-       num = folder->copy_msg(folder, dest, msginfo);
-       if (num > 0) dest->last_num = num;
+       return do_copy_msgs(dest, &list, TRUE);
+}
 
-       return num;
+/**
+ * Move a list of messages to a new folder.
+ *
+ * \param dest Destination folder
+ * \param msglist List of messages
+ */
+gint folder_item_move_msgs(FolderItem *dest, GSList *msglist)
+{
+       g_return_val_if_fail(dest != NULL, -1);
+       g_return_val_if_fail(msglist != NULL, -1);
+
+       return do_copy_msgs(dest, msglist, TRUE);
 }
-*/
 
+/**
+ * Copy a message to a new folder.
+ *
+ * \param dest Destination folder
+ * \param msginfo The message
+ */
 gint folder_item_copy_msg(FolderItem *dest, MsgInfo *msginfo)
 {
-       GSList msglist;
+       GSList list;
 
        g_return_val_if_fail(dest != NULL, -1);
        g_return_val_if_fail(msginfo != NULL, -1);
     
-       msglist.data = msginfo;
-       msglist.next = NULL;
+       list.data = msginfo;
+       list.next = NULL;
        
-       return folder_item_copy_msgs(dest, &msglist);
-}
-
-/*
-gint folder_item_copy_msgs_with_dest(FolderItem *dest, GSList *msglist)
-{
-       Folder *folder;
-       gint num;
-
-       g_return_val_if_fail(dest != NULL, -1);
-       g_return_val_if_fail(msglist != NULL, -1);
-
-       folder = dest->folder;
-       if (dest->last_num < 0) folder->scan(folder, dest);
-
-       num = folder->copy_msgs_with_dest(folder, dest, msglist);
-       if (num > 0) dest->last_num = num;
-       else dest->op_count = 0;
-
-       return num;
+       return do_copy_msgs(dest, &list, FALSE);
 }
-*/
 
+/**
+ * Copy a list of messages to a new folder.
+ *
+ * \param dest Destination folder
+ * \param msglist List of messages
+ */
 gint folder_item_copy_msgs(FolderItem *dest, GSList *msglist)
 {
-       Folder *folder;
-       gint num, lastnum = -1;
-       GSList *l;
-       gboolean folderscan = FALSE;
-       GRelation *relation;
-
        g_return_val_if_fail(dest != NULL, -1);
        g_return_val_if_fail(msglist != NULL, -1);
 
-       folder = dest->folder;
-       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, relation) < 0) {
-                       g_relation_destroy(relation);
-                       return -1;
-               }
-       } else {
-               for (l = msglist ; l != NULL ; l = g_slist_next(l)) {
-                       MsgInfo * msginfo = (MsgInfo *) l->data;
-
-                       num = folder->klass->copy_msg(folder, dest, msginfo);
-                       g_relation_insert(relation, msginfo, GINT_TO_POINTER(num));
-               }
-       }
-
-       /* 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
-        */
-       for (l = msglist; l != NULL; l = g_slist_next(l)) {
-               MsgInfo *msginfo = (MsgInfo *) l->data;
-                GTuples *tuples;
-
-                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;
-
-                       if (num == 0) {
-                               gchar *file;
-
-                               if (!folderscan) {
-                                       folder_item_scan_full(dest, FALSE);
-                                       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->klass->get_msginfo(folder, dest, num)) != NULL)) {
-                               newmsginfo = folder->klass->get_msginfo(folder, dest, num);
-                               add_msginfo_to_cache(dest, newmsginfo, msginfo);
-                               procmsg_msginfo_free(newmsginfo);
-                       } else if ((newmsginfo = msgcache_get_msg(dest->cache, num)) != NULL) {
-                               copy_msginfo_flags(msginfo, newmsginfo);
-                               procmsg_msginfo_free(newmsginfo);
-                       }
-               }
-       }
-       
-       if (folder->klass->finished_copy)
-               folder->klass->finished_copy(folder, dest);
-
-       g_relation_destroy(relation);
-
-       return lastnum;
+       return do_copy_msgs(dest, msglist, FALSE);
 }
 
 gint folder_item_remove_msg(FolderItem *item, gint num)
index 01cd4d1..30870e0 100644 (file)
@@ -63,6 +63,7 @@ typedef struct _IMAPFolderItem        IMAPFolderItem;
 #include "prefs_account.h"
 
 #define IMAP_FOLDER(obj)       ((IMAPFolder *)obj)
+#define IMAP_FOLDER_ITEM(obj)  ((IMAPFolderItem *)obj)
 #define IMAP_SESSION(obj)      ((IMAPSession *)obj)
 
 struct _IMAPFolder
@@ -976,7 +977,7 @@ static gint imap_do_copy_msgs(Folder *folder, FolderItem *dest,
        for (cur = msglist; cur != NULL; cur = g_slist_next(cur)) {
                MsgInfo *msginfo = (MsgInfo *)cur->data;
                GTuples *tuples;
-               
+
                tuples = g_relation_select(uid_mapping, 
                                           GINT_TO_POINTER(msginfo->msgnum),
                                           0);
@@ -1077,6 +1078,8 @@ gint imap_remove_msg(Folder *folder, FolderItem *item, gint uid)
                return ok;
        }
 
+       IMAP_FOLDER_ITEM(item)->uid_list = g_slist_remove(
+           IMAP_FOLDER_ITEM(item)->uid_list, numlist.data);
        dir = folder_item_get_path(item);
        if (is_dir_exist(dir))
                remove_numbered_files(dir, uid, uid);