aboutsummaryrefslogtreecommitdiffstats
path: root/mail/e-mail-store-utils.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-05-24 03:28:35 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-06-30 00:42:19 +0800
commita98cb0a9820d2119bf10c317e5f6a9d56dd9073c (patch)
treec4c49bc814546c8936425272324b7e905af96e53 /mail/e-mail-store-utils.c
parentef4592c1ebb09585c912a855730eeb9a356a937c (diff)
downloadgsoc2013-evolution-a98cb0a9820d2119bf10c317e5f6a9d56dd9073c.tar
gsoc2013-evolution-a98cb0a9820d2119bf10c317e5f6a9d56dd9073c.tar.gz
gsoc2013-evolution-a98cb0a9820d2119bf10c317e5f6a9d56dd9073c.tar.bz2
gsoc2013-evolution-a98cb0a9820d2119bf10c317e5f6a9d56dd9073c.tar.lz
gsoc2013-evolution-a98cb0a9820d2119bf10c317e5f6a9d56dd9073c.tar.xz
gsoc2013-evolution-a98cb0a9820d2119bf10c317e5f6a9d56dd9073c.tar.zst
gsoc2013-evolution-a98cb0a9820d2119bf10c317e5f6a9d56dd9073c.zip
Remove emfu_create_folder_real().
Use e_mail_store_create_folder() instead.
Diffstat (limited to 'mail/e-mail-store-utils.c')
-rw-r--r--mail/e-mail-store-utils.c123
1 files changed, 123 insertions, 0 deletions
diff --git a/mail/e-mail-store-utils.c b/mail/e-mail-store-utils.c
index 47c9970c25..52aecdcc0d 100644
--- a/mail/e-mail-store-utils.c
+++ b/mail/e-mail-store-utils.c
@@ -23,6 +23,129 @@
typedef struct _AsyncContext AsyncContext;
+struct _AsyncContext {
+ gchar *full_name;
+};
+
+static void
+async_context_free (AsyncContext *context)
+{
+ g_free (context->full_name);
+
+ g_slice_free (AsyncContext, context);
+}
+
+static void
+mail_store_create_folder_thread (GSimpleAsyncResult *simple,
+ GObject *object,
+ GCancellable *cancellable)
+{
+ AsyncContext *context;
+ GError *error = NULL;
+
+ context = g_simple_async_result_get_op_res_gpointer (simple);
+
+ e_mail_store_create_folder_sync (
+ CAMEL_STORE (object), context->full_name,
+ cancellable, &error);
+
+ if (error != NULL) {
+ g_simple_async_result_set_from_error (simple, error);
+ g_error_free (error);
+ }
+}
+
+gboolean
+e_mail_store_create_folder_sync (CamelStore *store,
+ const gchar *full_name,
+ GCancellable *cancellable,
+ GError **error)
+{
+ CamelFolderInfo *folder_info;
+ gchar *copied_full_name;
+ gchar *display_name;
+ const gchar *parent;
+ gboolean success = TRUE;
+
+ g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE);
+ g_return_val_if_fail (full_name != NULL, FALSE);
+
+ copied_full_name = g_strdup (full_name);
+ display_name = strrchr (copied_full_name, '/');
+ if (display_name == NULL) {
+ display_name = copied_full_name;
+ parent = "";
+ } else {
+ *display_name++ = '\0';
+ parent = copied_full_name;
+ }
+
+ folder_info = camel_store_create_folder_sync (
+ store, parent, display_name, cancellable, error);
+
+ g_free (copied_full_name);
+
+ if (folder_info == NULL)
+ return FALSE;
+
+ if (camel_store_supports_subscriptions (store))
+ success = camel_store_subscribe_folder_sync (
+ store, full_name, cancellable, error);
+
+ camel_store_free_folder_info (store, folder_info);
+
+ return success;
+}
+
+void
+e_mail_store_create_folder (CamelStore *store,
+ const gchar *full_name,
+ gint io_priority,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *simple;
+ AsyncContext *context;
+
+ g_return_if_fail (CAMEL_IS_STORE (store));
+ g_return_if_fail (full_name != NULL);
+
+ context = g_slice_new0 (AsyncContext);
+ context->full_name = g_strdup (full_name);
+
+ simple = g_simple_async_result_new (
+ G_OBJECT (store), callback, user_data,
+ e_mail_store_create_folder);
+
+ g_simple_async_result_set_op_res_gpointer (
+ simple, context, (GDestroyNotify) async_context_free);
+
+ g_simple_async_result_run_in_thread (
+ simple, mail_store_create_folder_thread,
+ io_priority, cancellable);
+
+ g_object_unref (simple);
+}
+
+gboolean
+e_mail_store_create_folder_finish (CamelStore *store,
+ GAsyncResult *result,
+ GError **error)
+{
+ GSimpleAsyncResult *simple;
+
+ g_return_val_if_fail (
+ g_simple_async_result_is_valid (
+ result, G_OBJECT (store),
+ e_mail_store_create_folder), FALSE);
+
+ simple = G_SIMPLE_ASYNC_RESULT (result);
+
+ /* Assume success unless a GError is set. */
+ return !g_simple_async_result_propagate_error (simple, error);
+}
+
static void
mail_store_go_offline_thread (GSimpleAsyncResult *simple,
CamelStore *store,