aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2012-12-05 02:35:55 +0800
committerMilan Crha <mcrha@redhat.com>2012-12-05 02:35:55 +0800
commit2bbd4baef086b6b4a077e8e7225029059bd6c1f8 (patch)
treeeea1e85b9e368e104620fdbf743f8c1bc64af959 /mail
parentae6344a22b041577fdab9bf3866dbfe779dc1409 (diff)
downloadgsoc2013-evolution-2bbd4baef086b6b4a077e8e7225029059bd6c1f8.tar.gz
gsoc2013-evolution-2bbd4baef086b6b4a077e8e7225029059bd6c1f8.tar.zst
gsoc2013-evolution-2bbd4baef086b6b4a077e8e7225029059bd6c1f8.zip
Do not empty trash/delete junk in disabled accounts on exit
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-backend.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c
index 27055208bd..4fb3291729 100644
--- a/mail/e-mail-backend.c
+++ b/mail/e-mail-backend.c
@@ -258,6 +258,7 @@ mail_backend_delete_junk (CamelService *service,
camel_folder_thaw (folder);
camel_folder_free_uids (folder, uids);
+ g_object_unref (folder);
}
/* Helper for mail_backend_prepare_for_quit_cb() */
@@ -277,17 +278,43 @@ mail_backend_ready_to_quit (EActivity *activity)
g_object_unref (activity);
}
+static gboolean
+mail_backend_service_is_enabled (ESourceRegistry *registry,
+ CamelService *service)
+{
+ const gchar *uid;
+ ESource *source;
+ gboolean enabled;
+
+ g_return_val_if_fail (registry != NULL, FALSE);
+ g_return_val_if_fail (service != NULL, FALSE);
+
+ uid = camel_service_get_uid (service);
+ g_return_val_if_fail (uid != NULL, FALSE);
+
+ source = e_source_registry_ref_source (registry, uid);
+ if (!source)
+ return FALSE;
+
+ enabled = e_source_registry_check_enabled (registry, source);
+ g_object_unref (source);
+
+ return enabled;
+}
+
static void
mail_backend_prepare_for_quit_cb (EShell *shell,
EActivity *activity,
EMailBackend *backend)
{
EMailSession *session;
+ ESourceRegistry *registry;
GList *list, *link;
gboolean delete_junk;
gboolean empty_trash;
session = e_mail_backend_get_session (backend);
+ registry = e_shell_get_registry (shell);
delete_junk = e_mail_backend_delete_junk_policy_decision (backend);
empty_trash = e_mail_backend_empty_trash_policy_decision (backend);
@@ -307,7 +334,8 @@ mail_backend_prepare_for_quit_cb (EShell *shell,
service = CAMEL_SERVICE (link->data);
- if (!CAMEL_IS_STORE (service))
+ if (!CAMEL_IS_STORE (service) ||
+ !mail_backend_service_is_enabled (registry, service))
continue;
mail_backend_delete_junk (service, backend);
@@ -319,7 +347,8 @@ mail_backend_prepare_for_quit_cb (EShell *shell,
service = CAMEL_SERVICE (link->data);
- if (!CAMEL_IS_STORE (service))
+ if (!CAMEL_IS_STORE (service) ||
+ !mail_backend_service_is_enabled (registry, service))
continue;
/* FIXME Not passing a GCancellable. */