[evolution-data-server/gnome-2-30] Use LIST-EXTENDED to return subscribed status from LIST
- From: David Woodhouse <dwmw2 src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-2-30] Use LIST-EXTENDED to return subscribed status from LIST
- Date: Mon, 28 Jun 2010 19:37:03 +0000 (UTC)
commit 4e67e5e3af04dc450bcfcf773d82cea41a0aa1f4
Author: David Woodhouse <David Woodhouse intel com>
Date: Fri Jun 25 00:01:36 2010 +0100
Use LIST-EXTENDED to return subscribed status from LIST
If the server supports LIST-EXTENDED, we don't have to follow the initial
LIST with an LSUB command to see which folders are subscribed -- we can
just ask it to tell us the subscribed status in the LIST responses.
(cherry picked from commit 9445941f962f42cc513903a12d3036d9607bae4c)
camel/providers/imapx/camel-imapx-server.c | 10 +++++++++-
camel/providers/imapx/camel-imapx-server.h | 2 +-
camel/providers/imapx/camel-imapx-store.c | 26 ++++++++++++++++----------
camel/providers/imapx/camel-imapx-utils.c | 1 +
4 files changed, 27 insertions(+), 12 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index a2527ee..a17c6d1 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -289,6 +289,7 @@ struct _CamelIMAPXJob {
struct {
gchar *pattern;
guint32 flags;
+ const gchar *ext;
GHashTable *folders;
} list;
@@ -3683,6 +3684,11 @@ imapx_job_list_start(CamelIMAPXServer *is, CamelIMAPXJob *job)
ic = camel_imapx_command_new(is, "LIST", NULL, "%s \"\" %s",
(job->u.list.flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED)?"LSUB":"LIST",
job->u.list.pattern);
+ if (job->u.list.ext) {
+ /* Hm, we need a way to add atoms _without_ quoting or using literals */
+ camel_imapx_command_add(ic, " ");
+ camel_imapx_command_add(ic, job->u.list.ext);
+ }
ic->pri = job->pri;
ic->job = job;
ic->complete = imapx_command_list_done;
@@ -4911,7 +4917,8 @@ imapx_list_cmp(gconstpointer ap, gconstpointer bp)
}
GPtrArray *
-camel_imapx_server_list(CamelIMAPXServer *is, const gchar *top, guint32 flags, CamelException *ex)
+camel_imapx_server_list(CamelIMAPXServer *is, const gchar *top, guint32 flags,
+ const gchar *ext, CamelException *ex)
{
CamelIMAPXJob *job;
GPtrArray *folders = NULL;
@@ -4924,6 +4931,7 @@ camel_imapx_server_list(CamelIMAPXServer *is, const gchar *top, guint32 flags, C
job->start = imapx_job_list_start;
job->pri = IMAPX_PRIORITY_LIST;
job->ex = ex;
+ job->u.list.ext = ext;
job->u.list.flags = flags;
job->u.list.folders = g_hash_table_new(imapx_name_hash, imapx_name_equal);
job->u.list.pattern = g_alloca(strlen(encoded_name)+5);
diff --git a/camel/providers/imapx/camel-imapx-server.h b/camel/providers/imapx/camel-imapx-server.h
index 2e3729a..502769d 100644
--- a/camel/providers/imapx/camel-imapx-server.h
+++ b/camel/providers/imapx/camel-imapx-server.h
@@ -119,7 +119,7 @@ CamelIMAPXServer *camel_imapx_server_new(struct _CamelStore *store, struct _Came
gboolean camel_imapx_server_connect(CamelIMAPXServer *is, gint state, CamelException *ex);
gboolean imapx_connect_to_server (CamelIMAPXServer *is, CamelException *ex);
-GPtrArray *camel_imapx_server_list(CamelIMAPXServer *is, const gchar *top, guint32 flags, CamelException *ex);
+GPtrArray *camel_imapx_server_list(CamelIMAPXServer *is, const gchar *top, guint32 flags, const gchar *ext, CamelException *ex);
void camel_imapx_server_refresh_info(CamelIMAPXServer *is, CamelFolder *folder, struct _CamelException *ex);
void camel_imapx_server_sync_changes(CamelIMAPXServer *is, CamelFolder *folder, CamelException *ex);
diff --git a/camel/providers/imapx/camel-imapx-store.c b/camel/providers/imapx/camel-imapx-store.c
index 2493fa6..be086d8 100644
--- a/camel/providers/imapx/camel-imapx-store.c
+++ b/camel/providers/imapx/camel-imapx-store.c
@@ -969,11 +969,11 @@ imapx_get_folders_free(gpointer k, gpointer v, gpointer d)
}
static void
-fetch_folders_for_pattern (CamelIMAPXStore *istore, const gchar *pattern, guint32 flags, GHashTable *table, CamelException *ex)
+fetch_folders_for_pattern (CamelIMAPXStore *istore, const gchar *pattern, guint32 flags, const gchar *ext, GHashTable *table, CamelException *ex)
{
GPtrArray *folders = NULL;
- folders = camel_imapx_server_list (istore->server, pattern, flags, ex);
+ folders = camel_imapx_server_list (istore->server, pattern, flags, ext, ex);
if (camel_exception_is_set (ex))
return;
@@ -1017,6 +1017,7 @@ fetch_folders_for_namespaces (CamelIMAPXStore *istore, const gchar *pattern, gbo
while (ns) {
guint32 flags = 0;
gchar *pat = NULL;
+ const gchar *list_ext = NULL;
if (!pattern) {
if (!*ns->path)
@@ -1029,20 +1030,25 @@ fetch_folders_for_namespaces (CamelIMAPXStore *istore, const gchar *pattern, gbo
if (sync)
flags |= CAMEL_STORE_FOLDER_INFO_SUBSCRIPTION_LIST;
+ if (istore->server->cinfo->capa & IMAPX_CAPABILITY_LIST_EXTENDED)
+ list_ext = "RETURN (SUBSCRIBED)";
+
flags |= CAMEL_STORE_FOLDER_INFO_RECURSIVE;
- fetch_folders_for_pattern (istore, pat, flags, folders, ex);
+ fetch_folders_for_pattern (istore, pat, flags, list_ext, folders, ex);
if (camel_exception_is_set (ex)) {
g_free (pat);
goto exception;
}
-
- flags |= CAMEL_STORE_FOLDER_INFO_SUBSCRIBED;
- fetch_folders_for_pattern (istore, pat, flags, folders, ex);
- if (camel_exception_is_set (ex)) {
- g_free (pat);
- goto exception;
+ if (!list_ext) {
+ /* If the server doesn't support LIST-EXTENDED then we have to
+ issue LSUB to list the subscribed folders separately */
+ flags |= CAMEL_STORE_FOLDER_INFO_SUBSCRIBED;
+ fetch_folders_for_pattern (istore, pat, flags, NULL, folders, ex);
+ if (camel_exception_is_set (ex)) {
+ g_free (pat);
+ goto exception;
+ }
}
-
g_free (pat);
if (pattern)
diff --git a/camel/providers/imapx/camel-imapx-utils.c b/camel/providers/imapx/camel-imapx-utils.c
index df2db27..274736d 100644
--- a/camel/providers/imapx/camel-imapx-utils.c
+++ b/camel/providers/imapx/camel-imapx-utils.c
@@ -1790,6 +1790,7 @@ static struct {
{ "\\NOSELECT", CAMEL_FOLDER_NOSELECT },
{ "\\MARKED", 1<< 16},
{ "\\UNMARKED", 1<< 17},
+ { "\\SUBSCRIBED", CAMEL_FOLDER_SUBSCRIBED },
};
struct _list_info *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]