From: Christoph Hohmann Date: Tue, 4 Mar 2003 22:48:28 +0000 (+0000) Subject: 0.8.10claws81 X-Git-Tag: rel_0_8_11~40 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=144f79df064de199c125ceeca2c2a31301776ff6;hp=30e85ee1b2bf06cd7bb3ae575676eb653576b433 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 --- diff --git a/ChangeLog.claws b/ChangeLog.claws index c55377b9b..e411893e9 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -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 diff --git a/configure.ac b/configure.ac index 7603ae0ef..5690f3fb7 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/src/folder.c b/src/folder.c index d6a88986e..3a6535cc9 100644 --- a/src/folder.c +++ b/src/folder.c @@ -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) diff --git a/src/news.c b/src/news.c index c3a10cf92..246a3b871 100644 --- a/src/news.c +++ b/src/news.c @@ -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