aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2012-07-09 19:21:42 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-07-09 20:44:22 +0800
commitb3d0f3d8ea8691c48e4edfc0436ed43ca12f6ea5 (patch)
tree4785baf3138d2094f7a59eac57d77a8146e67789 /mail
parent0a359ba9826d52378e64e4a9a9c96588255a1ad9 (diff)
downloadgsoc2013-evolution-b3d0f3d8ea8691c48e4edfc0436ed43ca12f6ea5.tar
gsoc2013-evolution-b3d0f3d8ea8691c48e4edfc0436ed43ca12f6ea5.tar.gz
gsoc2013-evolution-b3d0f3d8ea8691c48e4edfc0436ed43ca12f6ea5.tar.bz2
gsoc2013-evolution-b3d0f3d8ea8691c48e4edfc0436ed43ca12f6ea5.tar.lz
gsoc2013-evolution-b3d0f3d8ea8691c48e4edfc0436ed43ca12f6ea5.tar.xz
gsoc2013-evolution-b3d0f3d8ea8691c48e4edfc0436ed43ca12f6ea5.tar.zst
gsoc2013-evolution-b3d0f3d8ea8691c48e4edfc0436ed43ca12f6ea5.zip
Add e_mail_reader_expunge_folder_name().
Fetches the CamelFolder asynchronously, then expunges 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 eed03f30c6..38399731c1 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -447,6 +447,73 @@ e_mail_reader_expunge_folder (EMailReader *reader,
}
}
+/* Helper for e_mail_reader_expunge_folder_name() */
+static void
+mail_reader_expunge_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-expunge-folder",
+ context->folder_name, error->message, NULL);
+ g_error_free (error);
+
+ } else {
+ e_activity_set_state (
+ context->activity, E_ACTIVITY_COMPLETED);
+ e_mail_reader_expunge_folder (context->reader, folder);
+ }
+
+ async_context_free (context);
+}
+
+void
+e_mail_reader_expunge_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_expunge_folder_name_cb,
+ context);
+}
+
/* Helper for e_mail_reader_refresh_folder() */
static void
mail_reader_refresh_folder_cb (GObject *source_object,
diff --git a/mail/e-mail-reader-utils.h b/mail/e-mail-reader-utils.h
index 3f1d9243fe..4cb427f8b8 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_expunge_folder (EMailReader *reader,
CamelFolder *folder);
+void e_mail_reader_expunge_folder_name
+ (EMailReader *reader,
+ CamelStore *store,
+ const gchar *folder_name);
void e_mail_reader_refresh_folder (EMailReader *reader,
CamelFolder *folder);
void e_mail_reader_refresh_folder_name