aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-05-15 02:53:53 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-06-30 00:42:15 +0800
commit8c11fc5aac29413638286734b35705ef095dfcc8 (patch)
treee1eeaa529fea4b53f4a4695bb9808446a437d90b
parent426a7bdda444f9cd47c85c59b6f8ab59d6dda86c (diff)
downloadgsoc2013-evolution-8c11fc5aac29413638286734b35705ef095dfcc8.tar.gz
gsoc2013-evolution-8c11fc5aac29413638286734b35705ef095dfcc8.tar.zst
gsoc2013-evolution-8c11fc5aac29413638286734b35705ef095dfcc8.zip
EMFolderProperties: Fetch quota information asynchronously.
-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