[evolution-data-server] store the total/unread count on server in imapx folder
- From: Chenthill Palanisamy <pchen src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-data-server] store the total/unread count on server in imapx folder
- Date: Mon, 11 Jan 2010 16:56:39 +0000 (UTC)
commit 6cd02d1c683f2ee7b739f366e289fdd99da49b73
Author: Chenthill Palanisamy <pchenthill novell com>
Date: Wed Jan 6 12:49:34 2010 +0530
store the total/unread count on server in imapx folder
camel/providers/imapx/camel-imapx-folder.c | 2 +
camel/providers/imapx/camel-imapx-folder.h | 4 +++
camel/providers/imapx/camel-imapx-server.c | 33 ++++++++++++++++++++++------
3 files changed, 32 insertions(+), 7 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-folder.c b/camel/providers/imapx/camel-imapx-folder.c
index 10be8d4..2da272d 100644
--- a/camel/providers/imapx/camel-imapx-folder.c
+++ b/camel/providers/imapx/camel-imapx-folder.c
@@ -80,6 +80,8 @@ camel_imapx_folder_new(CamelStore *store, const gchar *path, const gchar *folder
folder->summary = camel_imapx_summary_new(folder, summary_file);
ifolder->search = camel_folder_search_new ();
ifolder->search_lock = g_mutex_new ();
+ ifolder->exists_on_server = -1;
+ ifolder->unread_on_server = -1;
g_free (summary_file);
diff --git a/camel/providers/imapx/camel-imapx-folder.h b/camel/providers/imapx/camel-imapx-folder.h
index 2cf4db7..c14dc77 100644
--- a/camel/providers/imapx/camel-imapx-folder.h
+++ b/camel/providers/imapx/camel-imapx-folder.h
@@ -41,6 +41,10 @@ typedef struct _CamelIMAPXFolder {
gchar *raw_name;
CamelFolderSearch *search;
+
+ guint32 exists_on_server;
+ guint32 unread_on_server;
+
GMutex *search_lock;
} CamelIMAPXFolder;
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index f7d9797..3e15f2b 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -1484,6 +1484,19 @@ imapx_command_complete (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
e_flag_set (ic->flag);
}
+/* change status to a job and remove command_run_sync */
+static void
+imapx_command_status_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
+{
+ CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) ic->job->folder;
+
+
+ ifolder->exists_on_server = is->exists;
+ ifolder->unread_on_server = is->unread;
+
+ e_flag_set (ic->flag);
+}
+
/* The caller should free the command as well */
static void
imapx_command_run_sync (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
@@ -1494,8 +1507,9 @@ imapx_command_run_sync (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
complete = ic->complete;
camel_imapx_command_close (ic);
- ic->complete = imapx_command_complete;
-
+ if (!ic->complete)
+ ic->complete = imapx_command_complete;
+
imapx_command_queue (is, ic);
e_flag_wait (ic->flag);
@@ -1544,11 +1558,13 @@ imapx_command_select_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
if (is->select_pending)
camel_object_unref(is->select_pending);
} else {
+ CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) is->select_pending;
printf("Select ok!\n");
is->select_folder = is->select_pending;
is->select = g_strdup(is->select_folder->full_name);
is->state = IMAPX_SELECTED;
+ ifolder->exists_on_server = is->exists;
#if 0
/* This must trigger a complete index rebuild! */
if (is->uidvalidity && is->uidvalidity != ((CamelIMAPXSummary *)is->select_folder->summary)->uidvalidity)
@@ -2328,12 +2344,13 @@ imapx_job_fetch_new_messages_start (CamelIMAPXServer *is, CamelIMAPXJob *job)
{
CamelIMAPXCommand *ic;
CamelFolder *folder = job->folder;
+ CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) folder;
guint32 total, diff;
gchar *uid = NULL;
total = camel_folder_summary_count (folder->summary);
- diff = is->exists - total;
-
+ diff = ifolder->exists_on_server - total;
+
if (total > 0)
uid = camel_folder_summary_uid_from_index (folder->summary, total - 1);
else
@@ -3207,6 +3224,7 @@ camel_imapx_server_refresh_info(CamelIMAPXServer *is, CamelFolder *folder, Camel
CamelIMAPXJob *job;
guint32 total;
CamelIMAPXCommand *ic;
+ CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) folder;
job = imapx_find_job (is, IMAPX_JOB_REFRESH_INFO, NULL);
if (job)
@@ -3228,7 +3246,7 @@ camel_imapx_server_refresh_info(CamelIMAPXServer *is, CamelFolder *folder, Camel
total = camel_folder_summary_count (folder->summary);
/* Fetch the new messages */
- if (is->exists > total)
+ if (ifolder->exists_on_server > total)
{
imapx_run_job(is, job);
@@ -3248,11 +3266,12 @@ camel_imapx_server_refresh_info(CamelIMAPXServer *is, CamelFolder *folder, Camel
total = camel_folder_summary_count (folder->summary);
/* Check if a rescan is needed */
- if (is->exists == total) {
+ if (ifolder->exists_on_server == total) {
guint32 unread;
ic = camel_imapx_command_new ("STATUS", folder->full_name, "STATUS %s (MESSAGES UNSEEN)", folder->full_name);
ic->job = job;
+ ic->complete = imapx_command_status_done;
imapx_command_run_sync (is, ic);
if (camel_exception_is_set (ic->ex) || ic->status->result != IMAP_OK) {
@@ -3267,7 +3286,7 @@ camel_imapx_server_refresh_info(CamelIMAPXServer *is, CamelFolder *folder, Camel
camel_imapx_command_free (ic);
camel_object_get (folder, NULL, CAMEL_FOLDER_UNREAD, &unread, NULL);
- if (is->exists == total && unread == is->unread)
+ if (ifolder->exists_on_server == total && unread == ifolder->unread_on_server)
goto done;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]