diff options
author | Jeffrey Stedfast <fejj@helixcode.com> | 2000-06-23 05:51:40 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2000-06-23 05:51:40 +0800 |
commit | a7f40b2f5ff709b9c0d3f5f487cdba6d6d3aa7b6 (patch) | |
tree | 75750e85f0fda73840a9c95971fe754ab3dc35f3 | |
parent | 4e9d56a6c03ee7ba65bb4cdd4fc4e7690f5e9c8c (diff) | |
download | gsoc2013-evolution-a7f40b2f5ff709b9c0d3f5f487cdba6d6d3aa7b6.tar.gz gsoc2013-evolution-a7f40b2f5ff709b9c0d3f5f487cdba6d6d3aa7b6.tar.zst gsoc2013-evolution-a7f40b2f5ff709b9c0d3f5f487cdba6d6d3aa7b6.zip |
Updated
2000-06-22 Jeffrey Stedfast <fejj@helixcode.com>
* providers/sendmail/camel-sendmail-provider.c:
* providers/vee/camel-vee-provider.c:
* providers/smtp/camel-smtp-provider.c:
* providers/mbox/camel-mbox-provider.c:
* providers/pop3/camel-pop3-provider.c:
* providers/imap/camel-imap-provider.c: Updated
* camel-session.c: Moved service_cache hash table into the
providers.
(service_cache_remove): Updated.
(camel_session_get_service): Updated.
* camel-url.c (camel_url_hash): Took out the hashing of
url->passwd. We don't want this anymore.
* providers/imap/camel-imap-folder.c (imap_init): Took out
references to 'namespace'
(camel_imap_folder_init): Same
* providers/imap/camel-imap-folder.h: No more namespace. We are
instead going to use url->path as the namespace.
svn path=/trunk/; revision=3700
-rw-r--r-- | camel/ChangeLog | 24 | ||||
-rw-r--r-- | camel/camel-provider.c | 4 | ||||
-rw-r--r-- | camel/camel-provider.h | 9 | ||||
-rw-r--r-- | camel/camel-session.c | 63 | ||||
-rw-r--r-- | camel/camel-session.h | 4 | ||||
-rw-r--r-- | camel/camel-url.c | 14 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-folder.c | 91 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-folder.h | 4 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-provider.c | 58 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-store.c | 43 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-store.h | 1 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-provider.c | 7 | ||||
-rw-r--r-- | camel/providers/pop3/camel-pop3-provider.c | 7 | ||||
-rw-r--r-- | camel/providers/sendmail/camel-sendmail-provider.c | 7 | ||||
-rw-r--r-- | camel/providers/smtp/camel-smtp-provider.c | 7 | ||||
-rw-r--r-- | camel/providers/vee/camel-vee-provider.c | 7 |
16 files changed, 254 insertions, 96 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 3f7ce6400c..b0b7c0a9e3 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,27 @@ +2000-06-22 Jeffrey Stedfast <fejj@helixcode.com> + + * providers/sendmail/camel-sendmail-provider.c: + * providers/vee/camel-vee-provider.c: + * providers/smtp/camel-smtp-provider.c: + * providers/mbox/camel-mbox-provider.c: + * providers/pop3/camel-pop3-provider.c: + * providers/imap/camel-imap-provider.c: Updated + + * camel-session.c: Moved service_cache hash table into the + providers. + (service_cache_remove): Updated. + (camel_session_get_service): Updated. + + * camel-url.c (camel_url_hash): Took out the hashing of + url->passwd. We don't want this anymore. + + * providers/imap/camel-imap-folder.c (imap_init): Took out + references to 'namespace' + (camel_imap_folder_init): Same + + * providers/imap/camel-imap-folder.h: No more namespace. We are + instead going to use url->path as the namespace. + 2000-06-21 Jeffrey Stedfast <fejj@helixcode.com> * providers/imap/camel-imap-store.c (imap_create): Modified to diff --git a/camel/camel-provider.c b/camel/camel-provider.c index 83a51c3579..9b76fc1766 100644 --- a/camel/camel-provider.c +++ b/camel/camel-provider.c @@ -6,6 +6,7 @@ * Authors: * Bertrand Guiheneuf <bertrand@helixcode.com> * Dan Winship <danw@helixcode.com> + * Jeffrey Stedfast <fejj@helixcode.com> * * Copyright 1999, 2000 Helix Code, Inc. (http://www.helixcode.com) * @@ -118,8 +119,7 @@ camel_provider_init (void) * itself with @session. **/ void -camel_provider_load (CamelSession *session, const char *path, - CamelException *ex) +camel_provider_load (CamelSession *session, const char *path, CamelException *ex) { GModule *module; CamelProvider *(*camel_provider_module_init) (); diff --git a/camel/camel-provider.h b/camel/camel-provider.h index 5f3c3d7c26..58d63a773e 100644 --- a/camel/camel-provider.h +++ b/camel/camel-provider.h @@ -3,8 +3,9 @@ /* * - * Author : + * Authors: * Bertrand Guiheneuf <bertrand@helixcode.com> + * Jeffrey Stedfast <fejj@helixcode.com> * * Copyright 1999, 2000 Helix Code, Inc. (http://www.helixcode.com) * @@ -73,11 +74,13 @@ typedef struct { int flags; GtkType object_types [CAMEL_NUM_PROVIDER_TYPES]; + + GHashTable *service_cache; + } CamelProvider; GHashTable *camel_provider_init (void); -void camel_provider_load (CamelSession *session, const char *path, - CamelException *ex); +void camel_provider_load (CamelSession *session, const char *path, CamelException *ex); /* This is defined by each module, not by camel-provider.c. */ void camel_provider_module_init (CamelSession *session); diff --git a/camel/camel-session.c b/camel/camel-session.c index 0df50c2906..3ee5766143 100644 --- a/camel/camel-session.c +++ b/camel/camel-session.c @@ -6,6 +6,7 @@ * Author: * Bertrand Guiheneuf <bertrand@helixcode.com> * Dan Winship <danw@helixcode.com> + * Jeffrey Stedfast <fejj@helixcode.com> * * Copyright 1999, 2000 Helix Code, Inc. (http://www.helixcode.com) * @@ -41,19 +42,27 @@ static void camel_session_init (CamelSession *session) { session->modules = camel_provider_init (); - session->providers = - g_hash_table_new (g_strcase_hash, g_strcase_equal); - session->service_cache = - g_hash_table_new (camel_url_hash, camel_url_equal); + session->providers = g_hash_table_new (g_strcase_hash, g_strcase_equal); +} + +static gboolean +camel_session_destroy_provider (gpointer key, gpointer value, gpointer user_data) +{ + CamelProvider *prov = (CamelProvider *)value; + + g_hash_table_destroy (prov->service_cache); + + return TRUE; } static void -camel_session_finalise(GtkObject *o) +camel_session_finalise (GtkObject *o) { CamelSession *session = (CamelSession *)o; - g_hash_table_destroy(session->service_cache); - g_hash_table_destroy(session->providers); + g_hash_table_foreach_remove (session->providers, + camel_session_destroy_provider, NULL); + g_hash_table_destroy (session->providers); GTK_OBJECT_CLASS (parent_class)->finalize (o); } @@ -173,8 +182,7 @@ camel_session_list_providers (CamelSession *session, gboolean load) g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL); if (load) { - g_hash_table_foreach (session->modules, ensure_loaded, - session); + g_hash_table_foreach (session->modules, ensure_loaded, session); } list = NULL; @@ -185,7 +193,14 @@ camel_session_list_providers (CamelSession *session, gboolean load) static void service_cache_remove (CamelService *service, CamelSession *session) { - g_hash_table_remove(session->service_cache, service->url); + CamelProvider *provider; + + g_return_if_fail (CAMEL_IS_SESSION (session)); + g_return_if_fail (service != NULL); + g_return_if_fail (service->url != NULL); + + provider = g_hash_table_lookup (session->providers, service->url->protocol); + g_hash_table_remove (provider->service_cache, service->url); } CamelService * @@ -200,17 +215,8 @@ camel_session_get_service (CamelSession *session, const char *url_string, if (!url) return NULL; - /* lookup in cache first */ - printf("looking up service in cache: \"%s\"\n", camel_url_to_string (url, FALSE)); - service = g_hash_table_lookup(session->service_cache, url); - if (service != NULL) { - printf("found!!\n"); - camel_url_free(url); - gtk_object_ref((GtkObject *)service); - return service; - } - printf("not found, creating service\n"); - + /* We need to look up the provider so we can then lookup + the service in the provider's cache */ provider = g_hash_table_lookup (session->providers, url->protocol); if (!provider) { /* See if there's one we can load. */ @@ -236,11 +242,22 @@ camel_session_get_service (CamelSession *session, const char *url_string, camel_url_free (url); return NULL; } + + /* Now look up the service in the provider's cache */ + printf ("looking up service in cache: \"%s\"\n", camel_url_to_string (url, FALSE)); + service = g_hash_table_lookup (provider->service_cache, url); + if (service != NULL) { + printf ("found!!\n"); + camel_url_free (url); + gtk_object_ref (GTK_OBJECT (service)); + return service; + } + printf ("not found, creating service\n"); service = camel_service_new (provider->object_types[type], session, url, ex); if (service) { - g_hash_table_insert(session->service_cache, url, service); - gtk_signal_connect((GtkObject *)service, "destroy", service_cache_remove, session); + g_hash_table_insert (provider->service_cache, url, service); + gtk_signal_connect (GTK_OBJECT (service), "destroy", service_cache_remove, session); } return service; diff --git a/camel/camel-session.h b/camel/camel-session.h index c669a4b223..67dfe729fc 100644 --- a/camel/camel-session.h +++ b/camel/camel-session.h @@ -58,9 +58,7 @@ struct _CamelSession CamelAuthCallback authenticator; - GHashTable *providers, - *modules, - *service_cache; + GHashTable *providers, *modules; }; typedef struct { diff --git a/camel/camel-url.c b/camel/camel-url.c index cb3f5a1408..75b7ac985e 100644 --- a/camel/camel-url.c +++ b/camel/camel-url.c @@ -293,7 +293,7 @@ camel_url_decode (char *part) } static void -add_hash(guint *hash, char *s) +add_hash (guint *hash, char *s) { if (s) *hash ^= g_str_hash(s); @@ -304,13 +304,13 @@ guint camel_url_hash (const void *v) const CamelURL *u = v; guint hash = 0; - add_hash(&hash, u->protocol); - add_hash(&hash, u->user); - add_hash(&hash, u->authmech); - add_hash(&hash, u->passwd); - add_hash(&hash, u->host); - add_hash(&hash, u->path); + add_hash (&hash, u->protocol); + add_hash (&hash, u->user); + add_hash (&hash, u->authmech); + add_hash (&hash, u->host); + add_hash (&hash, u->path); hash ^= u->port; + return hash; } diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index c203e888fa..5b31517f24 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -151,9 +151,8 @@ camel_imap_folder_init (gpointer object, gpointer klass) folder->can_hold_messages = TRUE; folder->can_hold_folders = TRUE; folder->has_summary_capability = TRUE; - folder->has_search_capability = FALSE; /* default - we have to query IMAP to know for sure */ + folder->has_search_capability = FALSE; /* default - we have to query IMAP to know for sure */ - imap_folder->namespace = NULL; imap_folder->summary = NULL; imap_folder->count = -1; } @@ -183,28 +182,15 @@ camel_imap_folder_get_type (void) } CamelFolder * -camel_imap_folder_new (CamelStore *parent, const char *folder_name, CamelException *ex) +camel_imap_folder_new (CamelStore *parent, char *folder_name, CamelException *ex) { CamelFolder *folder = CAMEL_FOLDER (gtk_object_new (camel_imap_folder_get_type (), NULL)); - CF_CLASS (folder)->init (folder, parent, NULL, folder_name, "/", FALSE, ex); + CF_CLASS (folder)->init (folder, parent, NULL, "INBOX", "/", FALSE, ex); return folder; } -void -camel_imap_folder_set_namespace (CamelFolder *folder, gchar *namespace) -{ - CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder); - g_return_if_fail (folder != NULL); - g_return_if_fail (namespace != NULL); - - if (imap_folder->namespace) - g_free (imap_folder->namespace); - - imap_folder->namespace = g_strdup (namespace); -} - static void imap_finalize (GtkObject *object) { @@ -237,8 +223,10 @@ imap_init (CamelFolder *folder, CamelStore *parent_store, CamelFolder *parent_fo const gchar *name, gchar *separator, gboolean path_begins_with_sep, CamelException *ex) { CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder); + CamelStore *store = CAMEL_STORE (parent_store); + CamelURL *url = CAMEL_SERVICE (store)->url; int status; - char *result; + char *result, *folder_path; /* call parent method */ parent_class->init (folder, parent_store, parent_folder, name, separator, path_begins_with_sep, ex); @@ -288,12 +276,15 @@ imap_init (CamelFolder *folder, CamelStore *parent_store, CamelFolder *parent_fo imap_folder->search = NULL; imap_folder->summary = NULL; - if (!imap_folder->namespace) - imap_folder->namespace = g_strdup("mail"); /* SELECT the IMAP mail spool */ + if (url && url->path && strcmp (folder->full_name, "INBOX")) + folder_path = g_strdup_printf ("%s/%s", url->path + 1, folder->full_name); + else + folder_path = g_strdup (folder->full_name); + status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder, - &result, "SELECT %s", folder->full_name); + &result, "SELECT %s", folder_path); if (status != CAMEL_IMAP_OK) { CamelService *service = CAMEL_SERVICE (folder->parent_store); @@ -306,6 +297,7 @@ imap_init (CamelFolder *folder, CamelStore *parent_store, CamelFolder *parent_fo /* parse the mode we opened it in */ } g_free (result); + g_free (folder_path); } static void @@ -420,7 +412,7 @@ imap_exists (CamelFolder *folder, CamelException *ex) /* look to see if any of those subfolders match... */ max = lsub->len; for (i = 0; i < max; i++) { - if (!strcmp(g_ptr_array_index (lsub, i), folder->full_name)) { + if (!strcmp (g_ptr_array_index (lsub, i), folder->full_name)) { exists = TRUE; break; } @@ -479,7 +471,9 @@ static gint imap_get_message_count (CamelFolder *folder, CamelException *ex) { CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder); - gchar *result, *msg_count; + CamelStore *store = CAMEL_STORE (folder->parent_store); + CamelURL *url = CAMEL_SERVICE (store)->url; + gchar *result, *msg_count, *folder_path; gint status; g_return_val_if_fail (folder != NULL, -1); @@ -488,6 +482,11 @@ imap_get_message_count (CamelFolder *folder, CamelException *ex) if (imap_folder->count != -1) return imap_folder->count; + if (url && url->path && strcmp (folder->full_name, "INBOX")) + folder_path = g_strdup_printf ("%s/%s", url->path + 1, folder->full_name); + else + folder_path = g_strdup (folder->full_name); + status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder, &result, "STATUS %s (MESSAGES)", folder->full_name); @@ -499,8 +498,10 @@ imap_get_message_count (CamelFolder *folder, CamelException *ex) status == CAMEL_IMAP_ERR ? result : "Unknown error"); g_free (result); + g_free (folder_path); return -1; } + g_free (folder_path); /* parse out the message count - should come in the form: "* STATUS <folder> (MESSAGES <count>)\r\n" */ if (result && *result == '*') { @@ -523,8 +524,10 @@ imap_get_message_count (CamelFolder *folder, CamelException *ex) static void imap_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex) { + CamelStore *store = CAMEL_STORE (folder->parent_store); + CamelURL *url = CAMEL_SERVICE (store)->url; CamelStreamMem *mem; - gchar *result; + gchar *result, *folder_path; gint status; g_return_if_fail (folder != NULL); @@ -543,10 +546,14 @@ imap_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelExcept } mem->buffer = g_byte_array_append (mem->buffer, g_strdup("\r\n"), 3); + if (url && url->path && strcmp(folder->full_name, "INBOX")) + folder_path = g_strdup_printf ("%s/%s", url->path, folder->full_name); + else + folder_path = g_strdup (folder->full_name); status = camel_imap_command (CAMEL_IMAP_STORE (folder->parent_store), folder, &result, "APPEND %s (\\Seen) {%d}\r\n%s", - folder->full_name, + folder_path, mem->buffer->len, mem->buffer->data); @@ -558,11 +565,12 @@ imap_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelExcept status == CAMEL_IMAP_ERR ? result : "Unknown error"); g_free (result); + g_free (folder_path); return; } - g_free(result); - return; + g_free (result); + g_free (folder_path); } static GPtrArray * @@ -632,22 +640,28 @@ static GPtrArray * imap_get_subfolder_names (CamelFolder *folder, CamelException *ex) { CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder); + CamelStore *store = CAMEL_STORE (folder->parent_store); + CamelURL *url = CAMEL_SERVICE (store)->url; GPtrArray *listing; gint status; - gchar *result, *fname; + gchar *result, *folder_path; g_return_val_if_fail (folder != NULL, g_ptr_array_new()); if (imap_folder->count != -1) return g_ptr_array_new (); - if (!strcmp (folder->full_name, "INBOX")) - fname = imap_folder->namespace; - else - fname = folder->full_name; + if (url && url->path) { + if (!strcmp (folder->full_name, "INBOX")) + folder_path = g_strdup (url->path + 1); + else + folder_path = g_strdup_printf ("%s/%s", url->path + 1, folder->full_name); + } else { + folder_path = g_strdup (folder->full_name); + } status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder, - &result, "LIST \"\" \"%s/*\"", fname); + &result, "LIST \"\" \"%s/*\"", folder_path); if (status != CAMEL_IMAP_OK) { CamelService *service = CAMEL_SERVICE (folder->parent_store); @@ -657,6 +671,7 @@ imap_get_subfolder_names (CamelFolder *folder, CamelException *ex) status == CAMEL_IMAP_ERR ? result : "Unknown error"); g_free (result); + g_free (folder_path); return g_ptr_array_new (); } @@ -688,8 +703,11 @@ imap_get_subfolder_names (CamelFolder *folder, CamelException *ex) } g_free (flags); - f = folder + strlen (fname) + 1; - memmove (folder, f, strlen (f) + 1); + /* chop out the folder prefix */ + if (!strncmp (folder, folder_path, strlen (folder_path))) { + f = folder + strlen (folder_path) + 1; + memmove (folder, f, strlen (f) + 1); + } printf ("adding folder: %s\n", folder); g_ptr_array_add (listing, folder); @@ -700,7 +718,8 @@ imap_get_subfolder_names (CamelFolder *folder, CamelException *ex) ptr++; } } - g_free(result); + g_free (result); + g_free (folder_path); return listing; } diff --git a/camel/providers/imap/camel-imap-folder.h b/camel/providers/imap/camel-imap-folder.h index bb27040d61..17f6d505d2 100644 --- a/camel/providers/imap/camel-imap-folder.h +++ b/camel/providers/imap/camel-imap-folder.h @@ -47,7 +47,6 @@ typedef struct { CamelFolderSearch *search; /* used to run searches */ GPtrArray *summary; - gchar *namespace; gint count; } CamelImapFolder; @@ -61,8 +60,7 @@ typedef struct { /* public methods */ -CamelFolder *camel_imap_folder_new (CamelStore *parent, - const char *folder_name, +CamelFolder *camel_imap_folder_new (CamelStore *parent, char *folder_name, CamelException *ex); void camel_imap_folder_set_namespace (CamelFolder *folder, gchar *namespace); diff --git a/camel/providers/imap/camel-imap-provider.c b/camel/providers/imap/camel-imap-provider.c index 0dbfd3f50c..b9d8c74847 100644 --- a/camel/providers/imap/camel-imap-provider.c +++ b/camel/providers/imap/camel-imap-provider.c @@ -27,6 +27,12 @@ #include "camel-imap-store.h" #include "camel-provider.h" #include "camel-session.h" +#include "camel-url.h" + +static void add_hash (guint *hash, char *s); +static guint imap_url_hash (gconstpointer key); +static gint check_equal (char *s1, char *s2); +static gint imap_url_equal (gconstpointer a, gconstpointer b); static CamelProvider imap_provider = { "imap", @@ -38,7 +44,9 @@ static CamelProvider imap_provider = { 0, - { 0, 0 } + { 0, 0 }, + + NULL }; void @@ -47,7 +55,55 @@ camel_provider_module_init (CamelSession *session) imap_provider.object_types[CAMEL_PROVIDER_STORE] = camel_imap_store_get_type(); + imap_provider.service_cache = g_hash_table_new (imap_url_hash, imap_url_equal); + camel_session_register_provider (session, &imap_provider); } +static void +add_hash (guint *hash, char *s) +{ + if (s) + *hash ^= g_str_hash(s); +} + +static guint +imap_url_hash (gconstpointer key) +{ + const CamelURL *u = (CamelURL *)key; + guint hash = 0; + add_hash (&hash, u->user); + add_hash (&hash, u->authmech); + add_hash (&hash, u->host); + hash ^= u->port; + + return hash; +} + +static gint +check_equal (char *s1, char *s2) +{ + if (s1 == NULL) { + if (s2 == NULL) + return TRUE; + else + return FALSE; + } + + if (s2 == NULL) + return FALSE; + + return strcmp (s1, s2) == 0; +} + +static gint +imap_url_equal (gconstpointer a, gconstpointer b) +{ + const CamelURL *u1 = a, *u2 = b; + + return check_equal (u1->user, u2->user) + && check_equal (u1->authmech, u2->authmech) + && check_equal (u1->host, u2->host) + && u1->port == u2->port; +} diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index 0c8dc87a9b..c3416533f4 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -340,10 +340,11 @@ imap_create (CamelFolder *folder, CamelException *ex) return TRUE; /* create the directory for the subfolder */ - if (url && url->path) - folder_path = g_strdup_printf ("%s/%s", url->path, folder->full_name); + if (url && url->path && strcmp (folder->full_name, "INBOX")) + folder_path = g_strdup_printf ("%s/%s", url->path + 1, folder->full_name); else folder_path = g_strdup (folder->full_name); + status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), NULL, &result, "CREATE %s", folder_path); @@ -368,11 +369,13 @@ static CamelFolder * get_folder (CamelStore *store, const char *folder_name, gboolean create, CamelException *ex) { CamelFolder *new_folder; + char *folder_path; g_return_val_if_fail (store != NULL, NULL); g_return_val_if_fail (folder_name != NULL, NULL); - - new_folder = camel_imap_folder_new (store, folder_name, ex); + + folder_path = g_strdup (folder_name); + new_folder = camel_imap_folder_new (store, folder_path, ex); if (!imap_create (new_folder, ex)) { /* we should set an exception */ @@ -431,6 +434,7 @@ camel_imap_status (char *cmdid, char *respbuf) gint camel_imap_command (CamelImapStore *store, CamelFolder *folder, char **ret, char *fmt, ...) { + CamelURL *url = CAMEL_SERVICE (store)->url; gchar *cmdbuf, *respbuf; gchar *cmdid; va_list ap; @@ -439,10 +443,16 @@ camel_imap_command (CamelImapStore *store, CamelFolder *folder, char **ret, char if (folder && store->current_folder != folder && strncmp (fmt, "STATUS", 6) && strncmp (fmt, "CREATE", 5) && strcmp (fmt, "CAPABILITY")) { /* We need to select the correct mailbox first */ - char *r; + char *r, *folder_path; int s; - s = camel_imap_command_extended (store, folder, &r, "SELECT %s", folder->full_name); + if (url && url->path && strcmp (folder->full_name, "INBOX")) + folder_path = g_strdup_printf ("%s/%s", url->path + 1, folder->full_name); + else + folder_path = g_strdup (folder->full_name); + + s = camel_imap_command_extended (store, folder, &r, "SELECT %s", folder_path); + g_free (folder_path); if (s != CAMEL_IMAP_OK) { *ret = r; return s; @@ -482,7 +492,7 @@ camel_imap_command (CamelImapStore *store, CamelFolder *folder, char **ret, char g_free (cmdbuf); g_free (cmdid); if (*ret) - *ret = g_strdup (strerror(errno)); + *ret = g_strdup (strerror (errno)); return CAMEL_IMAP_FAIL; } g_free (cmdbuf); @@ -491,11 +501,11 @@ camel_imap_command (CamelImapStore *store, CamelFolder *folder, char **ret, char respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (store->istream)); if (respbuf == NULL) { if (*ret) - *ret = g_strdup (strerror(errno)); + *ret = g_strdup (strerror (errno)); return CAMEL_IMAP_FAIL; } - fprintf(stderr, "received: %s\n", respbuf ? respbuf : "(null)"); + fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"); fflush (stderr); status = camel_imap_status (cmdid, respbuf); @@ -542,6 +552,7 @@ camel_imap_command (CamelImapStore *store, CamelFolder *folder, char **ret, char gint camel_imap_command_extended (CamelImapStore *store, CamelFolder *folder, char **ret, char *fmt, ...) { + CamelURL *url = CAMEL_SERVICE (CAMEL_STORE (store))->url; CamelStreamBuffer *stream = CAMEL_STREAM_BUFFER (store->istream); GPtrArray *data; gchar *cmdid, *cmdbuf, *respbuf; @@ -551,10 +562,16 @@ camel_imap_command_extended (CamelImapStore *store, CamelFolder *folder, char ** if (folder && store->current_folder != folder && strncmp (fmt, "SELECT", 6) && strncmp (fmt, "STATUS", 6) && strncmp (fmt, "CREATE", 5) && strcmp (fmt, "CAPABILITY")) { /* We need to select the correct mailbox first */ - char *r; + char *r, *folder_path; int s; - s = camel_imap_command_extended (store, folder, &r, "SELECT %s", folder->full_name); + if (url && url->path && strcmp (folder->full_name, "INBOX")) + folder_path = g_strdup_printf ("%s/%s", url->path + 1, folder->full_name); + else + folder_path = g_strdup (folder->full_name); + + s = camel_imap_command_extended (store, folder, &r, "SELECT %s", folder_path); + g_free (folder_path); if (s != CAMEL_IMAP_OK) { *ret = r; return s; @@ -587,11 +604,11 @@ camel_imap_command_extended (CamelImapStore *store, CamelFolder *folder, char ** respbuf = camel_stream_buffer_read_line (stream); if (!respbuf || !strncmp(respbuf, cmdid, strlen(cmdid)) ) { /* IMAP's last response starts with our command id */ - fprintf(stderr, "received: %s\n", respbuf ? respbuf : "(null)"); + fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"); break; } - fprintf(stderr, "received: %s\n", respbuf); + fprintf (stderr, "received: %s\n", respbuf); g_ptr_array_add (data, respbuf); } diff --git a/camel/providers/imap/camel-imap-store.h b/camel/providers/imap/camel-imap-store.h index c0687b9429..c8fa92eb89 100644 --- a/camel/providers/imap/camel-imap-store.h +++ b/camel/providers/imap/camel-imap-store.h @@ -46,6 +46,7 @@ typedef struct { CamelFolder *current_folder; CamelStream *istream, *ostream; + guint32 command; } CamelImapStore; diff --git a/camel/providers/mbox/camel-mbox-provider.c b/camel/providers/mbox/camel-mbox-provider.c index ade04aa20d..de206f18ef 100644 --- a/camel/providers/mbox/camel-mbox-provider.c +++ b/camel/providers/mbox/camel-mbox-provider.c @@ -27,6 +27,7 @@ #include "camel-mbox-store.h" #include "camel-provider.h" #include "camel-session.h" +#include "camel-url.h" static CamelProvider mbox_provider = { "mbox", @@ -39,7 +40,9 @@ static CamelProvider mbox_provider = { 0, - { 0, 0 } + { 0, 0 }, + + NULL }; void @@ -48,5 +51,7 @@ camel_provider_module_init (CamelSession *session) mbox_provider.object_types[CAMEL_PROVIDER_STORE] = camel_mbox_store_get_type(); + mbox_provider.service_cache = g_hash_table_new (camel_url_hash, camel_url_equal); + camel_session_register_provider (session, &mbox_provider); } diff --git a/camel/providers/pop3/camel-pop3-provider.c b/camel/providers/pop3/camel-pop3-provider.c index 40514ad60a..4ccb06058f 100644 --- a/camel/providers/pop3/camel-pop3-provider.c +++ b/camel/providers/pop3/camel-pop3-provider.c @@ -27,6 +27,7 @@ #include "camel-pop3-store.h" #include "camel-provider.h" #include "camel-session.h" +#include "camel-url.h" static CamelProvider pop3_provider = { "pop", @@ -40,7 +41,9 @@ static CamelProvider pop3_provider = { CAMEL_PROVIDER_IS_REMOTE, - { 0, 0 } + { 0, 0 }, + + NULL }; void @@ -49,5 +52,7 @@ camel_provider_module_init (CamelSession *session) pop3_provider.object_types[CAMEL_PROVIDER_STORE] = camel_pop3_store_get_type(); + pop3_provider.service_cache = g_hash_table_new (camel_url_hash, camel_url_equal); + camel_session_register_provider (session, &pop3_provider); } diff --git a/camel/providers/sendmail/camel-sendmail-provider.c b/camel/providers/sendmail/camel-sendmail-provider.c index dce20e4041..3b0b35dd72 100644 --- a/camel/providers/sendmail/camel-sendmail-provider.c +++ b/camel/providers/sendmail/camel-sendmail-provider.c @@ -27,6 +27,7 @@ #include "camel-provider.h" #include "camel-sendmail-transport.h" #include "camel-session.h" +#include "camel-url.h" static CamelProvider sendmail_provider = { "sendmail", @@ -39,7 +40,9 @@ static CamelProvider sendmail_provider = { 0, - { 0, 0 } + { 0, 0 }, + + NULL }; void @@ -48,6 +51,8 @@ camel_provider_module_init (CamelSession *session) sendmail_provider.object_types[CAMEL_PROVIDER_TRANSPORT] = camel_sendmail_transport_get_type(); + sendmail_provider.service_cache = g_hash_table_new (camel_url_hash, camel_url_equal); + camel_session_register_provider (session, &sendmail_provider); } diff --git a/camel/providers/smtp/camel-smtp-provider.c b/camel/providers/smtp/camel-smtp-provider.c index 9e6f571498..1d18e445cc 100644 --- a/camel/providers/smtp/camel-smtp-provider.c +++ b/camel/providers/smtp/camel-smtp-provider.c @@ -27,6 +27,7 @@ #include "camel-smtp-transport.h" #include "camel-provider.h" #include "camel-session.h" +#include "camel-url.h" static CamelProvider smtp_provider = { "smtp", @@ -38,7 +39,9 @@ static CamelProvider smtp_provider = { 0, - { 0, 0 } + { 0, 0 }, + + NULL }; void @@ -47,6 +50,8 @@ camel_provider_module_init (CamelSession *session) smtp_provider.object_types[CAMEL_PROVIDER_TRANSPORT] = camel_smtp_transport_get_type(); + smtp_provider.service_cache = g_hash_table_new (camel_url_hash, camel_url_equal); + camel_session_register_provider (session, &smtp_provider); } diff --git a/camel/providers/vee/camel-vee-provider.c b/camel/providers/vee/camel-vee-provider.c index 3d0063b55c..e36e7fcff1 100644 --- a/camel/providers/vee/camel-vee-provider.c +++ b/camel/providers/vee/camel-vee-provider.c @@ -23,6 +23,7 @@ #include "camel-vee-store.h" #include "camel-provider.h" #include "camel-session.h" +#include "camel-url.h" static CamelProvider vee_provider = { "vfolder", @@ -34,7 +35,9 @@ static CamelProvider vee_provider = { 0, - { 0, 0 } + { 0, 0 }, + + NULL }; void @@ -43,5 +46,7 @@ camel_provider_module_init (CamelSession *session) vee_provider.object_types[CAMEL_PROVIDER_STORE] = camel_vee_store_get_type(); + vee_provider.service_cache = g_hash_table_new (camel_url_hash, camel_url_equal); + camel_session_register_provider (session, &vee_provider); } |