Commit f31b4929 authored by Matthew Barnes's avatar Matthew Barnes Committed by Rodrigo Moya
Browse files

Adapt to sealed up CamelService.

parent a6dbbf97
......@@ -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 |
......
......@@ -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;
......
......@@ -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 */
......
......@@ -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);
......
......@@ -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';
}
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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++;
......
......@@ -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);
......
......@@ -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)) {
......
......@@ -103,6 +103,8 @@ install_folder_response (EMFolderSelector *emfs, gint response, gpointer *data)
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 (
......@@ -117,7 +119,9 @@ 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); */
uri = camel_url_to_string (((CamelService *) store)->url, CAMEL_URL_HIDE_ALL);
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);
......
......@@ -69,8 +69,11 @@ refresh_folder_tree (EMFolderTreeModel *model, CamelStore *store)
gchar *uri;
EAccount *account;
CamelProvider *provider;
CamelURL *url;
url = camel_service_get_camel_url (CAMEL_SERVICE (store));
uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
uri = camel_url_to_string (((CamelService *) store)->url, CAMEL_URL_HIDE_ALL);
account = e_get_account_by_source_url (uri);
if (!account) {
return;
......@@ -436,7 +439,7 @@ get_cnc (CamelStore *store)
return NULL;
service = CAMEL_SERVICE (store);
url = service->url;
url = camel_service_get_camel_url (service);
server_name = g_strdup (url->host);
user = g_strdup (url->user);
property_value = camel_url_get_param (url, "soap_port");
......@@ -453,10 +456,10 @@ get_cnc (CamelStore *store)
else
uri = g_strconcat ("http://", server_name, ":", port, "/soap", NULL);
cnc = e_gw_connection_new (uri, user, service->url->passwd);
cnc = e_gw_connection_new (uri, user, url->passwd);
if (!E_IS_GW_CONNECTION(cnc) && use_ssl && g_str_equal (use_ssl, "when-possible")) {
gchar *http_uri = g_strconcat ("http://", uri + 8, NULL);
cnc = e_gw_connection_new (http_uri, user, service->url->passwd);
cnc = e_gw_connection_new (http_uri, user, url->passwd);
g_free (http_uri);
}
g_free (use_ssl);
......
......@@ -834,7 +834,7 @@ find_server (struct _itip_puri *pitip, ECalComponent *comp)
parent_store = camel_folder_get_parent_store (pitip->folder);
url = CAMEL_SERVICE (parent_store)->url;
url = camel_service_get_camel_url (CAMEL_SERVICE (parent_store));
uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
itip_view_set_buttons_sensitive (ITIP_VIEW (pitip->view), FALSE);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment