From a9cf26004a74f3bd310afb9e180ebcabaab41757 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Wed, 2 May 2001 19:53:53 +0000 Subject: [PATCH] Clean this up a bit. Add a "tag_prefix" member. Move "useful_lsub" into * providers/imap/camel-imap-store.h: Clean this up a bit. Add a "tag_prefix" member. Move "useful_lsub" into capabilities. * providers/imap/camel-imap-store.c (camel_imap_store_init): Initialize the tag_prefix, based on a static variable. * providers/imap/camel-imap-command.c (camel_imap_command): Use the store's tag_prefix character rather than "A" at the start of the tag. Makes the verbose debug output easier to parse when connected to multiple IMAP servers. (Well, unless you're connected to more than 26 servers...) --- camel/ChangeLog | 12 ++++++++++++ camel/providers/imap/camel-imap-command.c | 4 ++-- camel/providers/imap/camel-imap-store.c | 13 ++++++++----- camel/providers/imap/camel-imap-store.h | 20 +++++++++----------- 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/camel/ChangeLog b/camel/ChangeLog index 74da010..4903f69 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,5 +1,17 @@ 2001-05-02 Dan Winship + * providers/imap/camel-imap-store.h: Clean this up a bit. Add a + "tag_prefix" member. Move "useful_lsub" into capabilities. + + * providers/imap/camel-imap-store.c (camel_imap_store_init): + Initialize the tag_prefix, based on a static variable. + + * providers/imap/camel-imap-command.c (camel_imap_command): Use + the store's tag_prefix character rather than "A" at the start of + the tag. Makes the verbose debug output easier to parse when + connected to multiple IMAP servers. (Well, unless you're connected + to more than 26 servers...) + * providers/imap/camel-imap-utils.c (imap_uid_array_to_set): Fix this up... it was losing count in some cases and giving a more verbose answer than it needed to. diff --git a/camel/providers/imap/camel-imap-command.c b/camel/providers/imap/camel-imap-command.c index 3c36dbf..4102d47 100644 --- a/camel/providers/imap/camel-imap-command.c +++ b/camel/providers/imap/camel-imap-command.c @@ -128,8 +128,8 @@ camel_imap_command (CamelImapStore *store, CamelFolder *folder, va_end (ap); camel_remote_store_send_string (CAMEL_REMOTE_STORE (store), ex, - "A%.5d %s\r\n", store->command++, - cmdbuf); + "%c%.5d %s\r\n", store->tag_prefix, + store->command++, cmdbuf); g_free (cmdbuf); if (camel_exception_is_set (ex)) { CAMEL_IMAP_STORE_UNLOCK (store, command_lock); diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index 8511b3e..42c2f12 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -54,12 +54,11 @@ #include "camel-imap-private.h" #include "camel-private.h" -#define d(x) x - /* Specified in RFC 2060 */ #define IMAP_PORT 143 static CamelRemoteStoreClass *remote_store_class = NULL; +static char imap_tag_prefix = 'A'; static void construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, @@ -169,10 +168,13 @@ camel_imap_store_init (gpointer object, gpointer klass) imap_store->dir_sep = '\0'; imap_store->current_folder = NULL; - imap_store->connected = FALSE; imap_store->subscribed_folders = NULL; + imap_store->tag_prefix = imap_tag_prefix++; + if (imap_tag_prefix > 'Z') + imap_tag_prefix = 'A'; + imap_store->priv = g_malloc0 (sizeof (*imap_store->priv)); #ifdef ENABLE_THREADS imap_store->priv->command_lock = e_mutex_new(E_MUTEX_REC); @@ -653,7 +655,7 @@ imap_store_setup_online (CamelImapStore *store, CamelException *ex) if (!imap_parse_list_response (result, &flags, NULL, &name)) continue; if (flags & (IMAP_LIST_FLAG_MARKED | IMAP_LIST_FLAG_UNMARKED)) - store->useful_lsub = TRUE; + store->capabilities |= IMAP_CAPABILITY_useful_lsub; if (flags & IMAP_LIST_FLAG_NOSELECT) { g_free (name); continue; @@ -1161,7 +1163,8 @@ get_folder_info (CamelStore *store, const char *top, gboolean fast, * use get_subscribed_folders_by_hand. In all other * cases, use a single LIST or LSUB command. */ - if (subscribed_only && !imap_store->useful_lsub && + if (subscribed_only && + !(imap_store->capabilities & IMAP_CAPABILITY_useful_lsub) && (imap_store->parameters & IMAP_PARAM_CHECK_ALL)) { get_subscribed_folders_by_hand (imap_store, name, folders, ex); diff --git a/camel/providers/imap/camel-imap-store.h b/camel/providers/imap/camel-imap-store.h index fb4be04..b05e525 100644 --- a/camel/providers/imap/camel-imap-store.h +++ b/camel/providers/imap/camel-imap-store.h @@ -52,6 +52,7 @@ typedef enum { #define IMAP_CAPABILITY_NAMESPACE (1 << 3) #define IMAP_CAPABILITY_UIDPLUS (1 << 4) #define IMAP_CAPABILITY_LITERALPLUS (1 << 5) +#define IMAP_CAPABILITY_useful_lsub (1 << 6) #define IMAP_PARAM_OVERRIDE_NAMESPACE (1 << 0) #define IMAP_PARAM_CHECK_ALL (1 << 1) @@ -61,20 +62,17 @@ struct _CamelImapStore { CamelRemoteStore parent_object; struct _CamelImapStorePrivate *priv; - CamelFolder *current_folder; - + /* Information about the command channel / connection status */ + gboolean connected; + char tag_prefix; guint32 command; - + CamelFolder *current_folder; + + /* Information about the server */ CamelImapServerLevel server_level; guint32 capabilities, parameters; - GHashTable *authtypes; - - char *namespace, dir_sep, *storage_path, *base_url; - - gboolean connected; - - GHashTable *subscribed_folders; - gboolean useful_lsub; + char *namespace, dir_sep, *base_url, *storage_path; + GHashTable *authtypes, *subscribed_folders; }; -- 2.7.4