Work to complete implementation of purge attachments operation
authorJose Dapena Paz <jdapena@igalia.com>
Thu, 28 Jun 2007 17:06:34 +0000 (17:06 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Thu, 28 Jun 2007 17:06:34 +0000 (17:06 +0000)
(fixes NB#61240).
* src/widget/modest-msg-view.[ch]:
        * Added API function to get all the attachments in
          the view, and not only the selected ones.
* src/widgets/modest-attachment-view.c:
        * Support for showing purged files improved (still pending
          a proper logical id).
* src/widgets/modest-msg-view-window.[ch]:
* src/modest-ui-actions.[ch]:
        * Added support for purging attachments of a message from the
          main window, with lots of exception conditions (trying to
          remove messages with all attachments already purged, etc).
        * Added confirmation dialog for removing attachments from
          main window.
* src/maemo/modest-main-window-ui.h:
        * Attach remove attachments action in main window.
* src/widgets/modest-msg-view-window.[ch]:
        * Now you cannot save or view a purged attachment.
        * Now you can choose in ..._remove_attachments to remove
          only selected attachments or all the available attachments.
        * Skip already removed attachments
        * More informationbanners for purge operation.
        * Now the message is correctly reloaded after being purged.
* src/widgets/modest-ui-dimming-rules.[ch]:
        * Added a lot of dimming rules for removing attachments both
          from main window and msg view window.

pmo-trunk-r2478

src/maemo/modest-main-window-ui.h
src/maemo/modest-msg-view-window.c
src/modest-ui-actions.c
src/modest-ui-dimming-rules.c
src/widgets/modest-attachment-view.c
src/widgets/modest-msg-view-window.h
src/widgets/modest-msg-view.c
src/widgets/modest-msg-view.h

index 841475f..d58aa91 100644 (file)
@@ -67,7 +67,7 @@ static const GtkActionEntry modest_action_entries [] = {
        { "EmailDelete",      NULL,  N_("mcen_me_inbox_delete"),    NULL,      NULL,   G_CALLBACK (modest_ui_actions_on_delete) },
        { "EmailContents",    NULL,  N_("mcen_me_inbox_retrieve_contents"), NULL,      NULL,   G_CALLBACK (modest_ui_actions_on_retrieve_msg_contents) },
        { "EmailDetails",     NULL,  N_("mcen_me_inbox_messagedetails"),        NULL,      NULL,   G_CALLBACK (modest_ui_actions_on_details) },
-       { "EmailPurgeAttachments", NULL, N_("mcen_me_inbox_remove_attachments"), NULL,  NULL,   NULL },
+       { "EmailPurgeAttachments", NULL, N_("mcen_me_inbox_remove_attachments"), NULL,  NULL,   G_CALLBACK (modest_ui_actions_remove_attachments) },
        
 
        /* Edit */
index c3b2116..b84a728 100644 (file)
@@ -1593,6 +1593,12 @@ modest_msg_view_window_view_attachment (ModestMsgViewWindow *window, TnyMimePart
                g_object_ref (mime_part);
        }
 
+       if (tny_mime_part_is_purged (mime_part)) {
+               g_object_unref (mime_part);
+               hildon_banner_show_information (NULL, NULL, _("mail_ib_attach_not_local"));
+               return;
+       }
+
        if (!TNY_IS_MSG (mime_part)) {
                gchar *filepath = NULL;
                const gchar *att_filename = tny_mime_part_get_filename (mime_part);
@@ -1776,7 +1782,7 @@ modest_msg_view_window_save_attachments (ModestMsgViewWindow *window, GList *mim
 }
 
 void
-modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window)
+modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window, gboolean get_all)
 {
        ModestMsgViewWindowPrivate *priv;
        GList *mime_parts = NULL, *node;
@@ -1789,7 +1795,25 @@ modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window)
        g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window));
        priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
 
-       mime_parts = modest_msg_view_get_selected_attachments (MODEST_MSG_VIEW (priv->msg_view));
+       if (get_all)
+               mime_parts = modest_msg_view_get_attachments (MODEST_MSG_VIEW (priv->msg_view));
+       else
+               mime_parts = modest_msg_view_get_selected_attachments (MODEST_MSG_VIEW (priv->msg_view));
+               
+       /* Remove already purged messages from mime parts list */
+       node = mime_parts;
+       while (node != NULL) {
+               TnyMimePart *part = TNY_MIME_PART (node->data);
+               if (tny_mime_part_is_purged (part)) {
+                       GList *deleted_node = node;
+                       node = g_list_next (node);
+                       g_object_unref (part);
+                       mime_parts = g_list_delete_link (mime_parts, deleted_node);
+               } else {
+                       node = g_list_next (node);
+               }
+       }
+
        if (mime_parts == NULL)
                return;
 
@@ -1820,22 +1844,26 @@ modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window)
        if (response != GTK_RESPONSE_OK)
                return;
 
-       msg = modest_msg_view_get_message (MODEST_MSG_VIEW (priv->msg_view));
 /*     folder = tny_msg_get_folder (msg); */
 /*     tny_msg_uncache_attachments (msg); */
 /*     tny_folder_refresh (folder, NULL); */
 /*     g_object_unref (folder); */
        
-       modest_msg_view_set_message (MODEST_MSG_VIEW (priv->msg_view), msg);
+       modest_platform_information_banner (NULL, NULL, _("mcen_ib_removing_attachment"));
 
        for (node = mime_parts; node != NULL; node = g_list_next (node)) {
                tny_mime_part_set_purged (TNY_MIME_PART (node->data));
 /*             modest_msg_view_remove_attachment (MODEST_MSG_VIEW (priv->msg_view), node->data); */
        }
+
+       msg = modest_msg_view_get_message (MODEST_MSG_VIEW (priv->msg_view));
+       modest_msg_view_set_message (MODEST_MSG_VIEW (priv->msg_view), NULL);
        tny_msg_rewrite_cache (msg);
+       modest_msg_view_set_message (MODEST_MSG_VIEW (priv->msg_view), msg);
+
        g_list_foreach (mime_parts, (GFunc) g_object_unref, NULL);
        g_list_free (mime_parts);
-       modest_platform_information_banner (NULL, NULL, _("mcen_ib_removing_attachment"));
+
 
 }
 
index f0195a2..97da754 100644 (file)
@@ -2875,6 +2875,124 @@ modest_ui_actions_move_folder_error_handler (ModestMailOperation *mail_op,
        g_object_unref (win);
 }
 
+static void
+open_msg_for_purge_cb (ModestMailOperation *mail_op, 
+                      TnyHeader *header, 
+                      TnyMsg *msg, 
+                      gpointer user_data)
+{
+       TnyList *parts;
+       TnyIterator *iter;
+       gint pending_purges = 0;
+       gboolean some_purged = FALSE;
+       ModestWindow *win = MODEST_WINDOW (user_data);
+       if (!msg)
+               return;
+
+       /* Once the message has been retrieved for purging, we check if
+        * it's all ok for purging */
+
+       parts = tny_simple_list_new ();
+       tny_mime_part_get_parts (TNY_MIME_PART (msg), parts);
+       iter = tny_list_create_iterator (parts);
+
+       while (!tny_iterator_is_done (iter)) {
+               TnyMimePart *part;
+               part = TNY_MIME_PART (tny_iterator_get_current (iter));
+               if (tny_mime_part_is_attachment (part) || TNY_IS_MSG (part)) {
+                       if (tny_mime_part_is_purged (part))
+                               some_purged = TRUE;
+                       else
+                               pending_purges++;
+               }
+               tny_iterator_next (iter);
+       }
+
+       if (pending_purges>0) {
+               gint response;
+               response = modest_platform_run_confirmation_dialog (GTK_WINDOW (win),_("mcen_nc_purge_file_text_inbox"));
+
+               if (response == GTK_RESPONSE_OK) {
+                       modest_platform_information_banner (NULL, NULL, _("mcen_ib_removing_attachment"));
+                       tny_iterator_first (iter);
+                       while (!tny_iterator_is_done (iter)) {
+                               TnyMimePart *part;
+                               
+                               part = TNY_MIME_PART (tny_iterator_get_current (iter));
+                               if (tny_mime_part_is_attachment (part) || TNY_IS_MSG (part))
+                                       tny_mime_part_set_purged (part);
+                               tny_iterator_next (iter);
+                       }
+                       
+                       tny_msg_rewrite_cache (msg);
+               }
+       } else {
+               modest_platform_information_banner (NULL, NULL, _("mail_ib_attachment_already_purged"));
+       }
+
+       /* remove attachments */
+       tny_iterator_first (iter);
+       while (!tny_iterator_is_done (iter)) {
+               TnyMimePart *part;
+                       
+               part = TNY_MIME_PART (tny_iterator_get_current (iter));
+               g_object_unref (part);
+               tny_iterator_next (iter);
+       }
+
+       g_object_unref (iter);
+       g_object_unref (parts);
+}
+
+static void
+modest_ui_actions_on_main_window_remove_attachments (GtkAction *action,
+                                                    ModestMainWindow *win)
+{
+       GtkWidget *header_view;
+       TnyList *header_list;
+       TnyIterator *iter;
+       TnyHeader *header;
+       TnyHeaderFlags flags;
+       GtkWidget *msg_view_window;
+       g_return_if_fail (MODEST_IS_MAIN_WINDOW (win));
+
+       header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
+                                                          MODEST_WIDGET_TYPE_HEADER_VIEW);
+
+       header_list = modest_header_view_get_selected_headers (MODEST_HEADER_VIEW (header_view));
+
+       if (tny_list_get_length (header_list) == 1) {
+               iter = tny_list_create_iterator (header_list);
+               header = TNY_HEADER (tny_iterator_get_current (iter));
+               g_object_unref (iter);
+       } else {
+               return;
+       }
+
+       msg_view_window = GTK_WIDGET (modest_window_mgr_find_window_by_header (modest_runtime_get_window_mgr (), header));
+       flags = tny_header_get_flags (header);
+       if (!(flags & TNY_HEADER_FLAG_CACHED))
+               return;
+
+       if (msg_view_window != NULL) {
+               modest_msg_view_window_remove_attachments (MODEST_MSG_VIEW_WINDOW (msg_view_window), TRUE);
+       } else {
+               ModestMailOperation *mail_op = NULL;
+               mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_OPEN,
+                                                                        G_OBJECT (win),
+                                                                        modest_ui_actions_get_msgs_full_error_handler,
+                                                                        NULL);
+               modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
+               modest_mail_operation_get_msg (mail_op, header, open_msg_for_purge_cb, win);
+
+               g_object_unref (mail_op);
+       }
+       if (header)
+               g_object_unref (header);
+       if (header_list)
+               g_object_unref (header_list);
+}
+
 /*
  * UI handler for the "Move to" action when invoked from the
  * ModestMainWindow
@@ -3132,8 +3250,10 @@ void
 modest_ui_actions_remove_attachments (GtkAction *action,
                                      ModestWindow *window)
 {
-       if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
-               modest_msg_view_window_remove_attachments (MODEST_MSG_VIEW_WINDOW (window));
+       if (MODEST_IS_MAIN_WINDOW (window)) {
+               modest_ui_actions_on_main_window_remove_attachments (action, MODEST_MAIN_WINDOW (window));
+       } else if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
+               modest_msg_view_window_remove_attachments (MODEST_MSG_VIEW_WINDOW (window), FALSE);
        } else {
                /* not supported window for this action */
                g_return_if_reached ();
index b1ebb4f..3aa5016 100644 (file)
@@ -44,7 +44,7 @@
 static gboolean _folder_is_any_of_type (TnyFolder *folder, TnyFolderType types[], guint ntypes);
 static gboolean _invalid_msg_selected (ModestMainWindow *win, gboolean unique, ModestDimmingRule *rule);
 static gboolean _invalid_attach_selected (ModestWindow *win, gboolean unique, gboolean for_view, ModestDimmingRule *rule);
-static gboolean _purged_attach_selected (ModestWindow *win);
+static gboolean _purged_attach_selected (ModestWindow *win, gboolean all, ModestDimmingRule *rule);
 static gboolean _clipboard_is_empty (ModestWindow *win);
 static gboolean _invalid_clipboard_selected (ModestWindow *win, ModestDimmingRule *rule);
 static gboolean _already_opened_msg (ModestWindow *win, guint *n_messages);
@@ -62,7 +62,7 @@ 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 _marked_as_deleted (ModestWindow *win);
-static gboolean _invalid_attachment_for_purge (ModestWindow *win, ModestDimmingRule *rule);
+static gboolean _invalid_folder_for_purge (ModestWindow *win, ModestDimmingRule *rule);
 static gboolean _transfer_mode_enabled (ModestWindow *win);
 
 
@@ -719,6 +719,13 @@ modest_ui_dimming_rules_on_view_attachments (ModestWindow *win, gpointer user_da
        /* Check dimmed rule */ 
        if (!dimmed) 
                dimmed = _invalid_attach_selected (win, TRUE, TRUE, rule);                      
+
+       if (!dimmed) {
+               dimmed = _purged_attach_selected (win, FALSE, NULL);
+               if (dimmed) {
+                       modest_dimming_rule_set_notification (rule, _("mail_ib_attach_not_local"));
+               }
+       }
                
        return dimmed;
 }
@@ -735,7 +742,14 @@ modest_ui_dimming_rules_on_save_attachments (ModestWindow *win, gpointer user_da
 
        /* Check dimmed rule */ 
        if (!dimmed) 
-               dimmed = _invalid_attach_selected (win, FALSE, FALSE, rule);                    
+               dimmed = _invalid_attach_selected (win, FALSE, FALSE, rule);
+
+       if (!dimmed) {
+               dimmed = _purged_attach_selected (win, FALSE, NULL);
+               if (dimmed) {
+                       modest_dimming_rule_set_notification (rule, _("mail_ib_attach_not_local"));
+               }
+       }
                
        return dimmed;
 }
@@ -750,15 +764,40 @@ modest_ui_dimming_rules_on_remove_attachments (ModestWindow *win, gpointer user_
        g_return_val_if_fail (MODEST_IS_DIMMING_RULE (user_data), FALSE);
        rule = MODEST_DIMMING_RULE (user_data);
 
-       /* Check dimmed rule */
+       /* Check in main window if there's only one message selected */
+       if (!dimmed && MODEST_IS_MAIN_WINDOW (win)) {
+               dimmed = _invalid_msg_selected (MODEST_MAIN_WINDOW (win), TRUE, rule);
+       }
+
+       /* Check in view window if there's any attachment selected */
+       if (!dimmed && MODEST_IS_MSG_VIEW_WINDOW (win)) {
+               dimmed = _invalid_attach_selected (win, FALSE, FALSE, NULL);
+               if (dimmed)
+                       modest_dimming_rule_set_notification (rule, _("FIXME:no attachment selected"));
+       }
+
+       /* cannot purge in editable drafts nor pop folders */
        if (!dimmed) {
-               dimmed = _purged_attach_selected (win);
+               dimmed = _invalid_folder_for_purge (win, rule);
+       }
+
+       /* Check if the selected message in main window has attachments */
+       if (!dimmed && MODEST_IS_MAIN_WINDOW (win)) {
+               dimmed = _selected_msg_marked_as (win, TNY_HEADER_FLAG_ATTACHMENTS, TRUE);
                if (dimmed)
-                       modest_dimming_rule_set_notification (rule, _("mail_ib_attachment_already_purged"));
+                       modest_dimming_rule_set_notification (rule, _("mail_ib_unable_to_purge_attachments"));
        }
 
+       /* Check if all attachments are already purged */
        if (!dimmed) {
-               dimmed = _invalid_attachment_for_purge (win, rule);
+               dimmed = _purged_attach_selected (win, TRUE, rule);
+       }
+
+       /* Check if the message is already downloaded */
+       if (!dimmed && MODEST_IS_MAIN_WINDOW (win)) {
+               dimmed = !_msg_download_completed (MODEST_MAIN_WINDOW (win));
+               if (dimmed)
+                       modest_dimming_rule_set_notification (rule, _("mail_ib_attach_not_local"));
        }
 
 
@@ -1419,29 +1458,46 @@ _invalid_attach_selected (ModestWindow *win,
 }
 
 static gboolean
-_purged_attach_selected (ModestWindow *win) 
+_purged_attach_selected (ModestWindow *win, gboolean all, ModestDimmingRule *rule) 
 {
        GList *attachments, *node;
-       gint n_selected;
+       gint purged = 0;
+       gint n_attachments = 0;
        gboolean result = FALSE;
 
+       /* This should check if _all_ the attachments are already purged. If only some
+        * of them are purged, then it does not cause dim as there's a confirmation dialog
+        * for removing only local attachments */
+
+       /* Get selected atachments */
        if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
-               
-               /* Get selected atachments */
                attachments = modest_msg_view_window_get_attachments (MODEST_MSG_VIEW_WINDOW(win));
-               n_selected = g_list_length (attachments);
+       } else if (MODEST_IS_MAIN_WINDOW (win)) {
+               /* If we're in main window, we won't know if there are already purged attachments */
+               return FALSE;
+       }
 
-               for (node = attachments; node != NULL && !result; node = g_list_next (node)) {
-                       TnyMimePart *mime_part = TNY_MIME_PART (node->data);
-                       if (tny_mime_part_is_purged (mime_part)) {
-                               result = TRUE;
-                               break;
-                       }
+       if (attachments == NULL)
+               return FALSE;
+
+       for (node = attachments; node != NULL; node = g_list_next (node)) {
+               TnyMimePart *mime_part = TNY_MIME_PART (node->data);
+               if (tny_mime_part_is_purged (mime_part)) {
+                       purged++;
                }
-               
-               /* Free */
-               g_list_free (attachments);
+               n_attachments++;
        }
+               
+       /* Free */
+       g_list_free (attachments);
+
+       if (all)
+               result = (purged == n_attachments);
+       else
+               result = (purged > 0);
+
+       if (result && (rule != NULL))
+               modest_dimming_rule_set_notification (rule, _("mail_ib_attachment_already_purged"));
 
        return result;
 }
@@ -1744,8 +1800,8 @@ _sending_in_progress (ModestWindow *win)
 }
 
 static gboolean
-_invalid_attachment_for_purge (ModestWindow *win, 
-                              ModestDimmingRule *rule)
+_invalid_folder_for_purge (ModestWindow *win, 
+                          ModestDimmingRule *rule)
 {
        TnyMsg *msg = NULL;
        TnyFolder *folder = NULL;
@@ -1762,33 +1818,57 @@ _invalid_attachment_for_purge (ModestWindow *win,
                        modest_dimming_rule_set_notification (rule, _("mail_ib_unable_to_purge_attachments"));
                        goto frees;                     
                }
-               account = modest_tny_folder_get_account (folder);
-               if (account == NULL) goto frees;                        
+               g_object_unref (msg);
+       } else if (MODEST_IS_MAIN_WINDOW (win)) {
+               GtkWidget *folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
+                                                                             MODEST_WIDGET_TYPE_FOLDER_VIEW);
+               if (!folder_view)
+                       return FALSE;
+               folder = TNY_FOLDER (modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view)));
+               if (folder == NULL || ! TNY_IS_FOLDER (folder))
+                       return FALSE;
+               g_object_ref (folder);
                
-               /* Check account */
-               if (!modest_tny_account_is_virtual_local_folders (TNY_ACCOUNT (account))) {
-                       const gchar *proto_str = tny_account_get_proto (TNY_ACCOUNT (account));
-                       /* If it's POP then dim */
-                       if (modest_protocol_info_get_transport_store_protocol (proto_str) == 
-                           MODEST_PROTOCOL_STORE_POP) {
-                               GList *attachments;
-                               gint n_selected;
-                               result = TRUE;
-                               attachments = modest_msg_view_window_get_attachments (MODEST_MSG_VIEW_WINDOW(win));
-                               n_selected = g_list_length (attachments);
-                               g_list_free (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));
-                       }
+       } else {
+               g_return_val_if_reached (FALSE);
+       }
+       account = modest_tny_folder_get_account (folder);
+       if (account == NULL) goto frees;                        
+               
+       /* Check account */
+       if (modest_tny_account_is_virtual_local_folders (TNY_ACCOUNT (account))) {
+               TnyFolderType types[2];
+               types[0] = TNY_FOLDER_TYPE_DRAFTS;
+               types[1] = TNY_FOLDER_TYPE_OUTBOX;
+               
+               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 {
+                       /* We're currently disabling purge in any local store */
+                       result = TRUE;
+                       modest_dimming_rule_set_notification (rule, _("mail_ib_unable_to_purge_attachments"));
+               }
+       } else {
+               const gchar *proto_str = tny_account_get_proto (TNY_ACCOUNT (account));
+               /* If it's POP then dim */
+               if (modest_protocol_info_get_transport_store_protocol (proto_str) == 
+                   MODEST_PROTOCOL_STORE_POP) {
+                       GList *attachments;
+                       gint n_selected;
+                       result = TRUE;
+                       attachments = modest_msg_view_window_get_attachments (MODEST_MSG_VIEW_WINDOW(win));
+                       n_selected = g_list_length (attachments);
+                       g_list_free (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 (msg != NULL)
-               g_object_unref (msg);
+       
+frees:
        if (folder != NULL)
                g_object_unref (folder);
        if (account != NULL)
index 483c35e..6eebfe6 100644 (file)
@@ -168,7 +168,7 @@ static void
 modest_attachment_view_set_part_default (TnyMimePartView *self, TnyMimePart *mime_part)
 {
        ModestAttachmentViewPriv *priv = NULL;
-       const gchar *filename = NULL;
+       gchar *filename = NULL;
        gchar *file_icon_name = NULL;
        gboolean show_size = FALSE;
        
@@ -195,19 +195,22 @@ modest_attachment_view_set_part_default (TnyMimePartView *self, TnyMimePart *mim
        priv->size = 0;
        
        if (tny_mime_part_is_purged (mime_part)) {
-               filename = _("TODO: purged file");
+               const gchar *real_filename = tny_mime_part_get_filename (mime_part);
+               if (real_filename == NULL)
+                       real_filename = "";
+               filename = g_strdup_printf (_("FIXME: Purged %s"), real_filename);
                file_icon_name = modest_platform_get_file_icon_name (NULL, NULL, NULL);
        } else if (TNY_IS_MSG (mime_part)) {
                TnyHeader *header = tny_msg_get_header (TNY_MSG (mime_part));
                if (TNY_IS_HEADER (header)) {
-                       filename = tny_header_get_subject (header);
+                       filename = g_strdup (tny_header_get_subject (header));
                        if (filename == NULL)
-                               filename = _("mail_va_no_subject");
+                               filename = g_strdup (_("mail_va_no_subject"));
                        file_icon_name = modest_platform_get_file_icon_name (NULL, tny_mime_part_get_content_type (mime_part), NULL);
                        g_object_unref (header);
                }
        } else {
-               filename = tny_mime_part_get_filename (mime_part);
+               filename = g_strdup (tny_mime_part_get_filename (mime_part));
                file_icon_name = modest_platform_get_file_icon_name (filename, 
                                                                     tny_mime_part_get_content_type (mime_part), 
                                                                     NULL);
@@ -222,6 +225,7 @@ modest_attachment_view_set_part_default (TnyMimePartView *self, TnyMimePart *mim
        }
 
        gtk_label_set_text (GTK_LABEL (priv->filename_view), filename);
+       g_free (filename);
        update_filename_request (MODEST_ATTACHMENT_VIEW (self));
 
        gtk_label_set_text (GTK_LABEL (priv->size_view), "");
index f07fc71..65b97cd 100644 (file)
@@ -209,10 +209,13 @@ void            modest_msg_view_window_save_attachments (ModestMsgViewWindow *wi
 /**
  * modest_msg_view_window_remove_attachments:
  * @window: a #ModestMsgViewWindow
+ * @get_all: a #gboolean. If %TRUE, purges all attachmnents, if %FALSE,
+ * purges only selected ones.
  *
  * Removes selected attachments.
  */
-void            modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window);
+void            modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window,
+                                                          gboolean get_all);
 
 
 /**
index 728ec5d..72dbaa9 100644 (file)
@@ -1556,6 +1556,18 @@ modest_msg_view_get_selected_attachments (ModestMsgView *self)
        
 }
 
+GList *
+modest_msg_view_get_attachments (ModestMsgView *self)
+{
+       ModestMsgViewPrivate *priv;
+
+       g_return_val_if_fail (MODEST_IS_MSG_VIEW (self), NULL);
+       priv = MODEST_MSG_VIEW_GET_PRIVATE (self);
+
+       return modest_attachments_view_get_attachments (MODEST_ATTACHMENTS_VIEW (priv->attachments_view));
+       
+}
+
 void
 modest_msg_view_grab_focus (ModestMsgView *view)
 {
index e496bab..0d73921 100644 (file)
@@ -134,6 +134,7 @@ gdouble modest_msg_view_get_zoom (ModestMsgView *self);
 TnyHeaderFlags modest_msg_view_get_priority (ModestMsgView *self);
 void modest_msg_view_set_priority (ModestMsgView *self, TnyHeaderFlags flags);
 GList *modest_msg_view_get_selected_attachments (ModestMsgView *self);
+GList *modest_msg_view_get_attachments (ModestMsgView *self);
 void modest_msg_view_grab_focus (ModestMsgView *self);
 void modest_msg_view_remove_attachment (ModestMsgView *view, TnyMimePart *attachment);