aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog7
-rw-r--r--mail/mail-callbacks.c18
-rw-r--r--mail/mail-ops.c75
-rw-r--r--mail/mail-ops.h5
4 files changed, 89 insertions, 16 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index c4219d3c47..5f96fe082b 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,10 @@
+2003-05-16 Dan Winship <danw@ximian.com>
+
+ * 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
+
2003-05-16 Radek Doulik <rodo@ximian.com>
* mail-callbacks.c (footer_info_new): gnome_font_get_descender
diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c
index dd6106331d..c8dd8a439b 100644
--- a/mail/mail-callbacks.c
+++ b/mail/mail-callbacks.c
@@ -3189,12 +3189,6 @@ stop_threads (BonoboUIComponent *uih, void *user_data, const char *path)
camel_operation_cancel (NULL);
}
-static void
-empty_trash_expunged_cb (CamelFolder *folder, void *data)
-{
- camel_object_unref (folder);
-}
-
void
empty_trash (BonoboUIComponent *uih, void *user_data, const char *path)
{
@@ -3226,11 +3220,7 @@ empty_trash (BonoboUIComponent *uih, void *user_data, const char *path)
/* make sure this store is a remote store */
if (provider->flags & CAMEL_PROVIDER_IS_STORAGE &&
provider->flags & CAMEL_PROVIDER_IS_REMOTE) {
- vtrash = mail_tool_get_trash (account->source->url, FALSE, &ex);
-
- if (vtrash) {
- mail_expunge_folder (vtrash, empty_trash_expunged_cb, NULL);
- }
+ mail_empty_trash (account, NULL, NULL);
}
}
@@ -3244,9 +3234,5 @@ empty_trash (BonoboUIComponent *uih, void *user_data, const char *path)
g_object_unref (iter);
/* Now empty the local trash folder */
- vtrash = mail_tool_get_trash ("file:/", TRUE, &ex);
- if (vtrash)
- mail_expunge_folder (vtrash, empty_trash_expunged_cb, NULL);
-
- camel_exception_clear (&ex);
+ mail_empty_trash (NULL, NULL, NULL);
}
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 {
diff --git a/mail/mail-ops.h b/mail/mail-ops.h
index e2024108cc..49dd8d5d85 100644
--- a/mail/mail-ops.h
+++ b/mail/mail-ops.h
@@ -37,6 +37,7 @@ extern "C" {
#include "evolution-storage.h" /*EvolutionStorage */
#include "e-util/e-msgport.h"
+#include "e-util/e-account.h"
void mail_append_mail (CamelFolder *folder, CamelMimeMessage *message, CamelMessageInfo *info,
void (*done)(CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, int ok,
@@ -88,6 +89,10 @@ void mail_expunge_folder (CamelFolder *folder,
void (*done) (CamelFolder *folder, void *data),
void *data);
+void mail_empty_trash (EAccount *account,
+ void (*done) (EAccount *account, void *data),
+ void *data);
+
/* get folder info asynchronously */
int mail_get_folderinfo (CamelStore *store,
void (*done)(CamelStore *store, CamelFolderInfo *info, void *data),