[evolution-data-server] Bug 233140 - Show message counts in subscribe folders dialog



commit 7e0d032c30712ab3b1ca157a6df376533526fb32
Author: Milan Crha <mcrha redhat com>
Date:   Mon Aug 10 12:13:57 2015 +0200

    Bug 233140 - Show message counts in subscribe folders dialog

 camel/providers/imapx/camel-imapx-store.c |   16 ++++++++++++++--
 camel/providers/nntp/camel-nntp-store.c   |   14 ++++++++------
 2 files changed, 22 insertions(+), 8 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-store.c b/camel/providers/imapx/camel-imapx-store.c
index 132a9f8..d426113 100644
--- a/camel/providers/imapx/camel-imapx-store.c
+++ b/camel/providers/imapx/camel-imapx-store.c
@@ -1119,8 +1119,7 @@ get_folder_info_offline (CamelStore *store,
                        g_clear_object (&mailbox);
                }
 
-               fi = imapx_store_build_folder_info (
-                       imapx_store, folder_path, 0);
+               fi = imapx_store_build_folder_info (imapx_store, folder_path, 0);
                fi->unread = si->unread;
                fi->total = si->total;
                if ((fi->flags & CAMEL_FOLDER_TYPE_MASK) != 0)
@@ -1144,6 +1143,19 @@ get_folder_info_offline (CamelStore *store,
                if (!fi->child)
                        fi->flags |= CAMEL_FOLDER_NOCHILDREN;
 
+               if (fi->unread == -1 && fi->total == -1) {
+                       CamelIMAPXMailbox *mailbox;
+
+                       mailbox = camel_imapx_store_ref_mailbox (imapx_store, ((CamelIMAPXStoreInfo *) 
si)->mailbox_name);
+
+                       if (mailbox) {
+                               fi->unread = camel_imapx_mailbox_get_unseen (mailbox);
+                               fi->total = camel_imapx_mailbox_get_messages (mailbox);
+                       }
+
+                       g_clear_object (&mailbox);
+               }
+
                g_ptr_array_add (folders, fi);
        }
 
diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c
index 0466719..c57264c 100644
--- a/camel/providers/nntp/camel-nntp-store.c
+++ b/camel/providers/nntp/camel-nntp-store.c
@@ -667,7 +667,8 @@ nntp_folder_info_from_name (CamelNNTPStore *store,
 /* handle list/newgroups response */
 static CamelStoreInfo *
 nntp_store_info_update (CamelNNTPStore *nntp_store,
-                        gchar *line)
+                        gchar *line,
+                       gboolean is_folder_list)
 {
        CamelNNTPStoreSummary *nntp_store_summary;
        CamelStoreSummary *store_summary;
@@ -721,7 +722,7 @@ nntp_store_info_update (CamelNNTPStore *nntp_store,
                        new = last - first;
        }
 
-       si->info.total = last > first ? last - first : 0;
+       si->info.total = last > first ? last - first : (is_folder_list ? -1 : 0);
        si->info.unread += new; /* this is a _guess_ */
        si->last = last;
        si->first = first;
@@ -881,8 +882,8 @@ nntp_push_to_hierarchy (CamelNNTPStore *store,
                        fi->full_name = g_strdup (pfi->full_name);
                        fi->display_name = g_strdup (name);
 
-                       fi->unread = 0;
-                       fi->total = 0;
+                       fi->unread = -1;
+                       fi->total = -1;
                        fi->flags =
                                CAMEL_FOLDER_NOSELECT |
                                CAMEL_FOLDER_CHILDREN;
@@ -1101,6 +1102,7 @@ nntp_store_get_folder_info_all (CamelNNTPStore *nntp_store,
        guchar *line;
        gint ret = -1;
        CamelFolderInfo *fi = NULL;
+       gboolean is_folder_list = (flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIPTION_LIST) != 0;
 
        nntp_store_summary = camel_nntp_store_ref_summary (nntp_store);
 
@@ -1132,7 +1134,7 @@ nntp_store_get_folder_info_all (CamelNNTPStore *nntp_store,
                        nntp_stream = camel_nntp_store_ref_stream (nntp_store);
 
                        while ((ret = camel_nntp_stream_line (nntp_stream, &line, &len, cancellable, error)) 
0)
-                               nntp_store_info_update (nntp_store, (gchar *) line);
+                               nntp_store_info_update (nntp_store, (gchar *) line, is_folder_list);
                } else {
                        CamelStoreSummary *store_summary;
                        CamelStoreInfo *si;
@@ -1172,7 +1174,7 @@ nntp_store_get_folder_info_all (CamelNNTPStore *nntp_store,
                        nntp_stream = camel_nntp_store_ref_stream (nntp_store);
 
                        while ((ret = camel_nntp_stream_line (nntp_stream, &line, &len, cancellable, error)) 
0) {
-                               si = nntp_store_info_update (nntp_store, (gchar *) line);
+                               si = nntp_store_info_update (nntp_store, (gchar *) line, is_folder_list);
                                g_hash_table_remove (all, si->path);
                        }
 


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