2007-07-12 Armin Burgmeier <armin@openismus.com>
authorArmin Burgmeier <armin@openismus.com>
Thu, 12 Jul 2007 13:20:03 +0000 (13:20 +0000)
committerArmin Burgmeier <armin@openismus.com>
Thu, 12 Jul 2007 13:20:03 +0000 (13:20 +0000)
* src/modest-error.h: Added MODEST_MAIL_OPERATION_FOLDER_EXISTS error.

* src/modest-mail-operation.c:
* src/modest-ui-actions.c: Check for already existing folder before
querying the server, show error message from camel if the request
still fails. This fixes projects.maemo.org bug NB#58701.

pmo-trunk-r2726

ChangeLog2
src/modest-error.h
src/modest-mail-operation.c
src/modest-ui-actions.c

index 9d1c67e..1801ce7 100644 (file)
@@ -1,3 +1,12 @@
+2007-07-12  Armin Burgmeier  <armin@openismus.com>
+
+       * src/modest-error.h: Added MODEST_MAIL_OPERATION_FOLDER_EXISTS error.
+
+       * src/modest-mail-operation.c:
+       * src/modest-ui-actions.c: Check for already existing folder before
+       querying the server, show error message from camel if the request
+       still fails. This fixes projects.maemo.org bug NB#58701.
+
 2007-07-12  Murray Cumming  <murrayc@murrayc.com>
 
        * src/modest-tny-account-store.h:
index 0a883c6..cba6d3f 100644 (file)
@@ -44,6 +44,7 @@ typedef enum _ModestErrorCode {
        MODEST_MAIL_OPERATION_ERROR_OPERATION_CANCELED,
        MODEST_MAIL_OPERATION_ERROR_ITEM_NOT_FOUND,
        MODEST_MAIL_OPERATION_ERROR_FOLDER_RULES,
+       MODEST_MAIL_OPERATION_ERROR_FOLDER_EXISTS, /* Folder to be created exists already. */
        MODEST_MAIL_OPERATION_ERROR_MESSAGE_SIZE_LIMIT, /* A message was too big to retrieve. */
        MODEST_MAIL_OPERATION_ERROR_RETRIEVAL_NUMBER_LIMIT, /* There were too many messages to retrieve. */
        MODEST_MAIL_OPERATION_ERROR_INSTANCE_CREATION_FAILED,
index 8e94e38..df94621 100644 (file)
@@ -1474,11 +1474,28 @@ 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) {
+               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 */
index ddf9368..61b68e3 100644 (file)
@@ -2171,18 +2171,13 @@ modest_ui_actions_new_folder_error_handler (ModestMailOperation *mail_op,
                                             gpointer user_data)
 {
        ModestMainWindow *window = MODEST_MAIN_WINDOW (user_data);
+       const GError *error = modest_mail_operation_get_error (mail_op);
 
-       /* TODO: Note that folder creation might go wrong due to other
-        * failures such as when the parent folder is non-writable. We can
-        * query a GError* with modest_mail_operation_get_error(), but the
-        * the error code (from tinymail) does not give us a clue about what
-        * has gone wrong. We might use the error->message but it might come
-        * from camel and not be suitable to show to the user directly. */
-       modest_platform_information_banner (GTK_WIDGET (window), NULL,
-                                           _CS("ckdg_ib_folder_already_exists"));
-
-/*     modest_platform_information_banner (GTK_WIDGET (window), NULL,
-                                           modest_mail_operation_get_error (mail_op)->message);*/
+       if(error)
+       {
+               modest_platform_information_banner (GTK_WIDGET (window), NULL,
+                                                   modest_mail_operation_get_error (mail_op)->message);
+       }
 }