From ea0fdf21ece0f81b6bbe3c08e1c21da76280acd4 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 17 Apr 2011 13:13:55 -0400 Subject: Adapt to sealed up CamelService. --- mail/e-mail-migrate.c | 18 ++++++++++++------ mail/e-mail-session-utils.c | 15 +++++++++------ mail/e-mail-session.c | 14 +++++++++----- mail/e-mail-store.c | 6 ++++-- mail/em-composer-utils.c | 9 +++++++-- mail/em-folder-tree-model.c | 13 ++++++++++--- mail/em-folder-tree.c | 7 ++++++- mail/em-folder-utils.c | 7 ++++++- mail/em-utils.c | 4 +++- mail/mail-folder-cache.c | 40 ++++++++++++++++++++++++++++++++-------- mail/mail-ops.c | 30 +++++++++++++++++++++++------- mail/mail-vfolder.c | 5 +++-- 12 files changed, 124 insertions(+), 44 deletions(-) (limited to 'mail') diff --git a/mail/e-mail-migrate.c b/mail/e-mail-migrate.c index 2f3ce8b6db..81b4fc762d 100644 --- a/mail/e-mail-migrate.c +++ b/mail/e-mail-migrate.c @@ -639,6 +639,7 @@ migrate_to_db (EShellBackend *shell_backend) gint i=0, len; CamelStore *store = NULL; CamelFolderInfo *info; + CamelURL *url; const gchar *data_dir; if (!(accounts = e_get_account_list ())) @@ -664,6 +665,8 @@ migrate_to_db (EShellBackend *shell_backend) em_migrate_set_progress ( (double)i/(len+1)); store = setup_local_store (shell_backend, session); + url = camel_service_get_camel_url (CAMEL_SERVICE (store)); + info = camel_store_get_folder_info_sync ( store, NULL, CAMEL_STORE_FOLDER_INFO_RECURSIVE | @@ -673,7 +676,7 @@ migrate_to_db (EShellBackend *shell_backend) if (info) { struct migrate_folders_to_db_structure migrate_dbs; - if (g_str_has_suffix (((CamelService *)store)->url->path, ".evolution/mail/local")) + if (g_str_has_suffix (url->path, ".evolution/mail/local")) migrate_dbs.is_local_store = TRUE; else migrate_dbs.is_local_store = FALSE; @@ -682,7 +685,9 @@ migrate_to_db (EShellBackend *shell_backend) migrate_dbs.store = store; migrate_dbs.done = FALSE; - g_thread_create ((GThreadFunc) migrate_folders_to_db_thread, &migrate_dbs, TRUE, NULL); + g_thread_create ( + (GThreadFunc) migrate_folders_to_db_thread, + &migrate_dbs, TRUE, NULL); while (!migrate_dbs.done) g_main_context_iteration (NULL, TRUE); } @@ -698,14 +703,15 @@ migrate_to_db (EShellBackend *shell_backend) 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) { + && service->url != NULL && service->url[0] + && strncmp (service->url, "mbox:", 5) != 0) { e_mail_store_add_by_uri ( mail_session, service->url, name); - store = (CamelStore *) camel_session_get_service (CAMEL_SESSION (session), service->url, CAMEL_PROVIDER_STORE, NULL); + 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 | diff --git a/mail/e-mail-session-utils.c b/mail/e-mail-session-utils.c index a16de66f70..26d6dcb310 100644 --- a/mail/e-mail-session-utils.c +++ b/mail/e-mail-session-utils.c @@ -402,7 +402,8 @@ mail_session_send_to_thread (GSimpleAsyncResult *simple, /* Send the message to all recipients. */ if (camel_address_length (context->recipients) > 0) { CamelTransport *transport; - CamelProviderFlags flags; + CamelProvider *provider; + CamelService *service; /* XXX This API does not allow for cancellation. */ transport = camel_session_get_transport ( @@ -418,8 +419,10 @@ mail_session_send_to_thread (GSimpleAsyncResult *simple, g_return_if_fail (CAMEL_IS_TRANSPORT (transport)); - flags = CAMEL_SERVICE (transport)->provider->flags; - if (flags & CAMEL_PROVIDER_DISABLE_SENT_FOLDER) + 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 ( @@ -839,7 +842,7 @@ e_mail_session_unsubscribe_folder_sync (EMailSession *session, { CamelURL *url; CamelStore *store; - CamelProviderURLFlags flags; + CamelProvider *provider; const gchar *message; const gchar *path = NULL; gboolean success = FALSE; @@ -859,9 +862,9 @@ e_mail_session_unsubscribe_folder_sync (EMailSession *session, if (url == NULL) goto exit; - flags = CAMEL_SERVICE (store)->provider->url_flags; + provider = camel_service_get_provider (CAMEL_SERVICE (store)); - if (flags & CAMEL_URL_FRAGMENT_IS_PATH) + if (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH) path = url->fragment; else if (url->path != NULL && *url->path != '\0') path = url->path + 1; diff --git a/mail/e-mail-session.c b/mail/e-mail-session.c index e701509a63..622ee6f367 100644 --- a/mail/e-mail-session.c +++ b/mail/e-mail-session.c @@ -499,9 +499,8 @@ mail_session_make_key (CamelService *service, if (service != NULL) key = camel_url_to_string ( - service->url, - CAMEL_URL_HIDE_PASSWORD | - CAMEL_URL_HIDE_PARAMS); + camel_service_get_camel_url (service), + CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_PARAMS); else key = g_strdup (item); @@ -598,11 +597,16 @@ mail_session_get_password (CamelSession *session, guint32 flags, GError **error) { - gchar *url; + gchar *url = NULL; gchar *ret = NULL; EAccount *account = NULL; - url = service?camel_url_to_string (service->url, CAMEL_URL_HIDE_ALL):NULL; + if (service != NULL) { + CamelURL *service_url; + + service_url = camel_service_get_camel_url (service); + url = camel_url_to_string (service_url, CAMEL_URL_HIDE_ALL); + } if (!strcmp(item, "popb4smtp_uri")) { /* not 100% mt safe, but should be ok */ diff --git a/mail/e-mail-store.c b/mail/e-mail-store.c index e5607ef1a3..c5b6be32b4 100644 --- a/mail/e-mail-store.c +++ b/mail/e-mail-store.c @@ -169,15 +169,17 @@ mail_store_add (EMailSession *session, { EMFolderTreeModel *default_model; MailFolderCache *folder_cache; + CamelProvider *provider; StoreInfo *store_info; g_return_if_fail (store_table != NULL); g_return_if_fail (store != NULL); g_return_if_fail (CAMEL_IS_STORE (store)); + provider = camel_service_get_provider (CAMEL_SERVICE (store)); + g_return_if_fail ( - (CAMEL_SERVICE (store)->provider->flags & - CAMEL_PROVIDER_IS_STORAGE) != 0); + (provider->flags & CAMEL_PROVIDER_IS_STORAGE) != 0); default_model = em_folder_tree_model_get_default (); folder_cache = e_mail_session_get_folder_cache (session); diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index 752a78af07..b916e15d29 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -2042,11 +2042,16 @@ reply_get_composer (EShell *shell, if (folder) { CamelStore *parent_store; + CamelService *service; + CamelURL *url; parent_store = camel_folder_get_parent_store (folder); + + service = CAMEL_SERVICE (parent_store); + url = camel_service_get_camel_url (service); + store_url = camel_url_to_string ( - CAMEL_SERVICE (parent_store)->url, - CAMEL_URL_HIDE_ALL); + url, CAMEL_URL_HIDE_ALL); if (store_url[strlen (store_url) - 1] == '/') store_url[strlen (store_url)-1] = '\0'; } diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c index d95b7db5ef..3455234c7f 100644 --- a/mail/em-folder-tree-model.c +++ b/mail/em-folder-tree-model.c @@ -267,7 +267,13 @@ account_added_cb (EAccountList *accounts, CAMEL_SESSION (session), uri, CAMEL_PROVIDER_STORE, NULL); if (store != NULL) { - if ((CAMEL_SERVICE (store)->provider->flags & CAMEL_PROVIDER_IS_STORAGE) != 0) + 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); @@ -1028,6 +1034,7 @@ em_folder_tree_model_add_store (EMFolderTreeModel *model, GtkTreeStore *tree_store; GtkTreeIter root, iter; GtkTreePath *path; + CamelURL *service_url; EAccount *account; gchar *uri; @@ -1041,8 +1048,8 @@ em_folder_tree_model_add_store (EMFolderTreeModel *model, if (si != NULL) em_folder_tree_model_remove_store (model, store); - uri = camel_url_to_string ( - ((CamelService *) store)->url, CAMEL_URL_HIDE_ALL); + service_url = camel_service_get_camel_url (CAMEL_SERVICE (store)); + uri = camel_url_to_string (service_url, CAMEL_URL_HIDE_ALL); account = e_get_account_by_source_url (uri); diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index 81803b53a3..e5ef9d4f0c 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -2736,11 +2736,16 @@ em_folder_tree_set_selected_list (EMFolderTree *folder_tree, priv->select_uris = g_slist_append (priv->select_uris, u); } } else { + CamelService *service; + CamelProvider *provider; const gchar *path; gchar *expand_key, *end; EAccount *account; - if (((CamelService *)u->store)->provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH) + service = CAMEL_SERVICE (u->store); + provider = camel_service_get_provider (service); + + if (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH) path = url->fragment; else path = url->path && url->path[0]=='/' ? url->path+1:url->path; diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c index 5e21fc47f2..e115929e4c 100644 --- a/mail/em-folder-utils.c +++ b/mail/em-folder-utils.c @@ -298,6 +298,8 @@ emfu_copy_folder_selected (EMailBackend *backend, struct _copy_folder_data *cfd = data; CamelStore *fromstore = NULL, *tostore = NULL; CamelStore *local_store; + CamelService *service; + CamelProvider *provider; const gchar *tobase = NULL; CamelURL *url; GError *local_error = NULL; @@ -341,8 +343,11 @@ emfu_copy_folder_selected (EMailBackend *backend, goto fail; } + service = CAMEL_SERVICE (tostore); + provider = camel_service_get_provider (service); + url = camel_url_new (uri, NULL); - if (((CamelService *)tostore)->provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH) + if (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH) tobase = url->fragment; else if (url->path && url->path[0]) tobase = url->path+1; diff --git a/mail/em-utils.c b/mail/em-utils.c index e674c61528..7ebe28c11e 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -2203,12 +2203,14 @@ guess_account_from_folder (CamelFolder *folder) CamelService *service; CamelStore *parent_store; EAccount *account; + CamelURL *url; gchar *source_url; parent_store = camel_folder_get_parent_store (folder); service = CAMEL_SERVICE (parent_store); - source_url = camel_url_to_string (service->url, CAMEL_URL_HIDE_ALL); + url = camel_service_get_camel_url (service); + source_url = camel_url_to_string (url, CAMEL_URL_HIDE_ALL); account = e_get_account_by_source_url (source_url); g_free (source_url); diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c index 06acae76ec..efed1025e6 100644 --- a/mail/mail-folder-cache.c +++ b/mail/mail-folder-cache.c @@ -562,13 +562,19 @@ store_folder_deleted_cb (CamelStore *store, } static gchar * -folder_to_url (CamelStore *store, const gchar *full_name) +folder_to_url (CamelStore *store, + const gchar *full_name) { + CamelProvider *provider; + CamelService *service; CamelURL *url; gchar *out; - url = camel_url_copy (((CamelService *)store)->url); - if (((CamelService *)store)->provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH) { + service = CAMEL_SERVICE (store); + provider = camel_service_get_provider (service); + + url = camel_url_copy (camel_service_get_camel_url (service)); + if (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH) { camel_url_set_fragment (url, full_name); } else { gchar *name = g_alloca (strlen (full_name)+2); @@ -797,9 +803,14 @@ ping_store_exec (struct _ping_store_msg *m, GCancellable *cancellable, GError **error) { + CamelServiceConnectionStatus status; + CamelService *service; gboolean online = FALSE; - if (CAMEL_SERVICE (m->store)->status == CAMEL_SERVICE_CONNECTED) { + service = CAMEL_SERVICE (m->store); + status = camel_service_get_connection_status (service); + + if (status == CAMEL_SERVICE_CONNECTED) { if (CAMEL_IS_DISCO_STORE (m->store) && camel_disco_store_status ( CAMEL_DISCO_STORE (m->store)) !=CAMEL_DISCO_STORE_OFFLINE) @@ -830,9 +841,14 @@ static MailMsgInfo ping_store_info = { static void ping_store (CamelStore *store) { + CamelServiceConnectionStatus status; + CamelService *service; struct _ping_store_msg *m; - if (CAMEL_SERVICE (store)->status != CAMEL_SERVICE_CONNECTED) + service = CAMEL_SERVICE (store); + status = camel_service_get_connection_status (service); + + if (status != CAMEL_SERVICE_CONNECTED) return; m = mail_msg_new (&ping_store_info); @@ -886,10 +902,18 @@ storeinfo_find_folder_info (CamelStore *store, struct _store_info *si, struct _find_info *fi) { + CamelProvider *provider; + CamelService *service; + CamelURL *url; + + service = CAMEL_SERVICE (store); + url = camel_service_get_camel_url (service); + provider = camel_service_get_provider (service); + if (fi->fi == NULL) { - if (((CamelService *)store)->provider->url_equal ( - fi->url, ((CamelService *)store)->url)) { - gchar *path = fi->url->fragment?fi->url->fragment:fi->url->path; + if (provider->url_equal (fi->url, url)) { + gchar *path = fi->url->fragment ? + fi->url->fragment : fi->url->path; if (path[0] == '/') path++; diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 79fce90458..3c3d65a389 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -203,10 +203,12 @@ mail_filter_folder (EMailSession *session, static gchar * uid_cachename_hack (CamelStore *store) { - CamelURL *url = CAMEL_SERVICE (store)->url; + CamelURL *url; gchar *encoded_url, *filename; const gchar *data_dir; + url = camel_service_get_camel_url (CAMEL_SERVICE (store)); + encoded_url = g_strdup_printf ("%s%s%s@%s", url->user, url->authmech ? ";auth=" : "", url->authmech ? url->authmech : "", @@ -474,6 +476,7 @@ mail_send_message (struct _send_queue_msg *m, CamelAddress *from, *recipients; CamelMessageInfo *info = NULL; CamelTransport *xport = NULL; + CamelProvider *provider; gchar *transport_url = NULL; gchar *sent_folder_uri = NULL; const gchar *resent_from, *tmp; @@ -609,8 +612,13 @@ mail_send_message (struct _send_queue_msg *m, } } - if (xport == NULL - || !( ((CamelService *)xport)->provider->flags & CAMEL_PROVIDER_DISABLE_SENT_FOLDER)) { + if (xport != NULL) + provider = camel_service_get_provider (CAMEL_SERVICE (xport)); + else + provider = NULL; + + if (provider == NULL + || !(provider->flags & CAMEL_PROVIDER_DISABLE_SENT_FOLDER)) { GError *local_error = NULL; if (sent_folder_uri) { @@ -1671,9 +1679,12 @@ struct _sync_store_msg { static gchar * sync_store_desc (struct _sync_store_msg *m) { + CamelURL *url; gchar *uri, *res; - uri = camel_url_to_string (((CamelService *)m->store)->url, CAMEL_URL_HIDE_ALL); + url = camel_service_get_camel_url (CAMEL_SERVICE (m->store)); + uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL); + res = g_strdup_printf (m->expunge ?_("Expunging and storing account '%s'") :_("Storing account '%s'"), @@ -1776,6 +1787,8 @@ folder_is_from_source_url (CamelFolder *folder, const gchar *source_url) { CamelStore *store; CamelService *service; + CamelProvider *provider; + CamelURL *service_url; CamelURL *url; gboolean res = FALSE; @@ -1787,13 +1800,16 @@ folder_is_from_source_url (CamelFolder *folder, const gchar *source_url) service = CAMEL_SERVICE (store); g_return_val_if_fail (service != NULL, FALSE); - g_return_val_if_fail (service->provider != NULL, FALSE); - g_return_val_if_fail (service->provider->url_equal != NULL, FALSE); + + provider = camel_service_get_provider (service); + g_return_val_if_fail (provider != NULL, FALSE); + g_return_val_if_fail (provider->url_equal != NULL, FALSE); url = camel_url_new (source_url, NULL); g_return_val_if_fail (url != NULL, FALSE); - res = service->provider->url_equal (service->url, url); + service_url = camel_service_get_camel_url (service); + res = provider->url_equal (service_url, url); camel_url_free (url); diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c index 5c349e20d7..b0ac26792c 100644 --- a/mail/mail-vfolder.c +++ b/mail/mail-vfolder.c @@ -464,13 +464,14 @@ mail_vfolder_add_uri (EMailSession *session, EFilterRule *rule; const gchar *source; CamelVeeFolder *vf; + CamelProvider *provider; GList *folders = NULL, *link; gint remote; gint is_ignore; gchar *uri; - remote = (((CamelService *)store)->provider->flags & - CAMEL_PROVIDER_IS_REMOTE) != 0; + provider = camel_service_get_provider (CAMEL_SERVICE (store)); + remote = (provider->flags & CAMEL_PROVIDER_IS_REMOTE) != 0; uri = em_uri_from_camel (curi); if (uri_is_spethal (store, curi)) { -- cgit