* 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
+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:
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,
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 */
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);
+ }
}