* Fixes NB#97139, New folder dialog is now always shown when invoked
authorSergio Villar Senin <svillar@igalia.com>
Fri, 9 Jan 2009 18:07:01 +0000 (18:07 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Fri, 9 Jan 2009 18:07:01 +0000 (18:07 +0000)
* If there is no MMC account, then fallback to local folders
* Fixed an invalid g_object_unref
* Fallback to local folders account if there is no active account

pmo-trunk-r7094

src/hildon2/modest-platform.c
src/modest-ui-actions.c

index a59415d..cba3df5 100644 (file)
@@ -955,6 +955,8 @@ modest_platform_run_new_folder_dialog (GtkWindow *parent_window,
 {
        gchar *real_suggested_name = NULL, *tmp = NULL;
        gint result;
 {
        gchar *real_suggested_name = NULL, *tmp = NULL;
        gint result;
+       ModestTnyAccountStore *acc_store;
+       TnyAccount *account;
 
        if(suggested_name == NULL)
        {
 
        if(suggested_name == NULL)
        {
@@ -990,10 +992,20 @@ modest_platform_run_new_folder_dialog (GtkWindow *parent_window,
        }
 
        /* In hildon 2.2 we always suggest the archive folder as parent */
        }
 
        /* In hildon 2.2 we always suggest the archive folder as parent */
-       suggested_folder = TNY_FOLDER_STORE (
-               modest_tny_account_get_special_folder 
-               (modest_tny_account_store_get_local_folders_account (modest_runtime_get_account_store ()),
-                TNY_FOLDER_TYPE_ARCHIVE));
+       acc_store = modest_runtime_get_account_store ();
+       account = modest_tny_account_store_get_mmc_folders_account (acc_store);
+       if (account) {
+               suggested_folder = (TnyFolderStore *)
+                       modest_tny_account_get_special_folder (account, 
+                                                              TNY_FOLDER_TYPE_ARCHIVE);
+               g_object_unref (account);
+               account = NULL;
+       }
+
+       /* If there is not archive folder then fallback to local folders account */ 
+       if (!suggested_folder)
+               suggested_folder = (TnyFolderStore *)
+                       modest_tny_account_store_get_local_folders_account (acc_store);
 
        tmp = g_strconcat (_("mcen_fi_new_folder_name"), ":", NULL);
        result = modest_platform_run_folder_common_dialog (parent_window, 
 
        tmp = g_strconcat (_("mcen_fi_new_folder_name"), ":", NULL);
        result = modest_platform_run_folder_common_dialog (parent_window, 
@@ -1874,7 +1886,7 @@ modest_platform_run_certificate_confirmation_dialog (const gchar* server_name,
 
        gchar *question = g_strdup_printf (_("mcen_nc_unknown_certificate"),
                                           server_name);
 
        gchar *question = g_strdup_printf (_("mcen_nc_unknown_certificate"),
                                           server_name);
-       
+
        /* We use GTK_RESPONSE_APPLY because we want the button in the
           middle of OK and CANCEL the same as the browser does for
           example. With GTK_RESPONSE_HELP the view button is aligned
        /* We use GTK_RESPONSE_APPLY because we want the button in the
           middle of OK and CANCEL the same as the browser does for
           example. With GTK_RESPONSE_HELP the view button is aligned
@@ -1886,7 +1898,7 @@ modest_platform_run_certificate_confirmation_dialog (const gchar* server_name,
                _HL("wdgt_bd_view"),          GTK_RESPONSE_APPLY,   /* abusing this... */
                _HL("wdgt_bd_no"), GTK_RESPONSE_CANCEL,
                NULL, NULL);
                _HL("wdgt_bd_view"),          GTK_RESPONSE_APPLY,   /* abusing this... */
                _HL("wdgt_bd_no"), GTK_RESPONSE_CANCEL,
                NULL, NULL);
-       
+
        g_signal_connect (G_OBJECT(note), "response", 
                          G_CALLBACK(on_cert_dialog_response),
                          (gpointer) certificate);
        g_signal_connect (G_OBJECT(note), "response", 
                          G_CALLBACK(on_cert_dialog_response),
                          (gpointer) certificate);
index 098aa41..b4795ed 100644 (file)
@@ -3268,17 +3268,17 @@ do_create_folder (GtkWindow *parent_window,
 {
        gint result;
        gchar *folder_name = NULL;
 {
        gint result;
        gchar *folder_name = NULL;
-       TnyFolderStore *parent_folder;
+       TnyFolderStore *parent_folder = NULL;
 
        result = modest_platform_run_new_folder_dialog (GTK_WINDOW (parent_window),
                                                        suggested_parent,
                                                        (gchar *) suggested_name,
                                                        &folder_name,
                                                        &parent_folder);
 
        result = modest_platform_run_new_folder_dialog (GTK_WINDOW (parent_window),
                                                        suggested_parent,
                                                        (gchar *) suggested_name,
                                                        &folder_name,
                                                        &parent_folder);
-       
+
        if (result == GTK_RESPONSE_ACCEPT && parent_folder) {
                ModestMailOperation *mail_op;
        if (result == GTK_RESPONSE_ACCEPT && parent_folder) {
                ModestMailOperation *mail_op;
-               
+
                mail_op  = modest_mail_operation_new ((GObject *) parent_window);
                modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), 
                                                 mail_op);
                mail_op  = modest_mail_operation_new ((GObject *) parent_window);
                modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), 
                                                 mail_op);
@@ -3289,7 +3289,9 @@ do_create_folder (GtkWindow *parent_window,
                                                     folder_name);
                g_object_unref (mail_op);
        }
                                                     folder_name);
                g_object_unref (mail_op);
        }
-       g_object_unref (parent_folder);
+
+       if (parent_folder)
+               g_object_unref (parent_folder);
 }
 
 static void
 }
 
 static void
@@ -3323,13 +3325,20 @@ modest_ui_actions_create_folder(GtkWidget *parent_window,
 #ifdef MODEST_TOOLKIT_HILDON2
        const gchar *active_account;
        TnyAccount *account;
 #ifdef MODEST_TOOLKIT_HILDON2
        const gchar *active_account;
        TnyAccount *account;
+       ModestTnyAccountStore *acc_store;
 
        /* In hildon 2.2 we use the current account as default parent */
 
        /* In hildon 2.2 we use the current account as default parent */
+       acc_store = modest_runtime_get_account_store ();
        active_account = modest_window_get_active_account (MODEST_WINDOW (parent_window));
        active_account = modest_window_get_active_account (MODEST_WINDOW (parent_window));
-       account = modest_tny_account_store_get_server_account (modest_runtime_get_account_store (),
-                                                              active_account,
-                                                              TNY_ACCOUNT_TYPE_STORE);
-       parent_folder = TNY_FOLDER_STORE (account);
+       if (active_account) {
+               account = modest_tny_account_store_get_server_account (acc_store,
+                                                                      active_account,
+                                                                      TNY_ACCOUNT_TYPE_STORE);
+               parent_folder = TNY_FOLDER_STORE (account);
+       } else {
+               parent_folder = (TnyFolderStore *) 
+                       modest_tny_account_store_get_local_folders_account (acc_store);
+       }
 #else
        parent_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW(folder_view));
 #endif
 #else
        parent_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW(folder_view));
 #endif