* Now we block sending mails (from any account) when we're changing
authorJose Dapena Paz <jdapena@igalia.com>
Mon, 22 Sep 2008 20:57:21 +0000 (20:57 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Mon, 22 Sep 2008 20:57:21 +0000 (20:57 +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-trunk-r5681

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

index e4d8b51..bdfb231 100644 (file)
@@ -1099,6 +1099,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) {
@@ -1206,6 +1208,10 @@ modest_default_account_settings_dialog_init (ModestDefaultAccountSettingsDialog
     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 e84c8d9..8707d0e 100644 (file)
@@ -1289,10 +1289,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 5344694..8d540c3 100644 (file)
@@ -145,6 +145,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), \
@@ -266,6 +269,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,
@@ -2205,3 +2209,24 @@ modest_tny_account_store_shutdown (ModestTnyAccountStore *self,
                g_free (op_data);
        }
 }
+
+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 9e7474e..8031fe5 100644 (file)
@@ -248,6 +248,30 @@ void modest_tny_account_store_shutdown (ModestTnyAccountStore *self,
                                        gpointer userdata);
                                        
 
+/**
+ * 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__ */