[evolution-data-server] Bug 685035 - [IMAPx] Nonsensical progress report on folder update



commit a5459e43e427775eb0cc644415e6d1cc07a1328a
Author: Milan Crha <mcrha redhat com>
Date:   Fri Jul 3 12:55:10 2015 +0200

    Bug 685035 - [IMAPx] Nonsensical progress report on folder update

 camel/providers/imapx/camel-imapx-server.c |   36 +++++++++++++++++++--------
 camel/providers/imapx/camel-imapx-server.h |    3 ++
 2 files changed, 28 insertions(+), 11 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index b14c1d5..12c977c 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -2150,7 +2150,7 @@ imapx_untagged_exists (CamelIMAPXServer *is,
 
        g_return_val_if_fail (CAMEL_IS_IMAPX_SERVER (is), FALSE);
 
-       mailbox = camel_imapx_server_ref_selected (is);
+       mailbox = camel_imapx_server_ref_pending_or_selected (is);
 
        if (mailbox == NULL) {
                g_warning ("%s: No mailbox available", G_STRFUNC);
@@ -2708,7 +2708,7 @@ imapx_untagged_recent (CamelIMAPXServer *is,
 
        g_return_val_if_fail (CAMEL_IS_IMAPX_SERVER (is), FALSE);
 
-       mailbox = camel_imapx_server_ref_selected (is);
+       mailbox = camel_imapx_server_ref_pending_or_selected (is);
 
        if (mailbox == NULL) {
                g_warning ("%s: No mailbox available", G_STRFUNC);
@@ -2889,15 +2889,7 @@ imapx_untagged_ok_no_bad (CamelIMAPXServer *is,
           overwritten with a value from a different mailbox, thus the offline
           cache will persist, instead of being vanished.
        */
-       g_mutex_lock (&is->priv->select_lock);
-
-       mailbox = g_weak_ref_get (&is->priv->select_pending);
-       if (!mailbox)
-               mailbox = g_weak_ref_get (&is->priv->select_mailbox);
-       if (!mailbox)
-               mailbox = g_weak_ref_get (&is->priv->select_closing);
-
-       g_mutex_unlock (&is->priv->select_lock);
+       mailbox = camel_imapx_server_ref_pending_or_selected (is);
 
        is->priv->context->sinfo = imapx_parse_status (
                CAMEL_IMAPX_INPUT_STREAM (input_stream),
@@ -8395,6 +8387,28 @@ camel_imapx_server_ref_selected (CamelIMAPXServer *is)
        return mailbox;
 }
 
+/* Some untagged responses updated pending SELECT mailbox, not the currently
+   selected or closing one, thus use this function instead. */
+CamelIMAPXMailbox *
+camel_imapx_server_ref_pending_or_selected (CamelIMAPXServer *is)
+{
+       CamelIMAPXMailbox *mailbox;
+
+       g_return_val_if_fail (CAMEL_IS_IMAPX_SERVER (is), NULL);
+
+       g_mutex_lock (&is->priv->select_lock);
+
+       mailbox = g_weak_ref_get (&is->priv->select_pending);
+       if (mailbox == NULL)
+               mailbox = g_weak_ref_get (&is->priv->select_mailbox);
+       if (mailbox == NULL)
+               mailbox = g_weak_ref_get (&is->priv->select_closing);
+
+       g_mutex_unlock (&is->priv->select_lock);
+
+       return mailbox;
+}
+
 static void
 imapx_disconnect (CamelIMAPXServer *is)
 {
diff --git a/camel/providers/imapx/camel-imapx-server.h b/camel/providers/imapx/camel-imapx-server.h
index bf34d4c..78289c7 100644
--- a/camel/providers/imapx/camel-imapx-server.h
+++ b/camel/providers/imapx/camel-imapx-server.h
@@ -152,6 +152,9 @@ GOutputStream *     camel_imapx_server_ref_output_stream
                                                (CamelIMAPXServer *is);
 CamelIMAPXMailbox *
                camel_imapx_server_ref_selected (CamelIMAPXServer *is);
+CamelIMAPXMailbox *
+               camel_imapx_server_ref_pending_or_selected
+                                               (CamelIMAPXServer *is);
 gboolean       camel_imapx_server_connect      (CamelIMAPXServer *is,
                                                 GCancellable *cancellable,
                                                 GError **error);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]