[evolution-data-server/gnome-3-8] Bug #705446 - Old POP3 mails can be removed before getting them
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-3-8] Bug #705446 - Old POP3 mails can be removed before getting them
- Date: Thu, 8 Aug 2013 05:47:10 +0000 (UTC)
commit 809b48f1f1fa3a5f242d311be236a93bb012db53
Author: Milan Crha <mcrha redhat com>
Date: Thu Aug 8 07:46:53 2013 +0200
Bug #705446 - Old POP3 mails can be removed before getting them
camel/providers/pop3/camel-pop3-folder.c | 92 +++++++++++++++++++++++++++++-
1 files changed, 91 insertions(+), 1 deletions(-)
---
diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c
index 2395c12..8390ef9 100644
--- a/camel/providers/pop3/camel-pop3-folder.c
+++ b/camel/providers/pop3/camel-pop3-folder.c
@@ -443,6 +443,47 @@ pop3_folder_get_uids (CamelFolder *folder)
return uids;
}
+static GPtrArray *
+pop3_get_uncached_uids (CamelFolder *folder,
+ GPtrArray *uids,
+ GError **error)
+{
+ CamelPOP3Folder *pop3_folder;
+ CamelPOP3Store *pop3_store;
+ CamelDataCache *pop3_cache;
+ GPtrArray *uncached_uids;
+ gint ii;
+
+ g_return_val_if_fail (CAMEL_IS_POP3_FOLDER (folder), NULL);
+ g_return_val_if_fail (uids != NULL, NULL);
+
+ pop3_folder = CAMEL_POP3_FOLDER (folder);
+ pop3_store = CAMEL_POP3_STORE (camel_folder_get_parent_store (folder));
+ pop3_cache = camel_pop3_store_ref_cache (pop3_store);
+
+ uncached_uids = g_ptr_array_new ();
+
+ for (ii = 0; ii < uids->len; ii++) {
+ const gchar *uid = uids->pdata[ii];
+ CamelStream *stream = NULL;
+ CamelPOP3FolderInfo *fi;
+ gchar buffer[1];
+
+ fi = g_hash_table_lookup (pop3_folder->uids_fi, uid);
+ if (!fi || !pop3_cache ||
+ (stream = camel_data_cache_get (pop3_cache, "cache", fi->uid, NULL)) == NULL ||
+ camel_stream_read (stream, buffer, 1, NULL, NULL) != 1 ||
+ buffer[0] != '#')
+ g_ptr_array_add (uncached_uids, (gpointer) camel_pstring_strdup (uid));
+
+ g_clear_object (&stream);
+ }
+
+ g_clear_object (&pop3_cache);
+
+ return uncached_uids;
+}
+
static gchar *
pop3_folder_get_filename (CamelFolder *folder,
const gchar *uid,
@@ -920,7 +961,7 @@ pop3_folder_synchronize_sync (CamelFolder *folder,
g_object_unref (settings);
- if (is_online && delete_after_days > 0 && !expunge) {
+ if (is_online && delete_after_days > 0 && !expunge && !g_cancellable_is_cancelled (cancellable)) {
camel_operation_push_message (
cancellable, _("Expunging old messages"));
@@ -930,6 +971,12 @@ pop3_folder_synchronize_sync (CamelFolder *folder,
camel_operation_pop_message (cancellable);
}
+ if (g_cancellable_is_cancelled (cancellable)) {
+ if (error && !*error)
+ g_cancellable_set_error_if_cancelled (cancellable, error);
+ return FALSE;
+ }
+
if (!expunge || (keep_on_server && !delete_expunged))
return TRUE;
@@ -948,6 +995,15 @@ pop3_folder_synchronize_sync (CamelFolder *folder,
pop3_engine = camel_pop3_store_ref_engine (pop3_store);
for (i = 0; i < pop3_folder->uids->len; i++) {
+ if (g_cancellable_set_error_if_cancelled (cancellable, error)) {
+ g_clear_object (&pop3_cache);
+ g_clear_object (&pop3_engine);
+
+ camel_operation_pop_message (cancellable);
+
+ return FALSE;
+ }
+
fi = pop3_folder->uids->pdata[i];
/* busy already? wait for that to finish first */
if (fi->cmd) {
@@ -971,6 +1027,15 @@ pop3_folder_synchronize_sync (CamelFolder *folder,
}
for (i = 0; i < pop3_folder->uids->len; i++) {
+ if (g_cancellable_set_error_if_cancelled (cancellable, error)) {
+ g_clear_object (&pop3_cache);
+ g_clear_object (&pop3_engine);
+
+ camel_operation_pop_message (cancellable);
+
+ return FALSE;
+ }
+
fi = pop3_folder->uids->pdata[i];
/* wait for delete commands to finish */
if (fi->cmd) {
@@ -1005,6 +1070,7 @@ camel_pop3_folder_class_init (CamelPOP3FolderClass *class)
folder_class->get_message_count = pop3_folder_get_message_count;
folder_class->get_uids = pop3_folder_get_uids;
folder_class->free_uids = camel_folder_free_shallow;
+ folder_class->get_uncached_uids = pop3_get_uncached_uids;
folder_class->get_filename = pop3_folder_get_filename;
folder_class->set_message_flags = pop3_folder_set_message_flags;
folder_class->get_message_sync = pop3_folder_get_message_sync;
@@ -1151,6 +1217,9 @@ camel_pop3_delete_old (CamelFolder *folder,
return FALSE;
}
+ if (g_cancellable_set_error_if_cancelled (cancellable, error))
+ return FALSE;
+
pop3_folder = CAMEL_POP3_FOLDER (folder);
pop3_store = CAMEL_POP3_STORE (parent_store);
pop3_cache = camel_pop3_store_ref_cache (pop3_store);
@@ -1163,6 +1232,13 @@ camel_pop3_delete_old (CamelFolder *folder,
message_time = 0;
fi = pop3_folder->uids->pdata[i];
+ if (g_cancellable_set_error_if_cancelled (cancellable, error)) {
+ g_clear_object (&pop3_cache);
+ g_clear_object (&pop3_engine);
+
+ return FALSE;
+ }
+
if (fi->cmd) {
while (camel_pop3_engine_iterate (pop3_engine, fi->cmd, cancellable, NULL) > 0) {
; /* do nothing - iterating until end */
@@ -1199,6 +1275,13 @@ camel_pop3_delete_old (CamelFolder *folder,
__FILE__, __LINE__, day_lag, days_to_delete));
if (day_lag > days_to_delete) {
+ if (g_cancellable_set_error_if_cancelled (cancellable, error)) {
+ g_clear_object (&pop3_cache);
+ g_clear_object (&pop3_engine);
+
+ return FALSE;
+ }
+
if (fi->cmd) {
while (camel_pop3_engine_iterate (pop3_engine, fi->cmd, cancellable,
NULL) > 0) {
; /* do nothing - iterating until end */
@@ -1224,6 +1307,13 @@ camel_pop3_delete_old (CamelFolder *folder,
}
for (i = 0; i < pop3_folder->uids->len; i++) {
+ if (g_cancellable_set_error_if_cancelled (cancellable, error)) {
+ g_clear_object (&pop3_cache);
+ g_clear_object (&pop3_engine);
+
+ return FALSE;
+ }
+
fi = pop3_folder->uids->pdata[i];
/* wait for delete commands to finish */
if (fi->cmd) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]