* src/modest-ui-dimming-rules.c:
[modest] / src / modest-ui-dimming-rules.c
index 4281fc1..a422bb8 100644 (file)
@@ -38,6 +38,7 @@
 #include "modest-debug.h"
 #include "modest-tny-folder.h"
 #include "modest-tny-account.h"
+#include "modest-tny-mime-part.h"
 #include "modest-text-utils.h"
 #include <widgets/modest-attachments-view.h>
 #include <modest-runtime.h>
@@ -70,7 +71,6 @@ static gboolean _msg_download_in_progress (ModestWindow *win);
 static gboolean _msg_download_completed (ModestMainWindow *win);
 static gboolean _selected_msg_sent_in_progress (ModestWindow *win);
 static gboolean _sending_in_progress (ModestWindow *win);
-static gboolean _invalid_account_for_purge (ModestWindow *win, ModestDimmingRule *rule);
 static gboolean _invalid_folder_for_purge (ModestWindow *win, ModestDimmingRule *rule);
 static gboolean _transfer_mode_enabled (ModestWindow *win);
 static gboolean _selected_folder_has_subfolder_with_same_name (ModestWindow *win);
@@ -1240,14 +1240,11 @@ modest_ui_dimming_rules_on_remove_attachments (ModestWindow *win, gpointer user_
                }
        }
 
-       /* cannot purge in pop accounts */
-       if (!dimmed) {
-               dimmed = _invalid_account_for_purge (win, rule);
-       }
-
        /* cannot purge in editable drafts nor pop folders */
        if (!dimmed) {
                dimmed = _invalid_folder_for_purge (win, rule);
+               if (dimmed)
+                       modest_dimming_rule_set_notification (rule, _("mail_ib_unable_to_purge_attachments"));
        }
 
        /* Check if the selected message in main window has attachments */
@@ -2405,7 +2402,7 @@ _invalid_attach_selected (ModestWindow *win,
                        while (!tny_iterator_is_done (iter) && !result) {
                                TnyMimePart *mime_part = TNY_MIME_PART (tny_iterator_get_current (iter));
                                TnyList *nested_list = tny_simple_list_new ();
-                               if (!for_remove && TNY_IS_MSG (mime_part)) {
+                               if (!for_remove && modest_tny_mime_part_is_msg (mime_part)) {
                                        selected_messages = TRUE;
                                        result = TRUE;
                                }
@@ -2600,49 +2597,6 @@ _sending_in_progress (ModestWindow *win)
 }
 
 static gboolean
-_invalid_account_for_purge (ModestWindow *win,
-                           ModestDimmingRule *rule)
-{
-       const gchar *account_name;
-       ModestTnyAccountStore *account_store;
-       TnyAccount *store_account = NULL;
-       gboolean result = FALSE;
-       const gchar *protocol_name;
-
-       account_name = modest_window_get_active_account (win);
-       if (account_name == NULL)
-               goto frees;
-
-       account_store = modest_runtime_get_account_store ();
-       store_account = modest_tny_account_store_get_server_account (account_store, account_name, TNY_ACCOUNT_TYPE_STORE);
-       if (store_account == NULL)
-               goto frees;
-
-       protocol_name = tny_account_get_proto (store_account);
-       if (modest_protocol_info_get_transport_store_protocol (protocol_name) == MODEST_PROTOCOL_STORE_POP) {
-               gint n_selected = 0;
-               result = TRUE;
-
-               if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
-                       TnyList *attachments;
-                       attachments = modest_msg_view_window_get_attachments (MODEST_MSG_VIEW_WINDOW(win));
-                       n_selected = tny_list_get_length (attachments);
-                       g_object_unref (attachments);
-               }
-                       
-               modest_dimming_rule_set_notification (rule, 
-                                                     ngettext ("mail_ib_unable_to_pure_attach_pop_mail_singular",
-                                                               "mail_ib_unable_to_pure_attach_pop_mail_plural", 
-                                                               n_selected));
-               
-       }
-frees:
-       if (store_account)
-               g_object_unref (store_account);
-       return result;
-}
-
-static gboolean
 _invalid_folder_for_purge (ModestWindow *win, 
                           ModestDimmingRule *rule)
 {
@@ -2659,7 +2613,6 @@ _invalid_folder_for_purge (ModestWindow *win,
                g_object_unref (msg);
                if (folder == NULL) {
                        result = TRUE;
-                       modest_dimming_rule_set_notification (rule, _("mail_ib_unable_to_purge_attachments"));
                        goto frees;
                }
        } else if (MODEST_IS_MAIN_WINDOW (win)) {
@@ -2684,7 +2637,6 @@ _invalid_folder_for_purge (ModestWindow *win,
                
                if (_selected_folder_is_any_of_type (win, types, 2)) {
                        result = TRUE;
-                       modest_dimming_rule_set_notification (rule, _("mail_ib_unable_to_purge_editable_msg"));
                }
        } else {
                const gchar *proto_str = tny_account_get_proto (TNY_ACCOUNT (account));
@@ -2693,7 +2645,6 @@ _invalid_folder_for_purge (ModestWindow *win,
                /* If it's a remote folder then dim */
                if (proto == MODEST_PROTOCOL_STORE_POP || proto == MODEST_PROTOCOL_STORE_IMAP) {
                        result = TRUE;
-                       modest_dimming_rule_set_notification (rule, _("mail_ib_unable_to_purge_attachments"));
                }
        }