[evolution-data-server] Show feedback on message download for offline after going online
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Show feedback on message download for offline after going online
- Date: Tue, 28 Nov 2017 17:59:41 +0000 (UTC)
commit c203e40a25ab9ede65255c07bfa42f942a104468
Author: Milan Crha <mcrha redhat com>
Date: Tue Nov 28 18:59:38 2017 +0100
Show feedback on message download for offline after going online
src/camel/camel-offline-folder.c | 16 ++++++-
src/camel/camel-offline-store.c | 57 +++++++++++++++++++----
src/camel/providers/imapx/camel-imapx-folder.c | 33 ++++++++++++++
3 files changed, 95 insertions(+), 11 deletions(-)
---
diff --git a/src/camel/camel-offline-folder.c b/src/camel/camel-offline-folder.c
index 33d8f57..3aa5cd8 100644
--- a/src/camel/camel-offline-folder.c
+++ b/src/camel/camel-offline-folder.c
@@ -468,9 +468,23 @@ offline_folder_downsync_sync (CamelOfflineFolder *offline,
}
if (download) {
+ /* Translators: The first “%d” is the sequence number of the message, the second “%d”
+ is the total number of messages to synchronize.
+ The first “%s” is replaced with an account name and the second “%s”
+ is replaced with a full path name. The spaces around “:” are intentional, as
+ the whole “%s : %s” is meant as an absolute identification of the folder. */
+ camel_operation_push_message (cancellable, _("Syncing message %d of %d in folder “%s
: %s” to disk"),
+ i + 1, uncached_uids->len,
+ camel_service_get_display_name (CAMEL_SERVICE (camel_folder_get_parent_store
(folder))),
+ camel_folder_get_full_name (folder));
+
/* Stop on failure */
- if (!camel_folder_synchronize_message_sync (folder, uid, cancellable, NULL))
+ if (!camel_folder_synchronize_message_sync (folder, uid, cancellable, NULL)) {
+ camel_operation_pop_message (cancellable);
break;
+ }
+
+ camel_operation_pop_message (cancellable);
}
camel_operation_progress (cancellable, i * 100 / uncached_uids->len);
diff --git a/src/camel/camel-offline-store.c b/src/camel/camel-offline-store.c
index 959f0ab..78cda43 100644
--- a/src/camel/camel-offline-store.c
+++ b/src/camel/camel-offline-store.c
@@ -50,6 +50,40 @@ enum {
G_DEFINE_TYPE (CamelOfflineStore, camel_offline_store, CAMEL_TYPE_STORE)
static void
+offline_store_downsync_folders_thread (CamelSession *session,
+ GCancellable *cancellable,
+ gpointer user_data,
+ GError **error)
+{
+ CamelStore *store = user_data;
+ GPtrArray *folders;
+ guint ii;
+
+ g_return_if_fail (CAMEL_IS_OFFLINE_STORE (store));
+
+ folders = camel_offline_store_dup_downsync_folders (CAMEL_OFFLINE_STORE (store));
+ if (!folders)
+ return;
+
+ for (ii = 0; ii < folders->len && !g_cancellable_is_cancelled (cancellable); ii++) {
+ CamelFolder *folder = folders->pdata[ii];
+ CamelOfflineFolder *offline_folder;
+
+ if (!CAMEL_IS_OFFLINE_FOLDER (folder))
+ continue;
+
+ offline_folder = CAMEL_OFFLINE_FOLDER (folder);
+
+ if (camel_offline_folder_can_downsync (offline_folder) &&
+ !camel_offline_folder_downsync_sync (offline_folder, NULL, cancellable, error))
+ break;
+ }
+
+ g_ptr_array_foreach (folders, (GFunc) g_object_unref, NULL);
+ g_ptr_array_free (folders, TRUE);
+}
+
+static void
offline_store_constructed (GObject *object)
{
CamelOfflineStorePrivate *priv;
@@ -223,23 +257,26 @@ camel_offline_store_set_online_sync (CamelOfflineStore *store,
if (host_reachable) {
GPtrArray *folders;
- guint ii;
+ CamelSession *session;
- folders = camel_offline_store_dup_downsync_folders (store);
+ session = camel_service_ref_session (service);
+ folders = session ? camel_offline_store_dup_downsync_folders (store) : NULL;
- for (ii = 0; folders && ii < folders->len; ii++) {
- CamelFolder *folder = folders->pdata[ii];
- CamelOfflineFolder *offline_folder;
+ if (folders && session) {
+ gchar *description;
- if (!CAMEL_IS_OFFLINE_FOLDER (folder))
- continue;
+ description = g_strdup_printf (_("Syncing messages in account “%s” to disk"),
+ camel_service_get_display_name (service));
- offline_folder = CAMEL_OFFLINE_FOLDER (folder);
+ camel_session_submit_job (session, description,
+ offline_store_downsync_folders_thread,
+ g_object_ref (store), g_object_unref);
- if (camel_offline_folder_can_downsync (offline_folder))
- camel_offline_folder_downsync_sync (offline_folder, NULL, cancellable, NULL);
+ g_free (description);
}
+ g_clear_object (&session);
+
if (folders) {
g_ptr_array_foreach (folders, (GFunc) g_object_unref, NULL);
g_ptr_array_free (folders, TRUE);
diff --git a/src/camel/providers/imapx/camel-imapx-folder.c b/src/camel/providers/imapx/camel-imapx-folder.c
index c3efeee..aa4dd7c 100644
--- a/src/camel/providers/imapx/camel-imapx-folder.c
+++ b/src/camel/providers/imapx/camel-imapx-folder.c
@@ -421,6 +421,38 @@ imapx_search_by_expression (CamelFolder *folder,
return matches;
}
+static GPtrArray *
+imapx_get_uncached_uids (CamelFolder *folder,
+ GPtrArray *uids,
+ GError **error)
+{
+ CamelIMAPXFolder *imapx_folder;
+ GPtrArray *result;
+ guint ii;
+
+ g_return_val_if_fail (CAMEL_IS_IMAPX_FOLDER (folder), NULL);
+ g_return_val_if_fail (uids != NULL, NULL);
+
+ imapx_folder = CAMEL_IMAPX_FOLDER (folder);
+
+ result = g_ptr_array_sized_new (uids->len);
+
+ for (ii = 0; ii < uids->len; ii++) {
+ const gchar *uid = uids->pdata[ii];
+ GIOStream *io_stream;
+
+ /* Assume that UIDs with existing stream are valid;
+ the imapx_get_message_cached() can fail with broken files, but it's rather unlikely. */
+ io_stream = camel_data_cache_get (imapx_folder->cache, "cur", uid, NULL);
+ if (io_stream)
+ g_object_unref (io_stream);
+ else
+ g_ptr_array_add (result, (gpointer) camel_pstring_strdup (uid));
+ }
+
+ return result;
+}
+
static gchar *
imapx_get_filename (CamelFolder *folder,
const gchar *uid,
@@ -982,6 +1014,7 @@ camel_imapx_folder_class_init (CamelIMAPXFolderClass *class)
folder_class->search_by_expression = imapx_search_by_expression;
folder_class->search_by_uids = imapx_search_by_uids;
folder_class->count_by_expression = imapx_count_by_expression;
+ folder_class->get_uncached_uids = imapx_get_uncached_uids;
folder_class->search_free = imapx_search_free;
folder_class->get_filename = imapx_get_filename;
folder_class->append_message_sync = imapx_append_message_sync;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]