[evolution-data-server/gnome-2-30] Propagate STATUS responses to folders directly from imapx_untagged()
- From: David Woodhouse <dwmw2 src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-2-30] Propagate STATUS responses to folders directly from imapx_untagged()
- Date: Mon, 28 Jun 2010 19:35:47 +0000 (UTC)
commit ce772d81def90cef86f4e684fcd606e154c6027c
Author: David Woodhouse <David Woodhouse intel com>
Date: Wed Jun 23 12:07:33 2010 +0100
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)
camel/providers/imapx/camel-imapx-server.c | 37 ++++++++++++++++-----------
camel/providers/imapx/camel-imapx-utils.c | 5 ++++
camel/providers/imapx/camel-imapx-utils.h | 1 +
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 8609f2f..14e6c7e 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 6b280c5..c287cfc 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 8bcd763..7057dab 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]