* configure.in
authorChristoph Hohmann <reboot@gmx.ch>
Sat, 16 Mar 2002 22:38:54 +0000 (22:38 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Sat, 16 Mar 2002 22:38:54 +0000 (22:38 +0000)
        add --with-compiler-flags option
        (only for developer hacking)
* src/mh.c
* src/procmsg.[ch]
* src/summaryview.c
        try to make folder-stats and flag handling more
        independent from the summaryview. msgcounts
        are only set when the folder is opened and
        procmsg_msginfo_(un)set_flags will handle it
        later and summaryview will get the values
        from the folder.

ChangeLog.claws
configure.in
src/mh.c
src/procmsg.c
src/procmsg.h
src/summaryview.c

index 3f3ea9d..942eef4 100644 (file)
@@ -1,3 +1,18 @@
+2002-03-16 [christoph] 0.7.4claws15
+
+       * configure.in
+               add --with-compiler-flags option
+               (only for developer hacking)
+       * src/mh.c
+       * src/procmsg.[ch]
+       * src/summaryview.c
+               try to make folder-stats and flag handling more
+               independent from the summaryview. msgcounts
+               are only set when the folder is opened and
+               procmsg_msginfo_(un)set_flags will handle it
+               later and summaryview will get the values
+               from the folder.
+
 2002-03-16 [paul]      0.7.4claws14
 
        * src/messageview.c
index 6a2f374..8f310da 100644 (file)
@@ -69,6 +69,11 @@ case "$target" in
        ;;
 esac
 
+dnl add additional parameters
+AC_ARG_WITH(compiler-flags,
+    [  --with-compiler-flags=FLAGS  add parameters to the compiler command],
+    CFLAGS="$CFLAGS $withval")
+
 dnl for gettext
 ALL_LINGUAS="cs de el es fr hr it ja ko nl pl pt_BR ru sv"
 AM_GNU_GETTEXT
index f2bb0fb..81184b3 100644 (file)
--- a/src/mh.c
+++ b/src/mh.c
@@ -652,6 +652,7 @@ gint mh_copy_msgs_with_dest(Folder *folder, FolderItem *dest, GSList *msglist)
 gint mh_remove_msg(Folder *folder, FolderItem *item, gint num)
 {
        gchar *file;
+       MsgInfo *msginfo;
 
        g_return_val_if_fail(item != NULL, -1);
 
@@ -664,6 +665,15 @@ gint mh_remove_msg(Folder *folder, FolderItem *item, gint num)
                return -1;
        }
 
+       if(msginfo = g_new0(MsgInfo, 1)) {
+               msginfo->msgnum = num;
+               msginfo->flags.perm_flags = MSG_REALLY_DELETED;
+               msginfo->folder = item;
+
+               procmsg_msginfo_write_flags(msginfo);
+               g_free(msginfo);
+       }
+       
        g_free(file);
        return 0;
 }
index d7f5e89..138077e 100644 (file)
@@ -465,8 +465,12 @@ static GHashTable *procmsg_read_mark_file(const gchar *folder)
 
                flags = g_new0(MsgFlags, 1);
                flags->perm_flags = perm_flags;
-
-               g_hash_table_insert(mark_table, GUINT_TO_POINTER(num), flags);
+    
+               if(!MSG_IS_REALLY_DELETED(*flags)) {
+                       g_hash_table_insert(mark_table, GUINT_TO_POINTER(num), flags);
+               } else {
+                       g_hash_table_remove(mark_table, GUINT_TO_POINTER(num));
+               }
        }
 
        fclose(fp);
@@ -540,7 +544,7 @@ GNode *procmsg_get_thread_tree(GSList *mlist)
                                parent = root;
                        } else {
                                if(MSG_IS_IGNORE_THREAD(((MsgInfo *)parent->data)->flags)) {
-                                       MSG_SET_PERM_FLAGS(msginfo->flags, MSG_IGNORE_THREAD);
+                                       procmsg_msginfo_set_flags(msginfo, MSG_IGNORE_THREAD, 0);
                                }
                        }
                }
@@ -571,7 +575,7 @@ GNode *procmsg_get_thread_tree(GSList *mlist)
                                (parent, parent->children, node);
                        /* CLAWS: ignore thread */
                        if(MSG_IS_IGNORE_THREAD(((MsgInfo *)parent->data)->flags)) {
-                               MSG_SET_PERM_FLAGS(msginfo->flags, MSG_IGNORE_THREAD);
+                               procmsg_msginfo_set_flags(msginfo, MSG_IGNORE_THREAD, 0);
                        }
                }
                node = next;
@@ -602,7 +606,7 @@ GNode *procmsg_get_thread_tree(GSList *mlist)
                                g_node_append(parent, node);
                                /* CLAWS: ignore thread */
                                if(MSG_IS_IGNORE_THREAD(((MsgInfo *)parent->data)->flags)) {
-                                       MSG_SET_PERM_FLAGS(msginfo->flags, MSG_IGNORE_THREAD);
+                                       procmsg_msginfo_set_flags(msginfo, MSG_IGNORE_THREAD, 0);
                                }
                        }
                }                                       
@@ -1224,3 +1228,122 @@ gint procmsg_send_message_queue(const gchar *file)
 
        return (newsval != 0 ? newsval : mailval);
 }
+
+#define CHANGE_FLAGS(msginfo) \
+{ \
+if (msginfo->folder->folder->change_flags != NULL) \
+msginfo->folder->folder->change_flags(msginfo->folder->folder, \
+                                     msginfo->folder, \
+                                     msginfo); \
+}
+
+void procmsg_msginfo_set_flags(MsgInfo *msginfo, MsgPermFlags perm_flags, MsgTmpFlags tmp_flags)
+{
+       gboolean changed = FALSE;
+       FolderItem *item = msginfo->folder;
+
+       debug_print(_("Setting flags for message %d in folder %s\n"), msginfo->msgnum, item->path);
+
+       /* if new flag is set */
+       if((perm_flags & MSG_NEW) && !MSG_IS_NEW(msginfo->flags) &&
+          !MSG_IS_IGNORE_THREAD(msginfo->flags)) {
+               item->new++;
+               changed = TRUE;
+       }
+
+       /* if unread flag is set */
+       if((perm_flags & MSG_UNREAD) && !MSG_IS_UNREAD(msginfo->flags) &&
+          !MSG_IS_IGNORE_THREAD(msginfo->flags)) {
+               item->unread++;
+               changed = TRUE;
+       }
+
+       /* if ignore thread flag is set */
+       if((perm_flags & MSG_IGNORE_THREAD) && !MSG_IS_IGNORE_THREAD(msginfo->flags)) {
+               if(MSG_IS_NEW(msginfo->flags) || (perm_flags & MSG_NEW)) {
+                       item->new--;
+                       changed = TRUE;
+               }
+               if(MSG_IS_UNREAD(msginfo->flags) || (perm_flags & MSG_UNREAD)) {
+                       item->unread--;
+                       changed = TRUE;
+               }
+       }
+
+       if (MSG_IS_IMAP(msginfo->flags))
+               imap_msg_set_perm_flags(msginfo, perm_flags);
+
+       msginfo->flags.perm_flags |= perm_flags;
+       msginfo->flags.tmp_flags |= tmp_flags;
+
+       if(changed) {
+               folderview_update_item(item, FALSE);
+       }
+       CHANGE_FLAGS(msginfo);
+       procmsg_msginfo_write_flags(msginfo);
+}
+
+void procmsg_msginfo_unset_flags(MsgInfo *msginfo, MsgPermFlags perm_flags, MsgTmpFlags tmp_flags)
+{
+       gboolean changed = FALSE;
+       FolderItem *item = msginfo->folder;
+       
+       debug_print(_("Unsetting flags for message %d in folder %s\n"), msginfo->msgnum, item->path);
+
+       /* if new flag is unset */
+       if((perm_flags & MSG_NEW) && MSG_IS_NEW(msginfo->flags) &&
+          !MSG_IS_IGNORE_THREAD(msginfo->flags)) {
+               item->new--;
+               changed = TRUE;
+       }
+
+       /* if unread flag is unset */
+       if((perm_flags & MSG_UNREAD) && MSG_IS_UNREAD(msginfo->flags) &&
+          !MSG_IS_IGNORE_THREAD(msginfo->flags)) {
+               item->unread--;
+               changed = TRUE;
+       }
+
+       /* if ignore thread flag is unset */
+       if((perm_flags & MSG_IGNORE_THREAD) && !MSG_IS_IGNORE_THREAD(msginfo->flags)) {
+               if(MSG_IS_NEW(msginfo->flags) || (perm_flags & MSG_NEW)) {
+                       item->new++;
+                       changed = TRUE;
+               }
+               if(MSG_IS_UNREAD(msginfo->flags) || (perm_flags & MSG_UNREAD)) {
+                       item->unread++;
+                       changed = TRUE;
+               }
+       }
+
+       if (MSG_IS_IMAP(msginfo->flags))
+               imap_msg_unset_perm_flags(msginfo, perm_flags);
+
+       msginfo->flags.perm_flags &= ~perm_flags;
+       msginfo->flags.tmp_flags &= ~tmp_flags;
+
+       if(changed) {
+               folderview_update_item(item, FALSE);
+       }
+       CHANGE_FLAGS(msginfo);
+       procmsg_msginfo_write_flags(msginfo);
+}
+
+void procmsg_msginfo_write_flags(MsgInfo *msginfo)
+{
+       gchar *destdir;
+       FILE *fp;
+
+       destdir = folder_item_get_path(msginfo->folder);
+       if (!is_dir_exist(destdir))
+               make_dir_hier(destdir);
+
+       if ((fp = procmsg_open_mark_file(destdir, TRUE))) {
+               procmsg_write_flags(msginfo, fp);
+               fclose(fp);
+       } else {
+               g_warning(_("Can't open mark file.\n"));
+       }
+       
+       g_free(destdir);
+}
index 03fced0..eddd6a2 100644 (file)
@@ -122,6 +122,9 @@ typedef enum
 #define MSG_SET_COLORLABEL_VALUE(msg, val) \
        MSG_SET_PERM_FLAGS(msg, ((((guint)(val)) & 7) << MSG_CLABEL_SBIT))
 
+#define MSG_COLORLABEL_TO_FLAGS(val) ((((guint)(val)) & 7) << MSG_CLABEL_SBIT)
+#define MSG_COLORLABEL_FROM_FLAGS(val) (val >> MSG_CLABEL_SBIT)
+
 #define MSG_IS_MOVE(msg)               (((msg).tmp_flags & MSG_MOVE) != 0)
 #define MSG_IS_COPY(msg)               (((msg).tmp_flags & MSG_COPY) != 0)
 
@@ -252,4 +255,11 @@ gint procmsg_cmp_msgnum_for_sort   (gconstpointer   a,
                                         gconstpointer   b);
 gint procmsg_send_message_queue                (const gchar *file);
 
+void procmsg_msginfo_set_flags         (MsgInfo *msginfo,
+                                        MsgPermFlags perm_flags,
+                                         MsgTmpFlags tmp_flags);
+void procmsg_msginfo_unset_flags       (MsgInfo *msginfo,
+                                        MsgPermFlags perm_flags,
+                                         MsgTmpFlags tmp_flags);
+
 #endif /* __PROCMSG_H__ */
index adf2f5a..67e0b3a 100644 (file)
@@ -844,6 +844,12 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item,
 
        g_slist_free(mlist);
 
+       summaryview->folder_item->new    = summaryview->newmsgs;
+       summaryview->folder_item->unread = summaryview->unread;
+       summaryview->folder_item->total  = summaryview->messages;
+       folderview_update_msg_num(summaryview->folderview,
+                                 summaryview->folderview->opened);
+
        summary_write_cache(summaryview);
 
        gtk_signal_handler_unblock_by_data(GTK_OBJECT(ctree), summaryview);
@@ -1662,6 +1668,10 @@ static void summary_status_show(SummaryView *summaryview)
                return;
        }
 
+       summaryview->newmsgs    = summaryview->folder_item->new;
+       summaryview->unread     = summaryview->folder_item->unread;
+       summaryview->messages   = summaryview->folder_item->total;
+
        rowlist = GTK_CLIST(summaryview->ctree)->selection;
        for (cur = rowlist; cur != NULL; cur = cur->next) {
                msginfo = gtk_ctree_node_get_row_data
@@ -1735,13 +1745,6 @@ static void summary_status_show(SummaryView *summaryview)
        }
        gtk_label_set(GTK_LABEL(summaryview->statlabel_msgs), str);
        g_free(str);
-
-       summaryview->folder_item->new    = summaryview->newmsgs;
-       summaryview->folder_item->unread = summaryview->unread;
-       summaryview->folder_item->total  = summaryview->messages;
-
-       folderview_update_msg_num(summaryview->folderview,
-                                 summaryview->folderview->opened);
 }
 
 static void summary_set_column_titles(SummaryView *summaryview)
@@ -2297,19 +2300,16 @@ static void summary_display_msg_full(SummaryView *summaryview,
        }
        g_free(filename);
 
+/* NOT NEEDED ANYMORE
        if (MSG_IS_NEW(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
                summaryview->newmsgs--;
        if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
                summaryview->unread--;
-       if (MSG_IS_NEW(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags) || 
-           MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags)) {
-               MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_NEW | MSG_UNREAD);
-               if (MSG_IS_IMAP(msginfo->flags))
-                       imap_msg_unset_perm_flags(msginfo, MSG_NEW | MSG_UNREAD);
-               summary_set_row_marks(summaryview, row);
-               gtk_clist_thaw(GTK_CLIST(ctree));
-               summary_status_show(summaryview);
-       }
+*/
+       procmsg_msginfo_unset_flags(msginfo, MSG_NEW | MSG_UNREAD, 0);
+       summary_set_row_marks(summaryview, row);
+       gtk_clist_thaw(GTK_CLIST(ctree));
+       summary_status_show(summaryview);
 
        flags = msginfo->flags;
 
@@ -2337,14 +2337,6 @@ static void summary_display_msg_full(SummaryView *summaryview,
                gtkut_ctree_node_move_if_on_the_edge(ctree, row);
        }
 
-       if (MSG_IS_NEW(msginfo->flags) || MSG_IS_UNREAD(msginfo->flags) ||
-           (MSG_IS_MIME(msginfo->flags) - MSG_IS_MIME(flags) != 0)) {
-               MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_NEW | MSG_UNREAD);
-               CHANGE_FLAGS(msginfo);
-               summary_set_row_marks(summaryview, row);
-               gtk_clist_thaw(GTK_CLIST(ctree));
-               summary_status_show(summaryview);
-       }
        summary_set_menu_sensitive(summaryview);
        main_window_set_toolbar_sensitive(summaryview->mainwin);
 
@@ -2707,12 +2699,8 @@ static void summary_mark_row(SummaryView *summaryview, GtkCTreeNode *row)
                        folderview_update_item(msginfo->to_folder, 0);
        }
        msginfo->to_folder = NULL;
-       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_DELETED);
-       MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_MOVE | MSG_COPY);
-       MSG_SET_PERM_FLAGS(msginfo->flags, MSG_MARKED);
-       if (MSG_IS_IMAP(msginfo->flags))
-               imap_msg_set_perm_flags(msginfo, MSG_MARKED);
-       CHANGE_FLAGS(msginfo);
+       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);
        debug_print(_("Message %s/%d is marked\n"), msginfo->folder->path, msginfo->msgnum);
 }
@@ -2741,12 +2729,8 @@ static void summary_lock_row(SummaryView *summaryview, GtkCTreeNode *row)
                        folderview_update_item(msginfo->to_folder, 0);
        }
        msginfo->to_folder = NULL;
-       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_DELETED);
-       MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_MOVE | MSG_COPY);
-       MSG_SET_PERM_FLAGS(msginfo->flags, MSG_LOCKED);
-       if (MSG_IS_IMAP(msginfo->flags))
-               imap_msg_set_perm_flags(msginfo, MSG_LOCKED);
-       CHANGE_FLAGS(msginfo);
+       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);
        debug_print(_("Message %d is locked\n"), msginfo->msgnum);
 }
@@ -2770,20 +2754,16 @@ static void summary_mark_row_as_read(SummaryView *summaryview,
        MsgInfo *msginfo;
 
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
+/* NOT NEEDED ANYMORE
        if (MSG_IS_NEW(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
                summaryview->newmsgs--;
        if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
                summaryview->unread--;
-       if (MSG_IS_NEW(msginfo->flags) ||
-           MSG_IS_UNREAD(msginfo->flags)) {
-               MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_NEW | MSG_UNREAD);
-               if (MSG_IS_IMAP(msginfo->flags))
-                       imap_msg_unset_perm_flags(msginfo, MSG_NEW | MSG_UNREAD);
-               CHANGE_FLAGS(msginfo);
-               summary_set_row_marks(summaryview, row);
-               debug_print(_("Message %d is marked as read\n"),
-                           msginfo->msgnum);
-       }
+*/
+       procmsg_msginfo_unset_flags(msginfo, MSG_NEW | MSG_UNREAD, 0);
+       summary_set_row_marks(summaryview, row);
+       debug_print(_("Message %d is marked as read\n"),
+               msginfo->msgnum);
 }
 
 void summary_mark_as_read(SummaryView *summaryview)
@@ -2827,22 +2807,18 @@ static void summary_mark_row_as_unread(SummaryView *summaryview,
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
        if (MSG_IS_DELETED(msginfo->flags)) {
                msginfo->to_folder = NULL;
-               MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_DELETED);
+               procmsg_msginfo_unset_flags(msginfo, MSG_DELETED, 0);
                summaryview->deleted--;
        }
-       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_REPLIED | MSG_FORWARDED);
-       if (MSG_IS_IMAP(msginfo->flags))
-               imap_msg_unset_perm_flags(msginfo, MSG_REPLIED);
-       if (!MSG_IS_UNREAD(msginfo->flags)) {
-               MSG_SET_PERM_FLAGS(msginfo->flags, MSG_UNREAD);
-               if (MSG_IS_IMAP(msginfo->flags))
-                       imap_msg_set_perm_flags(msginfo, MSG_UNREAD);
+/* NOT NEEDED ANYMORE
+       if (!MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
                summaryview->unread++;
-               debug_print(_("Message %d is marked as unread\n"),
-                           msginfo->msgnum);
-       }
+*/
 
-       CHANGE_FLAGS(msginfo);
+       procmsg_msginfo_unset_flags(msginfo, MSG_REPLIED | MSG_FORWARDED, 0);
+       procmsg_msginfo_set_flags(msginfo, MSG_UNREAD, 0);
+       debug_print(_("Message %d is marked as unread\n"),
+               msginfo->msgnum);
 
        summary_set_row_marks(summaryview, row);
 }
@@ -2937,12 +2913,8 @@ static void summary_delete_row(SummaryView *summaryview, GtkCTreeNode *row)
                        folderview_update_item(msginfo->to_folder, 0);
        }
        msginfo->to_folder = NULL;
-       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_MARKED);
-       if (MSG_IS_IMAP(msginfo->flags))
-               imap_msg_unset_perm_flags(msginfo, MSG_MARKED);
-       MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_MOVE | MSG_COPY);
-       MSG_SET_PERM_FLAGS(msginfo->flags, MSG_DELETED);
-       CHANGE_FLAGS(msginfo);
+       procmsg_msginfo_unset_flags(msginfo, MSG_MARKED, MSG_MOVE | MSG_COPY);
+       procmsg_msginfo_set_flags(msginfo, MSG_DELETED, 0);
        summaryview->deleted++;
 
        if (!prefs_common.immediate_exec && 
@@ -3068,11 +3040,7 @@ static void summary_unmark_row(SummaryView *summaryview, GtkCTreeNode *row)
                        folderview_update_item(msginfo->to_folder, 0);
        }
        msginfo->to_folder = NULL;
-       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_MARKED | MSG_DELETED);
-       if (MSG_IS_IMAP(msginfo->flags))
-               imap_msg_unset_perm_flags(msginfo, MSG_MARKED);
-       MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_MOVE | MSG_COPY);
-       CHANGE_FLAGS(msginfo);
+       procmsg_msginfo_unset_flags(msginfo, MSG_MARKED | MSG_DELETED, MSG_MOVE | MSG_COPY);
        summary_set_row_marks(summaryview, row);
        debug_print(_("Message %s/%d is unmarked\n"),
                    msginfo->folder->path, msginfo->msgnum);
@@ -3116,12 +3084,9 @@ static void summary_move_row_to(SummaryView *summaryview, GtkCTreeNode *row,
                if (!prefs_common.immediate_exec)
                        msginfo->to_folder->op_count--;
        }
-       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_MARKED | MSG_DELETED);
-       if (MSG_IS_IMAP(msginfo->flags))
-               imap_msg_unset_perm_flags(msginfo, MSG_MARKED);
-       MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_COPY);
+       procmsg_msginfo_unset_flags(msginfo, MSG_MARKED | MSG_DELETED, MSG_COPY);
        if (!MSG_IS_MOVE(msginfo->flags)) {
-               MSG_SET_TMP_FLAGS(msginfo->flags, MSG_MOVE);
+               procmsg_msginfo_set_flags(msginfo, 0, MSG_MOVE);
                summaryview->moved++;
                changed = TRUE;
        }
@@ -3208,12 +3173,9 @@ static void summary_copy_row_to(SummaryView *summaryview, GtkCTreeNode *row,
                if (!prefs_common.immediate_exec)
                        msginfo->to_folder->op_count--;
        }
-       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_MARKED | MSG_DELETED);
-       if (MSG_IS_IMAP(msginfo->flags))
-               imap_msg_unset_perm_flags(msginfo, MSG_MARKED);
-       MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_MOVE);
+       procmsg_msginfo_unset_flags(msginfo, MSG_MARKED | MSG_DELETED, MSG_MOVE);
        if (!MSG_IS_COPY(msginfo->flags)) {
-               MSG_SET_TMP_FLAGS(msginfo->flags, MSG_COPY);
+               procmsg_msginfo_set_flags(msginfo, 0, MSG_COPY);
                summaryview->copied++;
                changed = TRUE;
        }
@@ -3457,6 +3419,7 @@ static void summary_execute_move(SummaryView *summaryview)
                summaryview->mlist = NULL;
        }
 
+       folderview_update_item(summaryview->folder_item, FALSE);
        g_hash_table_destroy(summaryview->folder_table);
        summaryview->folder_table = NULL;
 }
@@ -3524,7 +3487,7 @@ static void summary_execute_copy_func(GtkCTree *ctree, GtkCTreeNode *node,
                summaryview->mlist =
                        g_slist_append(summaryview->mlist, msginfo);
 
-               MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_COPY);
+               procmsg_msginfo_unset_flags(msginfo, 0, MSG_COPY);
                summary_set_row_marks(summaryview, node);
        }
 }
@@ -3561,8 +3524,8 @@ static void summary_execute_delete(SummaryView *summaryview)
 
        if ((summaryview->folder_item != trash) && (trash != NULL)) {
                folder_item_scan(trash);
-               folderview_update_item(trash, FALSE);
        }
+       folderview_update_item(summaryview->folder_item, FALSE);
 }
 
 static void summary_execute_delete_func(GtkCTree *ctree, GtkCTreeNode *node,
@@ -4114,8 +4077,8 @@ void summary_set_colorlabel_color(GtkCTree *ctree, GtkCTreeNode *node,
        gint color_index;
 
        msginfo = gtk_ctree_node_get_row_data(ctree, node);
-       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_CLABEL_FLAG_MASK);
-       MSG_SET_COLORLABEL_VALUE(msginfo->flags, labelcolor);
+       procmsg_msginfo_unset_flags(msginfo, MSG_CLABEL_FLAG_MASK, 0);
+       procmsg_msginfo_set_flags(msginfo, MSG_COLORLABEL_TO_FLAGS(labelcolor), 0);
 
        color_index = labelcolor == 0 ? -1 : (gint)labelcolor - 1;
        ctree_style = gtk_widget_get_style(GTK_WIDGET(ctree));
@@ -4590,10 +4553,7 @@ static void summary_selected(GtkCTree *ctree, GtkCTreeNode *row,
        switch (column < 0 ? column : summaryview->col_state[column].type) {
        case S_COL_MARK:
                if (MSG_IS_MARKED(msginfo->flags)) {
-                       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_MARKED);
-                       if (MSG_IS_IMAP(msginfo->flags))
-                               imap_msg_unset_perm_flags(msginfo, MSG_MARKED);
-                       CHANGE_FLAGS(msginfo);
+                       procmsg_msginfo_unset_flags(msginfo, MSG_MARKED, 0);
                        summary_set_row_marks(summaryview, row);
                } else
                        summary_mark_row(summaryview, row);
@@ -4610,8 +4570,7 @@ static void summary_selected(GtkCTree *ctree, GtkCTreeNode *row,
                break;
        case S_COL_LOCKED:
                if (MSG_IS_LOCKED(msginfo->flags)) {
-                       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_LOCKED);
-                       CHANGE_FLAGS(msginfo);
+                       procmsg_msginfo_unset_flags(msginfo, MSG_LOCKED, 0);
                        summary_set_row_marks(summaryview, row);
                }
                else
@@ -4936,13 +4895,13 @@ static void summary_ignore_thread_func(GtkCTree *ctree, GtkCTreeNode *row, gpoin
        MsgInfo *msginfo;
 
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
+/* NOT NEEDED ANYMORE
        if (MSG_IS_NEW(msginfo->flags))
                summaryview->newmsgs--;
        if (MSG_IS_UNREAD(msginfo->flags))
                summaryview->unread--;
-       MSG_SET_PERM_FLAGS(msginfo->flags, MSG_IGNORE_THREAD);
-
-       CHANGE_FLAGS(msginfo);
+*/
+       procmsg_msginfo_set_flags(msginfo, MSG_IGNORE_THREAD, 0);
 
        summary_set_row_marks(summaryview, row);
        debug_print(_("Message %d is marked as ignore thread\n"),
@@ -4968,14 +4927,14 @@ static void summary_unignore_thread_func(GtkCTree *ctree, GtkCTreeNode *row, gpo
        MsgInfo *msginfo;
 
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
+/* NOT NEEDED ANYMORE
        if (MSG_IS_NEW(msginfo->flags))
                summaryview->newmsgs++;
        if (MSG_IS_UNREAD(msginfo->flags))
                summaryview->unread++;
-       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_IGNORE_THREAD);
+*/
+       procmsg_msginfo_unset_flags(msginfo, MSG_IGNORE_THREAD, 0);
 
-       CHANGE_FLAGS(msginfo);
-               
        summary_set_row_marks(summaryview, row);
        debug_print(_("Message %d is marked as unignore thread\n"),
            msginfo->msgnum);