Fixes the new folder dialog in Diablo
[modest] / src / maemo / modest-platform.c
index 9f8b4b1..5472fbe 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <config.h>
 #include <glib/gi18n.h>
+#include <modest-defs.h>
 #include <modest-platform.h>
 #include <modest-runtime.h>
 #include <modest-main-window.h>
@@ -43,6 +44,8 @@
 #include <tny-maemo-conic-device.h>
 #include <tny-simple-list.h>
 #include <tny-folder.h>
+#include <tny-error.h>
+#include <tny-merge-folder.h>
 #include <tny-camel-imap-store-account.h>
 #include <tny-camel-pop-store-account.h>
 #include <gtk/gtkicontheme.h>
@@ -759,7 +762,7 @@ modest_platform_run_new_folder_dialog (GtkWindow *parent_window,
                        else
                                real_suggested_name = g_strdup_printf (_("mcen_ia_default_folder_name_s"),
                                                                       num_str);
-                       exists = modest_tny_folder_has_subfolder_with_name (parent_folder,
+                       exists = modest_tny_folder_has_subfolder_with_name (suggested_parent,
                                                                            real_suggested_name,
                                                                            TRUE);
 
@@ -789,7 +792,7 @@ modest_platform_run_new_folder_dialog (GtkWindow *parent_window,
                g_free(real_suggested_name);
 
        if (parent_folder != NULL) {
-               parent_folder = suggested_parent?g_object_ref (suggested_parent): NULL;
+               *parent_folder = suggested_parent?g_object_ref (suggested_parent): NULL;
        }
 
        return result;
@@ -1978,17 +1981,21 @@ modest_platform_connect_if_remote_and_perform (GtkWindow *parent_window,
                                               gpointer user_data)
 {
        TnyAccount *account = NULL;
-       
-       if (!folder_store) {
+
+       if (!folder_store ||
+           (TNY_IS_MERGE_FOLDER (folder_store) &&
+            (tny_folder_get_folder_type (TNY_FOLDER(folder_store)) == TNY_FOLDER_TYPE_OUTBOX))) {
+
                /* We promise to instantly perform the callback, so ... */
                if (callback) {
-                       callback (FALSE, NULL, parent_window, NULL, user_data);
-               }
-               return; 
-               
-               /* Original comment: Maybe it is something local. */
-               /* PVH's comment: maybe we should KNOW this in stead of assuming? */
-               
+                       GError *error = NULL;
+                       g_set_error (&error, TNY_ERROR_DOMAIN, TNY_SERVICE_ERROR_UNKNOWN,
+                                    "Unable to move or not found folder");
+                       callback (FALSE, error, parent_window, NULL, user_data);
+                       g_error_free (error);
+               }
+               return;
+
        } else if (TNY_IS_FOLDER (folder_store)) {
                /* Get the folder's parent account: */
                account = tny_folder_get_account (TNY_FOLDER (folder_store));
@@ -2108,7 +2115,7 @@ modest_platform_check_memory_low (ModestWindow *win,
        if (win && lowmem && visuals)
                modest_platform_run_information_dialog (
                        GTK_WINDOW(win),
-                       dgettext("ke-recv","memr_ib_operation_disabled"),
+                       _KR("memr_ib_operation_disabled"),
                        TRUE);
 
        if (lowmem)
@@ -2241,6 +2248,9 @@ modest_platform_get_list_to_move (ModestWindow *window)
                        tny_list_prepend (list, G_OBJECT (header));
                        g_object_unref (header);
                }
+       } else {
+               g_return_val_if_reached (NULL);
        }
+
        return list;
 }