diff options
Diffstat (limited to 'camel/providers/imap')
-rw-r--r-- | camel/providers/imap/camel-imap-command.c | 11 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-store.c | 25 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-store.h | 2 |
3 files changed, 28 insertions, 10 deletions
diff --git a/camel/providers/imap/camel-imap-command.c b/camel/providers/imap/camel-imap-command.c index ea1f3aaccf..7a6045d16d 100644 --- a/camel/providers/imap/camel-imap-command.c +++ b/camel/providers/imap/camel-imap-command.c @@ -170,6 +170,15 @@ imap_read_response (CamelImapStore *store, CamelException *ex) g_free (respbuf); goto next; } + } else { + p = imap_next_word (respbuf); + if (!g_strncasecmp (p, "BYE", 3)) { + /* connection was lost, no more data to fetch */ + store->connected = FALSE; + g_free (respbuf); + respbuf = NULL; + break; + } } g_ptr_array_add (response->untagged, respbuf); @@ -187,7 +196,7 @@ imap_read_response (CamelImapStore *store, CamelException *ex) if (expunged) g_array_free (expunged, TRUE); - if (camel_exception_is_set (ex)) { + if (!respbuf || camel_exception_is_set (ex)) { camel_imap_response_free (response); return NULL; } diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index a561cab96d..6ad48107b1 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -108,11 +108,13 @@ camel_imap_store_init (gpointer object, gpointer klass) CAMEL_SERVICE_URL_NEED_HOST | CAMEL_SERVICE_URL_ALLOW_PATH | CAMEL_SERVICE_URL_ALLOW_AUTH); - + remote_store->default_port = 143; imap_store->dir_sep = NULL; imap_store->current_folder = NULL; + + imap_store->connected = FALSE; } CamelType @@ -259,6 +261,9 @@ imap_connect (CamelService *service, CamelException *ex) } } + /* At this point we know we're connected... */ + store->connected = TRUE; + /* Now lets find out the IMAP capabilities */ response = camel_imap_command (store, NULL, ex, "CAPABILITY"); if (!response) @@ -324,11 +329,13 @@ imap_disconnect (CamelService *service, CamelException *ex) { CamelImapStore *store = CAMEL_IMAP_STORE (service); CamelImapResponse *response; - - /* send the logout command */ - response = camel_imap_command (store, NULL, ex, "LOGOUT"); - camel_imap_response_free (response); - + + if (store->connected) { + /* send the logout command */ + response = camel_imap_command (store, NULL, ex, "LOGOUT"); + camel_imap_response_free (response); + } + g_free (store->dir_sep); store->dir_sep = NULL; @@ -416,7 +423,7 @@ static CamelFolder * get_folder (CamelStore *store, const char *folder_name, gboolean create, CamelException *ex) { CamelImapStore *imap_store = CAMEL_IMAP_STORE (store); - CamelFolder *new_folder; + CamelFolder *new_folder = NULL; char *folder_path, *summary_file, *p; gboolean selectable; @@ -554,8 +561,8 @@ get_folder_info (CamelStore *store, const char *top, gboolean fast, if (!topfi) { camel_exception_clear (ex); topfi = g_new0 (CamelFolderInfo, 1); - fi->full_name = g_strdup (namespace); - fi->name = g_strdup (namespace); + topfi->full_name = g_strdup (namespace); + topfi->name = g_strdup (namespace); } response = camel_imap_command (imap_store, NULL, ex, diff --git a/camel/providers/imap/camel-imap-store.h b/camel/providers/imap/camel-imap-store.h index a211457dbe..3c492c5aa3 100644 --- a/camel/providers/imap/camel-imap-store.h +++ b/camel/providers/imap/camel-imap-store.h @@ -57,6 +57,8 @@ typedef struct { gboolean has_status_capability; gchar *dir_sep, *storage_path; + + gboolean connected; } CamelImapStore; |