diff options
36 files changed, 638 insertions, 649 deletions
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 0bc9ca9c1d..945f5cc22b 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -1084,6 +1084,8 @@ composer_build_message (EMsgComposer *composer, "X-Priority", "1"); if (account != NULL) { + gchar *transport_uid; + /* X-Evolution-Account */ camel_medium_set_header ( CAMEL_MEDIUM (context->message), @@ -1095,9 +1097,12 @@ composer_build_message (EMsgComposer *composer, "X-Evolution-Fcc", account->sent_folder_uri); /* X-Evolution-Transport */ + transport_uid = g_strconcat ( + account->uid, "-transport", NULL); camel_medium_set_header ( CAMEL_MEDIUM (context->message), - "X-Evolution-Transport", account->transport->url); + "X-Evolution-Transport", transport_uid); + g_free (transport_uid); /* Organization */ if (account->id->organization != NULL) { diff --git a/e-util/e-account-utils.c b/e-util/e-account-utils.c index df93fa2202..d6dfa7aea3 100644 --- a/e-util/e-account-utils.c +++ b/e-util/e-account-utils.c @@ -324,9 +324,9 @@ e_get_any_enabled_account (void) * the global #EAccountList that has transport information, or finally %NULL * if no transport information could be found. * - * Returns: an #EAccountService with transport info, or %NULL + * Returns: an #EAccount with transport info, or %NULL **/ -EAccountService * +EAccount * e_get_default_transport (void) { EAccountList *account_list; @@ -335,7 +335,7 @@ e_get_default_transport (void) account = e_get_default_account (); if (account_has_transport_url (account)) - return account->transport; + return account; account_list = e_get_account_list (); iterator = e_list_get_iterator (E_LIST (account_list)); @@ -345,7 +345,7 @@ e_get_default_transport (void) account = (EAccount *) e_iterator_get (iterator); if (account_has_transport_url (account)) { g_object_unref (iterator); - return account->transport; + return account; } e_iterator_next (iterator); } @@ -385,12 +385,15 @@ e_get_subscribable_accounts (CamelSession *session) account = (EAccount *) e_iterator_get (iterator); if (account->enabled) { + CamelService *service; const gchar *url; url = e_account_get_string ( account, E_ACCOUNT_SOURCE_URL); - store = (CamelStore *) camel_session_get_service ( - session, url, CAMEL_PROVIDER_STORE, NULL); + service = camel_session_get_service ( + session, account->uid); + if (CAMEL_IS_STORE (service)) + store = CAMEL_STORE (service); } e_iterator_next (iterator); diff --git a/e-util/e-account-utils.h b/e-util/e-account-utils.h index 57ca8400be..ae148cdb36 100644 --- a/e-util/e-account-utils.h +++ b/e-util/e-account-utils.h @@ -32,8 +32,7 @@ EAccount * e_get_account_by_uid (const gchar *uid); EAccount * e_get_account_by_source_url (const gchar *source_url); EAccount * e_get_account_by_transport_url (const gchar *transport_url); EAccount * e_get_any_enabled_account (void); -EAccountService * - e_get_default_transport (void); +EAccount * e_get_default_transport (void); GList * e_get_subscribable_accounts (CamelSession *session); G_END_DECLS diff --git a/mail/e-mail-local.c b/mail/e-mail-local.c index 2779c0e054..42161c2d42 100644 --- a/mail/e-mail-local.c +++ b/mail/e-mail-local.c @@ -68,8 +68,8 @@ e_mail_local_init (EMailSession *session, g_free (temp); temp = camel_url_to_string (url, 0); - service = camel_session_get_service ( - CAMEL_SESSION (session), temp, + service = camel_session_add_service ( + CAMEL_SESSION (session), "local", temp, CAMEL_PROVIDER_STORE, &local_error); g_free (temp); @@ -90,10 +90,12 @@ e_mail_local_init (EMailSession *session, /* FIXME camel_store_get_folder() may block. */ default_local_folders[ii].folder_uri = folder_uri; if (!strcmp (display_name, "Inbox")) - default_local_folders[ii].folder = camel_store_get_inbox_folder_sync ( + default_local_folders[ii].folder = + camel_store_get_inbox_folder_sync ( CAMEL_STORE (service), NULL, NULL); else - default_local_folders[ii].folder = camel_store_get_folder_sync ( + default_local_folders[ii].folder = + camel_store_get_folder_sync ( CAMEL_STORE (service), display_name, CAMEL_STORE_FOLDER_CREATE, NULL, NULL); } diff --git a/mail/e-mail-migrate.c b/mail/e-mail-migrate.c index 81b4fc762d..d627088254 100644 --- a/mail/e-mail-migrate.c +++ b/mail/e-mail-migrate.c @@ -94,8 +94,6 @@ GType em_migrate_session_get_type (void); G_DEFINE_TYPE (EMMigrateSession, em_migrate_session, CAMEL_TYPE_SESSION) -static CamelSession *em_migrate_session_new (const gchar *path); - static void em_migrate_session_class_init (EMMigrateSessionClass *class) { @@ -106,15 +104,12 @@ em_migrate_session_init (EMMigrateSession *session) { } -static CamelSession * -em_migrate_session_new (const gchar *path) +static EMMigrateSession * +em_migrate_session_new (const gchar *user_data_dir) { - CamelSession *session; - - session = g_object_new (EM_TYPE_MIGRATE_SESSION, NULL); - camel_session_construct (session, path); - - return session; + return g_object_new ( + EM_TYPE_MIGRATE_SESSION, + "user-data-dir", user_data_dir, NULL); } static GtkWidget *window; @@ -601,7 +596,9 @@ setup_local_store (EShellBackend *shell_backend, camel_url_set_path (url, tmp); g_free (tmp); tmp = camel_url_to_string (url, 0); - store = (CamelStore *)camel_session_get_service (CAMEL_SESSION (session), tmp, CAMEL_PROVIDER_STORE, NULL); + store = (CamelStore *) camel_session_add_service ( + CAMEL_SESSION (session), "local", tmp, + CAMEL_PROVIDER_STORE, NULL); g_free (tmp); return store; @@ -655,7 +652,7 @@ migrate_to_db (EShellBackend *shell_backend) iter = e_list_get_iterator ((EList *) accounts); len = e_list_length ((EList *) accounts); - session = (EMMigrateSession *) em_migrate_session_new (data_dir); + session = em_migrate_session_new (data_dir); camel_session_set_online ((CamelSession *) session, FALSE); em_migrate_setup_progress_dialog ( _("Migrating Folders"), @@ -697,21 +694,16 @@ migrate_to_db (EShellBackend *shell_backend) while (e_iterator_is_valid (iter)) { EAccount *account = (EAccount *) e_iterator_get (iter); EAccountService *service; - const gchar *name; service = account->source; - name = account->name; em_migrate_set_progress ( (double)i/(len+1)); if (account->enabled && service->url != NULL && service->url[0] && strncmp (service->url, "mbox:", 5) != 0) { - e_mail_store_add_by_uri ( - mail_session, service->url, name); + store = e_mail_store_add_by_account ( + mail_session, account); - store = (CamelStore *) camel_session_get_service ( - CAMEL_SESSION (session), service->url, - CAMEL_PROVIDER_STORE, NULL); info = camel_store_get_folder_info_sync ( store, NULL, CAMEL_STORE_FOLDER_INFO_RECURSIVE | @@ -870,7 +862,8 @@ migrate_stores (struct MigrateStore *ms) } static gboolean -migrate_mbox_to_maildir (EShellBackend *shell_backend, EMMigrateSession *session) +migrate_mbox_to_maildir (EShellBackend *shell_backend, + EMMigrateSession *session) { CamelService *mbox_service, *maildir_service; CamelStore *mbox_store, *maildir_store; @@ -886,8 +879,8 @@ migrate_mbox_to_maildir (EShellBackend *shell_backend, EMMigrateSession *session g_free (temp); temp = camel_url_to_string (url, 0); - mbox_service = camel_session_get_service ( - CAMEL_SESSION (session), temp, + mbox_service = camel_session_add_service ( + CAMEL_SESSION (session), "local_mbox", temp, CAMEL_PROVIDER_STORE, NULL); g_free (temp); camel_url_free (url); @@ -899,8 +892,8 @@ migrate_mbox_to_maildir (EShellBackend *shell_backend, EMMigrateSession *session g_free (temp); temp = camel_url_to_string (url, 0); - maildir_service = camel_session_get_service ( - CAMEL_SESSION (session), temp, + maildir_service = camel_session_add_service ( + CAMEL_SESSION (session), "local", temp, CAMEL_PROVIDER_STORE, NULL); g_free (temp); camel_url_free (url); @@ -917,9 +910,6 @@ migrate_mbox_to_maildir (EShellBackend *shell_backend, EMMigrateSession *session while (!ms.complete) g_main_context_iteration (NULL, TRUE); - g_object_unref (mbox_store); - g_object_unref (maildir_store); - return TRUE; } @@ -947,7 +937,8 @@ exit: } static gboolean -create_mbox_account (EShellBackend *shell_backend, EMMigrateSession *session) +create_mbox_account (EShellBackend *shell_backend, + EMMigrateSession *session) { EMailBackend *mail_backend; EMailSession *mail_session; @@ -967,6 +958,9 @@ create_mbox_account (EShellBackend *shell_backend, EMMigrateSession *session) account = e_account_new (); account->enabled = TRUE; + g_free (account->uid); + account->uid = g_strdup ("local_mbox"); + url = camel_url_new ("mbox:", NULL); temp = g_build_filename (data_dir, "local_mbox", NULL); camel_url_set_path (url, temp); @@ -1005,7 +999,7 @@ create_mbox_account (EShellBackend *shell_backend, EMMigrateSession *session) g_free (folder_uri); e_account_list_add (accounts, account); - e_mail_store_add_by_uri (mail_session, uri, name); + e_mail_store_add_by_account (mail_session, account); e_account_list_save (accounts); exit: @@ -1042,7 +1036,7 @@ migrate_local_store (EShellBackend *shell_backend) if (!g_file_test (local_store, G_FILE_TEST_EXISTS)) g_mkdir_with_parents (local_store, 0700); - session = (EMMigrateSession *) em_migrate_session_new (data_dir); + session = em_migrate_session_new (data_dir); camel_session_set_online (CAMEL_SESSION (session), FALSE); migrate_mbox_to_maildir (shell_backend, session); diff --git a/mail/e-mail-session-utils.c b/mail/e-mail-session-utils.c index 26d6dcb310..fcdd6b87ac 100644 --- a/mail/e-mail-session-utils.c +++ b/mail/e-mail-session-utils.c @@ -51,9 +51,8 @@ struct _AsyncContext { GPtrArray *post_to_uris; gchar *folder_uri; - gchar *destination; gchar *message_uid; - gchar *transport_uri; + gchar *transport_uid; gchar *sent_folder_uri; }; @@ -93,9 +92,8 @@ async_context_free (AsyncContext *context) } g_free (context->folder_uri); - g_free (context->destination); g_free (context->message_uid); - g_free (context->transport_uri); + g_free (context->transport_uid); g_free (context->sent_folder_uri); g_slice_free (AsyncContext, context); @@ -401,36 +399,30 @@ mail_session_send_to_thread (GSimpleAsyncResult *simple, /* Send the message to all recipients. */ if (camel_address_length (context->recipients) > 0) { - CamelTransport *transport; CamelProvider *provider; CamelService *service; - /* XXX This API does not allow for cancellation. */ - transport = camel_session_get_transport ( - CAMEL_SESSION (session), - context->transport_uri, &error); + service = camel_session_get_service ( + CAMEL_SESSION (session), context->transport_uid); - if (error != NULL) { - g_warn_if_fail (transport == NULL); + g_return_if_fail (CAMEL_IS_TRANSPORT (service)); + + /* XXX This API does not allow for cancellation. */ + if (!camel_service_connect_sync (service, &error)) { g_simple_async_result_set_from_error (simple, error); g_error_free (error); return; } - g_return_if_fail (CAMEL_IS_TRANSPORT (transport)); - - service = CAMEL_SERVICE (transport); provider = camel_service_get_provider (service); if (provider->flags & CAMEL_PROVIDER_DISABLE_SENT_FOLDER) copy_to_sent = FALSE; camel_transport_send_to_sync ( - transport, context->message, - context->from, context->recipients, - cancellable, &error); - - g_object_unref (transport); + CAMEL_TRANSPORT (service), + context->message, context->from, + context->recipients, cancellable, &error); if (error != NULL) { g_simple_async_result_set_from_error (simple, error); @@ -622,7 +614,6 @@ exit: void e_mail_session_send_to (EMailSession *session, CamelMimeMessage *message, - const gchar *destination, gint io_priority, GCancellable *cancellable, CamelFilterGetFolderFunc get_folder_func, @@ -642,7 +633,7 @@ e_mail_session_send_to (EMailSession *session, struct _camel_header_raw *header; const gchar *string; const gchar *resent_from; - gchar *transport_uri = NULL; + gchar *transport_uid = NULL; gchar *sent_folder_uri = NULL; GError *error = NULL; @@ -668,7 +659,12 @@ e_mail_session_send_to (EMailSession *session, if (account != NULL) { if (account->transport != NULL) { - transport_uri = g_strdup (account->transport->url); + + /* XXX Transport UIDs are kludgy right now. We + * use the EAccount's regular UID and tack on + * "-transport". Will be better soon. */ + transport_uid = g_strconcat ( + account->uid, "-transport", NULL); /* to reprompt password on sending if needed */ account->transport->get_password_canceled = FALSE; @@ -677,16 +673,13 @@ e_mail_session_send_to (EMailSession *session, } string = camel_header_raw_find (&xev, "X-Evolution-Transport", NULL); - if (transport_uri == NULL && string != NULL) - transport_uri = g_strstrip (g_strdup (string)); + if (transport_uid == NULL && string != NULL) + transport_uid = g_strstrip (g_strdup (string)); string = camel_header_raw_find (&xev, "X-Evolution-Fcc", NULL); if (sent_folder_uri == NULL && string != NULL) sent_folder_uri = g_strstrip (g_strdup (string)); - if (transport_uri == NULL) - transport_uri = g_strdup (destination); - post_to_uris = g_ptr_array_new (); for (header = xev; header != NULL; header = header->next) { gchar *folder_uri; @@ -751,7 +744,6 @@ e_mail_session_send_to (EMailSession *session, context = g_slice_new0 (AsyncContext); context->message = g_object_ref (message); - context->destination = g_strdup (destination); context->io_priority = io_priority; context->from = from; context->recipients = recipients; @@ -759,7 +751,7 @@ e_mail_session_send_to (EMailSession *session, context->info = info; context->xev = xev; context->post_to_uris = post_to_uris; - context->transport_uri = transport_uri; + context->transport_uid = transport_uid; context->sent_folder_uri = sent_folder_uri; if (G_IS_CANCELLABLE (cancellable)) @@ -841,7 +833,7 @@ e_mail_session_unsubscribe_folder_sync (EMailSession *session, GError **error) { CamelURL *url; - CamelStore *store; + CamelService *service; CamelProvider *provider; const gchar *message; const gchar *path = NULL; @@ -853,16 +845,21 @@ e_mail_session_unsubscribe_folder_sync (EMailSession *session, message = _("Unsubscribing from folder '%s'"); camel_operation_push_message (cancellable, message, folder_uri); - store = camel_session_get_store ( - CAMEL_SESSION (session), folder_uri, error); - if (store == NULL) - goto exit; - url = camel_url_new (folder_uri, error); if (url == NULL) goto exit; - provider = camel_service_get_provider (CAMEL_SERVICE (store)); + service = camel_session_get_service_by_url ( + CAMEL_SESSION (session), url); + + if (!CAMEL_IS_STORE (service)) + goto exit; + + /* FIXME This should take our GCancellable. */ + if (!camel_service_connect_sync (service, error)) + goto exit; + + provider = camel_service_get_provider (service); if (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH) path = url->fragment; @@ -872,7 +869,7 @@ e_mail_session_unsubscribe_folder_sync (EMailSession *session, g_return_val_if_fail (path != NULL, FALSE); success = camel_store_unsubscribe_folder_sync ( - store, path, cancellable, error); + CAMEL_STORE (service), path, cancellable, error); camel_url_free (url); diff --git a/mail/e-mail-session-utils.h b/mail/e-mail-session-utils.h index c59d27f335..b398be5f84 100644 --- a/mail/e-mail-session-utils.h +++ b/mail/e-mail-session-utils.h @@ -66,7 +66,6 @@ gboolean e_mail_session_handle_source_headers_finish GError **error); void e_mail_session_send_to (EMailSession *session, CamelMimeMessage *message, - const gchar *destination, gint io_priority, GCancellable *cancellable, CamelFilterGetFolderFunc get_folder_func, diff --git a/mail/e-mail-session.c b/mail/e-mail-session.c index 622ee6f367..c95b21b3ba 100644 --- a/mail/e-mail-session.c +++ b/mail/e-mail-session.c @@ -79,6 +79,7 @@ struct _EMailSessionPrivate { struct _AsyncContext { /* arguments */ CamelStoreGetFolderFlags flags; + gchar *uid; gchar *uri; /* results */ @@ -486,6 +487,7 @@ async_context_free (AsyncContext *context) if (context->folder != NULL) g_object_unref (context->folder); + g_free (context->uid); g_free (context->uri); g_slice_free (AsyncContext, context); @@ -608,7 +610,7 @@ mail_session_get_password (CamelSession *session, url = camel_url_to_string (service_url, CAMEL_URL_HIDE_ALL); } - if (!strcmp(item, "popb4smtp_uri")) { + if (!strcmp(item, "popb4smtp_uid")) { /* not 100% mt safe, but should be ok */ if (url && (account = e_get_account_by_transport_url (url))) @@ -1010,10 +1012,6 @@ e_mail_session_init (EMailSession *session) /* Initialize the EAccount setup. */ e_account_writable (NULL, E_ACCOUNT_SOURCE_SAVE_PASSWD); - camel_session_construct ( - CAMEL_SESSION (session), - mail_session_get_data_dir ()); - client = gconf_client_get_default (); gconf_client_add_dir ( @@ -1038,7 +1036,13 @@ e_mail_session_init (EMailSession *session) EMailSession * e_mail_session_new (void) { - return g_object_new (E_TYPE_MAIL_SESSION, NULL); + const gchar *user_data_dir; + + user_data_dir = mail_session_get_data_dir (); + + return g_object_new ( + E_TYPE_MAIL_SESSION, + "user-data-dir", user_data_dir, NULL); } MailFolderCache * @@ -1060,7 +1064,7 @@ mail_session_get_inbox_thread (GSimpleAsyncResult *simple, context = g_simple_async_result_get_op_res_gpointer (simple); context->folder = e_mail_session_get_inbox_sync ( - session, context->uri, cancellable, &error); + session, context->uid, cancellable, &error); if (error != NULL) { g_simple_async_result_set_from_error (simple, error); @@ -1070,32 +1074,31 @@ mail_session_get_inbox_thread (GSimpleAsyncResult *simple, CamelFolder * e_mail_session_get_inbox_sync (EMailSession *session, - const gchar *service_uri, + const gchar *service_uid, GCancellable *cancellable, GError **error) { - CamelStore *store; - CamelFolder *folder; + CamelService *service; g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); - g_return_val_if_fail (service_uri != NULL, NULL); + g_return_val_if_fail (service_uid != NULL, NULL); - store = camel_session_get_store ( - CAMEL_SESSION (session), service_uri, error); + service = camel_session_get_service ( + CAMEL_SESSION (session), service_uid); - if (store == NULL) + if (!CAMEL_IS_STORE (service)) return NULL; - folder = camel_store_get_inbox_folder_sync (store, cancellable, error); - - g_object_unref (store); + if (!camel_service_connect_sync (service, error)) + return NULL; - return folder; + return camel_store_get_inbox_folder_sync ( + CAMEL_STORE (service), cancellable, error); } void e_mail_session_get_inbox (EMailSession *session, - const gchar *service_uri, + const gchar *service_uid, gint io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, @@ -1105,10 +1108,10 @@ e_mail_session_get_inbox (EMailSession *session, AsyncContext *context; g_return_if_fail (E_IS_MAIL_SESSION (session)); - g_return_if_fail (service_uri != NULL); + g_return_if_fail (service_uid != NULL); context = g_slice_new0 (AsyncContext); - context->uri = g_strdup (service_uri); + context->uid = g_strdup (service_uid); simple = g_simple_async_result_new ( G_OBJECT (session), callback, @@ -1160,7 +1163,7 @@ mail_session_get_trash_thread (GSimpleAsyncResult *simple, context = g_simple_async_result_get_op_res_gpointer (simple); context->folder = e_mail_session_get_trash_sync ( - session, context->uri, cancellable, &error); + session, context->uid, cancellable, &error); if (error != NULL) { g_simple_async_result_set_from_error (simple, error); @@ -1170,32 +1173,31 @@ mail_session_get_trash_thread (GSimpleAsyncResult *simple, CamelFolder * e_mail_session_get_trash_sync (EMailSession *session, - const gchar *service_uri, + const gchar *service_uid, GCancellable *cancellable, GError **error) { - CamelStore *store; - CamelFolder *folder; + CamelService *service; g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); - g_return_val_if_fail (service_uri != NULL, NULL); + g_return_val_if_fail (service_uid != NULL, NULL); - store = camel_session_get_store ( - CAMEL_SESSION (session), service_uri, error); + service = camel_session_get_service ( + CAMEL_SESSION (session), service_uid); - if (store == NULL) + if (!CAMEL_IS_STORE (service)) return NULL; - folder = camel_store_get_trash_folder_sync (store, cancellable, error); - - g_object_unref (store); + if (!camel_service_connect_sync (service, error)) + return NULL; - return folder; + return camel_store_get_trash_folder_sync ( + CAMEL_STORE (service), cancellable, error); } void e_mail_session_get_trash (EMailSession *session, - const gchar *service_uri, + const gchar *service_uid, gint io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, @@ -1205,10 +1207,10 @@ e_mail_session_get_trash (EMailSession *session, AsyncContext *context; g_return_if_fail (E_IS_MAIL_SESSION (session)); - g_return_if_fail (service_uri != NULL); + g_return_if_fail (service_uid != NULL); context = g_slice_new0 (AsyncContext); - context->uri = g_strdup (service_uri); + context->uid = g_strdup (service_uid); simple = g_simple_async_result_new ( G_OBJECT (session), callback, @@ -1277,7 +1279,7 @@ e_mail_session_uri_to_folder_sync (EMailSession *session, GError **error) { CamelURL *url; - CamelStore *store; + CamelService *service; CamelFolder *folder = NULL; gchar *camel_uri = NULL; gboolean vtrash = FALSE; @@ -1316,11 +1318,10 @@ e_mail_session_uri_to_folder_sync (EMailSession *session, goto exit; } - store = (CamelStore *) camel_session_get_service ( - CAMEL_SESSION (session), folder_uri, - CAMEL_PROVIDER_STORE, error); + service = camel_session_get_service_by_url ( + CAMEL_SESSION (session), url); - if (store != NULL) { + if (CAMEL_IS_STORE (service)) { const gchar *name = ""; /* If we have a fragment, then the path is actually @@ -1333,15 +1334,14 @@ e_mail_session_uri_to_folder_sync (EMailSession *session, if (vtrash) folder = camel_store_get_trash_folder_sync ( - store, cancellable, error); + CAMEL_STORE (service), cancellable, error); else if (vjunk) folder = camel_store_get_junk_folder_sync ( - store, cancellable, error); + CAMEL_STORE (service), cancellable, error); else folder = camel_store_get_folder_sync ( - store, name, flags, cancellable, error); - - g_object_unref (store); + CAMEL_STORE (service), name, + flags, cancellable, error); } if (folder != NULL) { diff --git a/mail/e-mail-session.h b/mail/e-mail-session.h index 99c1b77d7c..5cc6b8976e 100644 --- a/mail/e-mail-session.h +++ b/mail/e-mail-session.h @@ -67,11 +67,11 @@ EMailSession * e_mail_session_new (void); MailFolderCache * e_mail_session_get_folder_cache (EMailSession *session); CamelFolder * e_mail_session_get_inbox_sync (EMailSession *session, - const gchar *service_uri, + const gchar *service_uid, GCancellable *cancellable, GError **error); void e_mail_session_get_inbox (EMailSession *session, - const gchar *service_uri, + const gchar *service_uid, gint io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, @@ -80,11 +80,11 @@ CamelFolder * e_mail_session_get_inbox_finish (EMailSession *session, GAsyncResult *result, GError **error); CamelFolder * e_mail_session_get_trash_sync (EMailSession *session, - const gchar *service_uri, + const gchar *service_uid, GCancellable *cancellable, GError **error); void e_mail_session_get_trash (EMailSession *session, - const gchar *service_uri, + const gchar *service_uid, gint io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, diff --git a/mail/e-mail-store.c b/mail/e-mail-store.c index c5b6be32b4..65bcbc822b 100644 --- a/mail/e-mail-store.c +++ b/mail/e-mail-store.c @@ -74,8 +74,7 @@ store_info_new (CamelStore *store, store_info = g_slice_new0 (StoreInfo); store_info->ref_count = 1; - g_object_ref (store); - store_info->store = store; + store_info->store = g_object_ref (store); if (display_name == NULL) store_info->display_name = @@ -238,27 +237,50 @@ mail_store_load_accounts (EMailSession *session, for (iter = e_list_get_iterator ((EList *) account_list); e_iterator_is_valid (iter); e_iterator_next (iter)) { - EAccountService *service; EAccount *account; - const gchar *display_name; - const gchar *uri; + CamelURL *url; + gchar *transport_uid; + gboolean skip = FALSE; + GError *error = NULL; account = (EAccount *) e_iterator_get (iter); - display_name = account->name; - service = account->source; - uri = service->url; if (!account->enabled) continue; - if (uri == NULL || *uri == '\0') + /* Do not add local-delivery files. */ + 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) continue; - /* do not add local-delivery files into the tree those are server specifically */ - if (em_utils_is_local_delivery_mbox_file (uri)) + 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; - e_mail_store_add_by_uri (session, uri, display_name); + 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); + } } g_object_unref (iter); @@ -302,46 +324,43 @@ e_mail_store_add (EMailSession *session, } CamelStore * -e_mail_store_add_by_uri (EMailSession *session, - const gchar *uri, - const gchar *display_name) +e_mail_store_add_by_account (EMailSession *session, + EAccount *account) { CamelService *service; CamelProvider *provider; - GError *local_error = NULL; + GError *error = NULL; g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); - g_return_val_if_fail (uri != NULL, NULL); - g_return_val_if_fail (display_name != NULL, NULL); + g_return_val_if_fail (E_IS_ACCOUNT (account), NULL); /* Load the service, but don't connect. Check its provider, * and if this belongs in the folder tree model, add it. */ - provider = camel_provider_get (uri, &local_error); + provider = camel_provider_get (account->source->url, &error); if (provider == NULL) goto fail; - if (!(provider->flags & CAMEL_PROVIDER_IS_STORAGE)) - return NULL; + service = camel_session_add_service ( + CAMEL_SESSION (session), + account->uid, account->source->url, + CAMEL_PROVIDER_STORE, &error); - service = camel_session_get_service ( - CAMEL_SESSION (session), uri, - CAMEL_PROVIDER_STORE, &local_error); - if (service == NULL) + if (!CAMEL_IS_STORE (service)) goto fail; - e_mail_store_add (session, CAMEL_STORE (service), display_name); - - g_object_unref (service); + if (provider->flags & CAMEL_PROVIDER_IS_STORAGE) + e_mail_store_add ( + session, CAMEL_STORE (service), account->name); return CAMEL_STORE (service); fail: /* FIXME: Show an error dialog. */ g_warning ( - "Couldn't get service: %s: %s", uri, - local_error->message); - g_error_free (local_error); + "Couldn't get service: %s: %s", account->name, + error->message); + g_error_free (error); return NULL; } @@ -381,16 +400,16 @@ e_mail_store_remove (EMailSession *session, } void -e_mail_store_remove_by_uri (EMailSession *session, - const gchar *uri) +e_mail_store_remove_by_account (EMailSession *session, + EAccount *account) { CamelService *service; CamelProvider *provider; g_return_if_fail (E_IS_MAIL_SESSION (session)); - g_return_if_fail (uri != NULL); + g_return_if_fail (E_IS_ACCOUNT (account)); - provider = camel_provider_get (uri, NULL); + provider = camel_provider_get (account->source->url, NULL); if (provider == NULL) return; @@ -398,14 +417,11 @@ e_mail_store_remove_by_uri (EMailSession *session, return; service = camel_session_get_service ( - CAMEL_SESSION (session), uri, - CAMEL_PROVIDER_STORE, NULL); - if (service == NULL) - return; + CAMEL_SESSION (session), account->uid); - e_mail_store_remove (session, CAMEL_STORE (service)); + g_return_if_fail (CAMEL_IS_STORE (service)); - g_object_unref (service); + e_mail_store_remove (session, CAMEL_STORE (service)); } void diff --git a/mail/e-mail-store.h b/mail/e-mail-store.h index b120d14aef..a0326b2ded 100644 --- a/mail/e-mail-store.h +++ b/mail/e-mail-store.h @@ -25,6 +25,7 @@ #include <glib.h> #include <camel/camel.h> #include <mail/e-mail-session.h> +#include <libedataserver/e-account.h> G_BEGIN_DECLS @@ -33,13 +34,12 @@ void e_mail_store_init (EMailSession *session, void e_mail_store_add (EMailSession *session, CamelStore *store, const gchar *display_name); -CamelStore * e_mail_store_add_by_uri (EMailSession *session, - const gchar *uri, - const gchar *display_name); +CamelStore * e_mail_store_add_by_account (EMailSession *session, + EAccount *account); void e_mail_store_remove (EMailSession *session, CamelStore *store); -void e_mail_store_remove_by_uri (EMailSession *session, - const gchar *uri); +void e_mail_store_remove_by_account (EMailSession *session, + EAccount *account); void e_mail_store_foreach (GHFunc func, gpointer user_data); diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c index 639c82f251..f51f5edcae 100644 --- a/mail/em-account-editor.c +++ b/mail/em-account-editor.c @@ -1932,9 +1932,7 @@ emae_refresh_authtype (EMAccountEditor *emae, EMAccountEditorService *service) } static void -emae_check_authtype_done (const gchar *uri, - CamelProviderType type, - GList *types, +emae_check_authtype_done (GList *types, gpointer data) { EMAccountEditorService **pservice = data; @@ -2000,6 +1998,7 @@ emae_check_authtype (GtkWidget *w, EAccount *account; GtkWidget *editor; const gchar *uri; + gchar *uid; account = em_account_editor_get_modified_account (emae); editor = E_CONFIG (service->emae->config)->window; @@ -2017,12 +2016,18 @@ emae_check_authtype (GtkWidget *w, if (editor != NULL) gtk_widget_set_sensitive (editor, FALSE); + if (service->type == CAMEL_PROVIDER_TRANSPORT) + uid = g_strconcat (account->uid, "-transport", NULL); + else + uid = g_strdup (account->uid); + pservice = g_new0 (EMAccountEditorService *, 1); *pservice = service; service->check_data = pservice; service->check_id = mail_check_service ( - session, uri, service->type, - emae_check_authtype_done, pservice); + session, uid, emae_check_authtype_done, pservice); + + g_free (uid); } static void @@ -3772,21 +3777,9 @@ emae_commit (EConfig *ec, GSList *items, gpointer data) && emae->priv->source.provider && (emae->priv->source.provider->flags & CAMEL_PROVIDER_IS_STORAGE)) { EMailSession *session; - CamelStore *store; - const gchar *uri; session = em_account_editor_get_session (emae); - uri = e_account_get_string ( - modified_account, E_ACCOUNT_SOURCE_URL); - store = (CamelStore *) camel_session_get_service ( - CAMEL_SESSION (session), uri, - CAMEL_PROVIDER_STORE, NULL); - if (store != NULL) { - e_mail_store_add ( - session, store, - modified_account->name); - g_object_unref (store); - } + e_mail_store_add_by_account (session, account); } } diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index b916e15d29..31a40293e4 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -567,7 +567,7 @@ em_utils_composer_send_cb (EMsgComposer *composer, session = e_msg_composer_get_session (context->composer); e_mail_session_send_to ( - E_MAIL_SESSION (session), message, NULL, + E_MAIL_SESSION (session), message, G_PRIORITY_DEFAULT, cancellable, NULL, NULL, (GAsyncReadyCallback) composer_send_completed, context); @@ -1802,6 +1802,7 @@ em_utils_send_receipt (EMailSession *session, gchar *hostname; gchar *self_address, *receipt_subject; gchar *ua, *recipient; + gchar *transport_uid; message_id = camel_medium_get_header ( CAMEL_MEDIUM (message), "Message-ID"); @@ -1916,6 +1917,8 @@ em_utils_send_receipt (EMailSession *session, camel_mime_message_set_recipients (receipt, CAMEL_RECIPIENT_TYPE_TO, addr); g_object_unref (addr); + transport_uid = g_strconcat (account->uid, "-transport", NULL); + camel_medium_set_header ( CAMEL_MEDIUM (receipt), "Return-Path", "<>"); @@ -1926,12 +1929,14 @@ em_utils_send_receipt (EMailSession *session, camel_medium_set_header ( CAMEL_MEDIUM (receipt), "X-Evolution-Transport", - account->transport->url); + transport_uid); camel_medium_set_header ( CAMEL_MEDIUM (receipt), "X-Evolution-Fcc", account->sent_folder_uri); + g_free (transport_uid); + /* Send the receipt */ info = camel_message_info_new (NULL); out_folder = e_mail_local_get_folder (E_MAIL_LOCAL_FOLDER_OUTBOX); diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c index 3455234c7f..7a7a5f8716 100644 --- a/mail/em-folder-tree-model.c +++ b/mail/em-folder-tree-model.c @@ -204,8 +204,7 @@ account_changed_cb (EAccountList *accounts, EMFolderTreeModelStoreInfo *si; EMailSession *session; CamelProvider *provider; - CamelStore *store; - gchar *uri; + CamelService *service; session = em_folder_tree_model_get_session (model); @@ -216,24 +215,25 @@ account_changed_cb (EAccountList *accounts, em_folder_tree_model_remove_store (model, si->store); /* check if store needs to be added at all*/ - if (!account->enabled ||!(uri = account->source->url)) + if (!account->enabled) return; - if (!(provider = camel_provider_get (uri, NULL))) + provider = camel_provider_get (account->source->url, NULL); + if (provider == NULL) return; /* make sure the new store belongs in the tree */ if (!(provider->flags & CAMEL_PROVIDER_IS_STORAGE)) return; - store = (CamelStore *) camel_session_get_service ( - CAMEL_SESSION (session), uri, - CAMEL_PROVIDER_STORE, NULL); - if (store == NULL) + service = camel_session_get_service ( + CAMEL_SESSION (session), account->uid); + + if (!CAMEL_IS_STORE (service)) return; - em_folder_tree_model_add_store (model, store, account->name); - g_object_unref (store); + em_folder_tree_model_add_store ( + model, CAMEL_STORE (service), account->name); } static void @@ -257,27 +257,9 @@ account_added_cb (EAccountList *accounts, EMFolderTreeModel *model) { EMailSession *session; - CamelStore *store; - const gchar *uri; session = em_folder_tree_model_get_session (model); - uri = e_account_get_string (account, E_ACCOUNT_SOURCE_URL); - - store = (CamelStore *) camel_session_get_service ( - CAMEL_SESSION (session), uri, CAMEL_PROVIDER_STORE, NULL); - - if (store != NULL) { - CamelService *service; - CamelProvider *provider; - - service = CAMEL_SERVICE (store); - provider = camel_service_get_provider (service); - - if ((provider->flags & CAMEL_PROVIDER_IS_STORAGE) != 0) - e_mail_store_add (session, store, account->name); - - g_object_unref (store); - } + e_mail_store_add_by_account (session, account); } static void diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index e5ef9d4f0c..2a980cc975 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -71,7 +71,7 @@ struct _selected_uri { gchar *key; /* store:path or account/path */ gchar *uri; - CamelStore *store; + CamelService *service; gchar *path; }; @@ -370,8 +370,8 @@ static void folder_tree_free_select_uri (struct _selected_uri *u) { g_free (u->uri); - if (u->store) - g_object_unref (u->store); + if (u->service) + g_object_unref (u->service); g_free (u->key); g_free (u->path); g_free (u); @@ -473,8 +473,7 @@ folder_tree_expand_node (const gchar *key, if ((account = e_get_account_by_uid (uid)) && account->enabled) { store = (CamelStore *) camel_session_get_service ( - CAMEL_SESSION (session), account->source->url, - CAMEL_PROVIDER_STORE, NULL); + CAMEL_SESSION (session), account->uid); if (store == NULL) return; @@ -2723,27 +2722,32 @@ em_folder_tree_set_selected_list (EMFolderTree *folder_tree, struct _selected_uri *u = g_malloc0 (sizeof (*u)); CamelURL *url; + url = camel_url_new (u->uri, NULL); + + if (url != NULL) { + CamelService *service; + + service = camel_session_get_service_by_url ( + CAMEL_SESSION (session), url); + if (CAMEL_IS_STORE (service)) + u->service = g_object_ref (service); + } + u->uri = g_strdup (list->data); - u->store = (CamelStore *) camel_session_get_service ( - CAMEL_SESSION (session), u->uri, - CAMEL_PROVIDER_STORE, NULL); - url = camel_url_new (u->uri, NULL); - if (u->store == NULL || url == NULL) { + if (u->service == NULL || url == NULL) { if (!expand_only) { u->key = g_strdup_printf("dummy-%d:%s", id++, u->uri); g_hash_table_insert (priv->select_uris_table, u->key, u); priv->select_uris = g_slist_append (priv->select_uris, u); } } else { - CamelService *service; CamelProvider *provider; const gchar *path; gchar *expand_key, *end; EAccount *account; - service = CAMEL_SERVICE (u->store); - provider = camel_service_get_provider (service); + provider = camel_service_get_provider (u->service); if (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH) path = url->fragment; @@ -2757,7 +2761,7 @@ em_folder_tree_set_selected_list (EMFolderTree *folder_tree, * this made up path rather than the euri? */ if ((account = e_get_account_by_source_url (u->uri))) expand_key = g_strdup_printf ("%s/%s", account->uid, path); - else if (CAMEL_IS_VEE_STORE (u->store)) + else if (CAMEL_IS_VEE_STORE (u->service)) expand_key = g_strdup_printf ("vfolder/%s", path); else expand_key = g_strdup_printf ("local/%s", path); diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c index e115929e4c..9ea2521fb3 100644 --- a/mail/em-folder-utils.c +++ b/mail/em-folder-utils.c @@ -298,7 +298,7 @@ emfu_copy_folder_selected (EMailBackend *backend, struct _copy_folder_data *cfd = data; CamelStore *fromstore = NULL, *tostore = NULL; CamelStore *local_store; - CamelService *service; + CamelService *service = NULL; CamelProvider *provider; const gchar *tobase = NULL; CamelURL *url; @@ -312,9 +312,17 @@ emfu_copy_folder_selected (EMailBackend *backend, local_store = e_mail_local_get_store (); session = e_mail_backend_get_session (backend); - fromstore = camel_session_get_store ( - CAMEL_SESSION (session), cfd->fi->uri, &local_error); - if (fromstore == NULL) { + url = camel_url_new (cfd->fi->uri, &local_error); + if (url != NULL) { + service = camel_session_get_service_by_url ( + CAMEL_SESSION (session), url); + camel_url_free (url); + } + + if (service != NULL) + camel_service_connect_sync (service, &local_error); + + if (local_error != NULL) { e_mail_backend_submit_alert ( backend, cfd->delete ? "mail:no-move-folder-notexist" : @@ -324,6 +332,10 @@ emfu_copy_folder_selected (EMailBackend *backend, goto fail; } + g_return_if_fail (CAMEL_IS_STORE (service)); + + fromstore = CAMEL_STORE (service); + if (cfd->delete && fromstore == local_store && emfu_is_special_local_folder (cfd->fi->full_name)) { e_mail_backend_submit_alert ( backend, "mail:no-rename-special-folder", @@ -331,9 +343,17 @@ emfu_copy_folder_selected (EMailBackend *backend, goto fail; } - tostore = camel_session_get_store ( - CAMEL_SESSION (session), uri, &local_error); - if (tostore == NULL) { + url = camel_url_new (uri, &local_error); + if (url != NULL) { + service = camel_session_get_service_by_url ( + CAMEL_SESSION (session), url); + camel_url_free (url); + } + + if (service != NULL) + camel_service_connect_sync (service, &local_error); + + if (local_error != NULL) { e_mail_backend_submit_alert ( backend, cfd->delete ? "mail:no-move-folder-to-notexist" : @@ -343,7 +363,9 @@ emfu_copy_folder_selected (EMailBackend *backend, goto fail; } - service = CAMEL_SERVICE (tostore); + g_return_if_fail (CAMEL_IS_STORE (service)); + + tostore = CAMEL_STORE (service); provider = camel_service_get_provider (service); url = camel_url_new (uri, NULL); @@ -359,11 +381,6 @@ emfu_copy_folder_selected (EMailBackend *backend, camel_url_free (url); fail: - if (fromstore) - g_object_unref (fromstore); - if (tostore) - g_object_unref (tostore); - g_clear_error (&local_error); g_free (cfd); @@ -682,7 +699,8 @@ emfu_popup_new_folder_response (EMFolderSelector *emfs, EMailSession *session; GtkTreeModel *model; const gchar *uri, *path; - CamelStore *store; + CamelService *service = NULL; + CamelURL *url; struct _EMCreateFolderTempData *emcftd; if (response != GTK_RESPONSE_OK) { @@ -699,22 +717,23 @@ emfu_popup_new_folder_response (EMFolderSelector *emfs, session = em_folder_tree_get_session (folder_tree); - store = (CamelStore *) camel_session_get_service ( - CAMEL_SESSION (session), uri, - CAMEL_PROVIDER_STORE, NULL); - if (store == NULL) + url = camel_url_new (uri, NULL); + if (url != NULL) { + service = camel_session_get_service_by_url ( + CAMEL_SESSION (session), url); + camel_url_free (url); + } + + if (!CAMEL_IS_STORE (service)) return; model = gtk_tree_view_get_model (GTK_TREE_VIEW (emfs->emft)); si = em_folder_tree_model_lookup_store_info ( - EM_FOLDER_TREE_MODEL (model), store); - if (si == NULL) { - g_object_unref (store); - g_return_if_reached (); - } + EM_FOLDER_TREE_MODEL (model), CAMEL_STORE (service)); + g_return_if_fail (si != NULL); /* HACK: we need to create vfolders using the vfolder editor */ - if (CAMEL_IS_VEE_STORE (store)) { + if (CAMEL_IS_VEE_STORE (service)) { EFilterRule *rule; rule = em_vfolder_rule_new (session); @@ -729,12 +748,12 @@ emfu_popup_new_folder_response (EMFolderSelector *emfs, emcftd->emft = folder_tree; g_object_ref (emfs); - emfu_create_folder_real (si->store, path, new_folder_created_cb, emcftd); + emfu_create_folder_real ( + si->store, path, new_folder_created_cb, emcftd); } - - g_object_unref (store); } + /* FIXME: these functions must be documented */ void em_folder_utils_create_folder (CamelFolderInfo *folderinfo, diff --git a/mail/em-subscription-editor.c b/mail/em-subscription-editor.c index 99aa6f5247..368abcbe50 100644 --- a/mail/em-subscription-editor.c +++ b/mail/em-subscription-editor.c @@ -794,7 +794,7 @@ subscription_editor_add_account (EMSubscriptionEditor *editor, EAccount *account) { StoreData *data; - CamelStore *store; + CamelService *service; CamelSession *session; GtkListStore *list_store; GtkTreeStore *tree_store; @@ -804,16 +804,14 @@ subscription_editor_add_account (EMSubscriptionEditor *editor, GtkComboBoxText *combo_box; GtkWidget *container; GtkWidget *widget; - const gchar *url; combo_box = GTK_COMBO_BOX_TEXT (editor->priv->combo_box); gtk_combo_box_text_append_text (combo_box, account->name); session = em_subscription_editor_get_session (editor); - url = e_account_get_string (account, E_ACCOUNT_SOURCE_URL); + service = camel_session_get_service (session, account->uid); - store = (CamelStore *) camel_session_get_service ( - session, url, CAMEL_PROVIDER_STORE, NULL); + g_return_if_fail (CAMEL_IS_STORE (service)); tree_store = gtk_tree_store_new ( N_COLUMNS, @@ -891,7 +889,7 @@ subscription_editor_add_account (EMSubscriptionEditor *editor, data = g_slice_new0 (StoreData); data->account = g_object_ref (account); - data->store = g_object_ref (store); + data->store = g_object_ref (service); data->tree_view = g_object_ref (widget); data->list_store = GTK_TREE_MODEL (list_store); data->tree_store = GTK_TREE_MODEL (tree_store); diff --git a/mail/em-utils.c b/mail/em-utils.c index 7ebe28c11e..cee383b467 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -2429,26 +2429,14 @@ emu_restore_folder_tree_state (EMFolderTree *folder_tree) g_key_file_free (key_file); } -/* checks whether uri points to a local mbox file and returns TRUE if yes. */ +/* Returns TRUE if CamelURL points to a local mbox file. */ gboolean -em_utils_is_local_delivery_mbox_file (const gchar *uri) +em_utils_is_local_delivery_mbox_file (CamelURL *url) { - g_return_val_if_fail (uri != NULL, FALSE); - - if (g_str_has_prefix (uri, "mbox:///")) { - CamelURL *curl; - - curl = camel_url_new (uri, NULL); - if (curl) { - if (curl->path - && g_file_test (curl->path, G_FILE_TEST_EXISTS) - && !g_file_test (curl->path, G_FILE_TEST_IS_DIR)) { - camel_url_free (curl); - return TRUE; - } - camel_url_free (curl); - } - } + g_return_val_if_fail (url != NULL, FALSE); - return FALSE; + return g_str_has_prefix (url->protocol, "mbox:") && + (url->path != NULL) && + g_file_test (url->path, G_FILE_TEST_EXISTS) && + !g_file_test (url->path, G_FILE_TEST_IS_DIR); } diff --git a/mail/em-utils.h b/mail/em-utils.h index 73916b1c19..12fa7b36d5 100644 --- a/mail/em-utils.h +++ b/mail/em-utils.h @@ -102,7 +102,7 @@ void emu_free_mail_cache (void); void emu_restore_folder_tree_state (EMFolderTree *folder_tree); -gboolean em_utils_is_local_delivery_mbox_file (const gchar *uri); +gboolean em_utils_is_local_delivery_mbox_file (CamelURL *url); G_END_DECLS diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 3c3d65a389..f5a31e3ba7 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -69,13 +69,12 @@ struct _filter_mail_msg { struct _fetch_mail_msg { struct _filter_mail_msg fmsg; + CamelStore *store; GCancellable *cancellable; /* we have our own cancellation * struct, the other should be empty */ gint keep; /* keep on server? */ - gchar *source_uri; - - void (*done)(const gchar *source, gpointer data); + void (*done)(gpointer data); gpointer data; }; @@ -234,6 +233,7 @@ fetch_mail_exec (struct _fetch_mail_msg *m, GError **error) { struct _filter_mail_msg *fm = (struct _filter_mail_msg *)m; + CamelURL *url; gint i; fm->destination = e_mail_local_get_folder (E_MAIL_LOCAL_FOLDER_LOCAL_INBOX); @@ -243,29 +243,38 @@ fetch_mail_exec (struct _fetch_mail_msg *m, /* FIXME: this should support keep_on_server too, which would then perform a spool access thingy, right? problem is matching raw messages to uid's etc. */ - if (em_utils_is_local_delivery_mbox_file (m->source_uri)) { - gchar *path = mail_tool_do_movemail (m->source_uri, error); + url = camel_service_get_camel_url (CAMEL_SERVICE (m->store)); + if (em_utils_is_local_delivery_mbox_file (url)) { + gchar *path; + gchar *url_string; + + path = mail_tool_do_movemail (m->store, error); + url_string = camel_url_to_string (url, CAMEL_URL_HIDE_ALL); if (path && (!error || !*error)) { camel_folder_freeze (fm->destination); camel_filter_driver_set_default_folder ( fm->driver, fm->destination); camel_filter_driver_filter_mbox ( - fm->driver, path, m->source_uri, + fm->driver, path, url_string, cancellable, error); camel_folder_thaw (fm->destination); if (!error || !*error) g_unlink (path); } + g_free (path); + g_free (url_string); } else { CamelFolder *folder; + const gchar *uid; + + uid = camel_service_get_uid (CAMEL_SERVICE (m->store)); folder = fm->source_folder = e_mail_session_get_inbox_sync ( - fm->session, m->source_uri, - cancellable, error); + fm->session, uid, cancellable, error); if (folder) { /* this handles 'keep on server' stuff, if we have any new uid's to copy @@ -345,13 +354,14 @@ static void fetch_mail_done (struct _fetch_mail_msg *m) { if (m->done) - m->done (m->source_uri, m->data); + m->done (m->data); } static void fetch_mail_free (struct _fetch_mail_msg *m) { - g_free (m->source_uri); + if (m->store != NULL) + g_object_unref (m->store); if (m->cancellable != NULL) g_object_unref (m->cancellable); @@ -369,8 +379,7 @@ static MailMsgInfo fetch_mail_info = { /* ouch, a 'do everything' interface ... */ void -mail_fetch_mail (EMailSession *session, - const gchar *source, +mail_fetch_mail (CamelStore *store, gint keep, const gchar *type, GCancellable *cancellable, @@ -378,16 +387,21 @@ mail_fetch_mail (EMailSession *session, gpointer get_data, CamelFilterStatusFunc *status, gpointer status_data, - void (*done)(const gchar *source, gpointer data), + void (*done)(gpointer data), gpointer data) { struct _fetch_mail_msg *m; struct _filter_mail_msg *fm; + CamelSession *session; + + g_return_if_fail (CAMEL_IS_STORE (store)); + + session = camel_service_get_session (CAMEL_SERVICE (store)); m = mail_msg_new (&fetch_mail_info); fm = (struct _filter_mail_msg *)m; fm->session = g_object_ref (session); - m->source_uri = g_strdup (source); + m->store = g_object_ref (store); fm->delete = !keep; fm->cache = NULL; if (cancellable) @@ -395,8 +409,7 @@ mail_fetch_mail (EMailSession *session, m->done = done; m->data = data; - fm->driver = camel_session_get_filter_driver ( - CAMEL_SESSION (session), type, NULL); + fm->driver = camel_session_get_filter_driver (session, type, NULL); camel_filter_driver_set_folder_func (fm->driver, get_folder, get_data); if (status) camel_filter_driver_set_status_func (fm->driver, status, status_data); @@ -447,7 +460,7 @@ struct _send_queue_msg { EMailSession *session; CamelFolder *queue; - gchar *destination; + CamelTransport *transport; CamelFilterDriver *driver; @@ -455,7 +468,7 @@ struct _send_queue_msg { CamelFilterStatusFunc *status; gpointer status_data; - void (*done)(const gchar *destination, gpointer data); + void (*done)(gpointer data); gpointer data; }; @@ -466,7 +479,7 @@ static void mail_send_message (struct _send_queue_msg *m, CamelFolder *queue, const gchar *uid, - const gchar *destination, + CamelTransport *transport, CamelFilterDriver *driver, GCancellable *cancellable, GError **error) @@ -475,9 +488,8 @@ mail_send_message (struct _send_queue_msg *m, const CamelInternetAddress *iaddr; CamelAddress *from, *recipients; CamelMessageInfo *info = NULL; - CamelTransport *xport = NULL; CamelProvider *provider; - gchar *transport_url = NULL; + gchar *transport_uid = NULL; gchar *sent_folder_uri = NULL; const gchar *resent_from, *tmp; CamelFolder *folder = NULL; @@ -505,8 +517,20 @@ mail_send_message (struct _send_queue_msg *m, if ((account = e_get_account_by_uid (name)) /* 'old' x-evolution-account stored the name, how silly */ || (account = e_get_account_by_name (name))) { - if (account->transport && account->transport->url) - transport_url = g_strdup (account->transport->url); + if (account->transport) { + CamelService *service; + gchar *transport_uid; + + transport_uid = g_strconcat ( + account->uid, "-transport", NULL); + service = camel_session_get_service ( + CAMEL_SESSION (m->session), + transport_uid); + g_free (transport_uid); + + if (CAMEL_IS_TRANSPORT (service)) + transport = CAMEL_TRANSPORT (service); + } sent_folder_uri = g_strdup (account->sent_folder_uri); } @@ -517,20 +541,28 @@ mail_send_message (struct _send_queue_msg *m, /* default back to these headers */ tmp = camel_header_raw_find(&xev, "X-Evolution-Transport", NULL); if (tmp) - transport_url = g_strstrip (g_strdup (tmp)); + transport_uid = g_strstrip (g_strdup (tmp)); tmp = camel_header_raw_find(&xev, "X-Evolution-Fcc", NULL); if (tmp) sent_folder_uri = g_strstrip (g_strdup (tmp)); } - if (transport_url || destination) { - gchar *escaped = escape_percent_sign (transport_url ? transport_url : destination); + if (transport != NULL) { + CamelURL *url; + gchar *url_string; + gchar *escaped; + + url = camel_service_get_camel_url (CAMEL_SERVICE (transport)); + url_string = camel_url_to_string (url, CAMEL_URL_HIDE_ALL); + escaped = escape_percent_sign (url_string); - /* let the dialog know the right account it is using; percentage is ignored */ + /* Let the dialog know the right account it is using. */ report_status (m, CAMEL_FILTER_STATUS_ACTION, 0, escaped); g_free (escaped); + g_free (url_string); + camel_url_free (url); } /* Check for email sending */ @@ -553,15 +585,13 @@ mail_send_message (struct _send_queue_msg *m, } if (camel_address_length (recipients) > 0) { - xport = camel_session_get_transport ( - CAMEL_SESSION (m->session), - transport_url ? transport_url : - destination, error); - if (xport == NULL) + if (!camel_service_connect_sync ( + CAMEL_SERVICE (transport), error)) goto exit; if (!camel_transport_send_to_sync ( - xport, message, from, recipients, cancellable, error)) + transport, message, from, + recipients, cancellable, error)) goto exit; } @@ -612,10 +642,7 @@ mail_send_message (struct _send_queue_msg *m, } } - if (xport != NULL) - provider = camel_service_get_provider (CAMEL_SERVICE (xport)); - else - provider = NULL; + provider = camel_service_get_provider (CAMEL_SERVICE (transport)); if (provider == NULL || !(provider->flags & CAMEL_PROVIDER_DISABLE_SENT_FOLDER)) { @@ -714,10 +741,8 @@ exit: camel_message_info_free (info); g_object_unref (recipients); g_object_unref (from); - if (xport) - g_object_unref (xport); g_free (sent_folder_uri); - g_free (transport_url); + g_free (transport_uid); camel_header_raw_clear (&xev); g_string_free (err, TRUE); g_object_unref (message); @@ -797,7 +822,7 @@ send_queue_exec (struct _send_queue_msg *m, cancellable, (i+1) * 100 / send_uids->len); mail_send_message ( - m, m->queue, send_uids->pdata[i], m->destination, + m, m->queue, send_uids->pdata[i], m->transport, m->driver, cancellable, &local_error); if (local_error != NULL) { if (!g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { @@ -865,7 +890,7 @@ static void send_queue_done (struct _send_queue_msg *m) { if (m->done) - m->done (m->destination, m->data); + m->done (m->data); } static gchar * @@ -881,8 +906,9 @@ send_queue_free (struct _send_queue_msg *m) g_object_unref (m->session); if (m->driver != NULL) g_object_unref (m->driver); + if (m->transport != NULL) + g_object_unref (m->transport); g_object_unref (m->queue); - g_free (m->destination); } static MailMsgInfo send_queue_info = { @@ -897,14 +923,14 @@ static MailMsgInfo send_queue_info = { void mail_send_queue (EMailSession *session, CamelFolder *queue, - const gchar *destination, + CamelTransport *transport, const gchar *type, GCancellable *cancellable, CamelFilterGetFolderFunc get_folder, gpointer get_data, CamelFilterStatusFunc *status, gpointer status_data, - void (*done)(const gchar *destination, gpointer data), + void (*done)(gpointer data), gpointer data) { struct _send_queue_msg *m; @@ -912,7 +938,7 @@ mail_send_queue (EMailSession *session, m = mail_msg_new (&send_queue_info); m->session = g_object_ref (session); m->queue = g_object_ref (queue); - m->destination = g_strdup (destination); + m->transport = g_object_ref (transport); if (G_IS_CANCELLABLE (cancellable)) e_activity_set_cancellable (m->base.activity, cancellable); m->status = status; @@ -1360,83 +1386,6 @@ mail_get_folder_quota (CamelFolder *folder, return id; } -/* ** GET STORE ******************************************************* */ - -struct _get_store_msg { - MailMsg base; - - EMailSession *session; - gchar *uri; - CamelStore *store; - void (*done) (gchar *uri, CamelStore *store, gpointer data); - gpointer data; -}; - -static gchar * -get_store_desc (struct _get_store_msg *m) -{ - return g_strdup_printf (_("Opening store '%s'"), m->uri); -} - -static void -get_store_exec (struct _get_store_msg *m, - GCancellable *cancellable, - GError **error) -{ - /*camel_session_get_store connects us, which we don't want to do on startup. */ - - m->store = (CamelStore *) camel_session_get_service ( - CAMEL_SESSION (m->session), m->uri, - CAMEL_PROVIDER_STORE, error); -} - -static void -get_store_done (struct _get_store_msg *m) -{ - if (m->done) - m->done (m->uri, m->store, m->data); -} - -static void -get_store_free (struct _get_store_msg *m) -{ - g_object_unref (m->session); - g_free (m->uri); - if (m->store) - g_object_unref (m->store); -} - -static MailMsgInfo get_store_info = { - sizeof (struct _get_store_msg), - (MailMsgDescFunc) get_store_desc, - (MailMsgExecFunc) get_store_exec, - (MailMsgDoneFunc) get_store_done, - (MailMsgFreeFunc) get_store_free -}; - -gint -mail_get_store (EMailSession *session, - const gchar *uri, - GCancellable *cancellable, - void (*done) (gchar *uri, CamelStore *store, gpointer data), - gpointer data) -{ - struct _get_store_msg *m; - gint id; - - m = mail_msg_new (&get_store_info); - if (G_IS_CANCELLABLE (cancellable)) - e_activity_set_cancellable (m->base.activity, cancellable); - m->session = g_object_ref (session); - m->uri = g_strdup (uri); - m->data = data; - m->done = done; - - id = m->base.seq; - mail_msg_unordered_push (m); - return id; -} - /* ** REMOVE FOLDER ******************************************************* */ struct _remove_folder_msg { @@ -1881,7 +1830,8 @@ expunge_pop3_stores (CamelFolder *expunging, EMailSession *session, GCancellable if (account->enabled && account->source && account->source->url && g_str_has_prefix (account->source->url, "pop://")) { gboolean any_found = FALSE; - folder = e_mail_session_get_inbox_sync (session, account->source->url, cancellable, error); + folder = e_mail_session_get_inbox_sync ( + session, account->uid, cancellable, error); if (!folder || (error && *error)) continue; @@ -1925,15 +1875,10 @@ expunge_folder_exec (struct _sync_folder_msg *m, gboolean is_local_inbox_or_trash = m->folder == e_mail_local_get_folder (E_MAIL_LOCAL_FOLDER_INBOX); if (!is_local_inbox_or_trash && e_mail_local_get_store () == camel_folder_get_parent_store (m->folder)) { - const gchar *data_dir; CamelFolder *trash; - gchar *uri; - data_dir = mail_session_get_data_dir (); - uri = g_strdup_printf ("maildir:%s/local", data_dir); trash = e_mail_session_get_trash_sync ( - m->session, uri, cancellable, error); - g_free (uri); + m->session, "local", cancellable, error); is_local_inbox_or_trash = m->folder == trash; @@ -1996,20 +1941,12 @@ empty_trash_exec (struct _empty_trash_msg *m, GError **error) { CamelFolder *trash; - const gchar *data_dir; - gchar *uri; + const gchar *uid; - if (m->account) { - trash = e_mail_session_get_trash_sync ( - m->session, m->account->source->url, - cancellable, error); - } else { - data_dir = mail_session_get_data_dir (); - uri = g_strdup_printf ("maildir:%s/local", data_dir); - trash = e_mail_session_get_trash_sync ( - m->session, uri, cancellable, error); - g_free (uri); - } + uid = (m->account != NULL) ? m->account->uid : "local"; + + trash = e_mail_session_get_trash_sync ( + m->session, uid, cancellable, error); if (trash) { /* do this before expunge, to know which messages will be expunged */ @@ -2504,11 +2441,10 @@ struct _check_msg { MailMsg base; EMailSession *session; - gchar *url; - CamelProviderType type; + gchar *service_uid; GList *authtypes; - void (*done)(const gchar *url, CamelProviderType type, GList *types, gpointer data); + void (*done)(GList *types, gpointer data); gpointer data; }; @@ -2526,7 +2462,7 @@ check_service_exec (struct _check_msg *m, CamelService *service; service = camel_session_get_service ( - CAMEL_SESSION (m->session), m->url, m->type, error); + CAMEL_SESSION (m->session), m->service_uid); if (!service) return; @@ -2539,14 +2475,14 @@ static void check_service_done (struct _check_msg *m) { if (m->done) - m->done (m->url, m->type, m->authtypes, m->data); + m->done (m->authtypes, m->data); } static void check_service_free (struct _check_msg *m) { g_object_unref (m->session); - g_free (m->url); + g_free (m->service_uid); g_list_free (m->authtypes); } @@ -2560,9 +2496,8 @@ static MailMsgInfo check_service_info = { gint mail_check_service (EMailSession *session, - const gchar *url, - CamelProviderType type, - void (*done)(const gchar *url, CamelProviderType type, GList *authtypes, gpointer data), + const gchar *service_uid, + void (*done)(GList *authtypes, gpointer data), gpointer data) { struct _check_msg *m; @@ -2570,8 +2505,7 @@ mail_check_service (EMailSession *session, m = mail_msg_new (&check_service_info); m->session = g_object_ref (session); - m->url = g_strdup (url); - m->type = type; + m->service_uid = g_strdup (service_uid); m->done = done; m->data = data; diff --git a/mail/mail-ops.h b/mail/mail-ops.h index 98f9125ff7..c4026416f3 100644 --- a/mail/mail-ops.h +++ b/mail/mail-ops.h @@ -66,13 +66,6 @@ gint mail_get_folder_quota (CamelFolder *folder, void (*done)(CamelFolder *folder, const gchar *folder_uri, CamelFolderQuotaInfo *quota, gpointer data), gpointer data, MailMsgDispatchFunc dispatch); -/* and for a store */ -gint mail_get_store (EMailSession *session, - const gchar *uri, - GCancellable *cancellable, - void (*done) (gchar *uri, CamelStore *store, gpointer data), - gpointer data); - /* build an attachment */ void mail_build_attachment (CamelFolder *folder, GPtrArray *uids, void (*done)(CamelFolder *folder, GPtrArray *messages, @@ -123,18 +116,17 @@ gint mail_save_messages (CamelFolder *folder, GPtrArray *uids, const gchar *path /* yeah so this is messy, but it does a lot, maybe i can consolidate all user_data's to be the one */ void mail_send_queue (EMailSession *session, CamelFolder *queue, - const gchar *destination, + CamelTransport *transport, const gchar *type, GCancellable *cancellable, CamelFilterGetFolderFunc get_folder, gpointer get_data, CamelFilterStatusFunc *status, gpointer status_data, - void (*done)(const gchar *destination, gpointer data), + void (*done)(gpointer data), gpointer data); -void mail_fetch_mail (EMailSession *session, - const gchar *source, +void mail_fetch_mail (CamelStore *store, gint keep, const gchar *type, GCancellable *cancellable, @@ -142,7 +134,7 @@ void mail_fetch_mail (EMailSession *session, gpointer get_data, CamelFilterStatusFunc *status, gpointer status_data, - void (*done)(const gchar *source, gpointer data), + void (*done)(gpointer data), gpointer data); void mail_filter_folder (EMailSession *session, @@ -158,9 +150,8 @@ gint mail_store_prepare_offline (CamelStore *store); void mail_execute_shell_command (CamelFilterDriver *driver, gint argc, gchar **argv, gpointer data); gint mail_check_service (EMailSession *session, - const gchar *url, - CamelProviderType type, - void (*done)(const gchar *url, CamelProviderType type, GList *authtypes, gpointer data), + const gchar *service_uid, + void (*done)(GList *authtypes, gpointer data), gpointer data); gint mail_disconnect_store (CamelStore *store); diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c index e548d8b596..b54e433968 100644 --- a/mail/mail-send-recv.c +++ b/mail/mail-send-recv.c @@ -103,7 +103,7 @@ struct _send_info { send_info_t type; /* 0 = fetch, 1 = send */ EMailSession *session; GCancellable *cancellable; - gchar *uri; + gchar *service_uid; gboolean keep_on_server; send_state_t state; GtkWidget *progress_bar; @@ -149,7 +149,7 @@ free_send_info (struct _send_info *info) g_object_unref (info->session); if (info->cancellable) g_object_unref (info->cancellable); - g_free (info->uri); + g_free (info->service_uid); if (info->timeout_id != 0) g_source_remove (info->timeout_id); g_free (info->what); @@ -265,7 +265,7 @@ dialog_response (GtkDialog *gd, gint button, struct _send_data *data) } static GStaticMutex status_lock = G_STATIC_MUTEX_INIT; -static gchar *format_url (const gchar *internal_url, const gchar *account_name); +static gchar *format_url (EAccount *account, const gchar *internal_url); static gint operation_status_timeout (gpointer data) @@ -283,7 +283,7 @@ operation_status_timeout (gpointer data) GTK_LABEL (info->status_label), info->what); if (info->send_url && info->send_account_label) { - gchar *tmp = format_url (info->send_url, NULL); + gchar *tmp = format_url (NULL, info->send_url); g_free (info->send_url); info->send_url = NULL; @@ -337,26 +337,27 @@ operation_status (CamelOperation *op, } static gchar * -format_url (const gchar *internal_url, const gchar *account_name) +format_url (EAccount *account, + const gchar *internal_url) { CamelURL *url; gchar *pretty_url = NULL; url = camel_url_new (internal_url, NULL); - if (account_name) { + if (account != NULL && account->name != NULL) { if (url->host && *url->host) pretty_url = g_strdup_printf ( "<b>%s (%s)</b>: %s", - account_name, url->protocol, url->host); + account->name, url->protocol, url->host); else if (url->path) pretty_url = g_strdup_printf ( "<b>%s (%s)</b>: %s", - account_name, url->protocol, url->path); + account->name, url->protocol, url->path); else pretty_url = g_strdup_printf ( "<b>%s (%s)</b>", - account_name, url->protocol); + account->name, url->protocol); } else if (url) { if (url->host && *url->host) @@ -379,7 +380,7 @@ format_url (const gchar *internal_url, const gchar *account_name) } static send_info_t -get_receive_type (const gchar *url) +get_receive_type (CamelURL *url) { CamelProvider *provider; @@ -388,7 +389,7 @@ get_receive_type (const gchar *url) if (em_utils_is_local_delivery_mbox_file (url)) return SEND_RECEIVE; - provider = camel_provider_get (url, NULL); + provider = camel_provider_get (url->protocol, NULL); if (!provider) return SEND_INVALID; @@ -410,7 +411,7 @@ build_dialog (GtkWindow *parent, EMailSession *session, EAccountList *accounts, CamelFolder *outbox, - const gchar *destination, + EAccount *outgoing_account, gboolean allow_send) { GtkDialog *gd; @@ -475,7 +476,7 @@ build_dialog (GtkWindow *parent, /* Check to see if we have to send any mails. * If we don't, don't display the SMTP row in the table. */ - if (outbox && destination + if (outbox && outgoing_account && (camel_folder_get_message_count (outbox) - camel_folder_get_deleted_message_count (outbox)) == 0) num_sources--; @@ -516,11 +517,17 @@ build_dialog (GtkWindow *parent, } /* see if we have an outstanding download active */ - info = g_hash_table_lookup (data->active, source->url); + info = g_hash_table_lookup (data->active, account->uid); if (info == NULL) { - send_info_t type; + CamelURL *url; + send_info_t type = SEND_INVALID; + + url = camel_url_new (source->url, NULL); + if (url != NULL) { + type = get_receive_type (url); + camel_url_free (url); + } - type = get_receive_type (source->url); if (type == SEND_INVALID || type == SEND_SEND) { e_iterator_next (iter); continue; @@ -532,7 +539,7 @@ build_dialog (GtkWindow *parent, d(printf("adding source %s\n", source->url)); - info->uri = g_strdup (source->url); + info->service_uid = g_strdup (account->uid); info->keep_on_server = source->keep_on_server; info->cancellable = camel_operation_new (); info->state = allow_send ? SEND_ACTIVE : SEND_COMPLETE; @@ -542,7 +549,8 @@ build_dialog (GtkWindow *parent, info->cancellable, "status", G_CALLBACK (operation_status), info); - g_hash_table_insert (data->active, info->uri, info); + g_hash_table_insert ( + data->active, info->service_uid, info); list = g_list_prepend (list, info); } else if (info->progress_bar != NULL) { /* incase we get the same source pop up again */ @@ -553,7 +561,7 @@ build_dialog (GtkWindow *parent, recv_icon = gtk_image_new_from_icon_name ( "mail-inbox", GTK_ICON_SIZE_LARGE_TOOLBAR); - pretty_url = format_url (source->url, account->name); + pretty_url = format_url (account, source->url); label = gtk_label_new (NULL); gtk_label_set_ellipsize ( GTK_LABEL (label), PANGO_ELLIPSIZE_END); @@ -612,22 +620,29 @@ build_dialog (GtkWindow *parent, (EEvent *) em_event_peek (), "mail.sendreceive", (EEventTarget *) target); - /* Skip displaying the SMTP row if we've got no outbox, destination or unsent mails */ - if (allow_send && outbox && destination + /* Skip displaying the SMTP row if we've got no outbox, + * outgoing account or unsent mails. */ + if (allow_send && outbox && outgoing_account && (camel_folder_get_message_count (outbox) - camel_folder_get_deleted_message_count (outbox)) != 0) { info = g_hash_table_lookup (data->active, SEND_URI_KEY); if (info == NULL) { + gchar *transport_uid; + + transport_uid = g_strconcat ( + outgoing_account->uid, "-transport", NULL); + info = g_malloc0 (sizeof (*info)); info->type = SEND_SEND; - d(printf("adding dest %s\n", destination)); - info->uri = g_strdup (destination); + info->service_uid = g_strdup (transport_uid); info->keep_on_server = FALSE; info->cancellable = camel_operation_new (); info->state = SEND_ACTIVE; info->timeout_id = g_timeout_add (STATUS_TIMEOUT, operation_status_timeout, info); + g_free (transport_uid); + g_signal_connect ( info->cancellable, "status", G_CALLBACK (operation_status), info); @@ -639,7 +654,9 @@ build_dialog (GtkWindow *parent, send_icon = gtk_image_new_from_icon_name ( "mail-outbox", GTK_ICON_SIZE_LARGE_TOOLBAR); - pretty_url = format_url (destination, NULL); + pretty_url = format_url ( + outgoing_account, + outgoing_account->transport->url); label = gtk_label_new (NULL); gtk_label_set_ellipsize ( GTK_LABEL (label), PANGO_ELLIPSIZE_END); @@ -756,20 +773,29 @@ receive_status (CamelFilterDriver *driver, /* when receive/send is complete */ static void -receive_done (const gchar *uri, gpointer data) +receive_done (gpointer data) { struct _send_info *info = data; /* if we've been called to run again - run again */ if (info->type == SEND_SEND && info->state == SEND_ACTIVE && info->again) { CamelFolder *local_outbox; + CamelService *service; + + local_outbox = e_mail_local_get_folder ( + E_MAIL_LOCAL_FOLDER_OUTBOX); + + service = camel_session_get_service ( + CAMEL_SESSION (info->session), + info->service_uid); - local_outbox = e_mail_local_get_folder (E_MAIL_LOCAL_FOLDER_OUTBOX); + g_return_if_fail (CAMEL_IS_TRANSPORT (service)); info->again = 0; mail_send_queue ( info->session, - local_outbox, info->uri, + local_outbox, + CAMEL_TRANSPORT (service), E_FILTER_SOURCE_OUTGOING, info->cancellable, receive_get_folder, info, @@ -802,7 +828,7 @@ receive_done (const gchar *uri, gpointer data) if (info->type == SEND_SEND) g_hash_table_steal (info->data->active, SEND_URI_KEY); else - g_hash_table_steal (info->data->active, info->uri); + g_hash_table_steal (info->data->active, info->service_uid); info->data->infos = g_list_remove (info->data->infos, info); if (g_hash_table_size (info->data->active) == 0) { @@ -938,7 +964,7 @@ refresh_folders_exec (struct _refresh_folders_msg *m, static void refresh_folders_done (struct _refresh_folders_msg *m) { - receive_done("", m->info); + receive_done (m->info); } static void @@ -985,17 +1011,17 @@ receive_update_got_folderinfo (MailFolderCache *folder_cache, /* do not free folder info, we will free it later */ return FALSE; } else { - receive_done ("", data); + receive_done (data); } return TRUE; } static void -receive_update_got_store (gchar *uri, CamelStore *store, gpointer data) +receive_update_got_store (CamelStore *store, + struct _send_info *info) { MailFolderCache *folder_cache; - struct _send_info *info = data; folder_cache = e_mail_session_get_folder_cache (info->session); @@ -1006,7 +1032,7 @@ receive_update_got_store (gchar *uri, CamelStore *store, gpointer data) store, info->cancellable, receive_update_got_folderinfo, info); } else { - receive_done("", info); + receive_done (info); } } @@ -1038,15 +1064,22 @@ send_receive (GtkWindow *parent, EMailSession *session, gboolean allow_send) local_outbox = e_mail_local_get_folder (E_MAIL_LOCAL_FOLDER_OUTBOX); data = build_dialog ( parent, session, accounts, - local_outbox, account->transport->url, allow_send); - scan = data->infos; - while (scan) { + local_outbox, account, allow_send); + + for (scan = data->infos; scan != NULL; scan = scan->next) { struct _send_info *info = scan->data; + CamelService *service; + + service = camel_session_get_service ( + CAMEL_SESSION (session), info->service_uid); + + if (!CAMEL_IS_SERVICE (service)) + continue; switch (info->type) { case SEND_RECEIVE: mail_fetch_mail ( - session, info->uri, + CAMEL_STORE (service), info->keep_on_server, E_FILTER_SOURCE_INCOMING, info->cancellable, @@ -1057,7 +1090,8 @@ send_receive (GtkWindow *parent, EMailSession *session, gboolean allow_send) case SEND_SEND: /* todo, store the folder in info? */ mail_send_queue ( - session, local_outbox, info->uri, + session, local_outbox, + CAMEL_TRANSPORT (service), E_FILTER_SOURCE_OUTGOING, info->cancellable, receive_get_folder, info, @@ -1065,14 +1099,12 @@ send_receive (GtkWindow *parent, EMailSession *session, gboolean allow_send) receive_done, info); break; case SEND_UPDATE: - mail_get_store ( - session, info->uri, info->cancellable, - receive_update_got_store, info); + receive_update_got_store ( + CAMEL_STORE (service), info); break; default: break; } - scan = scan->next; } return send_recv_dialog; @@ -1104,16 +1136,8 @@ auto_timeout (gpointer data) { struct _auto_data *info = data; - if (camel_session_get_online (CAMEL_SESSION (info->session))) { - const gchar *uri; - gboolean keep_on_server; - - uri = e_account_get_string ( - info->account, E_ACCOUNT_SOURCE_URL); - keep_on_server = e_account_get_bool ( - info->account, E_ACCOUNT_SOURCE_KEEP_ON_SERVER); - mail_receive_uri (info->session, uri, keep_on_server); - } + if (camel_session_get_online (CAMEL_SESSION (info->session))) + mail_receive_account (info->session, info->account); return TRUE; } @@ -1288,37 +1312,38 @@ mail_autoreceive_init (EMailBackend *backend) /* We setup the download info's in a hashtable, if we later * need to build the gui, we insert them in to add them. */ void -mail_receive_uri (EMailSession *session, - const gchar *uri, - gboolean keep_on_server) +mail_receive_account (EMailSession *session, + EAccount *account) { struct _send_info *info; struct _send_data *data; CamelFolder *local_outbox; - send_info_t type; + CamelService *service; + CamelURL *url; + send_info_t type = SEND_INVALID; data = setup_send_data (); - info = g_hash_table_lookup (data->active, uri); - if (info != NULL) { - d(printf("download of %s still in progress\n", uri)); + info = g_hash_table_lookup (data->active, account->uid); + + if (info != NULL) return; - } - d(printf("starting non-interactive download of '%s'\n", uri)); + url = camel_url_new (account->source->url, NULL); + if (url != NULL) { + type = get_receive_type (url); + camel_url_free (url); + } - type = get_receive_type (uri); - if (type == SEND_INVALID || type == SEND_SEND) { - d(printf ("unsupported provider: '%s'\n", uri)); + if (type == SEND_INVALID || type == SEND_SEND) return; - } info = g_malloc0 (sizeof (*info)); info->type = type; info->session = g_object_ref (session); info->progress_bar = NULL; info->status_label = NULL; - info->uri = g_strdup (uri); - info->keep_on_server = keep_on_server; + info->service_uid = g_strdup (account->uid); + info->keep_on_server = account->source->keep_on_server; info->cancellable = camel_operation_new (); info->cancel_button = NULL; info->data = data; @@ -1331,12 +1356,17 @@ mail_receive_uri (EMailSession *session, d(printf("Adding new info %p\n", info)); - g_hash_table_insert (data->active, info->uri, info); + g_hash_table_insert (data->active, account->uid, info); + + service = camel_session_get_service ( + CAMEL_SESSION (session), account->uid); + + g_return_if_fail (CAMEL_IS_SERVICE (service)); switch (info->type) { case SEND_RECEIVE: mail_fetch_mail ( - info->session, info->uri, + CAMEL_STORE (service), info->keep_on_server, E_FILTER_SOURCE_INCOMING, info->cancellable, @@ -1346,10 +1376,12 @@ mail_receive_uri (EMailSession *session, break; case SEND_SEND: /* todo, store the folder in info? */ - local_outbox = e_mail_local_get_folder (E_MAIL_LOCAL_FOLDER_OUTBOX); + local_outbox = e_mail_local_get_folder ( + E_MAIL_LOCAL_FOLDER_OUTBOX); mail_send_queue ( info->session, - local_outbox, info->uri, + local_outbox, + CAMEL_TRANSPORT (service), E_FILTER_SOURCE_OUTGOING, info->cancellable, receive_get_folder, info, @@ -1357,10 +1389,7 @@ mail_receive_uri (EMailSession *session, receive_done, info); break; case SEND_UPDATE: - mail_get_store ( - info->session, - info->uri, info->cancellable, - receive_update_got_store, info); + receive_update_got_store (CAMEL_STORE (service), info); break; default: g_return_if_reached (); @@ -1371,13 +1400,16 @@ void mail_send (EMailSession *session) { CamelFolder *local_outbox; - EAccountService *transport; + CamelService *service; + EAccount *account; + CamelURL *url; struct _send_info *info; struct _send_data *data; - send_info_t type; + send_info_t type = SEND_INVALID; + gchar *transport_uid; - transport = e_get_default_transport (); - if (!transport || !transport->url) + account = e_get_default_transport (); + if (account == NULL || account->transport->url == NULL) return; data = setup_send_data (); @@ -1390,18 +1422,23 @@ mail_send (EMailSession *session) d(printf("starting non-interactive send of '%s'\n", transport->url)); - type = get_receive_type (transport->url); - if (type == SEND_INVALID) { - d(printf ("unsupported provider: '%s'\n", transport->url)); - return; + url = camel_url_new (account->transport->url, NULL); + if (url != NULL) { + type = get_receive_type (url); + camel_url_free (url); } + if (type == SEND_INVALID) + return; + + transport_uid = g_strconcat (account->uid, "-transport", NULL); + info = g_malloc0 (sizeof (*info)); info->type = SEND_SEND; info->session = g_object_ref (session); info->progress_bar = NULL; info->status_label = NULL; - info->uri = g_strdup (transport->url); + info->service_uid = g_strdup (transport_uid); info->keep_on_server = FALSE; info->cancellable = NULL; info->cancel_button = NULL; @@ -1415,9 +1452,17 @@ mail_send (EMailSession *session) /* todo, store the folder in info? */ local_outbox = e_mail_local_get_folder (E_MAIL_LOCAL_FOLDER_OUTBOX); + + service = camel_session_get_service ( + CAMEL_SESSION (session), transport_uid); + + g_free (transport_uid); + + g_return_if_fail (CAMEL_IS_TRANSPORT (service)); + mail_send_queue ( - session, - local_outbox, info->uri, + session, local_outbox, + CAMEL_TRANSPORT (service), E_FILTER_SOURCE_OUTGOING, info->cancellable, receive_get_folder, info, diff --git a/mail/mail-send-recv.h b/mail/mail-send-recv.h index 7ae0dd11d5..bba2eac67f 100644 --- a/mail/mail-send-recv.h +++ b/mail/mail-send-recv.h @@ -36,10 +36,9 @@ GtkWidget * mail_send_receive (GtkWindow *parent, GtkWidget * mail_receive (GtkWindow *parent, EMailSession *session); -/* receive a single uri */ -void mail_receive_uri (EMailSession *session, - const gchar *uri, - gboolean keep_on_server); +/* receive a single account */ +void mail_receive_account (EMailSession *session, + EAccount *account); void mail_send (EMailSession *session); diff --git a/mail/mail-tools.c b/mail/mail-tools.c index 1e1680be86..00c6b7e899 100644 --- a/mail/mail-tools.c +++ b/mail/mail-tools.c @@ -46,16 +46,18 @@ #ifndef G_OS_WIN32 static gchar * -mail_tool_get_local_movemail_path (const guchar *uri, +mail_tool_get_local_movemail_path (CamelStore *store, GError **error) { - guchar *safe_uri, *c; + const gchar *uid; + guchar *safe_uid, *c; const gchar *data_dir; gchar *path, *full; struct stat st; - safe_uri = (guchar *)g_strdup ((const gchar *)uri); - for (c = safe_uri; *c; c++) + uid = camel_service_get_uid (CAMEL_SERVICE (store)); + safe_uid = (guchar *)g_strdup ((const gchar *)uid); + for (c = safe_uid; *c; c++) if (strchr("/:;=|%&#!*^()\\, ", *c) || !isprint((gint) *c)) *c = '_'; @@ -72,9 +74,9 @@ mail_tool_get_local_movemail_path (const guchar *uri, return NULL; } - full = g_strdup_printf("%s/movemail.%s", path, safe_uri); + full = g_strdup_printf("%s/movemail.%s", path, safe_uid); g_free (path); - g_free (safe_uri); + g_free (safe_uid); return full; } @@ -82,38 +84,36 @@ mail_tool_get_local_movemail_path (const guchar *uri, #endif gchar * -mail_tool_do_movemail (const gchar *source_url, GError **error) +mail_tool_do_movemail (CamelStore *store, + GError **error) { #ifndef G_OS_WIN32 gchar *dest_path; struct stat sb; - CamelURL *uri; + CamelURL *url; gboolean success; - uri = camel_url_new (source_url, error); - if (uri == NULL) - return NULL; + g_return_val_if_fail (CAMEL_IS_STORE (store), NULL); + + url = camel_service_get_camel_url (CAMEL_SERVICE (store)); - if (strcmp (uri->protocol, "mbox") != 0) { + if (strcmp (url->protocol, "mbox") != 0) { /* This is really only an internal error anyway */ g_set_error ( error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_URL_INVALID, _("Trying to movemail a non-mbox source '%s'"), - source_url); - camel_url_free (uri); + camel_service_get_uid (CAMEL_SERVICE (store))); return NULL; } /* Set up our destination. */ - dest_path = mail_tool_get_local_movemail_path ( - (guchar *) source_url, error); + dest_path = mail_tool_get_local_movemail_path (store, error); if (dest_path == NULL) return NULL; /* Movemail from source (source_url) to dest_path */ - success = camel_movemail (uri->path, dest_path, error) != -1; - camel_url_free (uri); + success = camel_movemail (url->path, dest_path, error) != -1; if (g_stat (dest_path, &sb) < 0 || sb.st_size == 0) { g_unlink (dest_path); /* Clean up the movemail.foo file. */ diff --git a/mail/mail-tools.h b/mail/mail-tools.h index f943d963cf..779a864370 100644 --- a/mail/mail-tools.h +++ b/mail/mail-tools.h @@ -28,7 +28,7 @@ /* Does a camel_movemail into the local movemail folder * and returns the path to the new movemail folder that was created. which shoudl be freed later */ -gchar *mail_tool_do_movemail (const gchar *source_url, GError **error); +gchar *mail_tool_do_movemail (CamelStore *store, GError **error); struct _camel_header_raw *mail_tool_remove_xevolution_headers (CamelMimeMessage *message); void mail_tool_restore_xevolution_headers (CamelMimeMessage *message, struct _camel_header_raw *); diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c index b0ac26792c..aa13589ab2 100644 --- a/mail/mail-vfolder.c +++ b/mail/mail-vfolder.c @@ -1099,6 +1099,7 @@ vfolder_load_storage (EMailBackend *backend) /* lock for loading storage, it is safe to call it more than once */ G_LOCK_DEFINE_STATIC (vfolder_hash); + CamelService *service; const gchar *key; const gchar *data_dir; const gchar *config_dir; @@ -1129,23 +1130,28 @@ vfolder_load_storage (EMailBackend *backend) /* first, create the vfolder store, and set it up */ storeuri = g_strdup_printf("vfolder:%s/vfolder", data_dir); - vfolder_store = camel_session_get_store ( - CAMEL_SESSION (session), storeuri, NULL); - if (vfolder_store == NULL) { + service = camel_session_add_service ( + CAMEL_SESSION (session), "vfolder", + storeuri, CAMEL_PROVIDER_STORE, NULL); + if (service != NULL) + camel_service_connect_sync (service, NULL); + else { g_warning("Cannot open vfolder store - no vfolders available"); return; } + g_return_if_fail (CAMEL_IS_STORE (service)); + + vfolder_store = CAMEL_STORE (service); + g_signal_connect ( - vfolder_store, "folder-deleted", + service, "folder-deleted", G_CALLBACK (store_folder_deleted_cb), backend); g_signal_connect ( - vfolder_store, "folder-renamed", + service, "folder-renamed", G_CALLBACK (store_folder_renamed_cb), NULL); - d(printf("got store '%s' = %p\n", storeuri, vfolder_store)); - /* load our rules */ user = g_build_filename (config_dir, "vfolders.xml", NULL); context = em_vfolder_context_new (session); @@ -1162,7 +1168,7 @@ vfolder_load_storage (EMailBackend *backend) g_signal_connect(context, "rule_removed", G_CALLBACK(context_rule_removed), context); /* load store to mail component */ - e_mail_store_add_by_uri (session, storeuri, _("Search Folders")); + e_mail_store_add (session, vfolder_store, _("Search Folders")); /* and setup the rules we have */ rule = NULL; diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c index 2836b1bd09..aa48ed0788 100644 --- a/modules/mail/e-mail-shell-view-actions.c +++ b/modules/mail/e-mail-shell-view-actions.c @@ -109,7 +109,7 @@ action_mail_account_disable_cb (GtkAction *action, account->enabled = !account->enabled; e_account_list_change (account_list, account); - e_mail_store_remove_by_uri (session, folder_uri); + e_mail_store_remove_by_account (session, account); if (account->parent_uid != NULL) e_account_list_remove (account_list, account); diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c index 08ed7a97e7..ac13439eb6 100644 --- a/modules/mail/e-mail-shell-view-private.c +++ b/modules/mail/e-mail-shell-view-private.c @@ -1171,18 +1171,12 @@ e_mail_shell_view_send_receive (EMailShellView *mail_shell_view, } else { /* allow only receive on individual accounts */ EAccount *account; - const gchar *source_url = NULL; account = e_get_account_by_uid (account_uid); g_return_if_fail (account != NULL); if (account->enabled && account->source != NULL) - source_url = account->source->url; - - if (source_url != NULL && *source_url != '\0') - mail_receive_uri ( - session, source_url, - account->source->keep_on_server); + mail_receive_account (session, account); } } diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c index 2a3e2550ae..7655fba835 100644 --- a/modules/mail/e-mail-shell-view.c +++ b/modules/mail/e-mail-shell-view.c @@ -224,6 +224,7 @@ mail_shell_view_execute_search (EShellView *shell_view) EMailView *mail_view; CamelVeeFolder *search_folder; CamelFolder *folder; + CamelService *service; CamelStore *store; GtkAction *action; GtkTreeModel *model; @@ -554,13 +555,14 @@ all_accounts: list = NULL; /* list of CamelFolders */ - /* FIXME Using data_dir like this is not portable. */ - uri = g_strdup_printf ("vfolder:%s/vfolder", data_dir); - store = camel_session_get_store (CAMEL_SESSION (session), uri, NULL); - g_free (uri); + /* FIXME Complete lack of error checking here. */ + service = camel_session_get_service ( + CAMEL_SESSION (session), "vfolder"); + camel_service_connect_sync (service, NULL); search_folder = (CamelVeeFolder *) camel_vee_folder_new ( - store, _("All Account Search"), CAMEL_STORE_VEE_FOLDER_AUTO); + CAMEL_STORE (service), _("All Account Search"), + CAMEL_STORE_VEE_FOLDER_AUTO); priv->search_account_all = search_folder; /* Add local folders. */ @@ -737,13 +739,14 @@ current_account: list = g_list_reverse (list); - /* FIXME Using data_dir like this is not portable. */ - uri = g_strdup_printf ("vfolder:%s/vfolder", data_dir); - store = camel_session_get_store (CAMEL_SESSION (session), uri, NULL); - g_free (uri); + /* FIXME Complete lack of error checking here. */ + service = camel_session_get_service ( + CAMEL_SESSION (session), "vfolder"); + camel_service_connect_sync (service, NULL); search_folder = (CamelVeeFolder *) camel_vee_folder_new ( - store, _("Account Search"), CAMEL_STORE_VEE_FOLDER_AUTO); + CAMEL_STORE (service), _("Account Search"), + CAMEL_STORE_VEE_FOLDER_AUTO); priv->search_account_current = search_folder; camel_vee_folder_set_expression (search_folder, query); diff --git a/modules/mail/em-account-prefs.c b/modules/mail/em-account-prefs.c index 79d64eaf3e..356351a2f1 100644 --- a/modules/mail/em-account-prefs.c +++ b/modules/mail/em-account-prefs.c @@ -67,8 +67,7 @@ account_prefs_enable_account_cb (EAccountTreeView *tree_view, account = e_account_tree_view_get_selected (tree_view); g_return_if_fail (account != NULL); - e_mail_store_add_by_uri ( - prefs->priv->session, account->source->url, account->name); + e_mail_store_add_by_account (prefs->priv->session, account); } static void @@ -87,7 +86,7 @@ account_prefs_disable_account_cb (EAccountTreeView *tree_view, g_return_if_fail (account_list != NULL); if (!e_account_list_account_has_proxies (account_list, account)) { - e_mail_store_remove_by_uri (prefs->priv->session, account->source->url); + e_mail_store_remove_by_account (prefs->priv->session, account); return; } @@ -104,8 +103,7 @@ account_prefs_disable_account_cb (EAccountTreeView *tree_view, e_account_list_remove_account_proxies (account_list, account); - e_mail_store_remove_by_uri ( - prefs->priv->session, account->source->url); + e_mail_store_remove_by_account (prefs->priv->session, account); } static void @@ -310,9 +308,8 @@ account_prefs_delete_account (EAccountManager *manager) } /* Remove the account from the folder tree. */ - if (account->enabled && account->source && account->source->url) - e_mail_store_remove_by_uri ( - priv->session, account->source->url); + if (account->enabled) + e_mail_store_remove_by_account (priv->session, account); /* Remove all the proxies the account has created. */ if (has_proxies) diff --git a/plugins/groupwise-features/install-shared.c b/plugins/groupwise-features/install-shared.c index 969ea0c30d..3899dab95b 100644 --- a/plugins/groupwise-features/install-shared.c +++ b/plugins/groupwise-features/install-shared.c @@ -59,7 +59,7 @@ install_folder_response (EMFolderSelector *emfs, gint response, gpointer *data) gchar *parent_name; gchar *container_id; const gchar *item_id; - CamelStore *store; + CamelService *service = NULL; CamelFolder *folder; EAccount *account; CamelProvider *provider; @@ -69,6 +69,7 @@ install_folder_response (EMFolderSelector *emfs, gint response, gpointer *data) gtk_widget_destroy (GTK_WIDGET (emfs)); } else { CamelSession *session; + CamelURL *url; EShell *shell; shell = e_shell_get_default (); @@ -91,24 +92,30 @@ install_folder_response (EMFolderSelector *emfs, gint response, gpointer *data) else parent_name = NULL; } - store = (CamelStore *) camel_session_get_service ( - session, uri, CAMEL_PROVIDER_STORE, NULL); - if (store == NULL) { + + url = camel_url_new (uri, NULL); + if (url != NULL) { + service = camel_session_get_service_by_url ( + session, url); + camel_url_free (url); + } + + if (!CAMEL_IS_STORE (service)) { g_strfreev (names); return; } - cnc = get_cnc (store); + cnc = get_cnc (CAMEL_STORE (service)); if (E_IS_GW_CONNECTION (cnc)) { container_id = get_container_id (cnc, parent_name); if (e_gw_connection_accept_shared_folder (cnc, folder_name, container_id, (gchar *)item_id, NULL) == E_GW_CONNECTION_STATUS_OK) { - CamelService *service; CamelURL *url; /* FIXME Not passing a GCancellable or GError here. */ folder = camel_store_get_folder_sync ( - store, "Mailbox", 0, NULL, NULL); + CAMEL_STORE (service), + "Mailbox", 0, NULL, NULL); /*changes = camel_folder_change_info_new (); camel_folder_change_info_remove_uid (changes, (gchar *) item_id); camel_folder_summary_remove_uid (folder->summary, item_id);*/ @@ -119,12 +126,12 @@ install_folder_response (EMFolderSelector *emfs, gint response, gpointer *data) CAMEL_MESSAGE_DELETED); camel_folder_summary_touch (folder->summary); /* camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", changes); */ - service = CAMEL_SERVICE (store); url = camel_service_get_camel_url (service); uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL); account = e_get_account_by_source_url (uri); uri = account->source->url; - em_folder_tree_model_remove_store (model, store); + em_folder_tree_model_remove_store ( + model, CAMEL_STORE (service)); provider = camel_provider_get (uri, NULL); if (provider == NULL) { g_strfreev (names); @@ -137,8 +144,9 @@ install_folder_response (EMFolderSelector *emfs, gint response, gpointer *data) return; } - em_folder_tree_model_add_store (model, store, account->name); - g_object_unref (store); + em_folder_tree_model_add_store ( + model, CAMEL_STORE (service), + account->name); } } diff --git a/plugins/groupwise-features/proxy-login.c b/plugins/groupwise-features/proxy-login.c index 61e32216a4..2559dc2079 100644 --- a/plugins/groupwise-features/proxy-login.c +++ b/plugins/groupwise-features/proxy-login.c @@ -350,6 +350,8 @@ proxy_soap_login (gchar *email, GtkWindow *error_parent) proxy_cnc = e_gw_connection_get_proxy_connection (cnc, user_name, password, email, &permissions); if (proxy_cnc) { + CamelService *service; + parent = camel_url_new (e_account_get_string (srcAccount, E_ACCOUNT_SOURCE_URL), NULL); parent_source_url = camel_url_to_string (parent, CAMEL_URL_HIDE_PASSWORD); uri = camel_url_copy (parent); @@ -367,7 +369,12 @@ proxy_soap_login (gchar *email, GtkWindow *error_parent) e_account_list_change (accounts, srcAccount); e_account_list_save (accounts); g_object_set_data ((GObject *)dstAccount, "permissions", GINT_TO_POINTER(permissions)); - mail_get_store (session, e_account_get_string (dstAccount, E_ACCOUNT_SOURCE_URL), NULL, proxy_login_add_new_store, dstAccount); + + service = camel_session_get_service ( + CAMEL_SESSION (session), dstAccount->uid); + if (CAMEL_IS_STORE (service)) + proxy_login_add_new_store ( + CAMEL_STORE (service), dstAccount); g_free (proxy_source_url); g_free (parent_source_url); @@ -386,12 +393,12 @@ proxy_soap_login (gchar *email, GtkWindow *error_parent) } static void -proxy_login_add_new_store (gchar *uri, CamelStore *store, gpointer user_data) +proxy_login_add_new_store (CamelStore *store, + EAccount *account) { EShell *shell; EShellBackend *shell_backend; EMailSession *session; - EAccount *account = user_data; gint permissions = GPOINTER_TO_INT(g_object_get_data ((GObject *)account, "permissions")); shell = e_shell_get_default (); diff --git a/plugins/groupwise-features/proxy-login.h b/plugins/groupwise-features/proxy-login.h index 3c4ba8c392..496e0cb1c1 100644 --- a/plugins/groupwise-features/proxy-login.h +++ b/plugins/groupwise-features/proxy-login.h @@ -52,7 +52,7 @@ struct _proxyLoginClass { GType proxy_login_get_type (void); proxyLogin * proxy_login_new (void); -static void proxy_login_add_new_store (gchar *uri, CamelStore *store, gpointer user_data); +static void proxy_login_add_new_store (CamelStore *store, EAccount *account); static void proxy_login_setup_tree_view (void); proxyLogin* proxy_dialog_new (void); static void proxy_soap_login (gchar *email, GtkWindow *error_parent); diff --git a/plugins/groupwise-features/proxy.c b/plugins/groupwise-features/proxy.c index 555d3f716b..849d4ea3d4 100644 --- a/plugins/groupwise-features/proxy.c +++ b/plugins/groupwise-features/proxy.c @@ -658,9 +658,7 @@ org_gnome_proxy (EPlugin *epl, EConfigHookItemFactoryData *data) g_object_ref (account); store = (CamelOfflineStore *) camel_session_get_service ( - CAMEL_SESSION (session), - e_account_get_string (account, E_ACCOUNT_SOURCE_URL), - CAMEL_PROVIDER_STORE, NULL); + CAMEL_SESSION (session), account->uid); if (store == NULL) return NULL; @@ -724,8 +722,6 @@ org_gnome_proxy (EPlugin *epl, EConfigHookItemFactoryData *data) } } - g_object_unref (store); - return NULL; } diff --git a/plugins/groupwise-features/share-folder-common.c b/plugins/groupwise-features/share-folder-common.c index 521bd3a54c..19d46bad0b 100644 --- a/plugins/groupwise-features/share-folder-common.c +++ b/plugins/groupwise-features/share-folder-common.c @@ -249,7 +249,8 @@ users_dialog_response (GtkWidget *dialog, gint response, struct ShareInfo *ssi) EMFolderSelector *emfs = ssi->emfs; const gchar *uri, *path; EMailSession *session; - CamelStore *store; + CamelService *service = NULL; + CamelURL *url; if (response != GTK_RESPONSE_OK) { gtk_widget_destroy ((GtkWidget *) emfs); @@ -263,18 +264,24 @@ users_dialog_response (GtkWidget *dialog, gint response, struct ShareInfo *ssi) d(printf ("Creating new folder: %s (%s)\n", path, uri)); - store = (CamelStore *) camel_session_get_service ( - CAMEL_SESSION (session), uri, CAMEL_PROVIDER_STORE, NULL); - if (store == NULL) + url = camel_url_new (uri, NULL); + if (url != NULL) { + service = camel_session_get_service_by_url ( + CAMEL_SESSION (session), url); + camel_url_free (url); + } + + if (!CAMEL_IS_STORE (service)) return; - if (!(si = em_folder_tree_model_lookup_store_info (ssi->model, store))) { + si = em_folder_tree_model_lookup_store_info ( + ssi->model, CAMEL_STORE (service)); + if (si == NULL) { g_assert_not_reached (); - g_object_unref (store); return; } - if (CAMEL_IS_VEE_STORE (store)) { + if (CAMEL_IS_VEE_STORE (service)) { EFilterRule *rule; rule = em_vfolder_rule_new (session); @@ -287,7 +294,6 @@ users_dialog_response (GtkWidget *dialog, gint response, struct ShareInfo *ssi) create_folder (si->store, path, new_folder_created_cb, ssi); } - g_object_unref (store); } static void @@ -299,7 +305,8 @@ new_folder_response (EMFolderSelector *emfs, gint response, EMFolderTreeModel *m struct ShareInfo *ssi; const gchar *uri; EGwConnection *cnc; - CamelStore *store; + CamelService *service = NULL; + CamelURL *url; ssi = g_new0 (struct ShareInfo, 1); if (response != GTK_RESPONSE_OK) { @@ -309,12 +316,17 @@ new_folder_response (EMFolderSelector *emfs, gint response, EMFolderTreeModel *m /* i want store at this point to get cnc not sure proper or not*/ uri = em_folder_selector_get_selected_uri (emfs); - store = (CamelStore *) camel_session_get_service ( - session, uri, CAMEL_PROVIDER_STORE, NULL); - if (store == NULL) + + url = camel_url_new (uri, NULL); + if (url != NULL) { + service = camel_session_get_service_by_url (session, url); + camel_url_free (url); + } + + if (!CAMEL_IS_STORE (service)) return; - cnc = get_cnc (store); + cnc = get_cnc (CAMEL_STORE (service)); users_dialog = gtk_dialog_new_with_buttons ( _("Users"), NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); w = gtk_label_new_with_mnemonic (_("Enter the users and set permissions")); @@ -330,10 +342,6 @@ new_folder_response (EMFolderSelector *emfs, gint response, EMFolderTreeModel *m gtk_window_resize (GTK_WINDOW (users_dialog), 350, 300); gtk_widget_show (users_dialog); g_signal_connect (users_dialog, "response", G_CALLBACK (users_dialog_response), ssi); - - g_object_unref (store); - return; - } void diff --git a/widgets/misc/e-account-combo-box.c b/widgets/misc/e-account-combo-box.c index 40504a0083..e8b0bee6c5 100644 --- a/widgets/misc/e-account-combo-box.c +++ b/widgets/misc/e-account-combo-box.c @@ -106,8 +106,7 @@ account_combo_box_choose_account (EAccountComboBox *combo_box) static gboolean account_combo_box_test_account (EAccount *account) { - CamelStore *store; - const gchar *url; + CamelService *service; gboolean writable = FALSE; /* Account must be enabled. */ @@ -123,12 +122,10 @@ account_combo_box_test_account (EAccount *account) return TRUE; /* Account must be writable. */ - url = e_account_get_string (account, E_ACCOUNT_SOURCE_URL); - store = CAMEL_STORE (camel_session_get_service ( - camel_session, url, CAMEL_PROVIDER_STORE, NULL)); - if (store != NULL) { + service = camel_session_get_service (camel_session, account->uid); + if (CAMEL_IS_STORE (service)) { + CamelStore *store = CAMEL_STORE (service); writable = (store->mode & CAMEL_STORE_WRITE); - g_object_unref (store); } return writable; |