diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-mail-folder-utils.c | 4 | ||||
-rw-r--r-- | mail/e-mail-session-utils.c | 7 | ||||
-rw-r--r-- | mail/e-mail-store.c | 91 |
3 files changed, 46 insertions, 56 deletions
diff --git a/mail/e-mail-folder-utils.c b/mail/e-mail-folder-utils.c index 6f23158ab5..905874e6ac 100644 --- a/mail/e-mail-folder-utils.c +++ b/mail/e-mail-folder-utils.c @@ -686,6 +686,7 @@ e_mail_folder_uri_build (CamelStore *store, gchar *encoded_uid; gchar *uri; + g_return_val_if_fail (store != NULL, NULL); g_return_val_if_fail (CAMEL_IS_STORE (store), NULL); g_return_val_if_fail (folder_name != NULL, NULL); @@ -743,6 +744,7 @@ e_mail_folder_uri_parse (CamelSession *session, gchar *folder_name = NULL; gboolean success = FALSE; + g_return_val_if_fail (session != NULL, FALSE); g_return_val_if_fail (CAMEL_IS_SESSION (session), FALSE); g_return_val_if_fail (folder_uri != NULL, FALSE); @@ -883,6 +885,7 @@ e_mail_folder_uri_equal (CamelSession *session, gboolean success_b; gboolean equal = FALSE; + g_return_val_if_fail (session != NULL, FALSE); g_return_val_if_fail (CAMEL_IS_SESSION (session), FALSE); g_return_val_if_fail (folder_uri_a != NULL, FALSE); g_return_val_if_fail (folder_uri_b != NULL, FALSE); @@ -934,6 +937,7 @@ e_mail_folder_uri_from_folder (CamelFolder *folder) CamelStore *store; const gchar *folder_name; + g_return_val_if_fail (folder != NULL, NULL); g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL); store = camel_folder_get_parent_store (folder); diff --git a/mail/e-mail-session-utils.c b/mail/e-mail-session-utils.c index b307fdc15c..ae9bd96a39 100644 --- a/mail/e-mail-session-utils.c +++ b/mail/e-mail-session-utils.c @@ -406,7 +406,12 @@ mail_session_send_to_thread (GSimpleAsyncResult *simple, service = camel_session_get_service ( CAMEL_SESSION (session), context->transport_uid); - g_return_if_fail (CAMEL_IS_TRANSPORT (service)); + if (!CAMEL_IS_TRANSPORT (service)) { + g_simple_async_result_set_error (simple, + CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_URL_INVALID, + _("Cannot get transport service for account '%s'"), context->transport_uid); + return; + } /* XXX This API does not allow for cancellation. */ if (!camel_service_connect_sync (service, &error)) { diff --git a/mail/e-mail-store.c b/mail/e-mail-store.c index 214efb0bb3..d61f8521dc 100644 --- a/mail/e-mail-store.c +++ b/mail/e-mail-store.c @@ -235,67 +235,15 @@ mail_store_load_accounts (EMailSession *session, account_list = e_get_account_list (); for (iter = e_list_get_iterator ((EList *) account_list); - e_iterator_is_valid (iter); e_iterator_next (iter)) { - + e_iterator_is_valid (iter); e_iterator_next (iter)) { EAccount *account; - CamelURL *url; - gchar *transport_uid; - gboolean skip = FALSE; - GError *error = NULL; account = (EAccount *) e_iterator_get (iter); if (!account->enabled) continue; - /* Do not add local-delivery files, - * but make them ready for later use. */ - url = camel_url_new (account->source->url, NULL); - if (url != NULL) { - skip = em_utils_is_local_delivery_mbox_file (url); - camel_url_free (url); - } - - if (skip) { - GError *error = NULL; - - camel_session_add_service ( - CAMEL_SESSION (session), - account->uid, account->source->url, - CAMEL_PROVIDER_STORE, &error); - - if (error != NULL) { - g_warning ( - "Failed to add '%s' as store: %s", - account->source->url, - error->message); - g_error_free (error); - } - } else { - e_mail_store_add_by_account (session, account); - } - - /* While we're at it, add the account's transport to the - * CamelSession. The transport's UID is a kludge for now. - * We take the EAccount's UID and tack on "-transport". */ - - if (account->transport == NULL) - continue; - - transport_uid = g_strconcat ( - account->uid, "-transport", NULL); - - camel_session_add_service ( - CAMEL_SESSION (session), - transport_uid, account->transport->url, - CAMEL_PROVIDER_TRANSPORT, &error); - - g_free (transport_uid); - - if (error != NULL) { - g_warning ("%s", error->message); - g_error_free (error); - } + e_mail_store_add_by_account (session, account); } g_object_unref (iter); @@ -344,6 +292,8 @@ e_mail_store_add_by_account (EMailSession *session, { CamelService *service; CamelProvider *provider; + CamelURL *url; + gboolean skip; GError *error = NULL; g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); @@ -361,10 +311,41 @@ e_mail_store_add_by_account (EMailSession *session, account->uid, account->source->url, CAMEL_PROVIDER_STORE, &error); + if (account->transport) { + /* While we're at it, add the account's transport to the + * CamelSession. The transport's UID is a kludge for now. + * We take the EAccount's UID and tack on "-transport". */ + gchar *transport_uid; + GError *transport_error = NULL; + + transport_uid = g_strconcat ( + account->uid, "-transport", NULL); + + camel_session_add_service ( + CAMEL_SESSION (session), + transport_uid, account->transport->url, + CAMEL_PROVIDER_TRANSPORT, &transport_error); + + g_free (transport_uid); + + if (transport_error) { + g_warning ("%s: Failed to add transport service: %s", G_STRFUNC, transport_error->message); + g_error_free (transport_error); + } + } + if (!CAMEL_IS_STORE (service)) goto fail; - if (provider->flags & CAMEL_PROVIDER_IS_STORAGE) + /* Do not add local-delivery files, + * but make them ready for later use. */ + url = camel_url_new (account->source->url, NULL); + if (url != NULL) { + skip = em_utils_is_local_delivery_mbox_file (url); + camel_url_free (url); + } + + if (!skip && (provider->flags & CAMEL_PROVIDER_IS_STORAGE)) e_mail_store_add ( session, CAMEL_STORE (service), account->name); |