diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-07-18 22:52:50 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-07-19 20:36:55 +0800 |
commit | 270a0879744c2663b9578835271a1f8b4c9d6932 (patch) | |
tree | 4066a9898a9dfa6a1b99031dcbae8528171e4345 | |
parent | 209387d4e37fe665c385ef56886b119f7896890f (diff) | |
download | gsoc2013-evolution-270a0879744c2663b9578835271a1f8b4c9d6932.tar gsoc2013-evolution-270a0879744c2663b9578835271a1f8b4c9d6932.tar.gz gsoc2013-evolution-270a0879744c2663b9578835271a1f8b4c9d6932.tar.bz2 gsoc2013-evolution-270a0879744c2663b9578835271a1f8b4c9d6932.tar.lz gsoc2013-evolution-270a0879744c2663b9578835271a1f8b4c9d6932.tar.xz gsoc2013-evolution-270a0879744c2663b9578835271a1f8b4c9d6932.tar.zst gsoc2013-evolution-270a0879744c2663b9578835271a1f8b4c9d6932.zip |
e-mail-store-utils.c cleanups.
-rw-r--r-- | libemail-engine/e-mail-store-utils.c | 118 |
1 files changed, 61 insertions, 57 deletions
diff --git a/libemail-engine/e-mail-store-utils.c b/libemail-engine/e-mail-store-utils.c index bfb1ed5af3..a92aaaccf4 100644 --- a/libemail-engine/e-mail-store-utils.c +++ b/libemail-engine/e-mail-store-utils.c @@ -40,24 +40,6 @@ async_context_free (AsyncContext *context) 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_take_error (simple, error); -} - gboolean e_mail_store_create_folder_sync (CamelStore *store, const gchar *full_name, @@ -101,6 +83,26 @@ e_mail_store_create_folder_sync (CamelStore *store, return success; } +/* Helper for e_mail_store_create_folder() */ +static void +mail_store_create_folder_thread (GSimpleAsyncResult *simple, + GObject *source_object, + GCancellable *cancellable) +{ + AsyncContext *context; + GError *local_error = NULL; + + context = g_simple_async_result_get_op_res_gpointer (simple); + + e_mail_store_create_folder_sync ( + CAMEL_STORE (source_object), + context->full_name, + cancellable, &local_error); + + if (local_error != NULL) + g_simple_async_result_take_error (simple, local_error); +} + void e_mail_store_create_folder (CamelStore *store, const gchar *full_name, @@ -152,16 +154,17 @@ e_mail_store_create_folder_finish (CamelStore *store, return !g_simple_async_result_propagate_error (simple, error); } +/* Helper for e_mail_store_go_offline() */ static void mail_store_go_offline_thread (GSimpleAsyncResult *simple, - CamelStore *store, + GObject *source_object, GCancellable *cancellable) { CamelService *service; const gchar *display_name; - GError *error = NULL; + GError *local_error = NULL; - service = CAMEL_SERVICE (store); + service = CAMEL_SERVICE (source_object); display_name = camel_service_get_display_name (service); if (display_name == NULL || *display_name == '\0') @@ -170,34 +173,34 @@ mail_store_go_offline_thread (GSimpleAsyncResult *simple, camel_operation_push_message ( cancellable, _("Disconnecting from '%s'"), display_name); - if (CAMEL_IS_DISCO_STORE (store)) { + if (CAMEL_IS_DISCO_STORE (service)) { CamelDiscoStore *disco_store; - disco_store = CAMEL_DISCO_STORE (store); + disco_store = CAMEL_DISCO_STORE (service); if (camel_disco_store_can_work_offline (disco_store)) camel_disco_store_set_status ( disco_store, CAMEL_DISCO_STORE_OFFLINE, - cancellable, &error); + cancellable, &local_error); else camel_service_disconnect_sync ( - service, TRUE, cancellable, &error); + service, TRUE, cancellable, &local_error); - } else if (CAMEL_IS_OFFLINE_STORE (store)) { + } else if (CAMEL_IS_OFFLINE_STORE (service)) { CamelOfflineStore *offline_store; - offline_store = CAMEL_OFFLINE_STORE (store); + offline_store = CAMEL_OFFLINE_STORE (service); camel_offline_store_set_online_sync ( - offline_store, FALSE, cancellable, &error); + offline_store, FALSE, cancellable, &local_error); } else { camel_service_disconnect_sync ( - service, TRUE, cancellable, &error); + service, TRUE, cancellable, &local_error); } - if (error != NULL) - g_simple_async_result_take_error (simple, error); + if (local_error != NULL) + g_simple_async_result_take_error (simple, local_error); camel_operation_pop_message (cancellable); } @@ -220,8 +223,7 @@ e_mail_store_go_offline (CamelStore *store, g_simple_async_result_set_check_cancellable (simple, cancellable); g_simple_async_result_run_in_thread ( - simple, (GSimpleAsyncThreadFunc) - mail_store_go_offline_thread, + simple, mail_store_go_offline_thread, io_priority, cancellable); g_object_unref (simple); @@ -244,16 +246,17 @@ e_mail_store_go_offline_finish (CamelStore *store, return !g_simple_async_result_propagate_error (simple, error); } +/* Helper for e_mail_store_go_online() */ static void mail_store_go_online_thread (GSimpleAsyncResult *simple, - CamelStore *store, + GObject *source_object, GCancellable *cancellable) { CamelService *service; const gchar *display_name; - GError *error = NULL; + GError *local_error = NULL; - service = CAMEL_SERVICE (store); + service = CAMEL_SERVICE (source_object); display_name = camel_service_get_display_name (service); if (display_name == NULL || *display_name == '\0') @@ -262,19 +265,19 @@ mail_store_go_online_thread (GSimpleAsyncResult *simple, camel_operation_push_message ( cancellable, _("Reconnecting to '%s'"), display_name); - if (CAMEL_IS_DISCO_STORE (store)) + if (CAMEL_IS_DISCO_STORE (service)) camel_disco_store_set_status ( - CAMEL_DISCO_STORE (store), + CAMEL_DISCO_STORE (service), CAMEL_DISCO_STORE_ONLINE, - cancellable, &error); + cancellable, &local_error); - else if (CAMEL_IS_OFFLINE_STORE (store)) + else if (CAMEL_IS_OFFLINE_STORE (service)) camel_offline_store_set_online_sync ( - CAMEL_OFFLINE_STORE (store), - TRUE, cancellable, &error); + CAMEL_OFFLINE_STORE (service), + TRUE, cancellable, &local_error); - if (error != NULL) - g_simple_async_result_take_error (simple, error); + if (local_error != NULL) + g_simple_async_result_take_error (simple, local_error); camel_operation_pop_message (cancellable); } @@ -297,8 +300,7 @@ e_mail_store_go_online (CamelStore *store, g_simple_async_result_set_check_cancellable (simple, cancellable); g_simple_async_result_run_in_thread ( - simple, (GSimpleAsyncThreadFunc) - mail_store_go_online_thread, + simple, mail_store_go_online_thread, io_priority, cancellable); g_object_unref (simple); @@ -321,16 +323,17 @@ e_mail_store_go_online_finish (CamelStore *store, return !g_simple_async_result_propagate_error (simple, error); } +/* Helper for e_mail_store_prepare_for_offline() */ static void mail_store_prepare_for_offline_thread (GSimpleAsyncResult *simple, - CamelStore *store, + GObject *source_object, GCancellable *cancellable) { CamelService *service; const gchar *display_name; - GError *error = NULL; + GError *local_error = NULL; - service = CAMEL_SERVICE (store); + service = CAMEL_SERVICE (source_object); display_name = camel_service_get_display_name (service); if (display_name == NULL || *display_name == '\0') @@ -340,16 +343,18 @@ mail_store_prepare_for_offline_thread (GSimpleAsyncResult *simple, cancellable, _("Preparing account '%s' for offline"), display_name); - if (CAMEL_IS_DISCO_STORE (store)) + if (CAMEL_IS_DISCO_STORE (service)) camel_disco_store_prepare_for_offline ( - CAMEL_DISCO_STORE (store), cancellable, &error); + CAMEL_DISCO_STORE (service), + cancellable, &local_error); - else if (CAMEL_IS_OFFLINE_STORE (store)) + else if (CAMEL_IS_OFFLINE_STORE (service)) camel_offline_store_prepare_for_offline_sync ( - CAMEL_OFFLINE_STORE (store), cancellable, &error); + CAMEL_OFFLINE_STORE (service), + cancellable, &local_error); - if (error != NULL) - g_simple_async_result_take_error (simple, error); + if (local_error != NULL) + g_simple_async_result_take_error (simple, local_error); camel_operation_pop_message (cancellable); } @@ -372,8 +377,7 @@ e_mail_store_prepare_for_offline (CamelStore *store, g_simple_async_result_set_check_cancellable (simple, cancellable); g_simple_async_result_run_in_thread ( - simple, (GSimpleAsyncThreadFunc) - mail_store_prepare_for_offline_thread, + simple, mail_store_prepare_for_offline_thread, io_priority, cancellable); g_object_unref (simple); |