aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-folder-properties.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-05-15 02:53:53 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-05-15 03:19:56 +0800
commita37a66eed072e5f29390e6581739e0515b2bf402 (patch)
tree71e2d3d06799ce0570a3348b63b386120f4bbf4f /mail/em-folder-properties.c
parentd2f996640fe8b4272c3906abf45c7027c03b95b8 (diff)
downloadgsoc2013-evolution-a37a66eed072e5f29390e6581739e0515b2bf402.tar
gsoc2013-evolution-a37a66eed072e5f29390e6581739e0515b2bf402.tar.gz
gsoc2013-evolution-a37a66eed072e5f29390e6581739e0515b2bf402.tar.bz2
gsoc2013-evolution-a37a66eed072e5f29390e6581739e0515b2bf402.tar.lz
gsoc2013-evolution-a37a66eed072e5f29390e6581739e0515b2bf402.tar.xz
gsoc2013-evolution-a37a66eed072e5f29390e6581739e0515b2bf402.tar.zst
gsoc2013-evolution-a37a66eed072e5f29390e6581739e0515b2bf402.zip
EMFolderProperties: Fetch quota information asynchronously.
Diffstat (limited to 'mail/em-folder-properties.c')
-rw-r--r--mail/em-folder-properties.c63
1 files changed, 52 insertions, 11 deletions
diff --git a/mail/em-folder-properties.c b/mail/em-folder-properties.c
index 60ac872035..d61212f317 100644
--- a/mail/em-folder-properties.c
+++ b/mail/em-folder-properties.c
@@ -353,24 +353,30 @@ emfp_dialog_run (AsyncContext *context)
}
static void
-emfp_dialog_got_folder (CamelStore *store,
- GAsyncResult *result,
- AsyncContext *context)
+emfp_dialog_got_quota_info (CamelFolder *folder,
+ GAsyncResult *result,
+ AsyncContext *context)
{
EAlertSink *alert_sink;
GError *error = NULL;
alert_sink = e_activity_get_alert_sink (context->activity);
- context->folder = camel_store_get_folder_finish (
- store, result, &error);
+ context->quota_info =
+ camel_folder_get_quota_info_finish (folder, result, &error);
- if (e_activity_handle_cancellation (context->activity, error)) {
- g_warn_if_fail (context->folder == NULL);
+ /* If the folder does not implement quota info, just continue. */
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) {
+ g_warn_if_fail (context->quota_info == NULL);
+ g_error_free (error);
+
+ } else if (e_activity_handle_cancellation (context->activity, error)) {
+ g_warn_if_fail (context->quota_info == NULL);
async_context_free (context);
g_error_free (error);
return;
+ /* FIXME Add an EAlert for failing to get quota info. */
} else if (error != NULL) {
g_warn_if_fail (context->folder == NULL);
e_alert_submit (
@@ -381,10 +387,7 @@ emfp_dialog_got_folder (CamelStore *store,
return;
}
- g_return_if_fail (CAMEL_IS_FOLDER (context->folder));
-
- /* FIXME This blocks, but Camel does not offer an async function. */
- context->quota_info = camel_folder_get_quota_info (context->folder);
+ /* Quota info may still be NULL here if not supported. */
/* Finalize the activity here so we don't leave a message
* in the task bar while the properties window is shown. */
@@ -397,6 +400,44 @@ emfp_dialog_got_folder (CamelStore *store,
async_context_free (context);
}
+static void
+emfp_dialog_got_folder (CamelStore *store,
+ GAsyncResult *result,
+ AsyncContext *context)
+{
+ EAlertSink *alert_sink;
+ GCancellable *cancellable;
+ GError *error = NULL;
+
+ alert_sink = e_activity_get_alert_sink (context->activity);
+ cancellable = e_activity_get_cancellable (context->activity);
+
+ context->folder = camel_store_get_folder_finish (
+ store, result, &error);
+
+ if (e_activity_handle_cancellation (context->activity, error)) {
+ g_warn_if_fail (context->folder == NULL);
+ async_context_free (context);
+ g_error_free (error);
+ return;
+
+ } else if (error != NULL) {
+ g_warn_if_fail (context->folder == NULL);
+ e_alert_submit (
+ alert_sink, "mail:folder-open",
+ error->message, NULL);
+ async_context_free (context);
+ g_error_free (error);
+ return;
+ }
+
+ g_return_if_fail (CAMEL_IS_FOLDER (context->folder));
+
+ camel_folder_get_quota_info (
+ context->folder, G_PRIORITY_DEFAULT, cancellable,
+ (GAsyncReadyCallback) emfp_dialog_got_quota_info, context);
+}
+
/**
* em_folder_properties_show:
* @shell_view: an #EShellView