* Now we block sending mails (from any account) when we're changing
authorJose Dapena Paz <jdapena@igalia.com>
Fri, 26 Sep 2008 09:48:50 +0000 (09:48 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Fri, 26 Sep 2008 09:48:50 +0000 (09:48 +0000)
  the settings of an account. This should avoid crashes when we
  save settings and a send attempt shows at the same time the
  dialog to enter a password. It's an interlock. (fixes NB#87844).

pmo-diablo-r5770

src/maemo/modest-account-settings-dialog.c
src/modest-mail-operation.c
src/modest-tny-account-store.c
src/modest-tny-account-store.h

index 67bec94..c6b90a0 100644 (file)
@@ -1091,6 +1091,8 @@ on_response (GtkDialog *wizard_dialog,
                /* Don't let the dialog close */
                g_signal_stop_emission_by_name (wizard_dialog, "response");
                return; 
+       } else {
+               modest_tny_account_store_set_send_mail_blocked (modest_runtime_get_account_store (), FALSE);
        }
                
        if (response_id == GTK_RESPONSE_OK) {
@@ -1193,6 +1195,10 @@ modest_account_settings_dialog_init (ModestAccountSettingsDialog *self)
     modest_window_mgr_prevent_hibernation_while_window_is_shown (
        modest_runtime_get_window_mgr (), GTK_WINDOW (self)); 
 
+    /* Prevent sending mails while editing an account, to avoid hangs on unprotected locks
+     * while sending messages causes an error dialog and we have a lock */
+    modest_tny_account_store_set_send_mail_blocked (modest_runtime_get_account_store (), TRUE);
+
     hildon_help_dialog_help_enable (GTK_DIALOG(self), "applications_email_accountsettings",
                                    modest_maemo_utils_get_osso_context());
 }
index ff10f32..ffafe90 100644 (file)
@@ -1288,10 +1288,17 @@ static void
 update_account_send_mail (UpdateAccountInfo *info)
 {
        TnyTransportAccount *transport_account = NULL;
+       ModestTnyAccountStore *account_store;
+
+       account_store = modest_runtime_get_account_store ();
+
+       /* We don't try to send messages while sending mails is blocked */
+       if (modest_tny_account_store_is_send_mail_blocked (account_store))
+               return;
 
        /* Get the transport account */
        transport_account = (TnyTransportAccount *)
-               modest_tny_account_store_get_transport_account_for_open_connection (modest_runtime_get_account_store(),
+               modest_tny_account_store_get_transport_account_for_open_connection (account_store,
                                                                                    info->account_name);
 
        if (transport_account) {
index bed758f..bae02de 100644 (file)
@@ -144,6 +144,9 @@ struct _ModestTnyAccountStorePrivate {
        
        /* Matches transport accounts and outbox folder */
        GHashTable          *outbox_of_transport;
+
+       /* is sending mail blocked? */
+       gboolean send_mail_blocked;
 };
 
 #define MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(o)      (G_TYPE_INSTANCE_GET_PRIVATE((o), \
@@ -265,6 +268,7 @@ modest_tny_account_store_instance_init (ModestTnyAccountStore *obj)
        priv->session                = NULL;
        priv->device                 = NULL;
        priv->sighandlers            = NULL;
+       priv->send_mail_blocked      = FALSE;
        
        priv->outbox_of_transport = g_hash_table_new_full (g_direct_hash,
                                                           g_direct_equal,
@@ -1159,7 +1163,8 @@ modest_tny_account_store_alert (TnyAccountStore *self,
 
        if (error->code == TNY_SERVICE_ERROR_CERTIFICATE)
                retval = modest_platform_run_certificate_confirmation_dialog (server_name,
-                                                                             error->message);
+                                                                             error->message,
+                                                                             TRUE);
        else if (error->code == TNY_SERVICE_ERROR_AUTHENTICATE) {
                modest_platform_run_information_dialog (NULL, prompt, TRUE);
 
@@ -2194,3 +2199,24 @@ modest_tny_account_store_show_account_settings_dialog (ModestTnyAccountStore *se
        }
        
 }
+
+gboolean 
+modest_tny_account_store_is_send_mail_blocked (ModestTnyAccountStore *self)
+{
+       ModestTnyAccountStorePrivate *priv;
+
+       priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
+
+       return priv->send_mail_blocked;
+}
+
+void 
+modest_tny_account_store_set_send_mail_blocked (ModestTnyAccountStore *self, 
+                                               gboolean blocked)
+{
+       ModestTnyAccountStorePrivate *priv;
+
+       priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
+
+       priv->send_mail_blocked = blocked;
+}
index 1ed6d50..d2fe341 100644 (file)
@@ -247,6 +247,30 @@ TnyTransportAccount * modest_tny_account_store_new_connection_specific_transport
 GtkWidget *modest_tny_account_store_show_account_settings_dialog (ModestTnyAccountStore *self,
                                                                  const gchar *account_name);
 
+/**
+ * modest_tny_account_store_is_send_mail_blocked:
+ * @self: a #ModestTnyAccountStore
+ * 
+ * Tells if we've blocked the send queue flush attempts temporally. This is
+ * usually done when we're editing an account, to prevent sending mails as
+ * it can cause problems
+ *
+ * Returns: %TRUE if sending mail is blocked
+ */
+gboolean modest_tny_account_store_is_send_mail_blocked (ModestTnyAccountStore *self);
+
+/**
+ * modest_tny_account_store_set_send_mail_blocked:
+ * @self: a #ModestTnyAccountStore
+ * @blocked: a #gboolean
+ * 
+ * Sets as blocked/non blocked the send queue flush attempts temporally. This is
+ * usually done when we're editing an account, to prevent sending mails as
+ * it can cause problems
+ */
+void modest_tny_account_store_set_send_mail_blocked (ModestTnyAccountStore *self, gboolean blocked);
+
+
 G_END_DECLS
 
 #endif /* __MODEST_TNY_ACCOUNT_STORE_H__ */