* New Message toolbar button and menu item will be dimmed
[modest] / src / modest-mail-operation.c
index d15b510..22f3c38 100644 (file)
@@ -305,6 +305,7 @@ modest_mail_operation_new_with_error_handling (ModestMailOperationTypeOperation
        
        g_return_val_if_fail (error_handler != NULL, obj);
        priv->error_checking = error_handler;
+       priv->error_checking_user_data = user_data;
 
        return obj;
 }
@@ -1306,6 +1307,7 @@ update_account_thread (gpointer thr_user_data)
                        if (G_UNLIKELY (!first_time))
                                tny_folder_poke_status (TNY_FOLDER (folder));
                }
+
                tny_folder_remove_observer (TNY_FOLDER (folder), TNY_FOLDER_OBSERVER (observer));
                g_object_unref (observer);
                observer = NULL;                        
@@ -1558,28 +1560,19 @@ modest_mail_operation_create_folder (ModestMailOperation *self,
        ModestMailOperationPrivate *priv;
        TnyFolder *new_folder = NULL;
 
-       TnyList *list = tny_simple_list_new ();
-       TnyFolderStoreQuery *query = tny_folder_store_query_new ();
-
        g_return_val_if_fail (TNY_IS_FOLDER_STORE (parent), NULL);
        g_return_val_if_fail (name, NULL);
        
        priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
 
        /* Check for already existing folder */
-       tny_folder_store_query_add_item (query, name, TNY_FOLDER_STORE_QUERY_OPTION_MATCH_ON_NAME);
-       tny_folder_store_get_folders (parent, list, query, NULL);
-       g_object_unref (G_OBJECT (query));
-
-       if (tny_list_get_length (list) > 0) {
+       if (modest_tny_folder_has_subfolder_with_name (parent, name)) {
                priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
                g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
                             MODEST_MAIL_OPERATION_ERROR_FOLDER_EXISTS,
                             _CS("ckdg_ib_folder_already_exists"));
        }
 
-       g_object_unref (G_OBJECT (list));
-
        /* Check parent */
        if (TNY_IS_FOLDER (parent)) {
                /* Check folder rules */
@@ -1841,6 +1834,7 @@ modest_mail_operation_xfer_folder (ModestMailOperation *self,
        ModestTnyFolderRules parent_rules = 0, rules; 
        XFerMsgAsyncHelper *helper = NULL;
        const gchar *folder_name = NULL;
+       const gchar *error_msg;
 
        g_return_if_fail (MODEST_IS_MAIL_OPERATION (self));
        g_return_if_fail (TNY_IS_FOLDER (folder));
@@ -1849,6 +1843,11 @@ modest_mail_operation_xfer_folder (ModestMailOperation *self,
        priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
        folder_name = tny_folder_get_name (folder);
 
+       /* Set the error msg */
+       error_msg = (delete_original) ? 
+               _("mail_in_ui_folder_move_target_error") : 
+               _("mail_in_ui_folder_copy_target_error");
+
        /* Get account and set it into mail_operation */
        priv->account = modest_tny_folder_get_account (TNY_FOLDER(folder));
        priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
@@ -1867,7 +1866,7 @@ modest_mail_operation_xfer_folder (ModestMailOperation *self,
                priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
                g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
                             MODEST_MAIL_OPERATION_ERROR_FOLDER_RULES,
-                            _("mail_in_ui_folder_move_target_error"));
+                            error_msg);
 
                /* Notify the queue */
                modest_mail_operation_notify_end (self);
@@ -1879,7 +1878,7 @@ modest_mail_operation_xfer_folder (ModestMailOperation *self,
                priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
                g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
                             MODEST_MAIL_OPERATION_ERROR_FOLDER_RULES,
-                            _("FIXME: parent folder does not accept new folders"));
+                            error_msg);
 
                /* Notify the queue */
                modest_mail_operation_notify_end (self);
@@ -1891,7 +1890,7 @@ modest_mail_operation_xfer_folder (ModestMailOperation *self,
                priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
                g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
                             MODEST_MAIL_OPERATION_ERROR_FOLDER_RULES,
-                            _("mail_in_ui_folder_copy_target_error"));
+                            error_msg);
 
                /* Notify the queue */
                modest_mail_operation_notify_end (self);
@@ -1905,7 +1904,7 @@ modest_mail_operation_xfer_folder (ModestMailOperation *self,
                priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
                g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
                             MODEST_MAIL_OPERATION_ERROR_FOLDER_RULES,
-                            _("mail_in_ui_folder_move_target_error"));
+                            error_msg);
 
                /* Notify the queue */
                modest_mail_operation_notify_end (self);
@@ -1918,7 +1917,7 @@ modest_mail_operation_xfer_folder (ModestMailOperation *self,
                priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
                g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
                             MODEST_MAIL_OPERATION_ERROR_FOLDER_RULES,
-                            _("mail_in_ui_folder_move_target_error"));
+                            error_msg);
 
                /* Notify the queue */
                modest_mail_operation_notify_end (self);