From: Christoph Hohmann Date: Sun, 21 Sep 2003 20:32:33 +0000 (+0000) Subject: 0.9.5claws24 X-Git-Tag: ch_branch_last_merge~16 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=f220529f55ed7cff218ee1ad1ab182c3b6d4145a 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 --- diff --git a/ChangeLog.claws b/ChangeLog.claws index 048d3c576..8e04fd3c1 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -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 diff --git a/configure.ac b/configure.ac index 8b3357df4..3a9abf9d3 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/src/alertpanel.c b/src/alertpanel.c index 811b4014b..d456ea4ef 100644 --- a/src/alertpanel.c +++ b/src/alertpanel.c @@ -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-*-*-*-*-*-*-*," \ diff --git a/src/folder.c b/src/folder.c index ea9c6bfdd..c87d558b8 100644 --- a/src/folder.c +++ b/src/folder.c @@ -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) diff --git a/src/imap.c b/src/imap.c index 01cd4d1d3..30870e099 100644 --- a/src/imap.c +++ b/src/imap.c @@ -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);