* Fixes NB#77589, modest asks the user if they want to retrieve more mails than...
[modest] / src / modest-ui-actions.c
index 34a0d7b..908b0e4 100644 (file)
@@ -1055,9 +1055,7 @@ open_msgs_performer(gboolean canceled,
        not_opened_headers = TNY_LIST (user_data);
 
        status = tny_account_get_connection_status (account);
-       if (err || canceled || 
-           (modest_tny_folder_store_is_remote (TNY_FOLDER_STORE (account)) &&
-                                               status != TNY_CONNECTION_STATUS_CONNECTED)) {
+       if (err || canceled) {
                /* TODO: Show an error ? */
                goto clean;
        }
@@ -1651,6 +1649,29 @@ new_messages_arrived (ModestMailOperation *self,
                g_object_unref (source);
 }
 
+gboolean
+retrieve_all_messages_cb (GObject *source,
+                         guint num_msgs,
+                         guint retrieve_limit)
+{
+       GtkWindow *window;
+       gchar *msg;
+       gint response;
+
+       window = GTK_WINDOW (source);
+       msg = g_strdup_printf (_("mail_nc_msg_count_limit_exceeded"), 
+                              num_msgs, retrieve_limit);
+
+       /* Ask the user if they want to retrieve all the messages */
+       response = 
+               modest_platform_run_confirmation_dialog_with_buttons (window, msg,
+                                                                     _("mcen_bd_get_all"),
+                                                                     _("mcen_bd_newest_only"));
+       /* Free and return */
+       g_free (msg);
+       return (response == GTK_RESPONSE_ACCEPT) ? TRUE : FALSE;
+}
+
 typedef struct {
        TnyAccount *account;
        ModestWindow *win;
@@ -1679,7 +1700,7 @@ do_send_receive_performer (gboolean canceled,
                modest_main_window_notify_send_receive_initied (MODEST_MAIN_WINDOW (info->win));
        }
        
-       mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT (info->win),
+       mail_op = modest_mail_operation_new_with_error_handling ((info->win) ? G_OBJECT (info->win) : NULL,
                                                                 modest_ui_actions_send_receive_error_handler,
                                                                 NULL, NULL);
 
@@ -1691,6 +1712,7 @@ do_send_receive_performer (gboolean canceled,
        /* Send & receive. */
        modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
        modest_mail_operation_update_account (mail_op, info->account_name, (info->win) ? FALSE : TRUE,
+                                             (info->win) ? retrieve_all_messages_cb : NULL, 
                                              new_messages_arrived, info->win);
        g_object_unref (G_OBJECT (mail_op));