aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-ops.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2003-05-19 20:44:32 +0800
committerDan Winship <danw@src.gnome.org>2003-05-19 20:44:32 +0800
commit6784da1b28b5433943c3edc5520bb273b46f73b6 (patch)
treef874bf3795a4063b71434feee2a5869d12b9164d /mail/mail-ops.c
parent5b0ded9bd44ac6001ed9a74773abc0c5cd0ab21c (diff)
downloadgsoc2013-evolution-6784da1b28b5433943c3edc5520bb273b46f73b6.tar.gz
gsoc2013-evolution-6784da1b28b5433943c3edc5520bb273b46f73b6.tar.zst
gsoc2013-evolution-6784da1b28b5433943c3edc5520bb273b46f73b6.zip
New async "empty trash" op.
* mail-ops.c (mail_empty_trash): New async "empty trash" op. * mail-callbacks.c (empty_trash): Use it rather than requiring that mail_tool_get_vtrash() work without blocking. #43091 svn path=/trunk/; revision=21243
Diffstat (limited to 'mail/mail-ops.c')
-rw-r--r--mail/mail-ops.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 575bb7036a..787614f19b 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -1623,6 +1623,81 @@ mail_expunge_folder(CamelFolder *folder, void (*done) (CamelFolder *folder, void
e_thread_put(mail_thread_queued, (EMsg *)m);
}
+/* ******************************************************************************** */
+
+struct _empty_trash_msg {
+ struct _mail_msg msg;
+
+ EAccount *account;
+ void (*done) (EAccount *account, void *data);
+ void *data;
+};
+
+static char *empty_trash_desc(struct _mail_msg *mm, int done)
+{
+ /* FIXME after 1.4 is out and we're not in string freeze any more. */
+#if 0
+ struct _empty_trash_msg *m = (struct _empty_trash_msg *)mm;
+
+ return g_strdup_printf (_("Emptying trash in \'%s\'"),
+ m->account ? m->account->name : _("Local Folders"));
+#else
+ return g_strdup(_("Expunging folder"));
+#endif
+}
+
+static void empty_trash_empty(struct _mail_msg *mm)
+{
+ struct _empty_trash_msg *m = (struct _empty_trash_msg *)mm;
+ CamelFolder *trash;
+
+ if (m->account)
+ trash = mail_tool_get_trash (m->account->source->url, FALSE, &mm->ex);
+ else
+ trash = mail_tool_get_trash ("file:/", TRUE, &mm->ex);
+ if (trash)
+ camel_folder_expunge (trash, &mm->ex);
+ camel_object_unref(trash);
+}
+
+static void empty_trash_emptied(struct _mail_msg *mm)
+{
+ struct _empty_trash_msg *m = (struct _empty_trash_msg *)mm;
+
+ if (m->done)
+ m->done(m->account, m->data);
+}
+
+static void empty_trash_free(struct _mail_msg *mm)
+{
+ struct _empty_trash_msg *m = (struct _empty_trash_msg *)mm;
+
+ if (m->account)
+ g_object_unref(m->account);
+}
+
+static struct _mail_msg_op empty_trash_op = {
+ empty_trash_desc,
+ empty_trash_empty,
+ empty_trash_emptied,
+ empty_trash_free,
+};
+
+void
+mail_empty_trash(EAccount *account, void (*done) (EAccount *account, void *data), void *data)
+{
+ struct _empty_trash_msg *m;
+
+ m = mail_msg_new(&empty_trash_op, NULL, sizeof(*m));
+ m->account = account;
+ if (account)
+ g_object_ref(account);
+ m->data = data;
+ m->done = done;
+
+ e_thread_put(mail_thread_queued, (EMsg *)m);
+}
+
/* ** GET MESSAGE(s) ***************************************************** */
struct _get_message_msg {