Remove imap_use_trash account preference.
authorAndrej Kacian <ticho@claws-mail.org>
Thu, 12 May 2016 08:03:39 +0000 (10:03 +0200)
committerAndrej Kacian <ticho@claws-mail.org>
Wed, 18 May 2016 15:20:13 +0000 (17:20 +0200)
Disabling this preference made deleting messages behave
incorrectly - they were marked for deletion regardless
of whether "delete" or "move to trash" was used, and
these actions were not executed immediately, regardless
of "immediate_execution" common preference.

src/folder.c
src/imap.c
src/prefs_account.c
src/prefs_account.h
src/summaryview.c

index 2b4dbe0d12a17f9c8bd3707727795bfd82e52726..c229284daf6474c2472fcd1d08031b94ca7eb0d7 100644 (file)
@@ -3543,9 +3543,7 @@ static gint do_copy_msgs(FolderItem *dest, GSList *msglist, gboolean remove_sour
                                        item->folder->klass->remove_msg(item->folder,
                                                                msginfo->folder,
                                                                msginfo->msgnum);
-                               if (!item->folder->account || item->folder->account->imap_use_trash) {
-                                       remove_msginfo_from_cache(item, msginfo);
-                               }
+                               remove_msginfo_from_cache(item, msginfo);
                        }
                }
        }
@@ -3737,12 +3735,10 @@ gint folder_item_remove_msg(FolderItem *item, gint num)
        }
        ret = folder->klass->remove_msg(folder, item, num);
 
-       if (!item->folder->account || item->folder->account->imap_use_trash) {
-               if (msginfo != NULL) {
-                       if (ret == 0)
-                               remove_msginfo_from_cache(item, msginfo);
-                       procmsg_msginfo_free(&msginfo);
-               }
+       if (msginfo != NULL) {
+               if (ret == 0)
+                       remove_msginfo_from_cache(item, msginfo);
+               procmsg_msginfo_free(&msginfo);
        }
 
        return ret;
index a38c8d09cb119358ca2b2312027eea55c8c808aa..4bc5af1b95560c9d354bb947dbedf29654aadeb3 100644 (file)
@@ -400,7 +400,7 @@ static gint imap_cmd_store  (IMAPSession    *session,
                                 IMAPFlags flags,
                                 GSList *tags,
                                 int do_add);
-static gint imap_cmd_expunge   (IMAPSession    *session, gboolean force);
+static gint imap_cmd_expunge   (IMAPSession    *session);
 
 static void imap_path_separator_subst          (gchar          *str,
                                                 gchar           separator);
@@ -2554,7 +2554,7 @@ static gint imap_do_remove_msgs(Folder *folder, FolderItem *dest,
                        return ok;
                }
        } /* else we just need to expunge */
-       ok = imap_cmd_expunge(session, folder->account->imap_use_trash);
+       ok = imap_cmd_expunge(session);
        if (ok != MAILIMAP_NO_ERROR) {
                log_warning(LOG_PROTOCOL, _("can't expunge\n"));
                g_free(destdir);
@@ -4435,13 +4435,10 @@ static gint imap_cmd_store(IMAPSession *session,
        return MAILIMAP_NO_ERROR;
 }
 
-static gint imap_cmd_expunge(IMAPSession *session, gboolean do_expunge)
+static gint imap_cmd_expunge(IMAPSession *session)
 {
        int r;
        
-       if (!do_expunge)
-               return MAILIMAP_NO_ERROR;
-
        if (prefs_common.work_offline && 
            !inc_offline_should_override(FALSE,
                _("Claws Mail needs network access in order "
@@ -4464,7 +4461,7 @@ gint imap_expunge(Folder *folder, FolderItem *item)
        if (session == NULL)
                return -1;
        
-       return imap_cmd_expunge(session, TRUE);
+       return imap_cmd_expunge(session);
 }
 
 static void imap_path_separator_subst(gchar *str, gchar separator)
@@ -5060,7 +5057,7 @@ static gint imap_remove_msg(Folder *folder, FolderItem *item, gint uid)
                return ok;
        }
 
-       ok = imap_cmd_expunge(session, folder->account->imap_use_trash);
+       ok = imap_cmd_expunge(session);
 
        if (ok != MAILIMAP_NO_ERROR) {
                log_warning(LOG_PROTOCOL, _("can't expunge\n"));
index 31c0d6f06237e94f6cf97f4948b5a9c9b4b591a8..5a4deec3d3c559b5fa508c07667d697a26ba05e3 100644 (file)
@@ -309,7 +309,6 @@ typedef struct AdvancedPage
        GtkWidget *draft_folder_entry;
        GtkWidget *trash_folder_checkbtn;
        GtkWidget *trash_folder_entry;
-       GtkWidget *imap_use_trash_checkbtn;
 } AdvancedPage;
 
 static BasicPage basic_page;
@@ -880,10 +879,6 @@ static PrefParam advanced_param[] = {
         &advanced_page.trash_folder_entry,
         prefs_set_data_from_entry, prefs_set_entry},
         
-        {"imap_use_trash", "TRUE", &tmp_ac_prefs.imap_use_trash, P_BOOL,
-        &advanced_page.imap_use_trash_checkbtn,
-        prefs_set_data_from_toggle, prefs_set_toggle},
-
 
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
 };
@@ -2692,7 +2687,6 @@ static void advanced_create_widget_func(PrefsPage * _page,
        GtkWidget *draft_folder_entry;
        GtkWidget *trash_folder_checkbtn;
        GtkWidget *trash_folder_entry;
-       GtkWidget *imap_use_trash_checkbtn;
        GtkSizeGroup *size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
 
 #define PACK_HBOX(hbox) \
@@ -2768,11 +2762,6 @@ static void advanced_create_widget_func(PrefsPage * _page,
        gtk_box_pack_start (GTK_BOX (hbox1), entry_tunnelcmd, TRUE, TRUE, 0);
        SET_TOGGLE_SENSITIVITY (checkbtn_tunnelcmd, entry_tunnelcmd);
 #endif
-       PACK_HBOX (hbox1);
-       PACK_CHECK_BUTTON (hbox1, imap_use_trash_checkbtn,
-                          _("Move deleted mails to trash and expunge immediately"));
-       CLAWS_SET_TIP(imap_use_trash_checkbtn,
-                            _("Moves deleted mails to trash instead of using the \\Deleted flag without expunging."));
 
 #if !GTK_CHECK_VERSION(3, 0, 0)
        PACK_CHECK_BUTTON (hbox1, checkbtn_crosspost, 
@@ -2871,7 +2860,6 @@ static void advanced_create_widget_func(PrefsPage * _page,
        page->draft_folder_entry  = draft_folder_entry;
        page->trash_folder_checkbtn = trash_folder_checkbtn;
        page->trash_folder_entry  = trash_folder_entry;
-       page->imap_use_trash_checkbtn = imap_use_trash_checkbtn;
 
        tmp_ac_prefs = *ac_prefs;
 
@@ -4415,7 +4403,6 @@ static void prefs_account_protocol_changed(GtkComboBox *combobox, gpointer data)
                gtk_widget_hide(advanced_page.tunnelcmd_checkbtn);
                gtk_widget_hide(advanced_page.tunnelcmd_entry);
 #endif
-               gtk_widget_hide(advanced_page.imap_use_trash_checkbtn);
                gtk_widget_hide(receive_page.imapdir_label);
                gtk_widget_hide(receive_page.imapdir_entry);
                gtk_widget_hide(receive_page.subsonly_checkbtn);
@@ -4513,7 +4500,6 @@ static void prefs_account_protocol_changed(GtkComboBox *combobox, gpointer data)
                gtk_widget_hide(advanced_page.tunnelcmd_checkbtn);
                gtk_widget_hide(advanced_page.tunnelcmd_entry);
 #endif
-               gtk_widget_hide(advanced_page.imap_use_trash_checkbtn);
                gtk_widget_hide(receive_page.imapdir_label);
                gtk_widget_hide(receive_page.imapdir_entry);
                gtk_widget_hide(receive_page.subsonly_checkbtn);
@@ -4620,7 +4606,6 @@ static void prefs_account_protocol_changed(GtkComboBox *combobox, gpointer data)
                gtk_widget_show(advanced_page.tunnelcmd_checkbtn);
                gtk_widget_show(advanced_page.tunnelcmd_entry);
 #endif
-               gtk_widget_show(advanced_page.imap_use_trash_checkbtn);
                gtk_widget_show(receive_page.imapdir_label);
                gtk_widget_show(receive_page.imapdir_entry);
                gtk_widget_show(receive_page.subsonly_checkbtn);
@@ -4716,7 +4701,6 @@ static void prefs_account_protocol_changed(GtkComboBox *combobox, gpointer data)
                gtk_widget_hide(advanced_page.tunnelcmd_checkbtn);
                gtk_widget_hide(advanced_page.tunnelcmd_entry);
 #endif
-               gtk_widget_hide(advanced_page.imap_use_trash_checkbtn);
                gtk_widget_hide(receive_page.imapdir_label);
                gtk_widget_hide(receive_page.imapdir_entry);
                gtk_widget_hide(receive_page.subsonly_checkbtn);
@@ -4819,7 +4803,6 @@ static void prefs_account_protocol_changed(GtkComboBox *combobox, gpointer data)
                gtk_widget_hide(advanced_page.tunnelcmd_checkbtn);
                gtk_widget_hide(advanced_page.tunnelcmd_entry);
 #endif
-               gtk_widget_hide(advanced_page.imap_use_trash_checkbtn);
                gtk_widget_hide(receive_page.imapdir_label);
                gtk_widget_hide(receive_page.imapdir_entry);
                gtk_widget_hide(receive_page.subsonly_checkbtn);
index dd118c45447f6a1a26d842623e3914d4a077cc5b..b34c42577f2a9abb77bc02b528a7bf137d6bca15 100644 (file)
@@ -191,7 +191,6 @@ struct _PrefsAccount
        gchar *imap_dir;
        gboolean imap_subsonly;
        gboolean low_bandwidth;
-       gboolean imap_use_trash;
 
        gboolean set_sent_folder;
        gchar *sent_folder;
index 62e8e913768c3c420031fadb7c6c9fe2b534a983..731d24f6bdf1005379d405e4b922c58a75ae6176 100644 (file)
@@ -4342,8 +4342,6 @@ static void summary_delete_row(SummaryView *summaryview, GtkCMCTreeNode *row)
        if (!prefs_common.immediate_exec && 
            !folder_has_parent_of_type(summaryview->folder_item, F_TRASH)) {
                summary_set_row_marks(summaryview, row);
-       } else if (summaryview->folder_item->folder->account && !summaryview->folder_item->folder->account->imap_use_trash) {
-               summary_set_row_marks(summaryview, row);
        }
        debug_print("Message %s/%d is set to delete\n",
                    msginfo->folder->path, msginfo->msgnum);
@@ -4395,22 +4393,20 @@ void summary_delete(SummaryView *summaryview)
        
        START_LONG_OPERATION(summaryview, FALSE);
 
-       if (!summaryview->folder_item->folder->account || summaryview->folder_item->folder->account->imap_use_trash) {
-               if (!prefs_common.live_dangerously) {
-                       gchar *buf = NULL;
-                       int num = g_list_length(GTK_CMCLIST(summaryview->ctree)->selection);
-                       buf = g_strdup_printf(ngettext(
-                               "Do you really want to delete the selected message?",
-                               "Do you really want to delete the %d selected messages?", num), 
-                               num);
-                       aval = alertpanel(ngettext("Delete message", "Delete messages", num),
-                                         buf,
-                                         GTK_STOCK_CANCEL, "+"GTK_STOCK_DELETE, NULL);
-                       g_free(buf);
-                       if (aval != G_ALERTALTERNATE) {
-                               END_LONG_OPERATION(summaryview);
-                               return;
-                       }
+       if (!prefs_common.live_dangerously) {
+               gchar *buf = NULL;
+               int num = g_list_length(GTK_CMCLIST(summaryview->ctree)->selection);
+               buf = g_strdup_printf(ngettext(
+                       "Do you really want to delete the selected message?",
+                       "Do you really want to delete the %d selected messages?", num),
+                       num);
+               aval = alertpanel(ngettext("Delete message", "Delete messages", num),
+                                 buf,
+                                 GTK_STOCK_CANCEL, "+"GTK_STOCK_DELETE, NULL);
+               g_free(buf);
+               if (aval != G_ALERTALTERNATE) {
+                       END_LONG_OPERATION(summaryview);
+                       return;
                }
        }
 
@@ -4472,8 +4468,7 @@ void summary_delete_trash(SummaryView *summaryview)
                to_folder = summaryview->folder_item->folder->trash;
        
        if (to_folder == NULL || to_folder == summaryview->folder_item
-           || folder_has_parent_of_type(summaryview->folder_item, F_TRASH)
-           || (summaryview->folder_item->folder->account && !summaryview->folder_item->folder->account->imap_use_trash))
+           || folder_has_parent_of_type(summaryview->folder_item, F_TRASH))
                summary_delete(summaryview);
        else
                summary_move_selected_to(summaryview, to_folder);
@@ -4550,8 +4545,6 @@ static void summary_move_row_to(SummaryView *summaryview, GtkCMCTreeNode *row,
        
        if (!prefs_common.immediate_exec) {
                summary_set_row_marks(summaryview, row);
-       } else if (msginfo->folder->folder->account && !msginfo->folder->folder->account->imap_use_trash) {
-               summary_set_row_marks(summaryview, row);
        }
 
        debug_print("Message %d is set to move to %s\n",
@@ -5124,23 +5117,6 @@ gboolean summary_expunge(SummaryView *summaryview)
        return TRUE;
 }
 
-static void summary_set_deleted_func(GtkCMCTree *ctree, GtkCMCTreeNode *node,
-                                     gpointer data)
-{
-       SummaryView *summaryview = data;
-       MsgInfo *msginfo;
-
-       msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
-
-       if (msginfo && MSG_IS_MOVE(msginfo->flags)) {
-               msginfo->flags.tmp_flags &= ~ MSG_MOVE;
-               msginfo->flags.perm_flags |= MSG_DELETED;
-               summary_set_row_marks(summaryview, node);
-               summaryview->moved--;
-               summaryview->deleted++;
-       }
-}
-
 static gint summary_execute_move(SummaryView *summaryview)
 {
        GtkCMCTree *ctree = GTK_CMCTREE(summaryview->ctree);
@@ -5159,14 +5135,10 @@ static gint summary_execute_move(SummaryView *summaryview)
                hooks_register_hook(MSGINFO_UPDATE_HOOKLIST, 
                        summary_update_msg, (gpointer) summaryview);
 
-               if (!summaryview->folder_item->folder->account || summaryview->folder_item->folder->account->imap_use_trash) {
-                       for (cur = summaryview->mlist; cur != NULL && cur->data != NULL; cur = cur->next)
-                               procmsg_msginfo_free((MsgInfo **)&(cur->data));
-               } 
-               if (summaryview->folder_item->folder->account && !summaryview->folder_item->folder->account->imap_use_trash) {
-                       gtk_cmctree_pre_recursive(ctree, NULL, summary_set_deleted_func,
-                                       summaryview);
+               for (cur = summaryview->mlist; cur != NULL && cur->data != NULL; cur = cur->next) {
+                       procmsg_msginfo_free((MsgInfo **)&(cur->data));
                }
+
                g_slist_free(summaryview->mlist);
                summaryview->mlist = NULL;
                return val;
@@ -5185,22 +5157,19 @@ static void summary_execute_move_func(GtkCMCTree *ctree, GtkCMCTreeNode *node,
        if (msginfo && MSG_IS_MOVE(msginfo->flags) && msginfo->to_folder) {
                summaryview->mlist =
                        g_slist_prepend(summaryview->mlist, msginfo);
-               if (!summaryview->folder_item->folder->account || 
-                    summaryview->folder_item->folder->account->imap_use_trash) {
-                       gtk_cmctree_node_set_row_data(ctree, node, NULL);
-
-                       if (msginfo->msgid && *msginfo->msgid &&
-                           node == g_hash_table_lookup(summaryview->msgid_table,
-                                                       msginfo->msgid))
-                               g_hash_table_remove(summaryview->msgid_table,
-                                                   msginfo->msgid);
-                       if (prefs_common.thread_by_subject &&
-                           msginfo->subject && *msginfo->subject && 
-                           node == subject_table_lookup(summaryview->subject_table,
-                                                        msginfo->subject)) {
-                               subject_table_remove(summaryview->subject_table,
-                                                    msginfo->subject);
-                       }
+               gtk_cmctree_node_set_row_data(ctree, node, NULL);
+
+               if (msginfo->msgid && *msginfo->msgid &&
+                   node == g_hash_table_lookup(summaryview->msgid_table,
+                                               msginfo->msgid))
+                       g_hash_table_remove(summaryview->msgid_table,
+                                           msginfo->msgid);
+               if (prefs_common.thread_by_subject &&
+                   msginfo->subject && *msginfo->subject &&
+                   node == subject_table_lookup(summaryview->subject_table,
+                                                msginfo->subject)) {
+                       subject_table_remove(summaryview->subject_table,
+                                            msginfo->subject);
                }
        }
 }
@@ -5223,7 +5192,7 @@ static void summary_execute_copy(SummaryView *summaryview)
                summaryview->mlist = NULL;
        }
        summaryview->msginfo_update_callback_id =
-               hooks_register_hook(MSGINFO_UPDATE_HOOKLIST, 
+               hooks_register_hook(MSGINFO_UPDATE_HOOKLIST,
                        summary_update_msg, (gpointer) summaryview);
 }
 
@@ -5250,10 +5219,9 @@ static void summary_execute_delete(SummaryView *summaryview)
        GSList *cur;
 
        /* search deleting messages and execute */
-       if (!summaryview->folder_item->folder->account || summaryview->folder_item->folder->account->imap_use_trash) {
-               gtk_cmctree_pre_recursive
-                       (ctree, NULL, summary_execute_delete_func, summaryview);
-       }
+       gtk_cmctree_pre_recursive
+               (ctree, NULL, summary_execute_delete_func, summaryview);
+
        if (!summaryview->mlist) return;
 
        hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST,
@@ -5265,10 +5233,11 @@ static void summary_execute_delete(SummaryView *summaryview)
        summaryview->msginfo_update_callback_id =
                hooks_register_hook(MSGINFO_UPDATE_HOOKLIST, 
                        summary_update_msg, (gpointer) summaryview);
-       if (!summaryview->folder_item->folder->account || summaryview->folder_item->folder->account->imap_use_trash) {
-               for (cur = summaryview->mlist; cur != NULL && cur->data != NULL; cur = cur->next)
+
+       for (cur = summaryview->mlist; cur != NULL && cur->data != NULL; cur = cur->next) {
                        procmsg_msginfo_free((MsgInfo **)&(cur->data));
        }
+
        g_slist_free(summaryview->mlist);
        summaryview->mlist = NULL;
 }