* Fixes NB#62026, folders can now be moved to the root local account
authorSergio Villar Senin <svillar@igalia.com>
Thu, 28 Jun 2007 18:34:06 +0000 (18:34 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Thu, 28 Jun 2007 18:34:06 +0000 (18:34 +0000)
* Added some checking to cmp_rows of the folders view
* Removed some code of the mail operations that didn't allow a folder to be moved to an account
* The UI actions allows now a move to to an account, if it's the local account

pmo-trunk-r2482

src/modest-mail-operation.c
src/modest-ui-actions.c
src/widgets/modest-folder-view.c

index 56f6783..02d635b 100644 (file)
@@ -1414,7 +1414,6 @@ modest_mail_operation_xfer_folder (ModestMailOperation *self,
 
        g_return_if_fail (MODEST_IS_MAIL_OPERATION (self));
        g_return_if_fail (TNY_IS_FOLDER (folder));
-       g_return_if_fail (TNY_IS_FOLDER (parent));
 
        priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
 
@@ -1424,11 +1423,8 @@ modest_mail_operation_xfer_folder (ModestMailOperation *self,
 
        /* Get folder rules */
        rules = modest_tny_folder_get_rules (TNY_FOLDER (folder));
-       parent_rules = modest_tny_folder_get_rules (TNY_FOLDER (parent));
-
-       if (!TNY_IS_FOLDER_STORE (parent)) {
-               
-       }
+       if (TNY_IS_FOLDER (parent))
+               parent_rules = modest_tny_folder_get_rules (TNY_FOLDER (parent));
        
        /* The moveable restriction is applied also to copy operation */
        if ((!TNY_IS_FOLDER_STORE (parent)) || (rules & MODEST_FOLDER_RULES_FOLDER_NON_MOVEABLE)) {
@@ -1440,7 +1436,8 @@ modest_mail_operation_xfer_folder (ModestMailOperation *self,
 
                /* Notify the queue */
                modest_mail_operation_notify_end (self, FALSE);
-       } else if (parent_rules & MODEST_FOLDER_RULES_FOLDER_NON_WRITEABLE) {
+       } else if (TNY_IS_FOLDER (parent) && 
+                  (parent_rules & MODEST_FOLDER_RULES_FOLDER_NON_WRITEABLE)) {
                /* Set status failed and set an error */
                priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
                g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
index 97da754..19030e7 100644 (file)
@@ -3029,7 +3029,8 @@ modest_ui_actions_on_main_window_move_to (GtkAction *action,
 
        folder_store = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (tree_view));
 
-       if (TNY_IS_ACCOUNT (folder_store))
+       if (TNY_IS_ACCOUNT (folder_store) && 
+           !MODEST_IS_TNY_LOCAL_FOLDERS_ACCOUNT (folder_store))
                goto end;
 
        /* Get folder or messages to transfer */
index ca3e0ed..10d4d41 100644 (file)
@@ -1168,6 +1168,13 @@ cmp_rows (GtkTreeModel *tree_model, GtkTreeIter *iter1, GtkTreeIter *iter2,
                            TNY_GTK_FOLDER_STORE_TREE_MODEL_INSTANCE_COLUMN, &folder2,
                            -1);
 
+       /* Return if we get no folder. This could happen when folder
+          operations are happening. The model is updated after the
+          folder copy/move actually occurs, so there could be
+          situations where the model to be drawn is not correct */
+       if (!folder1 || !folder2)
+               return 0;
+
        if (type == TNY_FOLDER_TYPE_ROOT) {
                /* Compare the types, so that 
                 * Remote accounts -> Local account -> MMC account .*/