diff options
author | Jeffrey Stedfast <fejj@helixcode.com> | 2000-06-28 06:44:19 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2000-06-28 06:44:19 +0800 |
commit | 8b6fb870d7c9015ead885c4bbc8d6bc272d3f88b (patch) | |
tree | d4c126134503398810c04cebd975ef07ea358653 | |
parent | f704f45bbf6561376cb41236d3fa205689718c58 (diff) | |
download | gsoc2013-evolution-8b6fb870d7c9015ead885c4bbc8d6bc272d3f88b.tar gsoc2013-evolution-8b6fb870d7c9015ead885c4bbc8d6bc272d3f88b.tar.gz gsoc2013-evolution-8b6fb870d7c9015ead885c4bbc8d6bc272d3f88b.tar.bz2 gsoc2013-evolution-8b6fb870d7c9015ead885c4bbc8d6bc272d3f88b.tar.lz gsoc2013-evolution-8b6fb870d7c9015ead885c4bbc8d6bc272d3f88b.tar.xz gsoc2013-evolution-8b6fb870d7c9015ead885c4bbc8d6bc272d3f88b.tar.zst gsoc2013-evolution-8b6fb870d7c9015ead885c4bbc8d6bc272d3f88b.zip |
Move the CAPABILITY command here so we don't have to keep checking each
2000-06-27 Jeffrey Stedfast <fejj@helixcode.com>
* providers/imap/camel-imap-store.c (imap_connect): Move the
CAPABILITY command here so we don't have to keep checking
each time we open a folder.
(camel_imap_command_extended): If we are doing an EXAMINE,
don't bother doing a SELECT first.
* providers/imap/camel-imap-folder.c (imap_init): Update so
folder->has_search_capability depends on the parent IMAP store
(since this is really dependant on the IMAP implementation and
not the folder)
svn path=/trunk/; revision=3767
-rw-r--r-- | camel/ChangeLog | 13 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-folder.c | 32 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-store.c | 35 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-store.h | 1 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-stream.c | 43 |
5 files changed, 65 insertions, 59 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index e8f380361c..d6471af21b 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,16 @@ +2000-06-27 Jeffrey Stedfast <fejj@helixcode.com> + + * providers/imap/camel-imap-store.c (imap_connect): Move the + CAPABILITY command here so we don't have to keep checking + each time we open a folder. + (camel_imap_command_extended): If we are doing an EXAMINE, + don't bother doing a SELECT first. + + * providers/imap/camel-imap-folder.c (imap_init): Update so + folder->has_search_capability depends on the parent IMAP store + (since this is really dependant on the IMAP implementation and + not the folder) + 2000-06-27 Christopher James Lahey <clahey@helixcode.com> * providers/smtp/camel-smtp-transport.c: Don't close the filter diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index 51bab59eb4..6ab0fff9df 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -1,5 +1,5 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; fill-column: 160 -*- */ -/* camel-imap-folder.c : Abstract class for an email folder */ +/* camel-imap-folder.c: Abstract class for an email folder */ /* * Authors: Jeffrey Stedfast <fejj@helixcode.com> @@ -198,7 +198,7 @@ imap_finalize (GtkObject *object) CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (object); CamelMessageInfo *info; gint i, max; - + GTK_OBJECT_CLASS (parent_class)->finalize (object); g_return_if_fail (imap_folder->summary != NULL); @@ -238,30 +238,7 @@ imap_init (CamelFolder *folder, CamelStore *parent_store, CamelFolder *parent_fo folder->can_hold_messages = TRUE; folder->can_hold_folders = TRUE; folder->has_summary_capability = TRUE; - - /* now lets find out if we can do searches... */ - status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder, - &result, "CAPABILITY"); - - /* ugh, I forgot that CAPABILITY doesn't have a response code */ - if (status != CAMEL_IMAP_OK) { - CamelService *service = CAMEL_SERVICE (folder->parent_store); - - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - "Could not get capabilities on IMAP server %s: %s.", - service->url->host, - status == CAMEL_IMAP_ERR ? result : - "Unknown error"); - } - - if (strstrcase (result, "SEARCH")) - folder->has_search_capability = TRUE; - else - folder->has_search_capability = FALSE; - - g_free (result); - - fprintf (stderr, "IMAP provider does%shave SEARCH support\n", folder->has_search_capability ? " " : "n't "); + folder->has_search_capability = CAMEL_IMAP_STORE (store)->has_search_capability; /* some IMAP daemons support user-flags * * I would not, however, rely on this feature as * @@ -508,7 +485,8 @@ imap_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelExcept folder_path = g_strdup_printf ("%s/%s", url->path, folder->full_name); else folder_path = g_strdup (folder->full_name); - + + /* FIXME: len isn't really correct I don't think, we need to filter and possibly other things */ status = camel_imap_command (CAMEL_IMAP_STORE (folder->parent_store), folder, &result, "APPEND %s (\\Seen) {%d}\r\n%s", diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index f178ad8390..61f9171b09 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -45,6 +45,7 @@ #include "camel-stream-buffer.h" #include "camel-stream-fs.h" #include "camel-url.h" +#include "string-utils.h" /* Specified in RFC 2060 */ #define IMAP_PORT 143 @@ -209,7 +210,7 @@ imap_connect (CamelService *service, CamelException *ex) struct hostent *h; struct sockaddr_in sin; gint fd, status; - gchar *buf, *msg; + gchar *buf, *msg, *result; CamelImapStore *store = CAMEL_IMAP_STORE (service); @@ -268,9 +269,9 @@ imap_connect (CamelService *service, CamelException *ex) } g_free (buf); - status = camel_imap_command(store, NULL, &msg, "LOGIN \"%s\" \"%s\"", - service->url->user, - service->url->passwd); + status = camel_imap_command (store, NULL, &msg, "LOGIN \"%s\" \"%s\"", + service->url->user, + service->url->passwd); if (status != CAMEL_IMAP_OK) { camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, @@ -285,6 +286,28 @@ imap_connect (CamelService *service, CamelException *ex) g_message ("IMAP Service sucessfully authenticated user %s", service->url->user); } + /* Now lets find out the IMAP capabilities */ + status = camel_imap_command_extended (store, NULL, &result, "CAPABILITY"); + + if (status != CAMEL_IMAP_OK) { + CamelService *service = CAMEL_SERVICE (store); + + camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, + "Could not get capabilities on IMAP server %s: %s.", + service->url->host, + status == CAMEL_IMAP_ERR ? result : + "Unknown error"); + } + + if (strstrcase (result, "SEARCH")) + store->has_search_capability = TRUE; + else + store->has_search_capability = FALSE; + + g_free (result); + + fprintf (stderr, "IMAP provider does%shave SEARCH support\n", store->has_search_capability ? " " : "n't "); + service_class->connect (service, ex); return TRUE; } @@ -330,6 +353,7 @@ imap_folder_exists (CamelFolder *folder) else folder_path = g_strdup (folder->full_name); + printf ("doing an EXAMINE...\n"); status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), NULL, &result, "EXAMINE %s", folder_path); @@ -590,7 +614,8 @@ camel_imap_command_extended (CamelImapStore *store, CamelFolder *folder, char ** gint status = CAMEL_IMAP_OK; if (folder && store->current_folder != folder && strncmp (fmt, "SELECT", 6) && - strncmp (fmt, "STATUS", 6) && strncmp (fmt, "CREATE", 5) && strcmp (fmt, "CAPABILITY")) { + strncmp (fmt, "EXAMINE", 7) && strncmp (fmt, "STATUS", 6) && + strncmp (fmt, "CREATE", 6) && strcmp (fmt, "CAPABILITY")) { /* We need to select the correct mailbox first */ char *r, *folder_path; int s; diff --git a/camel/providers/imap/camel-imap-store.h b/camel/providers/imap/camel-imap-store.h index c8fa92eb89..d0ec78bf44 100644 --- a/camel/providers/imap/camel-imap-store.h +++ b/camel/providers/imap/camel-imap-store.h @@ -49,6 +49,7 @@ typedef struct { guint32 command; + gboolean has_search_capability; } CamelImapStore; diff --git a/camel/providers/imap/camel-imap-stream.c b/camel/providers/imap/camel-imap-stream.c index 43b1afb61a..74d46eb95c 100644 --- a/camel/providers/imap/camel-imap-stream.c +++ b/camel/providers/imap/camel-imap-stream.c @@ -95,10 +95,10 @@ camel_imap_stream_new (CamelImapFolder *folder, char *command) imap_stream = gtk_type_new (camel_imap_stream_get_type ()); - imap_stream->folder = folder; - gtk_object_ref(GTK_OBJECT (imap_stream->folder)); + imap_stream->folder = folder; + gtk_object_ref (GTK_OBJECT (imap_stream->folder)); - imap_stream->command = g_strdup(command); + imap_stream->command = g_strdup (command); return CAMEL_STREAM (imap_stream); } @@ -108,11 +108,11 @@ finalize (GtkObject *object) { CamelImapStream *imap_stream = CAMEL_IMAP_STREAM (object); - g_free(imap_stream->cache); - g_free(imap_stream->command); + g_free (imap_stream->cache); + g_free (imap_stream->command); if (imap_stream->folder) - gtk_object_unref(GTK_OBJECT (imap_stream->folder)); + gtk_object_unref (GTK_OBJECT (imap_stream->folder)); GTK_OBJECT_CLASS (parent_class)->finalize (object); } @@ -130,30 +130,30 @@ stream_read (CamelStream *stream, char *buffer, size_t n) CamelFolder *folder = CAMEL_FOLDER (imap_stream->folder); gint status; - status = camel_imap_command_extended(CAMEL_IMAP_STORE (folder->parent_store), - CAMEL_FOLDER (imap_stream->folder), - &imap_stream->cache, "%s", - imap_stream->command); - + status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), + CAMEL_FOLDER (imap_stream->folder), + &imap_stream->cache, "%s", + imap_stream->command); + if (status != CAMEL_IMAP_OK) { /* we got an error, dump this stuff */ - g_free(imap_stream->cache); + g_free (imap_stream->cache); imap_stream->cache = NULL; return -1; } /* we don't need the folder anymore... */ - gtk_object_unref(GTK_OBJECT (imap_stream->folder)); + gtk_object_unref (GTK_OBJECT (imap_stream->folder)); imap_stream->cache_ptr = imap_stream->cache; } /* we've already read this stream, so return whats in the cache */ - nread = MIN (n, strlen(imap_stream->cache_ptr)); + nread = MIN (n, strlen (imap_stream->cache_ptr)); if (nread > 0) { - memcpy(buffer, imap_stream->cache_ptr, nread); + memcpy (buffer, imap_stream->cache_ptr, nread); imap_stream->cache_ptr += nread; } else { nread = -1; @@ -177,16 +177,5 @@ stream_eos (CamelStream *stream) { CamelImapStream *imap_stream = CAMEL_IMAP_STREAM (stream); - return (imap_stream->cache_ptr && strlen(imap_stream->cache_ptr)); + return (imap_stream->cache_ptr && strlen (imap_stream->cache_ptr)); } - - - - - - - - - - - |