* Merged fixes from trunk for bugs 85428, 85378, 85399, 85397, 85455, 85299
authorSergio Villar Senin <svillar@igalia.com>
Thu, 15 May 2008 15:00:58 +0000 (15:00 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Thu, 15 May 2008 15:00:58 +0000 (15:00 +0000)
pmo-diablo-r4536

15 files changed:
src/dbus_api/modest-dbus-callbacks.c
src/gnome/modest-platform.c
src/maemo/easysetup/modest-easysetup-wizard-dialog.c
src/maemo/modest-account-settings-dialog.c
src/maemo/modest-connection-specific-smtp-window.c
src/maemo/modest-msg-edit-window.c
src/maemo/modest-platform.c
src/modest-error.h
src/modest-mail-operation.c
src/modest-platform.h
src/modest-tny-account-store.c
src/modest-ui-actions.c
src/widgets/modest-account-settings-dialog.h
src/widgets/modest-details-dialog.c
src/widgets/modest-window-mgr.c

index 6cb03ba..8e4c047 100644 (file)
@@ -1842,7 +1842,7 @@ modest_dbus_req_filter (DBusConnection *con,
                                         MODEST_DBUS_METHOD_SEARCH)) {
                
        /* don't try to search when there not enough mem */
-               if (modest_platform_check_memory_low (NULL)) {
+               if (modest_platform_check_memory_low (NULL, TRUE)) {
                        g_warning ("%s: not enough memory for searching",
                                   __FUNCTION__);
                        reply_empty_results (con, message);
index 76a5e61..ae40049 100644 (file)
@@ -499,7 +499,9 @@ modest_platform_get_account_settings_wizard (void)
 
 
 
-gboolean modest_platform_check_memory_low (ModestWindow *win)
+gboolean modest_platform_check_memory_low (ModestWindow *win,
+                                          gboolean visuals)
 {
+       g_debug ("%s not implemented", __FUNCTION__);
        return FALSE;
 }
index 94845c1..5aab10c 100644 (file)
@@ -757,9 +757,6 @@ update_incoming_server_title (ModestEasysetupWizardDialog *self)
                 _("mail_fi_emailtype_imap") );
                        
                
-       /* Note that this produces a compiler warning, 
-        * because the compiler does not know that the translated string will have a %s in it.
-        * I do not see a way to avoid the warning while still using these Logical IDs. murrayc. */
        gchar* incomingserver_title = g_strdup_printf(_("mcen_li_emailsetup_servertype"), type);
        g_object_set (G_OBJECT (priv->caption_incoming), "label", incomingserver_title, NULL);
        g_free(incomingserver_title);
index 7746939..04b7e16 100644 (file)
@@ -137,9 +137,6 @@ modest_account_settings_dialog_finalize (GObject *object)
        if (self->account_manager)
                g_object_unref (G_OBJECT (self->account_manager));
                
-       if (self->specific_window)
-               gtk_widget_destroy (self->specific_window);
-               
        if (self->signature_dialog)
                gtk_widget_destroy (self->signature_dialog);
 
@@ -432,7 +429,8 @@ static void
 on_button_signature (GtkButton *button, gpointer user_data)
 {
        ModestAccountSettingsDialog * self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
-       
+       gint response;
+
        /* Create the window, if necessary: */
        if (!(self->signature_dialog)) {
                self->signature_dialog = GTK_WIDGET (modest_signature_editor_dialog_new ());
@@ -450,19 +448,19 @@ on_button_signature (GtkButton *button, gpointer user_data)
        }
 
        /* Show the window: */  
-       gtk_window_set_transient_for (GTK_WINDOW (self->signature_dialog), GTK_WINDOW (self));
-       gtk_window_set_modal (GTK_WINDOW (self->signature_dialog), TRUE);
-    const gint response = gtk_dialog_run (GTK_DIALOG (self->signature_dialog));
-    gtk_widget_hide (self->signature_dialog);
-    if (response != GTK_RESPONSE_OK) {
-       /* Destroy the widget now, and its data: */
-       gtk_widget_destroy (self->signature_dialog);
-       self->signature_dialog = NULL;
-    }
-    else {
-       /* Mark modified, so we use the dialog's data later: */
-       self->modified = TRUE;  
-    }
+       modest_window_mgr_set_modal (modest_runtime_get_window_mgr (),
+                                    GTK_WINDOW (self->signature_dialog));
+
+       response = gtk_dialog_run (GTK_DIALOG (self->signature_dialog));
+       gtk_widget_hide (self->signature_dialog);
+       if (response != GTK_RESPONSE_OK) {
+               /* Destroy the widget now, and its data: */
+               gtk_widget_destroy (self->signature_dialog);
+               self->signature_dialog = NULL;
+       } else {
+               /* Mark modified, so we use the dialog's data later: */
+               self->modified = TRUE;  
+       }
 }
 
 static GtkWidget*
@@ -718,18 +716,15 @@ static void
 on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data)
 {
        ModestAccountSettingsDialog * self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
-       
+       ModestConnectionSpecificSmtpWindow *smtp_win;
+
        /* Create the window if necessary: */
-       if (!(self->specific_window)) {
-               self->specific_window = GTK_WIDGET (modest_connection_specific_smtp_window_new ());
-               modest_connection_specific_smtp_window_fill_with_connections (
-                       MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (self->specific_window), self->account_manager);
-       }
+       smtp_win = modest_connection_specific_smtp_window_new ();
+       modest_connection_specific_smtp_window_fill_with_connections (smtp_win, self->account_manager);
 
        /* Show the window: */  
-       gtk_window_set_transient_for (GTK_WINDOW (self->specific_window), GTK_WINDOW (self));
-       gtk_window_set_modal (GTK_WINDOW (self->specific_window), TRUE);
-       gtk_widget_show (self->specific_window);
+       modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (smtp_win));
+       gtk_widget_show (GTK_WIDGET (smtp_win));
        self->modified = TRUE;
 }
 
@@ -1547,13 +1542,7 @@ save_configuration (ModestAccountSettingsDialog *dialog)
        if (account_name != NULL)
                modest_account_mgr_save_account_settings (dialog->account_manager, dialog->settings);
 
-       if (dialog->specific_window) {
-               return modest_connection_specific_smtp_window_save_server_accounts (
-                       MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (dialog->specific_window));
-       } else {
-               return TRUE;
-       }
-
+       return TRUE;
 }
 
 static gboolean entry_is_empty (GtkWidget *entry)
index 64513d2..8c31398 100644 (file)
@@ -68,7 +68,11 @@ struct _ModestConnectionSpecificSmtpWindowPrivate
        ModestAccountMgr *account_manager;
 };
 
-static gboolean on_key_pressed (GtkWidget *self, GdkEventKey *event, gpointer user_data);
+static void on_response (GtkDialog *dialog, 
+                        gint response, 
+                        gpointer user_data);
+
+/* static gboolean on_key_pressed (GtkWidget *self, GdkEventKey *event, gpointer user_data); */
 
 static void
 modest_connection_specific_smtp_window_get_property (GObject *object, guint property_id,
@@ -219,11 +223,10 @@ modest_connection_specific_smtp_window_fill_with_connections (ModestConnectionSp
        update_model_server_names (self);
 #endif /*MODEST_HAVE_CONIC */
 }
-       
+       
 static void
-on_button_edit (GtkButton *button, gpointer user_data)
+on_button_edit (ModestConnectionSpecificSmtpWindow *self)
 {
-       ModestConnectionSpecificSmtpWindow *self = MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (user_data);
        ModestConnectionSpecificSmtpWindowPrivate *priv = CONNECTION_SPECIFIC_SMTP_WINDOW_GET_PRIVATE (self);
        ModestAccountMgr *mgr = modest_runtime_get_account_mgr ();
        
@@ -235,15 +238,15 @@ on_button_edit (GtkButton *button, gpointer user_data)
        GtkTreeIter iter;
        GtkTreeModel *model = 0;
        if (gtk_tree_selection_get_selected (sel, &model, &iter)) {
-               gtk_tree_model_get (priv->model, &iter, 
-                                   MODEL_COL_ID, &id, 
-                                   MODEL_COL_NAME, &connection_name, 
+               gtk_tree_model_get (priv->model, &iter,
+                                   MODEL_COL_ID, &id,
+                                   MODEL_COL_NAME, &connection_name,
                                    MODEL_COL_SERVER_ACCOUNT_NAME, &server_account_name,
                                    MODEL_COL_SERVER_ACCOUNT_SETTINGS, &server_settings,
                                    -1);
        
                /* printf("DEBUG: %s: BEFORE: connection-specific server_account_name=%s\n", __FUNCTION__, server_account_name); */
-               /* TODO: Is 0 an allowed libconic IAP ID? 
+               /* TODO: Is 0 an allowed libconic IAP ID?
                 * If not then we should check for it. */
                
                /* Get existing server account data if a server account is already specified: */
@@ -266,46 +269,36 @@ on_button_edit (GtkButton *button, gpointer user_data)
                        
                modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (window));
                
-               gboolean dialog_finished = FALSE;
-               while (!dialog_finished)
-               {
-                       gint response = gtk_dialog_run (GTK_DIALOG (window));
-                       if (response == GTK_RESPONSE_OK) {
-                               gtk_widget_hide (window);
-                               dialog_finished = TRUE;
-                               /* Delete any previous data for this row: */
-                               if (server_settings) 
-                               {
-                                       g_object_unref (server_settings);
-                                       server_settings = NULL;
-                               }
-                               
-                               /* Get the new account data and save it in the row for later:
-                                * We free this in finalize(),
-                                * and save it to our configuration in 
-                                * modest_connection_specific_smtp_window_save_server_accounts(). */
-                               server_settings = modest_connection_specific_smtp_edit_window_get_settings (
-                                       MODEST_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW (window));
-                               
-                               if (server_settings) {
-                                       gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter, 
-                                                           MODEL_COL_SERVER_ACCOUNT_SETTINGS, server_settings,
-                                                           MODEL_COL_SERVER_NAME, modest_server_account_settings_get_hostname (server_settings),
-                                                           -1);
-                               } else {
-                                       gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter, 
-                                                           MODEL_COL_SERVER_ACCOUNT_SETTINGS, NULL,
-                                                           MODEL_COL_SERVER_NAME, NULL,
-                                                           MODEL_COL_SERVER_ACCOUNT_NAME, NULL,
-                                                           -1);
-                               }
+               gint response = gtk_dialog_run (GTK_DIALOG (window));
+               if (response == GTK_RESPONSE_OK) {
+
+                       /* Delete any previous data for this row: */
+                       if (server_settings) {
+                               g_object_unref (server_settings);
+                               server_settings = NULL;
                        }
-                       else
-                       {
-                               gtk_widget_hide(window);
-                               dialog_finished = TRUE;
+                       
+                       /* Get the new account data and save it in the row for later:
+                        * We free this in finalize(),
+                        * and save it to our configuration in
+                        * modest_connection_specific_smtp_window_save_server_accounts(). */
+                       server_settings = modest_connection_specific_smtp_edit_window_get_settings (
+                                                                                                   MODEST_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW (window));
+                       
+                       if (server_settings) {
+                               gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter,
+                                                   MODEL_COL_SERVER_ACCOUNT_SETTINGS, server_settings,
+                                                   MODEL_COL_SERVER_NAME, modest_server_account_settings_get_hostname (server_settings),
+                                                   -1);
+                       } else {
+                               gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter,
+                                                   MODEL_COL_SERVER_ACCOUNT_SETTINGS, NULL,
+                                                   MODEL_COL_SERVER_NAME, NULL,
+                                                   MODEL_COL_SERVER_ACCOUNT_NAME, NULL,
+                                                   -1);
                        }
                }
+               gtk_widget_destroy (window);
        }
        g_free (connection_name);
        g_free (id);
@@ -314,16 +307,6 @@ on_button_edit (GtkButton *button, gpointer user_data)
 }
 
 static void
-on_button_cancel (GtkButton *button, gpointer user_data)
-{
-       ModestConnectionSpecificSmtpWindow *self = MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (user_data);
-
-       /* Hide the window.
-        * The code that showed it will respond to the hide signal. */  
-       gtk_widget_hide (GTK_WIDGET (self));
-}
-
-static void
 on_selection_changed (GtkTreeSelection *sel, ModestConnectionSpecificSmtpWindow *self)
 {
        ModestConnectionSpecificSmtpWindowPrivate *priv = 
@@ -367,7 +350,7 @@ modest_connection_specific_smtp_window_init (ModestConnectionSpecificSmtpWindow
 
        /* Show the column headers,
         * which does not seem to be the default on Maemo.
-        */                     
+        */
        gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(priv->treeview), TRUE);
        
        /* name column:
@@ -417,27 +400,12 @@ modest_connection_specific_smtp_window_init (ModestConnectionSpecificSmtpWindow
        gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (priv->treeview));
        gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (scrolled_window), TRUE, TRUE, MODEST_MARGIN_HALF);
        gtk_widget_show (GTK_WIDGET (priv->treeview));
-       
-       /* Add the buttons: */
-       GtkWidget *hbox = gtk_hbox_new (FALSE, MODEST_MARGIN_HALF);
-       gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, MODEST_MARGIN_HALF);
-       gtk_widget_show (hbox);
-       
-       priv->button_edit = gtk_button_new_from_stock (_("mcen_bd_edit"));
-       gtk_box_pack_start (GTK_BOX (hbox), priv->button_edit, TRUE, FALSE, MODEST_MARGIN_HALF);
-       gtk_widget_show (priv->button_edit);
-       g_signal_connect (G_OBJECT (priv->button_edit), "clicked",
-               G_CALLBACK (on_button_edit), self);
-       
-       GtkWidget *button_cancel = gtk_button_new_from_stock (_("mcen_bd_close"));
-       gtk_box_pack_start (GTK_BOX (hbox), button_cancel, TRUE, FALSE, MODEST_MARGIN_HALF);
-       gtk_widget_show (button_cancel);
-       g_signal_connect (G_OBJECT (button_cancel), "clicked",
-               G_CALLBACK (on_button_cancel), self);
-       
-       //gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (vbox));
        gtk_widget_show (vbox);
        
+       /* Hack: we use the response apply to identify the click on the edit button */
+       priv->button_edit = gtk_dialog_add_button (GTK_DIALOG(self), _("mcen_bd_edit"), GTK_RESPONSE_APPLY);
+       gtk_dialog_add_button (GTK_DIALOG(self), _("mcen_bd_close"), GTK_RESPONSE_CLOSE);
+       
        /* Disable the Edit button when nothing is selected: */
        GtkTreeSelection *sel = gtk_tree_view_get_selection (priv->treeview);
        g_signal_connect (sel, "changed",
@@ -453,13 +421,10 @@ modest_connection_specific_smtp_window_init (ModestConnectionSpecificSmtpWindow
        /* Set window title */
        gtk_window_set_title (GTK_WINDOW (self), _("mcen_ti_optionalsmtp_servers"));
 
-       /* Track key presses to close the window if the Escape is pressed */
-       g_signal_connect (G_OBJECT (self), 
-                         "key-press-event", 
-                         G_CALLBACK (on_key_pressed), NULL);
+       g_signal_connect (self, "response", G_CALLBACK (on_response), NULL);
        
        hildon_help_dialog_help_enable (GTK_DIALOG(self),
-                                       "applications_email_connectionsspecificsmtpconf",
+                                       "email_connectionsspecificsmtpconf",
                                        modest_maemo_utils_get_osso_context());
 }
 
@@ -594,15 +559,23 @@ void update_model_server_names (ModestConnectionSpecificSmtpWindow *self)
        }
 }
 
-static gboolean
-on_key_pressed (GtkWidget *self,
-               GdkEventKey *event,
-               gpointer user_data)
+static void
+on_response (GtkDialog *dialog,
+            gint response,
+            gpointer user_data)
 {
-       if (event->keyval == GDK_Escape) {
-               /* Simulate a press on Cancel to close the dialog */
-               on_button_cancel (NULL, self);
+       switch (response) {
+       case GTK_RESPONSE_APPLY:
+               /* We use it for the edit button */
+               on_button_edit (MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (dialog));
+               g_signal_stop_emission_by_name (dialog, "response");
+               break;
+       case GTK_RESPONSE_CLOSE:
+       case GTK_RESPONSE_NONE:
+       case GTK_RESPONSE_DELETE_EVENT:
+               /* Generated as a response to delete-event, i.e,
+                  pressin Esc, or by pressing the Close button */
+               modest_connection_specific_smtp_window_save_server_accounts (MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (dialog));
+               gtk_widget_destroy (GTK_WIDGET (dialog));
        }
-       
-       return FALSE;
 }
index a4c83fe..dc93da1 100644 (file)
@@ -2258,7 +2258,7 @@ modest_msg_edit_window_offer_attach_file (ModestMsgEditWindow *window)
                
        priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
 
-       if (modest_platform_check_memory_low (MODEST_WINDOW(window)))
+       if (modest_platform_check_memory_low (MODEST_WINDOW(window), TRUE))
                return;
        
        dialog = hildon_file_chooser_dialog_new (GTK_WINDOW (window), GTK_FILE_CHOOSER_ACTION_OPEN);
@@ -2659,10 +2659,9 @@ modest_msg_edit_window_open_addressbook (ModestMsgEditWindow *window,
        /* we check for low-mem; in that case, show a warning, and don't allow
         * for the addressbook
         */
-       if (modest_platform_check_memory_low (MODEST_WINDOW(window)))
+       if (modest_platform_check_memory_low (MODEST_WINDOW(window), TRUE))
                return;
 
-
        priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
 
        if (editor == NULL) {
index 4c76772..4519e0f 100644 (file)
@@ -2267,24 +2267,23 @@ modest_platform_get_current_connection (void)
 
 
 gboolean
-modest_platform_check_memory_low (ModestWindow *win)
+modest_platform_check_memory_low (ModestWindow *win,
+                                 gboolean visuals)
 {
        gboolean lowmem;
-
-       g_return_val_if_fail (win == NULL || MODEST_IS_WINDOW(win), FALSE);
        
        /* are we in low memory state? */
        lowmem = osso_mem_in_lowmem_state () ? TRUE : FALSE;
        
-       if (win && lowmem)
+       if (win && lowmem && visuals)
                modest_platform_run_information_dialog (
                        GTK_WINDOW(win),
                        dgettext("ke-recv","memr_ib_operation_disabled"),
                        TRUE);
 
        if (lowmem)
-               g_warning ("%s: low memory reached. disallowing some operations",
-                          __FUNCTION__);
+               g_debug ("%s: low memory reached. disallowing some operations",
+                        __FUNCTION__);
 
        return lowmem;
 }
index 2e2d2ae..e929517 100644 (file)
@@ -49,6 +49,7 @@ typedef enum _ModestErrorCode {
        MODEST_MAIL_OPERATION_ERROR_INSTANCE_CREATION_FAILED,
        MODEST_MAIL_OPERATION_ERROR_FILE_IO, /* couldn't retrieve a file to construct a mail */
        MODEST_MAIL_OPERATION_ERROR_SEND_QUEUE_ADD_ERROR,
+       MODEST_MAIL_OPERATION_ERROR_LOW_MEMORY,
 } ModestErrorCode;
 
 G_END_DECLS
index 267e8e8..b73aafd 100644 (file)
@@ -107,6 +107,8 @@ static void     sync_folder_finish_callback (TnyFolder *self,
                                             GError *err, 
                                             gpointer user_data);
 
+static gboolean _check_memory_low         (ModestMailOperation *mail_op);
+
 enum _ModestMailOperationSignals 
 {
        PROGRESS_CHANGED_SIGNAL,
@@ -2198,13 +2200,20 @@ modest_mail_operation_get_msg (ModestMailOperation *self,
        g_return_if_fail (TNY_IS_HEADER (header));
        
        priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
-       folder = tny_header_get_folder (header);
-
        priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
        priv->total = 1;
        priv->done = 0;
 
+       /* Check memory low */
+       if (_check_memory_low (self)) {
+               if (user_callback)
+                       user_callback (self, header, FALSE, NULL, priv->error, user_data);
+               modest_mail_operation_notify_end (self);
+               return;
+       }
+
        /* Get account and set it into mail_operation */
+       folder = tny_header_get_folder (header);
        priv->account = modest_tny_folder_get_account (TNY_FOLDER(folder));
        
        /* Check for cached messages */
@@ -2234,6 +2243,7 @@ modest_mail_operation_get_msg (ModestMailOperation *self,
        state->total = 0;
        g_signal_emit (G_OBJECT (self), signals[PROGRESS_CHANGED_SIGNAL], 
                                0, state, NULL);
+       g_slice_free (ModestMailOperationState, state);
        
        tny_folder_get_msg_async (folder, header, get_msg_async_cb, get_msg_status_cb, helper);
 
@@ -2363,6 +2373,28 @@ modest_mail_operation_get_msgs_full (ModestMailOperation *self,
        priv->done = 0;
        priv->total = tny_list_get_length(header_list);
 
+       /* Check memory low */
+       if (_check_memory_low (self)) {
+               if (user_callback) {
+                       TnyHeader *header = NULL;
+                       TnyIterator *iter;
+
+                       if (tny_list_get_length (header_list) > 0) {
+                               iter = tny_list_create_iterator (header_list);
+                               header = (TnyHeader *) tny_iterator_get_current (iter);
+                               g_object_unref (iter);
+                       }
+                       user_callback (self, header, FALSE, NULL, priv->error, user_data);
+                       if (header)
+                               g_object_unref (header);
+               }
+               if (notify)
+                       notify (user_data);
+               /* Notify about operation end */
+               modest_mail_operation_notify_end (self);
+               return;
+       }
+
        /* Check uncached messages */
        for (iter = tny_list_create_iterator (header_list), has_uncached_messages = FALSE;
             !has_uncached_messages && !tny_iterator_is_done (iter); 
@@ -2997,9 +3029,17 @@ modest_mail_operation_refresh_folder  (ModestMailOperation *self,
 
        priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
 
-       priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
+       /* Check memory low */
+       if (_check_memory_low (self)) {
+               if (user_callback)
+                       user_callback (self, folder, user_data);
+               /* Notify about operation end */
+               modest_mail_operation_notify_end (self);
+               return;
+       }
 
        /* Get account and set it into mail_operation */
+       priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
        priv->account = modest_tny_folder_get_account  (folder);
        priv->op_type = MODEST_MAIL_OPERATION_TYPE_RECEIVE;
 
@@ -3235,3 +3275,25 @@ modest_mail_operation_to_string (ModestMailOperation *self)
                                priv->done, priv->total,
                                priv->error && priv->error->message ? priv->error->message : "");
 }
+
+/* 
+ * Once the mail operations were objects this will be no longer
+ * needed. I don't like it, but we need it for the moment
+ */
+static gboolean
+_check_memory_low (ModestMailOperation *mail_op)
+{
+       if (modest_platform_check_memory_low (NULL, FALSE)) {
+               ModestMailOperationPrivate *priv;
+
+               priv = MODEST_MAIL_OPERATION_GET_PRIVATE (mail_op);
+               priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
+               g_set_error (&(priv->error),
+                            MODEST_MAIL_OPERATION_ERROR,
+                            MODEST_MAIL_OPERATION_ERROR_LOW_MEMORY,
+                            "Not enough memory to complete the operation");
+               return TRUE;
+       } else {
+               return FALSE;
+       }
+}
index c196d28..9098084 100644 (file)
@@ -513,13 +513,15 @@ ModestConnectedVia modest_platform_get_current_connection (void);
  * modest_platform_check_memory_low:
  * 
  * @win: a ModestWindow, or NULL
+ * @visuals: whether or not show visual information
  *
  * see if memory is too low for big memory consuming operations
  * optionally show a warning dialog if @win was provided
  *
  * Returns: TRUE if we're in lowmem state, FALSE otherwise
  */
-gboolean modest_platform_check_memory_low (ModestWindow *win);
+gboolean modest_platform_check_memory_low (ModestWindow *win,
+                                          gboolean visuals);
 
 
 G_END_DECLS
index 4d29902..a0fd3de 100644 (file)
@@ -521,9 +521,8 @@ show_wrong_password_dialog (TnyAccount *account)
 { 
        /* This is easier than using a struct for the user_data: */
        ModestTnyAccountStore *self = modest_runtime_get_account_store();
-       const gchar *modest_account_name;
        GtkWidget *main_window;
-       GtkWidget *dialog;
+       GtkWidget *dialog = NULL;
 
        main_window = (GtkWidget *) modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (),
                                                                       FALSE); /* don't create */
@@ -532,16 +531,16 @@ show_wrong_password_dialog (TnyAccount *account)
                return;
        }
 
-       modest_account_name = modest_tny_account_get_parent_modest_account_name_for_server_account (account);
-       if (!modest_account_name) {
-               g_warning ("%s: modest_tny_account_get_parent_modest_account_name_for_server_account() failed.\n", 
-                       __FUNCTION__);
+       if (g_object_get_data (G_OBJECT (account), "connection_specific") != NULL) {
+               modest_ui_actions_on_smtp_servers (NULL, NULL);
+       } else {
+               const gchar *modest_account_name;
+               modest_account_name = modest_tny_account_get_parent_modest_account_name_for_server_account (account);   
+               dialog = modest_tny_account_store_show_account_settings_dialog (self, modest_account_name);
+               modest_account_settings_dialog_save_password (MODEST_ACCOUNT_SETTINGS_DIALOG (dialog));
        }
-       
-       dialog = modest_tny_account_store_show_account_settings_dialog (self, modest_account_name);
-       modest_account_settings_dialog_save_password (MODEST_ACCOUNT_SETTINGS_DIALOG (dialog));
        /* Show an explanatory temporary banner: */
-       modest_platform_information_banner (GTK_WIDGET(dialog), NULL, _("mcen_ib_username_pw_incorrect"));
+       modest_platform_information_banner (dialog, NULL, _("mcen_ib_username_pw_incorrect"));
 }
 
 /* This callback will be called by Tinymail when it needs the password
@@ -970,16 +969,8 @@ modest_tny_account_store_new (ModestAccountMgr *account_mgr,
           global OUTBOX hosted in the local account */
        add_existing_accounts (MODEST_TNY_ACCOUNT_STORE (obj));
        
-       /* FIXME: I'm doing this (adding an "if (FALSE)"because this
-          stuff is not working properly and could cause SIGSEVs, for
-          example one send queue will be created for each connection
-          specific SMTP server, so when tinymail asks for the outbox
-          it will return NULL because there is no outbox folder for
-          this specific transport accounts, and it's a must that the
-          send queue returns an outbox */
-       if (TRUE)
-               /* Add connection-specific transport accounts */
-               add_connection_specific_transport_accounts (MODEST_TNY_ACCOUNT_STORE(obj));
+       /* Add connection-specific transport accounts */
+       add_connection_specific_transport_accounts (MODEST_TNY_ACCOUNT_STORE(obj));
        
        /* This is a singleton, so it does not need to be unrefed. */
        if (volume_path_is_mounted (MODEST_MCC1_VOLUMEPATH)) {
@@ -1913,6 +1904,9 @@ modest_tny_account_store_new_connection_specific_transport_account (ModestTnyAcc
                g_object_set_data (G_OBJECT(tny_account), 
                                   "account_store", 
                                   (gpointer)self);
+               g_object_set_data (G_OBJECT(tny_account), 
+                                  "connection_specific", 
+                                  GINT_TO_POINTER (TRUE));
                
                tny_list_append (priv->transport_accounts, G_OBJECT (tny_account));
                add_outbox_from_transport_account_to_global_outbox (self, 
index dbaa76b..2abfeca 100644 (file)
@@ -102,6 +102,7 @@ typedef struct _ReplyForwardHelper {
        ReplyForwardAction action;
        gchar *account_name;
        GtkWidget *parent_window;
+       TnyHeader *header;
 } ReplyForwardHelper;
 
 typedef struct _MoveToHelper {
@@ -655,18 +656,6 @@ modest_ui_actions_on_accounts (GtkAction *action,
        }
 }
 
-#ifdef MODEST_PLATFORM_MAEMO
-static void
-on_smtp_servers_window_hide (GtkWindow* window, gpointer user_data)
-{
-       /* Save any changes. */
-       modest_connection_specific_smtp_window_save_server_accounts (
-                       MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (window));
-       gtk_widget_destroy (GTK_WIDGET (window));
-}
-#endif
-
-
 void
 modest_ui_actions_on_smtp_servers (GtkAction *action, ModestWindow *win)
 {
@@ -682,14 +671,10 @@ modest_ui_actions_on_smtp_servers (GtkAction *action, ModestWindow *win)
                MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (specific_window), 
                modest_runtime_get_account_mgr());
 
-       /* Show the window: */  
-       gtk_window_set_transient_for (GTK_WINDOW (specific_window), GTK_WINDOW (win));
-       gtk_window_set_modal (GTK_WINDOW (specific_window), TRUE);
+       /* Show the window: */
+       modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), 
+                                    GTK_WINDOW (specific_window));
        gtk_widget_show (specific_window);
-    
-       /* Save changes when the window is hidden: */
-       g_signal_connect (specific_window, "hide", 
-               G_CALLBACK (on_smtp_servers_window_hide), win);
 #endif /* MODEST_PLATFORM_MAEMO */
 }
 
@@ -717,7 +702,7 @@ modest_ui_actions_compose_msg(ModestWindow *win,
        /* we check for low-mem; in that case, show a warning, and don't allow
         * composing a message with attachments
         */
-       if (attachments && modest_platform_check_memory_low (win))
+       if (attachments && modest_platform_check_memory_low (win, TRUE))
                goto cleanup;
 
        account_name = modest_account_mgr_get_default_account(mgr);
@@ -816,6 +801,17 @@ modest_ui_actions_msg_retrieval_check (ModestMailOperation *mail_op,
        /* If there is no message or the operation was not successful */
        status = modest_mail_operation_get_status (mail_op);
        if (!msg || status != MODEST_MAIL_OPERATION_STATUS_SUCCESS) {
+               const GError *error;
+
+               /* If it's a memory low issue, then show a banner */
+               error = modest_mail_operation_get_error (mail_op);
+               if (error && error->code == MODEST_MAIL_OPERATION_ERROR_LOW_MEMORY) {
+                       GObject *source = modest_mail_operation_get_source (mail_op);
+                       modest_platform_run_information_dialog (GTK_IS_WINDOW (source) ? GTK_WINDOW (source) : NULL,
+                                                               dgettext("ke-recv","memr_ib_operation_disabled"),
+                                                               TRUE);
+                       g_object_unref (source);
+               }
 
                /* Remove the header from the preregistered uids */
                modest_window_mgr_unregister_header (modest_runtime_get_window_mgr (),  
@@ -1406,7 +1402,7 @@ modest_ui_actions_on_open (GtkAction *action, ModestWindow *win)
        /* we check for low-mem; in that case, show a warning, and don't allow
         * opening
         */
-       if (modest_platform_check_memory_low (MODEST_WINDOW(win)))
+       if (modest_platform_check_memory_low (MODEST_WINDOW(win), TRUE))
                return;
 
        /* Get headers */
@@ -1420,6 +1416,26 @@ modest_ui_actions_on_open (GtkAction *action, ModestWindow *win)
        g_object_unref(headers);
 }
 
+static ReplyForwardHelper*
+create_reply_forward_helper (ReplyForwardAction action, 
+                            ModestWindow *win,
+                            guint reply_forward_type,
+                            TnyHeader *header)
+{
+       ReplyForwardHelper *rf_helper = NULL;
+       const gchar *active_acc = modest_window_get_active_account (win);
+
+       rf_helper = g_slice_new0 (ReplyForwardHelper);
+       rf_helper->reply_forward_type = reply_forward_type;
+       rf_helper->action = action;
+       rf_helper->parent_window = (MODEST_IS_WINDOW (win)) ? GTK_WIDGET (win) : NULL;
+       rf_helper->header = (header) ? g_object_ref (header) : NULL;
+       rf_helper->account_name = (active_acc) ? 
+               g_strdup (active_acc) :
+               modest_account_mgr_get_default_account (modest_runtime_get_account_mgr());
+
+       return rf_helper;
+}
 
 static void
 free_reply_forward_helper (gpointer data)
@@ -1428,6 +1444,8 @@ free_reply_forward_helper (gpointer data)
 
        helper = (ReplyForwardHelper *) data;
        g_free (helper->account_name);
+       if (helper->header)
+               g_object_unref (helper->header);
        g_slice_free (ReplyForwardHelper, helper);
 }
 
@@ -1439,7 +1457,7 @@ reply_forward_cb (ModestMailOperation *mail_op,
                  GError *err,
                  gpointer user_data)
 {
-       TnyMsg *new_msg;
+       TnyMsg *new_msg = NULL;
        ReplyForwardHelper *rf_helper;
        ModestWindow *msg_win = NULL;
        ModestEditType edit_type;
@@ -1452,11 +1470,9 @@ reply_forward_cb (ModestMailOperation *mail_op,
        /* If there was any error. The mail operation could be NULL,
           this means that we already have the message downloaded and
           that we didn't do a mail operation to retrieve it */
-       if (mail_op && !modest_ui_actions_msg_retrieval_check (mail_op, header, msg))
-               return;
-                       
-       g_return_if_fail (user_data != NULL);
        rf_helper = (ReplyForwardHelper *) user_data;
+       if (mail_op && !modest_ui_actions_msg_retrieval_check (mail_op, header, msg))
+               goto cleanup;
 
        from = modest_account_mgr_get_from_string (modest_runtime_get_account_mgr(),
                                                   rf_helper->account_name);
@@ -1492,10 +1508,11 @@ reply_forward_cb (ModestMailOperation *mail_op,
                return;
        }
 
+       g_free (from);
        g_free (signature);
 
        if (!new_msg) {
-               g_printerr ("modest: failed to create message\n");
+               g_warning ("%s: failed to create message\n", __FUNCTION__);
                goto cleanup;
        }
 
@@ -1503,7 +1520,7 @@ reply_forward_cb (ModestMailOperation *mail_op,
                                                                       rf_helper->account_name,
                                                                       TNY_ACCOUNT_TYPE_STORE);
        if (!account) {
-               g_printerr ("modest: failed to get tnyaccount for '%s'\n", rf_helper->account_name);
+               g_warning ("%s: failed to get tnyaccount for '%s'\n", __FUNCTION__, rf_helper->account_name);
                goto cleanup;
        }
 
@@ -1529,7 +1546,6 @@ cleanup:
                g_object_unref (G_OBJECT (new_msg));
        if (account)
                g_object_unref (G_OBJECT (account));
-/*     g_object_unref (msg); */
        free_reply_forward_helper (rf_helper);
 }
 
@@ -1586,25 +1602,48 @@ connect_to_get_msg (ModestWindow *win,
        return modest_platform_connect_and_wait((GtkWindow *) win, account);
 }
 
+static void
+reply_forward_performer (gboolean canceled, 
+                        GError *err,
+                        GtkWindow *parent_window, 
+                        TnyAccount *account, 
+                        gpointer user_data)
+{
+       ReplyForwardHelper *rf_helper = NULL;
+       ModestMailOperation *mail_op;
+
+       rf_helper = (ReplyForwardHelper *) user_data;
+
+       if (canceled || err) {
+               free_reply_forward_helper (rf_helper);
+               return;
+       }
+
+       /* Retrieve the message */
+       mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT (parent_window),
+                                                                modest_ui_actions_disk_operations_error_handler,
+                                                                NULL, NULL);
+       modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
+       modest_mail_operation_get_msg (mail_op, rf_helper->header, reply_forward_cb, rf_helper);
+
+       /* Frees */
+       g_object_unref(mail_op);
+}
+
 /*
  * Common code for the reply and forward actions
  */
 static void
 reply_forward (ReplyForwardAction action, ModestWindow *win)
 {
-       ModestMailOperation *mail_op = NULL;
-       TnyList *header_list = NULL;
        ReplyForwardHelper *rf_helper = NULL;
        guint reply_forward_type;
-       gboolean continue_download = TRUE;
-       gboolean do_retrieve = TRUE;
        
        g_return_if_fail (MODEST_IS_WINDOW(win));
-
                        
        /* we check for low-mem; in that case, show a warning, and don't allow
         * reply/forward (because it could potentially require a lot of memory */
-       if (modest_platform_check_memory_low (MODEST_WINDOW(win)))
+       if (modest_platform_check_memory_low (MODEST_WINDOW(win), TRUE))
                return;
 
 
@@ -1614,113 +1653,115 @@ reply_forward (ReplyForwardAction action, ModestWindow *win)
                        return;
        }
        
-       header_list = get_selected_headers (win);
-       if (!header_list)
-               return;
-
-       reply_forward_type = 
+       reply_forward_type =
                modest_conf_get_int (modest_runtime_get_conf (),
-                                    (action == ACTION_FORWARD) ? MODEST_CONF_FORWARD_TYPE : MODEST_CONF_REPLY_TYPE,
+                                    (action == ACTION_FORWARD) ? 
+                                    MODEST_CONF_FORWARD_TYPE :
+                                    MODEST_CONF_REPLY_TYPE,
                                     NULL);
 
-       /* check if we need to download msg before asking about it */
-       do_retrieve = (action == ACTION_FORWARD) ||
-                       (reply_forward_type != MODEST_TNY_MSG_REPLY_TYPE_CITE);
-
-       if (do_retrieve){
-               gint num_of_unc_msgs;
-
-               /* check that the messages have been previously downloaded */
-               num_of_unc_msgs = header_list_count_uncached_msgs(header_list);
-               /* If there are any uncached message ask the user
-                * whether he/she wants to download them. */
-               if (num_of_unc_msgs) {
-                       TnyAccount *account = get_account_from_header_list (header_list);
-                       if (account) {
-                               continue_download = connect_to_get_msg (win, num_of_unc_msgs, account);
-                               g_object_unref (account);
-                       }
-               }
-       }
-
-       if (!continue_download) {
-               g_object_unref (header_list);
-               return;
-       }
-       
-       /* We assume that we can only select messages of the
-          same folder and that we reply all of them from the
-          same account. In fact the interface currently only
-          allows single selection */
-       
-       /* Fill helpers */
-       rf_helper = g_slice_new0 (ReplyForwardHelper);
-       rf_helper->reply_forward_type = reply_forward_type;
-       rf_helper->action = action;
-       rf_helper->account_name = g_strdup (modest_window_get_active_account (win));
-       
-       if ((win != NULL) && (MODEST_IS_WINDOW (win)))
-               rf_helper->parent_window = GTK_WIDGET (win);
-       if (!rf_helper->account_name)
-               rf_helper->account_name =
-                       modest_account_mgr_get_default_account (modest_runtime_get_account_mgr());
-
-       if (MODEST_IS_MSG_VIEW_WINDOW(win)) {
-               TnyMsg *msg;
-               TnyHeader *header;
+       if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
+               TnyMsg *msg = NULL;
+               TnyHeader *header = NULL;
                /* Get header and message. Do not free them here, the
                   reply_forward_cb must do it */
                msg = modest_msg_view_window_get_message (MODEST_MSG_VIEW_WINDOW(win));
-               header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW(win));
-               if (!msg || !header) {
-                       if (msg)
-                               g_object_unref (msg);
-                       g_printerr ("modest: no message found\n");
-                       return;
-               } else {
+               header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (win));
+
+               if (msg && header) {
+                       /* Create helper */
+                       rf_helper = create_reply_forward_helper (action, win, 
+                                                                reply_forward_type, header);
                        reply_forward_cb (NULL, header, FALSE, msg, NULL, rf_helper);
+               } else {
+                       g_warning("%s: no message or header found in viewer\n", __FUNCTION__);
                }
-               if (header)
+               
+               if (msg)
+                       g_object_unref (msg);
+               if (header)
                        g_object_unref (header);
        } else {
-               TnyHeader *header;
+               TnyHeader *header = NULL;
                TnyIterator *iter;
+               gboolean do_retrieve = TRUE;
+               TnyList *header_list = NULL;
+
+               header_list = get_selected_headers (win);
+               if (!header_list)
+                       return;
+               if (tny_list_get_length (header_list) == 0) {
+                       g_object_unref (header_list);
+                       return;
+               }
 
                /* Only reply/forward to one message */
                iter = tny_list_create_iterator (header_list);
                header = TNY_HEADER (tny_iterator_get_current (iter));
                g_object_unref (iter);
 
-               if (header) {
-                       /* Retrieve messages */
-                       if (do_retrieve) {
-                               mail_op = 
-                                       modest_mail_operation_new_with_error_handling (G_OBJECT(win),
-                                                                                      modest_ui_actions_disk_operations_error_handler, 
-                                                                                      NULL, NULL);
-                               modest_mail_operation_queue_add (
-                                       modest_runtime_get_mail_operation_queue (), mail_op);
-                               
-                               modest_mail_operation_get_msg (mail_op,
-                                                              header,
-                                                              reply_forward_cb,
-                                                              rf_helper);
-                               /* Clean */
-                               g_object_unref(mail_op);
-                       } else {
-                               /* we put a ref here to prevent double unref as the reply
-                                * forward callback unrefs the header at its end */
-                               reply_forward_cb (NULL, header, FALSE, NULL, NULL, rf_helper);
-                       }
+               /* Retrieve messages */
+               do_retrieve = (action == ACTION_FORWARD) ||
+                       (reply_forward_type != MODEST_TNY_MSG_REPLY_TYPE_CITE);
 
+               if (do_retrieve) {
+                       TnyAccount *account = NULL;
+                       TnyFolder *folder = NULL;
+                       gdouble download = TRUE;
+                       guint uncached_msgs = 0;
 
-                       g_object_unref (header);
+                       folder = tny_header_get_folder (header);
+                       if (!folder)
+                               goto do_retrieve_frees;
+                       account = tny_folder_get_account (folder);
+                       if (!account)
+                               goto do_retrieve_frees;
+
+                       uncached_msgs = header_list_count_uncached_msgs (header_list);
+
+                       if (uncached_msgs > 0) {
+                               /* Allways download if we are online. */
+                               if (!tny_device_is_online (modest_runtime_get_device ())) {
+                                       gint response;
+                                       
+                                       /* If ask for user permission to download the messages */
+                                       response = modest_platform_run_confirmation_dialog (GTK_WINDOW (win),
+                                                                                           ngettext("mcen_nc_get_msg",
+                                                                                                    "mcen_nc_get_msgs",
+                                                                                                    uncached_msgs));
+                                       
+                                       /* End if the user does not want to continue */
+                                       if (response == GTK_RESPONSE_CANCEL)
+                                               download = FALSE;
+                               }
+                       }
+                       
+                       if (download) {
+                               /* Create helper */
+                               rf_helper = create_reply_forward_helper (action, win, 
+                                                                        reply_forward_type, header);
+                               if (uncached_msgs > 0) {
+                                       modest_platform_connect_and_perform (GTK_WINDOW (win), 
+                                                                            TRUE, account, 
+                                                                            reply_forward_performer, 
+                                                                            rf_helper);
+                               } else {
+                                       reply_forward_performer (FALSE, NULL, GTK_WINDOW (win), 
+                                                                account, rf_helper);
+                               }
+                       }
+               do_retrieve_frees:
+                       if (account)
+                               g_object_unref (account);
+                       if (folder)
+                               g_object_unref (folder);
+               } else {
+                       reply_forward_cb (NULL, header, FALSE, NULL, NULL, rf_helper);
                }
-
+               /* Frees */
+               g_object_unref (header_list);
+               g_object_unref (header);
        }
-
-       /* Free */
-       g_object_unref (header_list);
 }
 
 void
@@ -2204,7 +2245,7 @@ modest_ui_actions_on_header_activated (ModestHeaderView *header_view,
        /* we check for low-mem; in that case, show a warning, and don't allow
         * activating headers
         */
-       if (modest_platform_check_memory_low (MODEST_WINDOW(main_window)))
+       if (modest_platform_check_memory_low (MODEST_WINDOW(main_window), TRUE))
                return;
 
        modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (main_window));
@@ -2259,10 +2300,21 @@ folder_refreshed_cb (ModestMailOperation *mail_op,
 {
        ModestMainWindow *win = NULL;
        GtkWidget *header_view;
+       const GError *error;
 
        g_return_if_fail (TNY_IS_FOLDER (folder));
 
        win = MODEST_MAIN_WINDOW (user_data);
+
+       /* Check if the operation failed due to memory low conditions */
+       error = modest_mail_operation_get_error (mail_op);
+       if (error && error->code == MODEST_MAIL_OPERATION_ERROR_LOW_MEMORY) {
+               modest_platform_run_information_dialog (GTK_WINDOW (win),
+                                                       dgettext("ke-recv","memr_ib_operation_disabled"),
+                                                       TRUE);
+               return;
+       }
+
        header_view = 
                modest_main_window_get_child_widget(win, MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
 
@@ -2441,7 +2493,7 @@ modest_ui_actions_on_msg_attachment_clicked (ModestMsgView *msgview, TnyMimePart
        /* we check for low-mem; in that case, show a warning, and don't allow
         * viewing attachments
         */
-       if (modest_platform_check_memory_low (MODEST_WINDOW(win)))
+       if (modest_platform_check_memory_low (MODEST_WINDOW(win), TRUE))
                return;
 
        modest_msg_view_window_view_attachment (MODEST_MSG_VIEW_WINDOW (win), mime_part);
@@ -2525,7 +2577,7 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi
         */
        if (expected_size > MODEST_MAX_LOW_MEMORY_MESSAGE_SIZE) {
 
-               if (modest_platform_check_memory_low (MODEST_WINDOW(edit_window))) {
+               if (modest_platform_check_memory_low (MODEST_WINDOW(edit_window), TRUE)) {
                        modest_msg_edit_window_free_msg_data (edit_window, data);
                        return FALSE;
                }
@@ -2695,7 +2747,7 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window)
         * this should still allow for sending anything critical... 
         */
        if (expected_size > MODEST_MAX_LOW_MEMORY_MESSAGE_SIZE) {
-               if (modest_platform_check_memory_low (MODEST_WINDOW(edit_window))) {
+               if (modest_platform_check_memory_low (MODEST_WINDOW(edit_window), TRUE)) {
                        modest_msg_edit_window_free_msg_data (edit_window, data);
                        return FALSE;
                }
@@ -2917,7 +2969,7 @@ modest_ui_actions_on_insert_image (GtkAction *action,
        g_return_if_fail (GTK_IS_ACTION (action));
 
 
-       if (modest_platform_check_memory_low (MODEST_WINDOW(window)))
+       if (modest_platform_check_memory_low (MODEST_WINDOW(window), TRUE))
                return;
 
        if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW(window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
@@ -2933,7 +2985,7 @@ modest_ui_actions_on_attach_file (GtkAction *action,
        g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
        g_return_if_fail (GTK_IS_ACTION (action));
 
-       if (modest_platform_check_memory_low (MODEST_WINDOW(window)))
+       if (modest_platform_check_memory_low (MODEST_WINDOW(window), TRUE))
                return;
        
        modest_msg_edit_window_offer_attach_file (window);
@@ -5404,7 +5456,7 @@ modest_ui_actions_save_attachments (GtkAction *action,
 {
        if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
 
-               if (modest_platform_check_memory_low (MODEST_WINDOW(window)))
+               if (modest_platform_check_memory_low (MODEST_WINDOW(window), TRUE))
                        return;
 
                modest_msg_view_window_save_attachments (MODEST_MSG_VIEW_WINDOW (window), NULL);
@@ -5461,6 +5513,19 @@ modest_ui_actions_on_help (GtkAction *action,
                g_warning ("%s: no help for window %p", __FUNCTION__, win);
 }
 
+static void     
+retrieve_contents_cb (ModestMailOperation *mail_op, 
+                     TnyHeader *header, 
+                     gboolean canceled,
+                     TnyMsg *msg,
+                     GError *err,
+                     gpointer user_data)
+{
+       /* We only need this callback to show an error in case of
+          memory low condition */
+       modest_ui_actions_msg_retrieval_check (mail_op, header, msg);
+}
+
 static void
 retrieve_msg_contents_performer (gboolean canceled, 
                                 GError *err,
@@ -5485,7 +5550,7 @@ retrieve_msg_contents_performer (gboolean canceled,
                                                                 modest_ui_actions_disk_operations_error_handler, 
                                                                 NULL, NULL);
        modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
-       modest_mail_operation_get_msgs_full (mail_op, headers, NULL, NULL, NULL);
+       modest_mail_operation_get_msgs_full (mail_op, headers, retrieve_contents_cb, NULL, NULL);
 
        /* Frees */
        g_object_unref (mail_op);
@@ -5645,7 +5710,7 @@ modest_ui_actions_on_search_messages (GtkAction *action, ModestWindow *window)
        /* we check for low-mem; in that case, show a warning, and don't allow
         * searching
         */
-       if (modest_platform_check_memory_low (window))
+       if (modest_platform_check_memory_low (window, TRUE))
                return;
        
        modest_platform_show_search_messages (GTK_WINDOW (window));
@@ -5660,7 +5725,7 @@ modest_ui_actions_on_open_addressbook (GtkAction *action, ModestWindow *win)
        /* we check for low-mem; in that case, show a warning, and don't allow
         * for the addressbook
         */
-       if (modest_platform_check_memory_low (win))
+       if (modest_platform_check_memory_low (win, TRUE))
                return;
 
 
index 2d15ce9..5e0be24 100644 (file)
@@ -88,7 +88,6 @@ typedef struct {
        GtkWidget *checkbox_outgoing_smtp_specific;
        GtkWidget *button_outgoing_smtp_servers;
        
-       GtkWidget *specific_window;
        GtkWidget *signature_dialog;
        
 } ModestAccountSettingsDialog;
index ebc7959..5e578c0 100644 (file)
@@ -315,14 +315,19 @@ modest_details_dialog_set_folder_default (ModestDetailsDialog *self,
                size_s = modest_text_utils_get_display_size (size);
 
        /* Different names for the local folders */
-       if (modest_tny_folder_is_local_folder (folder)) {
+       if (modest_tny_folder_is_local_folder (folder) ||
+           modest_tny_folder_is_memory_card_folder (folder)) {
                gint type = modest_tny_folder_get_local_or_mmc_folder_type (folder);
                if (type != TNY_FOLDER_TYPE_UNKNOWN)
                        name = g_strdup(modest_local_folder_info_get_type_display_name (type));
-       } 
+       }
 
-       if (!name)      
-               name = g_strdup (tny_folder_get_name (folder));
+       if (!name) {
+               if (tny_folder_get_folder_type (folder) == TNY_FOLDER_TYPE_INBOX)
+                       name = g_strdup (_("mcen_me_folder_inbox"));
+               else
+                       name = g_strdup (tny_folder_get_name (folder));
+       }
 
        tmp = g_strconcat (_("mcen_fi_folder_properties_foldername"), ":", NULL);
        modest_details_dialog_add_data (self, tmp, name);
index 6e93da1..741b5c5 100644 (file)
@@ -52,6 +52,9 @@ static gboolean on_modal_window_close    (GtkWidget *widget,
                                          GdkEvent *event,
                                          gpointer user_data);
 
+static void on_modal_dialog_destroy      (GtkObject *object,
+                                         gpointer   user_data);
+
 static void     on_modal_dialog_close    (GtkDialog *dialog,
                                          gint arg1,
                                          gpointer user_data);
@@ -1130,7 +1133,7 @@ modest_window_mgr_set_modal (ModestWindowMgr *self,
        g_queue_push_head (priv->modal_windows, window);
        g_mutex_unlock (priv->queue_lock);
 
-       if (GTK_IS_DIALOG (window))
+       if (GTK_IS_DIALOG (window)) {
                /* Note that response is not always enough because it
                   could be captured and removed easily by dialogs but
                   works for most of situations */
@@ -1140,13 +1143,25 @@ modest_window_mgr_set_modal (ModestWindowMgr *self,
                                                   "response",
                                                   G_CALLBACK (on_modal_dialog_close), 
                                                   self);
-       else
+               /* We need this as well because dialogs are often
+                  destroyed with gtk_widget_destroy and this one will
+                  prevent response from happening */
+               priv->modal_handler_uids = 
+                       modest_signal_mgr_connect (priv->modal_handler_uids, 
+                                                  G_OBJECT (window), 
+                                                  "destroy",
+                                                  G_CALLBACK (on_modal_dialog_destroy),
+                                                  self);
+       } else {
                priv->modal_handler_uids = 
                        modest_signal_mgr_connect (priv->modal_handler_uids, 
                                                   G_OBJECT (window), 
                                                   "delete-event",
                                                   G_CALLBACK (on_modal_window_close), 
                                                   self);
+       }
+       /* Destroy width parent */
+       gtk_window_set_destroy_with_parent (window, TRUE);
 }
 
 
@@ -1271,12 +1286,17 @@ remove_modal_from_queue (GtkWidget *widget,
        g_mutex_unlock (priv->queue_lock);
 
        /* Disconnect handler */
-       priv->modal_handler_uids = 
-               modest_signal_mgr_disconnect (priv->modal_handler_uids, 
+       priv->modal_handler_uids =
+               modest_signal_mgr_disconnect (priv->modal_handler_uids,
                                              G_OBJECT (widget),
-                                             GTK_IS_DIALOG (widget) ? 
-                                             "response" : 
-                                             "destroy-event");
+                                             GTK_IS_DIALOG (widget) ?
+                                             "response" :
+                                             "delete-event");
+       if (GTK_IS_DIALOG (widget))
+               priv->modal_handler_uids =
+                       modest_signal_mgr_disconnect (priv->modal_handler_uids,
+                                                     G_OBJECT (widget),
+                                                     "destroy");
 
        /* Schedule the next one for being shown */
        g_idle_add (idle_top_modal, self);
@@ -1303,10 +1323,22 @@ on_modal_dialog_close (GtkDialog *dialog,
 {
        ModestWindowMgr *self = MODEST_WINDOW_MGR (user_data);
 
-       /* Remove modal window from queue */
+       /* Remove modal window from queue. Note that if "destroy"
+          signal was invoked before the response the window could be
+          already deleted */
        remove_modal_from_queue (GTK_WIDGET (dialog), self);
 }
 
+static void
+on_modal_dialog_destroy (GtkObject *object,
+                        gpointer   user_data)
+{
+       ModestWindowMgr *self = MODEST_WINDOW_MGR (user_data);
+
+       /* Remove modal window from queue */
+       remove_modal_from_queue (GTK_WIDGET (object), self);
+}
+
 gint 
 modest_window_mgr_num_windows (ModestWindowMgr *self)
 {