On saving attachments, detect no space condition (fixes NB#96905).
[modest] / src / hildon2 / modest-msg-view-window.c
index 226d5b5..66df0c9 100644 (file)
@@ -33,6 +33,7 @@
 #include <tny-msg.h>
 #include <tny-mime-part.h>
 #include <tny-vfs-stream.h>
+#include <tny-error.h>
 #include "modest-marshal.h"
 #include "modest-platform.h"
 #include <modest-utils.h>
@@ -1537,7 +1538,7 @@ modest_msg_view_window_zoom_plus (ModestWindow *window)
 
        /* set zoom level */
        int_zoom = (gint) rint (zoom_level*100.0+0.1);
-       banner_text = g_strdup_printf (_("wdgt_ib_zoom"), int_zoom);
+       banner_text = g_strdup_printf (_HL("wdgt_ib_zoom"), int_zoom);
        modest_platform_information_banner (GTK_WIDGET (window), NULL, banner_text);
        g_free (banner_text);
        modest_zoomable_set_zoom (MODEST_ZOOMABLE (priv->msg_view), zoom_level);
@@ -1578,7 +1579,7 @@ modest_msg_view_window_zoom_minus (ModestWindow *window)
 
        /* set zoom level */
        int_zoom = (gint) rint (zoom_level*100.0+0.1);
-       banner_text = g_strdup_printf (_("wdgt_ib_zoom"), int_zoom);
+       banner_text = g_strdup_printf (_HL("wdgt_ib_zoom"), int_zoom);
        modest_platform_information_banner (GTK_WIDGET (window), NULL, banner_text);
        g_free (banner_text);
        modest_zoomable_set_zoom (MODEST_ZOOMABLE (priv->msg_view), zoom_level);
@@ -2394,7 +2395,8 @@ modest_msg_view_window_get_attachments (ModestMsgViewWindow *win)
        g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (win), NULL);
        priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (win);
 
-       selected_attachments = modest_msg_view_get_selected_attachments (MODEST_MSG_VIEW (priv->msg_view));
+       /* In Hildon 2.2 as there's no selection we assume we have all attachments selected */
+       selected_attachments = modest_msg_view_get_attachments (MODEST_MSG_VIEW (priv->msg_view));
        
        return selected_attachments;
 }
@@ -2643,8 +2645,14 @@ save_mime_part_to_file (SaveMimePartInfo *info)
                stream = tny_vfs_stream_new (handle);
                if (tny_mime_part_decode_to_stream (pair->part, stream, &error) < 0) {
                        g_warning ("modest: could not save attachment %s: %d (%s)\n", pair->filename, error?error->code:-1, error?error->message:"Unknown error");
-                       
-                       info->result = GNOME_VFS_ERROR_IO;
+
+                       if ((error->domain == TNY_ERROR_DOMAIN) && 
+                           (error->code = TNY_IO_ERROR_WRITE) &&
+                           (errno == ENOSPC)) {
+                               info->result = GNOME_VFS_ERROR_NO_SPACE;
+                       } else {
+                               info->result = GNOME_VFS_ERROR_IO;
+                       }
                }
                g_object_unref (G_OBJECT (stream));
                g_object_unref (pair->part);
@@ -2771,7 +2779,9 @@ modest_msg_view_window_save_attachments (ModestMsgViewWindow *window, TnyList *m
        priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
 
        if (mime_parts == NULL) {
-               mime_parts = modest_msg_view_get_selected_attachments (MODEST_MSG_VIEW (priv->msg_view));
+               /* In Hildon 2.2 save and delete operate over all the attachments as there's no
+                * selection available */
+               mime_parts = modest_msg_view_get_attachments (MODEST_MSG_VIEW (priv->msg_view));
                if (mime_parts == NULL || tny_list_get_length (mime_parts) == 0)
                        return;
        } else {
@@ -2867,10 +2877,10 @@ modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window, gboolean
        g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window));
        priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
 
-       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));
+       /* In hildon 2.2 we ignore the get_all flag as we always get all attachments. This is
+        * because we don't have selection
+        */
+       mime_parts = modest_msg_view_get_attachments (MODEST_MSG_VIEW (priv->msg_view));
                
        /* Remove already purged messages from mime parts list */
        iter = tny_list_create_iterator (mime_parts);