From cce201b06e98e85dba8a1bb3a2848d7537c0aeda Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Wed, 20 Oct 2004 17:45:29 +0000 Subject: Removed an already-fixed FIXME comment. (imap4_summary_fetch_flags): Same. 2004-10-19 Jeffrey Stedfast * providers/imap4/camel-imap4-summary.c (imap4_summary_fetch_all): Removed an already-fixed FIXME comment. (imap4_summary_fetch_flags): Same. * providers/imap4/camel-imap4-folder.c (imap4_get_path_delim): Removed. Use camel_imap4_get_path_delim() instead. (camel_imap4_folder_new): Updated. (imap4_sync): If we aren't online, we're done. nothing to do. (imap4_refresh_info): Same. (imap4_append_message): Same but set an exception. (imap4_transfer_messages_to): Same. * providers/imap4/camel-imap4-utils.c (camel_imap4_get_path_delim): Moved here from camel-imap4-store.c * providers/imap4/camel-imap4-store.c (imap4_try_authenticate): Change the service string for the sasl mechanism to"imap" rather than "imap4". (imap4_get_path_delim): Removed. (imap4_create_folder): Updated. (imap4_folder_utf7_name): Same. svn path=/trunk/; revision=27651 --- camel/ChangeLog | 20 ++++--- camel/providers/imap4/camel-imap4-folder.c | 86 ++++++++++++------------------ camel/providers/imap4/camel-imap4-store.c | 57 +------------------- camel/providers/imap4/camel-imap4-utils.c | 52 ++++++++++++++++++ camel/providers/imap4/camel-imap4-utils.h | 2 + 5 files changed, 102 insertions(+), 115 deletions(-) diff --git a/camel/ChangeLog b/camel/ChangeLog index f070247ef7..44cdd79de5 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -4,11 +4,23 @@ Removed an already-fixed FIXME comment. (imap4_summary_fetch_flags): Same. -2004-10-18 Jeffrey Stedfast + * providers/imap4/camel-imap4-folder.c (imap4_get_path_delim): + Removed. Use camel_imap4_get_path_delim() instead. + (camel_imap4_folder_new): Updated. + (imap4_sync): If we aren't online, we're done. nothing to do. + (imap4_refresh_info): Same. + (imap4_append_message): Same but set an exception. + (imap4_transfer_messages_to): Same. + + * providers/imap4/camel-imap4-utils.c + (camel_imap4_get_path_delim): Moved here from camel-imap4-store.c * providers/imap4/camel-imap4-store.c (imap4_try_authenticate): Change the service string for the sasl mechanism to"imap" rather than "imap4". + (imap4_get_path_delim): Removed. + (imap4_create_folder): Updated. + (imap4_folder_utf7_name): Same. 2004-10-13 Not Zed @@ -107,12 +119,6 @@ 2004-10-01 Jeffrey Stedfast - * providers/imap4/camel-imap4-folder.c (imap4_sync): If we aren't - online, we're done. nothing to do. - (imap4_refresh_info): Same. - (imap4_append_message): Same but set an exception. - (imap4_transfer_messages_to): Same. - * camel-service.c (camel_getaddrinfo): Avoid assigning a value to the member of a const struct (which newer gcc's apparently break over) by casting to non-const. diff --git a/camel/providers/imap4/camel-imap4-folder.c b/camel/providers/imap4/camel-imap4-folder.c index 9fc12fea2b..f0f8793933 100644 --- a/camel/providers/imap4/camel-imap4-folder.c +++ b/camel/providers/imap4/camel-imap4-folder.c @@ -196,56 +196,6 @@ imap_store_build_filename (void *store, const char *full_name) return path; } -static char -imap4_get_path_delim (CamelIMAP4Engine *engine, const char *full_name) -{ - CamelIMAP4Namespace *namespace; - const char *slash; - size_t len; - char *top; - - if ((slash = strchr (full_name, '/'))) - len = (slash - full_name); - else - len = strlen (full_name); - - top = g_alloca (len + 1); - memcpy (top, full_name, len); - top[len] = '\0'; - - if (!g_ascii_strcasecmp (top, "INBOX")) - top = "INBOX"; - - retry: - namespace = engine->namespaces.personal; - while (namespace != NULL) { - if (!strcmp (namespace->path, top)) - return namespace->sep; - namespace = namespace->next; - } - - namespace = engine->namespaces.other; - while (namespace != NULL) { - if (!strcmp (namespace->path, top)) - return namespace->sep; - namespace = namespace->next; - } - - namespace = engine->namespaces.shared; - while (namespace != NULL) { - if (!strcmp (namespace->path, top)) - return namespace->sep; - namespace = namespace->next; - } - - if (top[0] != '\0') { - /* look for a default namespace? */ - top[0] = '\0'; - goto retry; - } - - return '/'; -} CamelFolder * camel_imap4_folder_new (CamelStore *store, const char *full_name, CamelException *ex) @@ -267,7 +217,7 @@ camel_imap4_folder_new (CamelStore *store, const char *full_name, CamelException utf7_name = g_alloca (strlen (full_name) + 1); strcpy (utf7_name, full_name); - sep = imap4_get_path_delim (((CamelIMAP4Store *) store)->engine, full_name); + sep = camel_imap4_get_path_delim (((CamelIMAP4Store *) store)->engine, full_name); if (sep != '/') { p = utf7_name; while (*p != '\0') { @@ -445,6 +395,7 @@ static void imap4_sync (CamelFolder *folder, gboolean expunge, CamelException *ex) { CamelIMAP4Engine *engine = ((CamelIMAP4Store *) folder->parent_store)->engine; + CamelSession *session = ((CamelService *) folder->parent_store)->session; CamelIMAP4MessageInfo *iinfo; CamelMessageInfo *info; CamelIMAP4Command *ic; @@ -453,6 +404,9 @@ imap4_sync (CamelFolder *folder, gboolean expunge, CamelException *ex) int id, max, i; int retval; + if (!camel_session_is_online (!session)) + return; + CAMEL_SERVICE_LOCK (folder->parent_store, connect_lock); /* gather a list of changes to sync to the server */ @@ -532,10 +486,14 @@ static void imap4_refresh_info (CamelFolder *folder, CamelException *ex) { CamelIMAP4Engine *engine = ((CamelIMAP4Store *) folder->parent_store)->engine; + CamelSession *session = ((CamelService *) folder->parent_store)->session; CamelFolder *selected = (CamelFolder *) engine->folder; CamelIMAP4Command *ic; int id; + if (!camel_session_is_online (session)) + return; + CAMEL_SERVICE_LOCK (folder->parent_store, connect_lock); if (folder != selected) { @@ -672,6 +630,10 @@ imap4_get_message (CamelFolder *folder, const char *uid, CamelException *ex) CAMEL_SERVICE_LOCK (folder->parent_store, connect_lock); + /* FIXME: try to pull the message from the cache first. if + * that fails and we are offline, we're done. else do the + * following code */ + ic = camel_imap4_engine_queue (engine, folder, "UID FETCH %s BODY.PEEK[]\r\n", uid); camel_imap4_command_register_untagged (ic, "FETCH", untagged_fetch); ic->user_data = stream = camel_stream_mem_new (); @@ -723,9 +685,10 @@ static char *tm_months[] = { static void imap4_append_message (CamelFolder *folder, CamelMimeMessage *message, - const CamelMessageInfo *info, char **appended_uid, CamelException *ex) + const CamelMessageInfo *info, char **appended_uid, CamelException *ex) { CamelIMAP4Engine *engine = ((CamelIMAP4Store *) folder->parent_store)->engine; + CamelSession *session = ((CamelService *) folder->parent_store)->session; CamelIMAP4Summary *summary = (CamelIMAP4Summary *) folder->summary; CamelIMAP4RespCode *resp; CamelIMAP4Command *ic; @@ -736,6 +699,11 @@ imap4_append_message (CamelFolder *folder, CamelMimeMessage *message, struct tm tm; int id, i; + if (!camel_session_is_online (session)) { + camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot append messages to IMAP folders in offline mode.")); + return; + } + CAMEL_SERVICE_LOCK (folder->parent_store, connect_lock); /* construct the option flags list */ @@ -884,15 +852,27 @@ info_uid_sort (const CamelMessageInfo **info0, const CamelMessageInfo **info1) static void imap4_transfer_messages_to (CamelFolder *src, GPtrArray *uids, CamelFolder *dest, - GPtrArray **transferred_uids, gboolean move, CamelException *ex) + GPtrArray **transferred_uids, gboolean move, CamelException *ex) { CamelIMAP4Engine *engine = ((CamelIMAP4Store *) src->parent_store)->engine; + CamelSession *session = ((CamelService *) folder->parent_store)->session; int i, j, n, id, dest_namelen; CamelMessageInfo *info; CamelIMAP4Command *ic; GPtrArray *infos; char *set; + if (!camel_session_is_online (session)) { + if (move) + camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, + _("Cannot move messages to or from IMAP folders in offline mode.")); + else + camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, + _("Cannot copy messages to or from IMAP folders in offline mode.")); + + return; + } + infos = g_ptr_array_new (); for (i = 0; i < uids->len; i++) { if (!(info = camel_folder_summary_uid (src->summary, uids->pdata[i]))) diff --git a/camel/providers/imap4/camel-imap4-store.c b/camel/providers/imap4/camel-imap4-store.c index d01efcd388..c643bbf901 100644 --- a/camel/providers/imap4/camel-imap4-store.c +++ b/camel/providers/imap4/camel-imap4-store.c @@ -544,59 +544,6 @@ imap4_query_auth_types (CamelService *service, CamelException *ex) return g_list_prepend (sasl_types, &camel_imap4_password_authtype); } - -static char -imap4_get_path_delim (CamelIMAP4Engine *engine, const char *full_name) -{ - /* FIXME: move this to utils so imap4-folder.c can share */ - CamelIMAP4Namespace *namespace; - const char *slash; - size_t len; - char *top; - - if ((slash = strchr (full_name, '/'))) - len = (slash - full_name); - else - len = strlen (full_name); - - top = g_alloca (len + 1); - memcpy (top, full_name, len); - top[len] = '\0'; - - if (!g_ascii_strcasecmp (top, "INBOX")) - top = "INBOX"; - - retry: - namespace = engine->namespaces.personal; - while (namespace != NULL) { - if (!strcmp (namespace->path, top)) - return namespace->sep; - namespace = namespace->next; - } - - namespace = engine->namespaces.other; - while (namespace != NULL) { - if (!strcmp (namespace->path, top)) - return namespace->sep; - namespace = namespace->next; - } - - namespace = engine->namespaces.shared; - while (namespace != NULL) { - if (!strcmp (namespace->path, top)) - return namespace->sep; - namespace = namespace->next; - } - - if (top[0] != '\0') { - /* look for a default namespace? */ - top[0] = '\0'; - goto retry; - } - - return '/'; -} - static char * imap4_folder_utf7_name (CamelStore *store, const char *folder_name, char wildcard) { @@ -604,7 +551,7 @@ imap4_folder_utf7_name (CamelStore *store, const char *folder_name, char wildcar char sep; int len; - sep = imap4_get_path_delim (((CamelIMAP4Store *) store)->engine, folder_name); + sep = camel_imap4_get_path_delim (((CamelIMAP4Store *) store)->engine, folder_name); if (sep != '/') { p = real_name = g_alloca (strlen (folder_name) + 1); @@ -738,7 +685,7 @@ imap4_create_folder (CamelStore *store, const char *parent_name, const char *fol char sep; int id; - sep = imap4_get_path_delim (engine, parent_name); + sep = camel_imap4_get_path_delim (engine, parent_name); c = folder_name; while (*c != '\0') { diff --git a/camel/providers/imap4/camel-imap4-utils.c b/camel/providers/imap4/camel-imap4-utils.c index 55c6431dc7..1c8dc0c1ef 100644 --- a/camel/providers/imap4/camel-imap4-utils.c +++ b/camel/providers/imap4/camel-imap4-utils.c @@ -75,6 +75,58 @@ camel_imap4_merge_flags (guint32 original, guint32 local, guint32 server) } +char +camel_imap4_get_path_delim (CamelIMAP4Engine *engine, const char *full_name) +{ + CamelIMAP4Namespace *namespace; + const char *slash; + size_t len; + char *top; + + if ((slash = strchr (full_name, '/'))) + len = (slash - full_name); + else + len = strlen (full_name); + + top = g_alloca (len + 1); + memcpy (top, full_name, len); + top[len] = '\0'; + + if (!g_ascii_strcasecmp (top, "INBOX")) + top = "INBOX"; + + retry: + namespace = engine->namespaces.personal; + while (namespace != NULL) { + if (!strcmp (namespace->path, top)) + return namespace->sep; + namespace = namespace->next; + } + + namespace = engine->namespaces.other; + while (namespace != NULL) { + if (!strcmp (namespace->path, top)) + return namespace->sep; + namespace = namespace->next; + } + + namespace = engine->namespaces.shared; + while (namespace != NULL) { + if (!strcmp (namespace->path, top)) + return namespace->sep; + namespace = namespace->next; + } + + if (top[0] != '\0') { + /* look for a default namespace? */ + top[0] = '\0'; + goto retry; + } + + return '/'; +} + + struct _uidset_range { struct _uidset_range *next; guint32 first, last; diff --git a/camel/providers/imap4/camel-imap4-utils.h b/camel/providers/imap4/camel-imap4-utils.h index 6202c1697e..c378165357 100644 --- a/camel/providers/imap4/camel-imap4-utils.h +++ b/camel/providers/imap4/camel-imap4-utils.h @@ -42,6 +42,8 @@ struct _CamelIMAP4Engine; struct _CamelIMAP4Command; struct _camel_imap4_token_t; +char camel_imap4_get_path_delim (struct _CamelIMAP4Engine *engine, const char *full_name); + int camel_imap4_get_uid_set (struct _CamelIMAP4Engine *engine, struct _CamelFolderSummary *summary, GPtrArray *infos, int cur, size_t linelen, char **set); void camel_imap4_utils_set_unexpected_token_error (CamelException *ex, struct _CamelIMAP4Engine *engine, struct _camel_imap4_token_t *token); -- cgit v1.2.3