Fixes NB#139404, download remote message attachments and open them from modest
[modest] / src / hildon2 / modest-msg-view-window.c
index d7719ed..b45d4f6 100644 (file)
@@ -2157,6 +2157,7 @@ view_msg_cb (ModestMailOperation *mail_op,
                if (self) {
                        /* Restore window title */
                        update_window_title (self);
+                       modest_ui_actions_on_close_window (NULL, MODEST_WINDOW (self));
                        g_object_unref (self);
                }
                return;
@@ -2170,6 +2171,7 @@ view_msg_cb (ModestMailOperation *mail_op,
                if (self) {
                        /* Restore window title */
                        update_window_title (self);
+                       modest_ui_actions_on_close_window (NULL, MODEST_WINDOW (self));
                        g_object_unref (self);
                }
                return;
@@ -2578,23 +2580,32 @@ on_decode_to_stream_async_handler (TnyMimePart *mime_part,
        DecodeAsyncHelper *helper = (DecodeAsyncHelper *) user_data;
        const gchar *content_type;
 
-       /* It could happen that the window was closed */
-       if (GTK_WIDGET_VISIBLE (helper->self))
-               set_progress_hint (helper->self, FALSE);
-
        if (cancelled || err) {
                if (err) {
-                       gchar *msg = g_strdup_printf (_KR("cerm_device_memory_full"), "");
+                       gchar *msg;
+                       if ((err->domain == TNY_ERROR_DOMAIN) && 
+                           (err->code == TNY_IO_ERROR_WRITE) &&
+                           (errno == ENOSPC)) {
+                               msg = g_strdup_printf (_KR("cerm_device_memory_full"), "");
+                       } else {
+                               msg = g_strdup (_("mail_ib_file_operation_failed"));
+                       }
                        modest_platform_information_banner (NULL, NULL, msg);
                        g_free (msg);
                }
                goto free;
        }
 
+       /* It could happen that the window was closed. So we
+          assume it is a cancelation */
+       if (!GTK_WIDGET_VISIBLE (helper->self))
+               goto free;
+
+       /* Remove the progress hint */
+       set_progress_hint (helper->self, FALSE);
+
        content_type = tny_mime_part_get_content_type (mime_part);
-       if ((g_str_has_prefix (content_type, "message/rfc822") ||
-            g_str_has_prefix (content_type, "multipart/") ||
-            g_str_has_prefix (content_type, "text/"))) {
+       if (g_str_has_prefix (content_type, "message/rfc822")) {
                ModestWindowMgr *mgr;
                ModestWindow *msg_win = NULL;
                TnyMsg * msg;
@@ -2624,7 +2635,10 @@ on_decode_to_stream_async_handler (TnyMimePart *mime_part,
                                gtk_widget_show_all (GTK_WIDGET (msg_win));
                        else
                                gtk_widget_destroy (GTK_WIDGET (msg_win));
+                       g_object_unref (msg);
                        g_object_unref (file_stream);
+               } else {
+                       modest_platform_information_banner (NULL, NULL, _("mail_ib_file_operation_failed"));
                }
 
        } else {