[evolution-data-server] Bug 772292 - [IMAPx] New mail not shown in UI until folder refresh
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug 772292 - [IMAPx] New mail not shown in UI until folder refresh
- Date: Fri, 25 Nov 2016 08:20:52 +0000 (UTC)
commit c2cefc038412727b5f3e43ea5e689927cf2ee366
Author: Milan Crha <mcrha redhat com>
Date: Fri Nov 25 09:20:16 2016 +0100
Bug 772292 - [IMAPx] New mail not shown in UI until folder refresh
src/camel/camel-folder.c | 53 ++++++-----------
src/camel/providers/imapx/camel-imapx-server.c | 74 +++++++++++++----------
2 files changed, 60 insertions(+), 67 deletions(-)
---
diff --git a/src/camel/camel-folder.c b/src/camel/camel-folder.c
index bab3ced..2d04065 100644
--- a/src/camel/camel-folder.c
+++ b/src/camel/camel-folder.c
@@ -95,7 +95,7 @@ struct _CamelFolderChangeInfoPrivate {
};
struct _SignalClosure {
- GWeakRef folder;
+ CamelFolder *folder;
gchar *folder_name;
};
@@ -165,7 +165,7 @@ async_context_free (AsyncContext *async_context)
static void
signal_closure_free (SignalClosure *signal_closure)
{
- g_weak_ref_clear (&signal_closure->folder);
+ g_clear_object (&signal_closure->folder);
g_free (signal_closure->folder_name);
@@ -177,23 +177,18 @@ folder_emit_changed_cb (gpointer user_data)
{
SignalClosure *signal_closure = user_data;
CamelFolder *folder;
+ CamelFolderChangeInfo *changes;
- folder = g_weak_ref_get (&signal_closure->folder);
-
- if (folder != NULL) {
- CamelFolderChangeInfo *changes;
+ folder = signal_closure->folder;
- g_mutex_lock (&folder->priv->change_lock);
- changes = folder->priv->pending_changes;
- folder->priv->pending_changes = NULL;
- g_mutex_unlock (&folder->priv->change_lock);
+ g_mutex_lock (&folder->priv->change_lock);
+ changes = folder->priv->pending_changes;
+ folder->priv->pending_changes = NULL;
+ g_mutex_unlock (&folder->priv->change_lock);
- g_signal_emit (folder, signals[CHANGED], 0, changes);
+ g_signal_emit (folder, signals[CHANGED], 0, changes);
- camel_folder_change_info_free (changes);
-
- g_object_unref (folder);
- }
+ camel_folder_change_info_free (changes);
return FALSE;
}
@@ -202,14 +197,8 @@ static gboolean
folder_emit_deleted_cb (gpointer user_data)
{
SignalClosure *signal_closure = user_data;
- CamelFolder *folder;
- folder = g_weak_ref_get (&signal_closure->folder);
-
- if (folder != NULL) {
- g_signal_emit (folder, signals[DELETED], 0);
- g_object_unref (folder);
- }
+ g_signal_emit (signal_closure->folder, signals[DELETED], 0);
return FALSE;
}
@@ -218,17 +207,11 @@ static gboolean
folder_emit_renamed_cb (gpointer user_data)
{
SignalClosure *signal_closure = user_data;
- CamelFolder *folder;
-
- folder = g_weak_ref_get (&signal_closure->folder);
- if (folder != NULL) {
- g_signal_emit (
- folder,
- signals[RENAMED], 0,
- signal_closure->folder_name);
- g_object_unref (folder);
- }
+ g_signal_emit (
+ signal_closure->folder,
+ signals[RENAMED], 0,
+ signal_closure->folder_name);
return FALSE;
}
@@ -2381,7 +2364,7 @@ camel_folder_delete (CamelFolder *folder)
return;
signal_closure = g_slice_new0 (SignalClosure);
- g_weak_ref_init (&signal_closure->folder, folder);
+ signal_closure->folder = g_object_ref (folder);
/* Prioritize ahead of GTK+ redraws. */
camel_session_idle_add (
@@ -2436,7 +2419,7 @@ camel_folder_rename (CamelFolder *folder,
return;
signal_closure = g_slice_new0 (SignalClosure);
- g_weak_ref_init (&signal_closure->folder, folder);
+ signal_closure->folder = g_object_ref (folder);
signal_closure->folder_name = old_name; /* transfer ownership */
/* Prioritize ahead of GTK+ redraws. */
@@ -2501,7 +2484,7 @@ camel_folder_changed (CamelFolder *folder,
folder->priv->pending_changes = pending_changes;
signal_closure = g_slice_new0 (SignalClosure);
- g_weak_ref_init (&signal_closure->folder, folder);
+ signal_closure->folder = g_object_ref (folder);
camel_session_idle_add (
session, G_PRIORITY_LOW,
diff --git a/src/camel/providers/imapx/camel-imapx-server.c b/src/camel/providers/imapx/camel-imapx-server.c
index 284141a..e706972 100644
--- a/src/camel/providers/imapx/camel-imapx-server.c
+++ b/src/camel/providers/imapx/camel-imapx-server.c
@@ -2312,38 +2312,42 @@ imapx_completion (CamelIMAPXServer *is,
c (is->priv->tagprefix, "Got completion response for command %05u '%s'\n", ic->tag,
camel_imapx_job_get_kind_name (ic->job_kind));
- g_mutex_lock (&is->priv->changes_lock);
+ /* The camel_imapx_server_refresh_info_sync() gets any piled change
+ notifications and will emit the signal with all of them at once. */
+ if (!is->priv->fetch_changes_mailbox && !is->priv->fetch_changes_folder &&
!is->priv->fetch_changes_infos) {
+ g_mutex_lock (&is->priv->changes_lock);
- if (camel_folder_change_info_changed (is->priv->changes)) {
- CamelFolder *folder = NULL;
- CamelIMAPXMailbox *mailbox;
- CamelFolderChangeInfo *changes;
+ if (camel_folder_change_info_changed (is->priv->changes)) {
+ CamelFolder *folder = NULL;
+ CamelIMAPXMailbox *mailbox;
+ CamelFolderChangeInfo *changes;
- changes = is->priv->changes;
- is->priv->changes = camel_folder_change_info_new ();
+ changes = is->priv->changes;
+ is->priv->changes = camel_folder_change_info_new ();
- g_mutex_unlock (&is->priv->changes_lock);
+ g_mutex_unlock (&is->priv->changes_lock);
- mailbox = camel_imapx_server_ref_selected (is);
+ mailbox = camel_imapx_server_ref_selected (is);
- g_warn_if_fail (mailbox != NULL);
+ g_warn_if_fail (mailbox != NULL);
- if (mailbox) {
- folder = imapx_server_ref_folder (is, mailbox);
- g_return_val_if_fail (folder != NULL, FALSE);
+ if (mailbox) {
+ folder = imapx_server_ref_folder (is, mailbox);
+ g_return_val_if_fail (folder != NULL, FALSE);
- camel_folder_summary_save (camel_folder_get_folder_summary (folder), NULL);
+ camel_folder_summary_save (camel_folder_get_folder_summary (folder), NULL);
- imapx_update_store_summary (folder);
- camel_folder_changed (folder, changes);
- }
+ imapx_update_store_summary (folder);
+ camel_folder_changed (folder, changes);
+ }
- camel_folder_change_info_free (changes);
+ camel_folder_change_info_free (changes);
- g_clear_object (&folder);
- g_clear_object (&mailbox);
- } else {
- g_mutex_unlock (&is->priv->changes_lock);
+ g_clear_object (&folder);
+ g_clear_object (&mailbox);
+ } else {
+ g_mutex_unlock (&is->priv->changes_lock);
+ }
}
if (g_list_next (ic->current_part) != NULL) {
@@ -4986,6 +4990,7 @@ camel_imapx_server_refresh_info_sync (CamelIMAPXServer *is,
CamelIMAPXMailbox *selected_mailbox;
CamelIMAPXSummary *imapx_summary;
CamelFolder *folder;
+ CamelFolderChangeInfo *changes;
GHashTable *known_uids;
guint32 messages;
guint32 unseen;
@@ -5096,16 +5101,20 @@ camel_imapx_server_refresh_info_sync (CamelIMAPXServer *is,
if (success && uidl != 1)
success = imapx_server_fetch_changes (is, mailbox, folder, known_uids, 0, uidl, cancellable,
error);
+ g_mutex_lock (&is->priv->changes_lock);
+
+ changes = is->priv->changes;
+ is->priv->changes = camel_folder_change_info_new ();
+
+ g_mutex_unlock (&is->priv->changes_lock);
+
if (success) {
- CamelFolderChangeInfo *changes;
GList *removed = NULL;
GPtrArray *array;
gint ii;
camel_folder_summary_lock (camel_folder_get_folder_summary (folder));
- changes = camel_folder_change_info_new ();
-
array = camel_folder_summary_get_array (camel_folder_get_folder_summary (folder));
for (ii = 0; array && ii < array->len; ii++) {
const gchar *uid = array->pdata[ii];
@@ -5129,16 +5138,17 @@ camel_imapx_server_refresh_info_sync (CamelIMAPXServer *is,
g_list_free (removed);
}
- if (camel_folder_change_info_changed (changes)) {
- camel_folder_summary_save (camel_folder_get_folder_summary (folder), NULL);
- imapx_update_store_summary (folder);
- camel_folder_changed (folder, changes);
- }
-
- camel_folder_change_info_free (changes);
camel_folder_summary_free_array (array);
}
+ if (camel_folder_change_info_changed (changes)) {
+ camel_folder_summary_save (camel_folder_get_folder_summary (folder), NULL);
+ imapx_update_store_summary (folder);
+ camel_folder_changed (folder, changes);
+ }
+
+ camel_folder_change_info_free (changes);
+
g_hash_table_destroy (known_uids);
g_object_unref (folder);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]