diff options
Diffstat (limited to 'camel/providers')
-rw-r--r-- | camel/providers/imap/camel-imap-folder.c | 109 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-folder.h | 2 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-store.h | 4 | ||||
-rw-r--r-- | camel/providers/pop3/camel-pop3-store.c | 45 | ||||
-rw-r--r-- | camel/providers/smtp/camel-smtp-transport.c | 9 |
5 files changed, 93 insertions, 76 deletions
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index 25a9cdbb66..e32d1696d9 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -1015,12 +1015,12 @@ imap_append_online (CamelFolder *folder, CamelMimeMessage *message, CamelImapResponse *response; char *uid; int count; - + count = camel_folder_summary_count (folder->summary); response = do_append (folder, message, info, &uid, ex); if (!response) return; - + if (uid) { /* Cache first, since freeing response may trigger a * summary update that will want this information. @@ -1032,9 +1032,9 @@ imap_append_online (CamelFolder *folder, CamelMimeMessage *message, CAMEL_IMAP_FOLDER_UNLOCK (folder, cache_lock); g_free (uid); } - + camel_imap_response_free (store, response); - + /* Make sure a "folder_changed" is emitted. */ if (store->current_folder != folder || camel_folder_summary_count (folder->summary) == count) @@ -1048,24 +1048,24 @@ imap_append_resyncing (CamelFolder *folder, CamelMimeMessage *message, CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store); CamelImapResponse *response; char *uid; - + response = do_append (folder, message, info, &uid, ex); if (!response) return; - + if (uid) { CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder); const char *olduid = camel_message_info_uid (info); - + CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock); camel_imap_message_cache_copy (imap_folder->cache, olduid, imap_folder->cache, uid, ex); CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock); - + camel_disco_diary_uidmap_add (CAMEL_DISCO_STORE (store)->diary, olduid, uid); } - + camel_imap_response_free (store, response); } @@ -1204,19 +1204,19 @@ imap_copy_online (CamelFolder *source, GPtrArray *uids, { CamelImapStore *store = CAMEL_IMAP_STORE (source->parent_store); int count; - + /* Sync message flags if needed. */ imap_sync_online (source, ex); if (camel_exception_is_set (ex)) return; - + count = camel_folder_summary_count (destination->summary); - + /* Now copy the messages */ do_copy (source, uids, destination, ex); if (camel_exception_is_set (ex)) return; - + /* Make the destination notice its new messages */ if (store->current_folder != destination || camel_folder_summary_count (destination->summary) == count) @@ -1401,33 +1401,42 @@ get_content (CamelImapFolder *imap_folder, const char *uid, CamelDataWrapper *content = NULL; CamelStream *stream; char *child_spec; - + /* There are three cases: multipart, message/rfc822, and "other" */ - + if (header_content_type_is (ci->type, "multipart", "*")) { CamelMultipart *body_mp; int speclen, num; - + body_mp = camel_multipart_new (); camel_data_wrapper_set_mime_type_field ( CAMEL_DATA_WRAPPER (body_mp), ci->type); camel_multipart_set_boundary (body_mp, NULL); - + speclen = strlen (part_spec); child_spec = g_malloc (speclen + 15); memcpy (child_spec, part_spec, speclen); if (speclen > 0) child_spec[speclen++] = '.'; - + ci = ci->childs; num = 1; while (ci) { sprintf (child_spec + speclen, "%d.MIME", num++); stream = camel_imap_folder_fetch_data (imap_folder, uid, child_spec, FALSE, ex); if (stream) { + int ret; + part = camel_mime_part_new (); - camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (part), stream); + ret = camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (part), stream); camel_object_unref (CAMEL_OBJECT (stream)); + if (ret == -1) { + camel_object_unref (CAMEL_OBJECT (part)); + camel_object_unref (CAMEL_OBJECT (body_mp)); + g_free (child_spec); + return NULL; + } + *(strchr (child_spec + speclen, '.')) = '\0'; content = get_content (imap_folder, uid, child_spec, part, ci, ex); } @@ -1436,7 +1445,7 @@ get_content (CamelImapFolder *imap_folder, const char *uid, camel_object_unref (CAMEL_OBJECT (body_mp)); return NULL; } - + camel_medium_set_content_object (CAMEL_MEDIUM (part), content); camel_object_unref (CAMEL_OBJECT (content)); camel_multipart_add_part (body_mp, part); @@ -1472,27 +1481,32 @@ get_message (CamelImapFolder *imap_folder, const char *uid, CamelMimeMessage *msg; CamelStream *stream; char *section_text; - + int ret; + section_text = g_strdup_printf ("%s%s%s", part_spec, *part_spec ? "." : "", store->server_level >= IMAP_LEVEL_IMAP4REV1 ? "HEADER" : "0"); stream = camel_imap_folder_fetch_data (imap_folder, uid, section_text, FALSE, ex); g_free (section_text); if (!stream) return NULL; - + msg = camel_mime_message_new (); - camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), stream); + ret = camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), stream); camel_object_unref (CAMEL_OBJECT (stream)); - + if (ret == -1) { + camel_object_unref (CAMEL_OBJECT (msg)); + return NULL; + } + content = get_content (imap_folder, uid, part_spec, CAMEL_MIME_PART (msg), ci, ex); if (!content) { camel_object_unref (CAMEL_OBJECT (msg)); return NULL; } - + camel_medium_set_content_object (CAMEL_MEDIUM (msg), content); camel_object_unref (CAMEL_OBJECT (content)); - + return msg; } @@ -1506,7 +1520,8 @@ get_message_simple (CamelImapFolder *imap_folder, const char *uid, CamelMimeMessage *msg; CamelImapStore *imap_store = CAMEL_IMAP_STORE (CAMEL_FOLDER (imap_folder)->parent_store); - + int ret; + if (!stream) { stream = camel_imap_folder_fetch_data (imap_folder, uid, "", FALSE, ex); @@ -1515,9 +1530,13 @@ get_message_simple (CamelImapFolder *imap_folder, const char *uid, } msg = camel_mime_message_new (); - camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), - stream); + ret = camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), + stream); camel_object_unref (CAMEL_OBJECT (stream)); + if (ret == -1) { + camel_object_unref (CAMEL_OBJECT (msg)); + return NULL; + } /* FIXME, this shouldn't be done this way. */ camel_medium_set_header (CAMEL_MEDIUM (msg), "X-Evolution-Source", @@ -1643,26 +1662,30 @@ static void add_message_from_data (CamelFolder *folder, GPtrArray *messages, int first, GData *data) { - int seq; CamelMimeMessage *msg; CamelStream *stream; CamelMessageInfo *mi; - + int seq; + seq = GPOINTER_TO_INT (g_datalist_get_data (&data, "SEQUENCE")); if (seq < first) return; stream = g_datalist_get_data (&data, "BODY_PART_STREAM"); if (!stream) return; - + if (seq - first >= messages->len) g_ptr_array_set_size (messages, seq - first + 1); - + msg = camel_mime_message_new (); - camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), stream); + if (camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), stream) == -1) { + camel_object_unref (CAMEL_OBJECT (msg)); + return; + } + mi = camel_folder_summary_info_new_from_message (folder->summary, msg); camel_object_unref (CAMEL_OBJECT (msg)); - + messages->pdata[seq - first] = mi; } @@ -1954,7 +1977,7 @@ camel_imap_folder_fetch_data (CamelImapFolder *imap_folder, const char *uid, GData *fetch_data; char *found_uid; int i; - + /* EXPUNGE responses have to modify the cache, which means * they have to grab the cache_lock while holding the * command_lock. So we grab the command_lock now, in case @@ -1962,7 +1985,7 @@ camel_imap_folder_fetch_data (CamelImapFolder *imap_folder, const char *uid, * after the cache_lock. */ CAMEL_IMAP_STORE_LOCK (store, command_lock); - + CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock); stream = camel_imap_message_cache_get (imap_folder->cache, uid, section_text); if (!stream && (!strcmp (section_text, "HEADER") || !strcmp (section_text, "0"))) @@ -1972,7 +1995,7 @@ camel_imap_folder_fetch_data (CamelImapFolder *imap_folder, const char *uid, CAMEL_IMAP_STORE_UNLOCK (store, command_lock); return stream; } - + if (camel_disco_store_status (CAMEL_DISCO_STORE (store)) == CAMEL_DISCO_STORE_OFFLINE) { camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, _("This message is not currently available")); @@ -1980,7 +2003,7 @@ camel_imap_folder_fetch_data (CamelImapFolder *imap_folder, const char *uid, CAMEL_IMAP_STORE_UNLOCK (store, command_lock); return NULL; } - + if (store->server_level < IMAP_LEVEL_IMAP4REV1 && !*section_text) { response = camel_imap_command (store, folder, ex, "UID FETCH %s RFC822.PEEK", @@ -1992,19 +2015,19 @@ camel_imap_folder_fetch_data (CamelImapFolder *imap_folder, const char *uid, } /* We won't need the command_lock again after this. */ CAMEL_IMAP_STORE_UNLOCK (store, command_lock); - + if (!response) { CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock); return NULL; } - + for (i = 0; i < response->untagged->len; i++) { fetch_data = parse_fetch_response (imap_folder, response->untagged->pdata[i]); found_uid = g_datalist_get_data (&fetch_data, "UID"); stream = g_datalist_get_data (&fetch_data, "BODY_PART_STREAM"); if (found_uid && stream && !strcmp (uid, found_uid)) break; - + g_datalist_clear (&fetch_data); stream = NULL; } @@ -2018,7 +2041,7 @@ camel_imap_folder_fetch_data (CamelImapFolder *imap_folder, const char *uid, camel_object_ref (CAMEL_OBJECT (stream)); g_datalist_clear (&fetch_data); } - + return stream; } diff --git a/camel/providers/imap/camel-imap-folder.h b/camel/providers/imap/camel-imap-folder.h index 05e46ce6a1..8ab7d009da 100644 --- a/camel/providers/imap/camel-imap-folder.h +++ b/camel/providers/imap/camel-imap-folder.h @@ -34,7 +34,7 @@ extern "C" { #endif /* __cplusplus }*/ #include "camel-imap-types.h" -#include "camel-disco-folder.h" +#include <camel/camel-disco-folder.h> #include <camel/camel-folder-search.h> #define CAMEL_IMAP_FOLDER_TYPE (camel_imap_folder_get_type ()) diff --git a/camel/providers/imap/camel-imap-store.h b/camel/providers/imap/camel-imap-store.h index 09c7ddf9b2..43c9b8e1f0 100644 --- a/camel/providers/imap/camel-imap-store.h +++ b/camel/providers/imap/camel-imap-store.h @@ -32,10 +32,10 @@ extern "C" { #endif /* __cplusplus }*/ #include "camel-imap-types.h" -#include "camel-disco-store.h" +#include <camel/camel-disco-store.h> #ifdef ENABLE_THREADS -#include "e-util/e-msgport.h" +#include <e-util/e-msgport.h> typedef struct _CamelImapMsg CamelImapMsg; diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c index e959aa2de3..6ff88d61c2 100644 --- a/camel/providers/pop3/camel-pop3-store.c +++ b/camel/providers/pop3/camel-pop3-store.c @@ -348,7 +348,7 @@ pop3_try_authenticate (CamelService *service, const char *errmsg, CamelPop3Store *store = (CamelPop3Store *)service; int status; char *msg; - + /* The KPOP code will have set the password to be the username * in connect_to_server. Password and APOP are the only other * cases, and they both need a password. So if there's no @@ -356,19 +356,18 @@ pop3_try_authenticate (CamelService *service, const char *errmsg, */ if (!service->url->passwd) { char *prompt; - + prompt = g_strdup_printf (_("%sPlease enter the POP3 password " "for %s@%s"), errmsg ? errmsg : "", service->url->user, service->url->host); - service->url->passwd = camel_session_get_password ( - camel_service_get_session (service), - prompt, TRUE, service, "password", ex); + service->url->passwd = camel_session_get_password (camel_service_get_session (service), + prompt, TRUE, service, "password", ex); g_free (prompt); if (!service->url->passwd) return FALSE; } - + if (!service->url->authmech || !strcmp (service->url->authmech, "+KPOP")) { status = camel_pop3_command (store, &msg, ex, "USER %s", service->url->user); @@ -385,22 +384,22 @@ pop3_try_authenticate (CamelService *service, const char *errmsg, return FALSE; } g_free (msg); - + status = camel_pop3_command (store, &msg, ex, "PASS %s", service->url->passwd); } else if (!strcmp (service->url->authmech, "+APOP") && store->apop_timestamp) { char *secret, md5asc[33], *d; unsigned char md5sum[16], *s; - + secret = g_strdup_printf ("%s%s", store->apop_timestamp, service->url->passwd); md5_get_digest (secret, strlen (secret), md5sum); g_free (secret); - + for (s = md5sum, d = md5asc; d < md5asc + 32; s++, d += 2) sprintf (d, "%.2x", *s); - + status = camel_pop3_command (store, &msg, ex, "APOP %s %s", service->url->user, md5asc); } else { @@ -410,15 +409,16 @@ pop3_try_authenticate (CamelService *service, const char *errmsg, "authentication mechanism.")); return FALSE; } - + if (status == CAMEL_POP3_ERR) { camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, _("Unable to connect to POP server.\n" "Error sending password: %s"), msg ? msg : _("(Unknown)")); } - + g_free (msg); + return status == CAMEL_POP3_ERR; } @@ -427,36 +427,33 @@ pop3_connect (CamelService *service, CamelException *ex) { char *errbuf = NULL; gboolean tryagain; - + if (!connect_to_server (service, ex)) return FALSE; - + camel_exception_clear (ex); do { if (camel_exception_is_set (ex)) { - errbuf = g_strdup_printf ( - "%s\n\n", - camel_exception_get_description (ex)); + errbuf = g_strdup_printf ("%s\n\n", camel_exception_get_description (ex)); camel_exception_clear (ex); - + /* Uncache the password before prompting again. */ - camel_session_forget_password ( - camel_service_get_session (service), - service, "password", ex); + camel_session_forget_password (camel_service_get_session (service), + service, "password", ex); g_free (service->url->passwd); service->url->passwd = NULL; } - + tryagain = pop3_try_authenticate (service, errbuf, ex); g_free (errbuf); errbuf = NULL; } while (tryagain); - + if (camel_exception_is_set (ex)) { camel_service_disconnect (service, TRUE, ex); return FALSE; } - + return TRUE; } diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c index 73dfbea344..78509fad28 100644 --- a/camel/providers/smtp/camel-smtp-transport.c +++ b/camel/providers/smtp/camel-smtp-transport.c @@ -406,8 +406,7 @@ smtp_connect (CamelService *service, CamelException *ex) while (!authenticated) { if (errbuf) { /* We need to un-cache the password before prompting again */ - camel_session_forget_password ( - session, service, "password", ex); + camel_session_forget_password (session, service, "password", ex); g_free (service->url->passwd); service->url->passwd = NULL; } @@ -419,10 +418,8 @@ smtp_connect (CamelService *service, CamelException *ex) errbuf ? errbuf : "", service->url->user, service->url->host); - service->url->passwd = - camel_session_get_password ( - session, prompt, TRUE, - service, "password", ex); + service->url->passwd = camel_session_get_password (session, prompt, TRUE, + service, "password", ex); g_free (prompt); g_free (errbuf); |