aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libemail-engine/mail-ops.c59
-rw-r--r--libemail-engine/mail-ops.h1
-rw-r--r--mail/e-mail-reader.c4
-rw-r--r--mail/mail-config.ui4
-rw-r--r--mail/mail-send-recv.c4
-rw-r--r--modules/mail/e-mail-shell-backend.c4
-rw-r--r--modules/mail/e-mail-shell-view-private.c2
-rw-r--r--modules/mail/em-mailer-prefs.c15
8 files changed, 76 insertions, 17 deletions
diff --git a/libemail-engine/mail-ops.c b/libemail-engine/mail-ops.c
index d93a17b45f..bd4b4f9676 100644
--- a/libemail-engine/mail-ops.c
+++ b/libemail-engine/mail-ops.c
@@ -1247,6 +1247,7 @@ struct _sync_folder_msg {
MailMsg base;
CamelFolder *folder;
+ gboolean test_for_expunge;
void (*done) (CamelFolder *folder, gpointer data);
gpointer data;
};
@@ -1264,8 +1265,60 @@ sync_folder_exec (struct _sync_folder_msg *m,
GCancellable *cancellable,
GError **error)
{
- camel_folder_synchronize_sync (
- m->folder, FALSE, cancellable, error);
+ gboolean expunge = FALSE;
+
+ if (m->test_for_expunge) {
+ GSettings *settings;
+ gboolean delete_junk;
+
+ settings = g_settings_new ("org.gnome.evolution.mail");
+
+ expunge = g_settings_get_boolean (settings, "trash-empty-on-exit") &&
+ g_settings_get_int (settings, "trash-empty-on-exit-days") == -1;
+ delete_junk = g_settings_get_boolean (settings, "junk-empty-on-exit") &&
+ g_settings_get_int (settings, "junk-empty-on-exit-days") == -1;
+
+ g_object_unref (settings);
+
+ /* delete junk first, if requested */
+ if (delete_junk) {
+ CamelStore *store;
+ CamelFolder *folder;
+
+ store = camel_folder_get_parent_store (m->folder);
+ folder = camel_store_get_junk_folder_sync (store, cancellable, error);
+ if (folder != NULL) {
+ GPtrArray *uids;
+ guint32 flags;
+ guint32 mask;
+ guint ii;
+
+ uids = camel_folder_get_uids (folder);
+ flags = mask = CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_SEEN;
+
+ camel_folder_freeze (folder);
+
+ for (ii = 0; ii < uids->len && !g_cancellable_is_cancelled (cancellable); ii++) {
+ const gchar *uid = uids->pdata[ii];
+ camel_folder_set_message_flags (folder, uid, flags, mask);
+ }
+
+ camel_folder_thaw (folder);
+ camel_folder_free_uids (folder, uids);
+
+ g_object_unref (folder);
+
+ if (g_cancellable_set_error_if_cancelled (cancellable, error))
+ return;
+ }
+
+ /* error should be set already, from the get_junk_folder_sync() call */
+ if (g_cancellable_is_cancelled (cancellable))
+ return;
+ }
+ }
+
+ camel_folder_synchronize_sync (m->folder, expunge, cancellable, error);
}
static void
@@ -1292,6 +1345,7 @@ static MailMsgInfo sync_folder_info = {
void
mail_sync_folder (CamelFolder *folder,
+ gboolean test_for_expunge,
void (*done) (CamelFolder *folder,
gpointer data),
gpointer data)
@@ -1300,6 +1354,7 @@ mail_sync_folder (CamelFolder *folder,
m = mail_msg_new (&sync_folder_info);
m->folder = g_object_ref (folder);
+ m->test_for_expunge = test_for_expunge;
m->data = data;
m->done = done;
diff --git a/libemail-engine/mail-ops.h b/libemail-engine/mail-ops.h
index 18eca7571b..42f3118987 100644
--- a/libemail-engine/mail-ops.h
+++ b/libemail-engine/mail-ops.h
@@ -40,6 +40,7 @@ void mail_transfer_messages (EMailSession *session,
gpointer data);
void mail_sync_folder (CamelFolder *folder,
+ gboolean test_for_expunge,
void (*done) (CamelFolder *folder, gpointer data), gpointer data);
void mail_sync_store (CamelStore *store, gint expunge,
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index cc96053198..923b3d403c 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -3076,7 +3076,7 @@ mail_reader_set_folder (EMailReader *reader,
(CAMEL_IS_VEE_FOLDER (previous_folder) ||
e_shell_get_online (shell));
if (sync_folder)
- mail_sync_folder (previous_folder, NULL, NULL);
+ mail_sync_folder (previous_folder, TRUE, NULL, NULL);
/* Skip the rest if we're already viewing the folder. */
if (folder == previous_folder)
@@ -3094,7 +3094,7 @@ mail_reader_set_folder (EMailReader *reader,
/* this is to make sure any post-poned changes in Search Folders
* will be propagated on folder selection */
if (folder && CAMEL_IS_VEE_FOLDER (folder))
- mail_sync_folder (folder, NULL, NULL);
+ mail_sync_folder (folder, FALSE, NULL, NULL);
message_list_set_folder (
MESSAGE_LIST (message_list), folder, outgoing);
diff --git a/mail/mail-config.ui b/mail/mail-config.ui
index cef8453de7..162cdd4dd7 100644
--- a/mail/mail-config.ui
+++ b/mail/mail-config.ui
@@ -2047,7 +2047,7 @@
<property name="spacing">4</property>
<child>
<object class="GtkCheckButton" id="chkEmptyTrashOnExit">
- <property name="label" translatable="yes">Empty trash folders on e_xit</property>
+ <property name="label" translatable="yes">Empty _trash folders</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@@ -2766,7 +2766,7 @@
<property name="spacing">4</property>
<child>
<object class="GtkCheckButton" id="junk_empty_check">
- <property name="label" translatable="yes">Delete junk messages on e_xit</property>
+ <property name="label" translatable="yes">_Delete junk messages</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c
index 3118bf7a72..e5001157a8 100644
--- a/mail/mail-send-recv.c
+++ b/mail/mail-send-recv.c
@@ -144,7 +144,7 @@ static void
free_folder_info (struct _folder_info *info)
{
/*camel_folder_thaw (info->folder); */
- mail_sync_folder (info->folder, NULL, NULL);
+ mail_sync_folder (info->folder, FALSE, NULL, NULL);
g_object_unref (info->folder);
g_free (info->uri);
g_free (info);
@@ -215,7 +215,7 @@ free_send_data (void)
g_return_if_fail (g_hash_table_size (data->active) == 0);
if (data->inbox) {
- mail_sync_folder (data->inbox, NULL, NULL);
+ mail_sync_folder (data->inbox, FALSE, NULL, NULL);
/*camel_folder_thaw (data->inbox); */
g_object_unref (data->inbox);
}
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index 7db1b13b86..c05e8518fe 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -663,7 +663,7 @@ mail_shell_backend_delete_junk_policy_decision (EMailBackend *backend)
empty_date = g_settings_get_int (settings, "junk-empty-date");
}
- delete_junk &= (empty_days == 0) || (empty_date + empty_days <= now);
+ delete_junk = delete_junk && ((empty_days == 0) || (empty_days > 0 && empty_date + empty_days <= now));
if (delete_junk) {
g_settings_set_int (settings, "junk-empty-date", now);
@@ -704,7 +704,7 @@ mail_shell_backend_empty_trash_policy_decision (EMailBackend *backend)
empty_date = g_settings_get_int (settings, "trash-empty-date");
}
- empty_trash &= (empty_days == 0) || (empty_date + empty_days <= now);
+ empty_trash = empty_trash && ((empty_days == 0) || (empty_days > 0 && empty_date + empty_days <= now));
if (empty_trash) {
g_settings_set_int (settings, "trash-empty-date", now);
diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c
index 6bdbcb3adf..9752461191 100644
--- a/modules/mail/e-mail-shell-view-private.c
+++ b/modules/mail/e-mail-shell-view-private.c
@@ -532,7 +532,7 @@ mail_shell_view_prepare_for_quit_cb (EMailShellView *mail_shell_view,
return;
mail_sync_folder (
- folder,
+ folder, TRUE,
mail_shell_view_prepare_for_quit_done_cb,
g_object_ref (activity));
}
diff --git a/modules/mail/em-mailer-prefs.c b/modules/mail/em-mailer-prefs.c
index 4720470c2a..0dd3d38147 100644
--- a/modules/mail/em-mailer-prefs.c
+++ b/modules/mail/em-mailer-prefs.c
@@ -83,10 +83,11 @@ static const struct {
const gchar *label;
gint days;
} empty_trash_frequency[] = {
- { N_("Every time"), 0 },
- { N_("Once per day"), 1 },
- { N_("Once per week"), 7 },
- { N_("Once per month"), 30 },
+ { N_("On exit, every time"), 0 },
+ { N_("On exit, once per day"), 1 },
+ { N_("On exit, once per week"), 7 },
+ { N_("On exit, once per month"), 30 },
+ { N_("Immediately, on folder leave"), -1 }
};
G_DEFINE_TYPE (
@@ -623,7 +624,8 @@ emmp_empty_trash_init (EMMailerPrefs *prefs,
gtk_list_store_clear (store);
for (ii = 0; ii < G_N_ELEMENTS (empty_trash_frequency); ii++) {
- if (days >= empty_trash_frequency[ii].days)
+ if (days == empty_trash_frequency[ii].days ||
+ (empty_trash_frequency[ii].days != -1 && days > empty_trash_frequency[ii].days))
hist = ii;
gtk_list_store_append (store, &iter);
@@ -672,7 +674,8 @@ emmp_empty_junk_init (EMMailerPrefs *prefs,
gtk_list_store_clear (store);
for (ii = 0; ii < G_N_ELEMENTS (empty_trash_frequency); ii++) {
- if (days >= empty_trash_frequency[ii].days)
+ if (days == empty_trash_frequency[ii].days ||
+ (empty_trash_frequency[ii].days != -1 && days >= empty_trash_frequency[ii].days))
hist = ii;
gtk_list_store_append (store, &iter);