Work to fix bug NB#81989:
[modest] / src / modest-ui-actions.c
index bb8402f..d7d3d7a 100644 (file)
@@ -1801,6 +1801,7 @@ typedef struct {
        ModestWindow *win;
        gchar *account_name;
        gboolean poke_status;
+       gboolean interactive;
 } SendReceiveInfo;
 
 static void
@@ -1835,7 +1836,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->poke_status,
+       modest_mail_operation_update_account (mail_op, info->account_name, info->poke_status, info->interactive,
                                              (info->win) ? retrieve_all_messages_cb : NULL, 
                                              new_messages_arrived, info->win);
        g_object_unref (G_OBJECT (mail_op));
@@ -1861,6 +1862,7 @@ void
 modest_ui_actions_do_send_receive (const gchar *account_name, 
                                   gboolean force_connection,
                                   gboolean poke_status,
+                                  gboolean interactive,
                                   ModestWindow *win)
 {
        gchar *acc_name = NULL;
@@ -1889,6 +1891,7 @@ modest_ui_actions_do_send_receive (const gchar *account_name,
        info->account_name = acc_name;
        info->win = (win) ? g_object_ref (win) : NULL;
        info->poke_status = poke_status;
+       info->interactive = interactive;
        info->account = modest_tny_account_store_get_server_account (acc_store, acc_name,
                                                                     TNY_ACCOUNT_TYPE_STORE);
 
@@ -1978,7 +1981,8 @@ modest_ui_actions_cancel_send (GtkAction *action,  ModestWindow *win)
 void
 modest_ui_actions_do_send_receive_all (ModestWindow *win, 
                                       gboolean force_connection,
-                                      gboolean poke_status)
+                                      gboolean poke_status,
+                                      gboolean interactive)
 {
        GSList *account_names, *iter;
 
@@ -1989,7 +1993,7 @@ modest_ui_actions_do_send_receive_all (ModestWindow *win,
        while (iter) {                  
                modest_ui_actions_do_send_receive ((const char*) iter->data, 
                                                   force_connection, 
-                                                  poke_status, win);
+                                                  poke_status, interactive, win);
                iter = g_slist_next (iter);
        }
 
@@ -2032,7 +2036,7 @@ modest_ui_actions_on_send_receive (GtkAction *action, ModestWindow *win)
        
        /* Refresh the active account. Force the connection if needed
           and poke the status of all folders */
-       modest_ui_actions_do_send_receive (NULL, TRUE, TRUE, win);
+       modest_ui_actions_do_send_receive (NULL, TRUE, TRUE, TRUE, win);
 }
 
 
@@ -2915,7 +2919,6 @@ static void
 modest_ui_actions_rename_folder_error_handler (ModestMailOperation *mail_op,
                                               gpointer user_data)
 {
-       ModestMainWindow *window = MODEST_MAIN_WINDOW (user_data);
        const GError *error = NULL;
        const gchar *message = NULL;
        
@@ -2929,12 +2932,12 @@ modest_ui_actions_rename_folder_error_handler (ModestMailOperation *mail_op,
                message = _CS("ckdg_ib_folder_already_exists");
                break;
        default:
-               g_warning ("%s: BUG: unexpected error:[%d]: %s", __FUNCTION__,
-                          error->code, error->message);
-               return;
+               message = _("emev_ib_ui_imap_unable_to_rename");
        }
 
-       modest_platform_information_banner (GTK_WIDGET (window), NULL, message);
+       /* We don't set a parent for the dialog because the dialog
+          will be destroyed so the banner won't appear */
+       modest_platform_information_banner (NULL, NULL, message);
 }
 
 typedef struct {
@@ -2947,9 +2950,15 @@ on_rename_folder_cb (ModestMailOperation *mail_op,
                     TnyFolder *new_folder,
                     gpointer user_data)
 {
-       /* Select now */
-       modest_folder_view_select_folder (MODEST_FOLDER_VIEW (user_data),
-                                         new_folder, FALSE);
+       ModestFolderView *folder_view;
+
+       folder_view = MODEST_FOLDER_VIEW (user_data);
+       /* Note that if the rename fails new_folder will be NULL */
+       if (new_folder) {
+               modest_folder_view_select_folder (folder_view, new_folder, FALSE);
+       } else {
+               modest_folder_view_select_first_inbox_or_local (folder_view);
+       }
 }
 
 static void
@@ -5506,21 +5515,20 @@ modest_ui_actions_on_send_queue_error_happened (TnySendQueue *self,
        TnyTransportAccount *server_account;
        gchar *message = NULL;
 
-       /* Don't show anything if the user cancelled something */
-       if (err->code == TNY_SYSTEM_ERROR_CANCEL)
+       /* Don't show anything if the user cancelled something or the send receive request is not
+        * interactive */
+       if (err->code == TNY_SYSTEM_ERROR_CANCEL ||
+           !modest_tny_send_queue_get_requested_send_receive (MODEST_TNY_SEND_QUEUE (self)))
                return;
 
+
        /* Get the server name: */
        server_account = 
                TNY_TRANSPORT_ACCOUNT (tny_camel_send_queue_get_transport_account (TNY_CAMEL_SEND_QUEUE (self)));
-       if (server_account) {
-               server_name = tny_account_get_hostname (TNY_ACCOUNT (server_account));
-                       
-               g_object_unref (server_account);
-               server_account = NULL;
-       }
-       
-       g_return_if_fail (server_name);
+       if (server_account)
+               server_name = tny_account_get_hostname (TNY_ACCOUNT (server_account));          
+       else
+               g_return_if_reached ();
 
        /* Show the appropriate message text for the GError: */
        switch (err->code) {
@@ -5549,6 +5557,7 @@ modest_ui_actions_on_send_queue_error_happened (TnySendQueue *self,
 
        modest_platform_run_information_dialog (NULL, message);
        g_free (message);
+       g_object_unref (server_account);
 }
 
 void