summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2010-06-23 12:07:33 +0100
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-06-28 13:39:51 +0100
commitce772d81def90cef86f4e684fcd606e154c6027c (patch)
treea806184806f016ea0c6448510e79d9e6e462ad4e
parentd0e79bf9626fdbb8ef0ba1204d35d8ffbfc1935b (diff)
downloadevolution-data-server-ce772d81def90cef86f4e684fcd606e154c6027c.tar.gz
Propagate STATUS responses to folders directly from imapx_untagged()
Storing this in the server-global variables like is->exists is broken; any SELECT command which is sent between the untagged STATUS response and the tagged completion of the command is going to overwrite the data. Not to mention the fact that LIST-STATUS and NOTIFY will be totally hosed, when we get more than one untagged STATUS response between tagged commands. (cherry picked from commit 61859b2fd607c86cd0dcf68c0fcfbc9ee86db9b2)
-rw-r--r--camel/providers/imapx/camel-imapx-server.c37
-rw-r--r--camel/providers/imapx/camel-imapx-utils.c5
-rw-r--r--camel/providers/imapx/camel-imapx-utils.h1
3 files changed, 28 insertions, 15 deletions
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 8609f2f16..14e6c7e1d 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -1467,10 +1467,29 @@ imapx_untagged(CamelIMAPXServer *imap, CamelException *ex)
case IMAPX_STATUS: {
struct _state_info *sinfo = imapx_parse_status_info (imap->stream, ex);
if (sinfo) {
- /* this is what we use atm */
- imap->exists = sinfo->messages;
- imap->unseen = sinfo->unseen;
+ CamelIMAPXStoreSummary *s = ((CamelIMAPXStore *)imap->store)->summary;
+ CamelIMAPXStoreNamespace *ns;
+ CamelIMAPXFolder *ifolder = NULL;;
+
+ ns = camel_imapx_store_summary_namespace_find_full(s, sinfo->name);
+ if (ns) {
+ gchar *path_name;
+
+ path_name = camel_imapx_store_summary_full_to_path(s, sinfo->name, ns->sep);
+ c(printf("Got folder path '%s' for full '%s'\n", path_name, sinfo->name));
+ if (path_name) {
+ ifolder = (void *)camel_store_get_folder(imap->store, path_name, 0, ex);
+ g_free (path_name);
+ }
+ }
+ if (ifolder) {
+ ifolder->unread_on_server = sinfo->unseen;
+ ifolder->exists_on_server = sinfo->messages;
+ } else {
+ c(printf("Received STATUS for unknown folder '%s'\n", sinfo->name));
+ }
+ g_free (sinfo->name);
g_free (sinfo);
}
break;
@@ -1805,17 +1824,6 @@ 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->unread_on_server = is->unseen;
- ifolder->exists_on_server = is->exists;
- e_flag_set (ic->flag);
-}
-
/* The caller should free the command as well */
static void
imapx_command_run_sync (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
@@ -3517,7 +3525,6 @@ imapx_job_refresh_info_start (CamelIMAPXServer *is, CamelIMAPXJob *job)
ic = camel_imapx_command_new (is, "STATUS", folder->full_name, "STATUS %f (MESSAGES UNSEEN)", folder);
ic->job = job;
ic->pri = job->pri;
- ic->complete = imapx_command_status_done;
imapx_command_run_sync (is, ic);
if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
diff --git a/camel/providers/imapx/camel-imapx-utils.c b/camel/providers/imapx/camel-imapx-utils.c
index 6b280c553..c287cfcc2 100644
--- a/camel/providers/imapx/camel-imapx-utils.c
+++ b/camel/providers/imapx/camel-imapx-utils.c
@@ -1502,6 +1502,11 @@ imapx_parse_status_info (struct _CamelIMAPXStream *is, CamelException *ex)
/* skip the folder name */
camel_imapx_stream_astring (is, &token, ex);
+ if (camel_exception_is_set(ex)) {
+ g_free (sinfo);
+ return NULL;
+ }
+ sinfo->name = camel_utf7_utf8 ((gchar *)token);
tok = camel_imapx_stream_token(is, &token, &len, ex);
if (tok != '(') {
diff --git a/camel/providers/imapx/camel-imapx-utils.h b/camel/providers/imapx/camel-imapx-utils.h
index 8bcd763e4..7057dab2f 100644
--- a/camel/providers/imapx/camel-imapx-utils.h
+++ b/camel/providers/imapx/camel-imapx-utils.h
@@ -175,6 +175,7 @@ void imapx_free_status(struct _status_info *sinfo);
/* ********************************************************************** */
/* parses the response from the status command */
struct _state_info {
+ gchar *name;
guint32 messages;
guint32 recent;
guint32 uidnext;