aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2012-07-09 02:57:37 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-07-09 20:44:22 +0800
commita7bab4dcafe4ecb2e838c330f9b1777e641c7d14 (patch)
treeb122584a973da0910e3260edf04575b50554f904 /mail
parent84cfc5b80c4d3845b41358d68e33383c2c66a566 (diff)
downloadgsoc2013-evolution-a7bab4dcafe4ecb2e838c330f9b1777e641c7d14.tar.gz
gsoc2013-evolution-a7bab4dcafe4ecb2e838c330f9b1777e641c7d14.tar.zst
gsoc2013-evolution-a7bab4dcafe4ecb2e838c330f9b1777e641c7d14.zip
Add e_mail_reader_refresh_folder_name().
Fetches the CamelFolder asynchronously, then refreshes it asynchronously.
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-reader-utils.c67
-rw-r--r--mail/e-mail-reader-utils.h4
2 files changed, 71 insertions, 0 deletions
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index 6d52be1534..e88d2c6bb3 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -434,6 +434,73 @@ e_mail_reader_refresh_folder (EMailReader *reader,
mail_reader_refresh_folder_cb, context);
}
+/* Helper for e_mail_reader_refresh_folder_name() */
+static void
+mail_reader_refresh_folder_name_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ CamelStore *store;
+ CamelFolder *folder;
+ AsyncContext *context;
+ EAlertSink *alert_sink;
+ GError *error = NULL;
+
+ store = CAMEL_STORE (source_object);
+ context = (AsyncContext *) user_data;
+
+ alert_sink = e_activity_get_alert_sink (context->activity);
+
+ /* XXX The returned CamelFolder is a borrowed reference. */
+ folder = camel_store_get_folder_finish (store, result, &error);
+
+ if (e_activity_handle_cancellation (context->activity, error)) {
+ g_error_free (error);
+
+ } else if (error != NULL) {
+ e_alert_submit (
+ alert_sink, "mail:no-refresh-folder",
+ context->folder_name, error->message, NULL);
+ g_error_free (error);
+
+ } else {
+ e_activity_set_state (
+ context->activity, E_ACTIVITY_COMPLETED);
+ e_mail_reader_refresh_folder (context->reader, folder);
+ }
+
+ async_context_free (context);
+}
+
+void
+e_mail_reader_refresh_folder_name (EMailReader *reader,
+ CamelStore *store,
+ const gchar *folder_name)
+{
+ EActivity *activity;
+ AsyncContext *context;
+ GCancellable *cancellable;
+
+ g_return_if_fail (E_IS_MAIL_READER (reader));
+ g_return_if_fail (CAMEL_IS_STORE (store));
+ g_return_if_fail (folder_name != NULL);
+
+ activity = e_mail_reader_new_activity (reader);
+ cancellable = e_activity_get_cancellable (activity);
+
+ context = g_slice_new0 (AsyncContext);
+ context->activity = activity;
+ context->reader = g_object_ref (reader);
+ context->folder_name = g_strdup (folder_name);
+
+ camel_store_get_folder (
+ store, folder_name,
+ CAMEL_STORE_FOLDER_INFO_FAST,
+ G_PRIORITY_DEFAULT, cancellable,
+ mail_reader_refresh_folder_name_cb,
+ context);
+}
+
/* Helper for e_mail_reader_unsubscribe_folder_name() */
static void
mail_reader_unsubscribe_folder_name_cb (GObject *source_object,
diff --git a/mail/e-mail-reader-utils.h b/mail/e-mail-reader-utils.h
index 21006deacb..ee1f8394bb 100644
--- a/mail/e-mail-reader-utils.h
+++ b/mail/e-mail-reader-utils.h
@@ -45,6 +45,10 @@ void e_mail_reader_delete_folder_name
const gchar *folder_name);
void e_mail_reader_refresh_folder (EMailReader *reader,
CamelFolder *folder);
+void e_mail_reader_refresh_folder_name
+ (EMailReader *reader,
+ CamelStore *store,
+ const gchar *folder_name);
void e_mail_reader_unsubscribe_folder_name
(EMailReader *reader,
CamelStore *store,