if (!mlist) return;
+ folder_item_update_freeze();
+
for (cur = mlist; cur != NULL; cur = cur->next) {
msginfo = (MsgInfo *)cur->data;
if (!dest) {
dest = msginfo->to_folder;
movelist = g_slist_append(movelist, msginfo);
}
+ procmsg_msginfo_set_to_folder(msginfo, NULL);
}
if (movelist) {
folder_item_move_msgs_with_dest(dest, movelist);
g_slist_free(movelist);
}
+
+ folder_item_update_thaw();
}
void procmsg_copy_messages(GSList *mlist)
if (!mlist) return;
- /*
-
- Horrible: Scanning 2 times for every copy!
-
- hash = procmsg_to_folder_hash_table_create(mlist);
- folder_item_scan_foreach(hash);
- g_hash_table_destroy(hash);
- */
+ folder_item_update_freeze();
for (cur = mlist; cur != NULL; cur = cur->next) {
msginfo = (MsgInfo *)cur->data;
dest = msginfo->to_folder;
copylist = g_slist_append(copylist, msginfo);
}
+ procmsg_msginfo_set_to_folder(msginfo, NULL);
}
if (copylist) {
folder_item_copy_msgs_with_dest(dest, copylist);
g_slist_free(copylist);
}
+
+ folder_item_update_thaw();
}
gchar *procmsg_get_message_file_path(MsgInfo *msginfo)
full_msginfo->size = msginfo->size;
full_msginfo->mtime = msginfo->mtime;
full_msginfo->folder = msginfo->folder;
- full_msginfo->to_folder = msginfo->to_folder;
#if USE_GPGME
full_msginfo->plaintext_file = g_strdup(msginfo->plaintext_file);
full_msginfo->decryption_failed = msginfo->decryption_failed;
#endif
+ procmsg_msginfo_set_to_folder(full_msginfo, msginfo->to_folder);
return full_msginfo;
}
if (msginfo->refcnt > 0)
return;
+ if (msginfo->to_folder) {
+ msginfo->to_folder->op_count--;
+ folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
+ }
+
g_free(msginfo->fromspace);
g_free(msginfo->references);
g_free(msginfo->returnreceiptto);
procmsg_msginfo_free(tmp);
}
}
+
+/**
+ * Set the destination folder for a copy or move operation
+ *
+ * \param msginfo The message which's destination folder is changed
+ * \param to_folder The destination folder for the operation
+ */
+void procmsg_msginfo_set_to_folder(MsgInfo *msginfo, FolderItem *to_folder)
+{
+ if(msginfo->to_folder != NULL) {
+ msginfo->to_folder->op_count--;
+ folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
+ }
+ msginfo->to_folder = to_folder;
+ if(to_folder != NULL) {
+ to_folder->op_count++;
+ folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
+ }
+}
if (MSG_IS_MOVE(msginfo->flags)) {
summaryview->moved--;
changed = TRUE;
- msginfo->to_folder->op_count--;
- if (msginfo->to_folder->op_count == 0)
- folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
}
if (MSG_IS_COPY(msginfo->flags)) {
summaryview->copied--;
changed = TRUE;
- msginfo->to_folder->op_count--;
- if (msginfo->to_folder->op_count == 0)
- folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
}
changed |= summary_update_unread_children (summaryview, msginfo, TRUE);
- msginfo->to_folder = NULL;
+ procmsg_msginfo_set_to_folder(msginfo, NULL);
procmsg_msginfo_unset_flags(msginfo, MSG_DELETED, MSG_MOVE | MSG_COPY);
procmsg_msginfo_set_flags(msginfo, MSG_MARKED, 0);
summary_set_row_marks(summaryview, row);
summaryview->copied--;
changed = TRUE;
}
- if (changed && !prefs_common.immediate_exec) {
- msginfo->to_folder->op_count--;
- if (msginfo->to_folder->op_count == 0)
- folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
- }
- msginfo->to_folder = NULL;
+ procmsg_msginfo_set_to_folder(msginfo, NULL);
procmsg_msginfo_unset_flags(msginfo, MSG_DELETED, MSG_MOVE | MSG_COPY);
procmsg_msginfo_set_flags(msginfo, MSG_LOCKED, 0);
summary_set_row_marks(summaryview, row);
msginfo = gtk_ctree_node_get_row_data(ctree, row);
if (MSG_IS_DELETED(msginfo->flags)) {
- msginfo->to_folder = NULL;
+ procmsg_msginfo_set_to_folder(msginfo, NULL);
procmsg_msginfo_unset_flags(msginfo, MSG_DELETED, 0);
summaryview->deleted--;
}
if (MSG_IS_MOVE(msginfo->flags)) {
summaryview->moved--;
changed = TRUE;
- msginfo->to_folder->op_count--;
- if (msginfo->to_folder->op_count == 0)
- folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
}
if (MSG_IS_COPY(msginfo->flags)) {
summaryview->copied--;
changed = TRUE;
- msginfo->to_folder->op_count--;
- if (msginfo->to_folder->op_count == 0)
- folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
}
changed |= summary_update_unread_children (summaryview, msginfo, FALSE);
- msginfo->to_folder = NULL;
+ procmsg_msginfo_set_to_folder(msginfo, NULL);
procmsg_msginfo_unset_flags(msginfo, MSG_MARKED, MSG_MOVE | MSG_COPY);
procmsg_msginfo_set_flags(msginfo, MSG_DELETED, 0);
summaryview->deleted++;
if (MSG_IS_DELETED(msginfo->flags))
summaryview->deleted--;
if (MSG_IS_MOVE(msginfo->flags)) {
- if (!prefs_common.immediate_exec) {
- msginfo->to_folder->op_count--;
- if (msginfo->to_folder->op_count == 0)
- folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
- }
summaryview->moved--;
changed = TRUE;
}
if (MSG_IS_COPY(msginfo->flags)) {
- if (!prefs_common.immediate_exec) {
- msginfo->to_folder->op_count--;
- if (msginfo->to_folder->op_count == 0)
- folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
- }
summaryview->copied--;
changed = TRUE;
}
changed |= summary_update_unread_children (summaryview, msginfo, FALSE);
- msginfo->to_folder = NULL;
+ procmsg_msginfo_set_to_folder(msginfo, NULL);
procmsg_msginfo_unset_flags(msginfo, MSG_MARKED | MSG_DELETED, MSG_MOVE | MSG_COPY);
summary_set_row_marks(summaryview, row);
static void summary_move_row_to(SummaryView *summaryview, GtkCTreeNode *row,
FolderItem *to_folder)
{
- gboolean changed = FALSE;
GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
MsgInfo *msginfo;
g_return_if_fail(to_folder != NULL);
msginfo = gtk_ctree_node_get_row_data(ctree, row);
- if (MSG_IS_MOVE(msginfo->flags)) {
- if (!prefs_common.immediate_exec) {
- msginfo->to_folder->op_count--;
- if (msginfo->to_folder->op_count == 0) {
- folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
- changed = TRUE;
- }
- }
- }
- msginfo->to_folder = to_folder;
+ procmsg_msginfo_set_to_folder(msginfo, to_folder);
if (MSG_IS_DELETED(msginfo->flags))
summaryview->deleted--;
if (MSG_IS_COPY(msginfo->flags)) {
summaryview->copied--;
- if (!prefs_common.immediate_exec)
- msginfo->to_folder->op_count--;
}
procmsg_msginfo_unset_flags(msginfo, MSG_MARKED | MSG_DELETED, MSG_COPY);
if (!MSG_IS_MOVE(msginfo->flags)) {
procmsg_msginfo_set_flags(msginfo, 0, MSG_MOVE);
summaryview->moved++;
- changed = TRUE;
}
if (!prefs_common.immediate_exec) {
summary_set_row_marks(summaryview, row);
- if (changed) {
- msginfo->to_folder->op_count++;
- if (msginfo->to_folder->op_count == 1)
- folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
- }
}
debug_print("Message %d is set to move to %s\n",
static void summary_copy_row_to(SummaryView *summaryview, GtkCTreeNode *row,
FolderItem *to_folder)
{
- gboolean changed = FALSE;
GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
MsgInfo *msginfo;
g_return_if_fail(to_folder != NULL);
msginfo = gtk_ctree_node_get_row_data(ctree, row);
- if (MSG_IS_COPY(msginfo->flags)) {
- if (!prefs_common.immediate_exec) {
- msginfo->to_folder->op_count--;
- if (msginfo->to_folder->op_count == 0) {
- changed = TRUE;
- }
- }
- }
- msginfo->to_folder = to_folder;
+ procmsg_msginfo_set_to_folder(msginfo, to_folder);
if (MSG_IS_DELETED(msginfo->flags))
summaryview->deleted--;
if (MSG_IS_MOVE(msginfo->flags)) {
summaryview->moved--;
- if (!prefs_common.immediate_exec)
- msginfo->to_folder->op_count--;
}
procmsg_msginfo_unset_flags(msginfo, MSG_MARKED | MSG_DELETED, MSG_MOVE);
if (!MSG_IS_COPY(msginfo->flags)) {
procmsg_msginfo_set_flags(msginfo, 0, MSG_COPY);
summaryview->copied++;
- changed = TRUE;
}
if (!prefs_common.immediate_exec) {
summary_set_row_marks(summaryview, row);
- if (changed) {
- msginfo->to_folder->op_count++;
- if (msginfo->to_folder->op_count == 1)
- folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
- }
}
debug_print("Message %d is set to copy to %s\n",
msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
if (msginfo && MSG_IS_MOVE(msginfo->flags) && msginfo->to_folder) {
- if (!prefs_common.immediate_exec &&
- msginfo->to_folder->op_count > 0)
- msginfo->to_folder->op_count--;
-
summaryview->mlist =
g_slist_append(summaryview->mlist, msginfo);
gtk_ctree_node_set_row_data(ctree, node, NULL);
msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
if (msginfo && MSG_IS_COPY(msginfo->flags) && msginfo->to_folder) {
- if (!prefs_common.immediate_exec &&
- msginfo->to_folder->op_count > 0)
- msginfo->to_folder->op_count--;
-
summaryview->mlist =
g_slist_append(summaryview->mlist, msginfo);