- gchar *account_name = modest_account_view_get_selected_account (priv->account_view);
- if(!account_name)
- return;
-
- if (account_name) {
- gchar *account_title = modest_account_mgr_get_display_name(account_mgr, account_name);
-
- if (check_for_active_acount (self, account_name)) {
- /* The warning text depends on the account type: */
- gchar *txt = NULL;
- if (modest_account_mgr_get_store_protocol (account_mgr, account_name)
- == MODEST_PROTOCOL_STORE_POP) {
- txt = g_strdup_printf (_("emev_nc_delete_mailbox"),
- account_title);
- } else {
- txt = g_strdup_printf (_("emev_nc_delete_mailboximap"),
- account_title);
- }
-
- GtkDialog *dialog = GTK_DIALOG (hildon_note_new_confirmation (GTK_WINDOW (self),
- txt));
- gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (self));
- g_free (txt);
- txt = NULL;
-
- if (gtk_dialog_run (dialog) == GTK_RESPONSE_OK) {
- /* Remove account. If it succeeds then it also removes
- the account from the ModestAccountView: */
-
- gboolean is_default = FALSE;
- gchar *default_account_name = modest_account_mgr_get_default_account (account_mgr);
- if (default_account_name && (strcmp (default_account_name, account_name) == 0))
- is_default = TRUE;
- g_free (default_account_name);
-
- gboolean removed = modest_account_mgr_remove_account (account_mgr, account_name);
- if (!removed) {
- g_warning ("%s: modest_account_mgr_remove_account() failed.\n", __FUNCTION__);
- }
- }
- gtk_widget_destroy (GTK_WIDGET (dialog));
- g_free (account_title);
- }
-
- g_free (account_name);
- }
+ account_name = modest_account_view_get_selected_account (priv->account_view);
+ account_title = modest_account_mgr_get_display_name(account_mgr, account_name);
+
+ if (modest_ui_actions_check_for_active_account (self, account_name))
+ modest_ui_actions_on_delete_account (GTK_WINDOW (self), account_name, account_title);
+
+ g_free (account_title);
+ g_free (account_name);
+}
+
+static void
+on_account_settings_dialog_response (GtkDialog *dialog,
+ gint response,
+ gpointer user_data)
+{
+ TnyAccount *store_account = NULL;
+ gchar* account_name = NULL;
+ ModestAccountViewWindowPrivate *priv = NULL;
+
+ priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE (user_data);
+ account_name = modest_account_view_get_selected_account (priv->account_view);
+ store_account = modest_tny_account_store_get_server_account (modest_runtime_get_account_store (),
+ account_name,
+ TNY_ACCOUNT_TYPE_STORE);
+
+ /* Reconnect the store account, no need to reconnect the
+ transport account because it will connect when needed */
+ if (tny_account_get_connection_status (store_account) ==
+ TNY_CONNECTION_STATUS_DISCONNECTED)
+ tny_camel_account_set_online (TNY_CAMEL_ACCOUNT (store_account),
+ TRUE, NULL, NULL);
+
+ /* Disconnect this handler */
+ g_signal_handlers_disconnect_by_func (dialog, on_account_settings_dialog_response, user_data);
+
+ /* Free */
+ g_free (account_name);
+ g_object_unref (store_account);