[evolution-data-server] Seal up CamelService.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Seal up CamelService.
- Date: Sun, 17 Apr 2011 18:07:05 +0000 (UTC)
commit 97c5c417fa02b84674020c6d3562827fc9153d66
Author: Matthew Barnes <mbarnes redhat com>
Date: Sun Apr 17 11:17:50 2011 -0400
Seal up CamelService.
And add accessor functions:
camel_service_get_camel_url()
camel_service_get_connection_status()
This change increments libcamel's soname.
camel/camel-disco-folder.c | 10 +-
camel/camel-disco-store.c | 46 ++++--
camel/camel-folder-summary.c | 13 +-
camel/camel-folder.c | 11 +-
camel/camel-offline-folder.c | 11 +-
camel/camel-offline-store.c | 18 ++-
camel/camel-sasl-cram-md5.c | 9 +-
camel/camel-sasl-digest-md5.c | 16 +-
camel/camel-sasl-gssapi.c | 12 +-
camel/camel-sasl-login.c | 3 +-
camel/camel-sasl-ntlm.c | 53 ++++---
camel/camel-sasl-plain.c | 3 +-
camel/camel-sasl-popb4smtp.c | 2 +-
camel/camel-service.c | 147 ++++++++++++------
camel/camel-service.h | 10 +-
camel/camel-session.c | 16 +-
camel/camel-store.c | 25 ++-
camel/camel-vee-folder.c | 6 +-
camel/camel-vee-store.c | 14 ++-
camel/providers/groupwise/camel-groupwise-folder.c | 37 +++--
camel/providers/groupwise/camel-groupwise-store.c | 87 +++++++----
.../groupwise/camel-groupwise-transport.c | 24 ++-
camel/providers/imap/camel-imap-command.c | 19 ++-
camel/providers/imap/camel-imap-folder.c | 19 ++-
camel/providers/imap/camel-imap-store.c | 164 ++++++++++++--------
camel/providers/imap/camel-imap-wrapper.c | 7 +-
camel/providers/imapx/camel-imapx-conn-manager.c | 13 +-
camel/providers/imapx/camel-imapx-server.c | 46 ++++---
camel/providers/imapx/camel-imapx-store.c | 52 +++++--
camel/providers/local/camel-local-folder.c | 4 +-
camel/providers/local/camel-local-store.c | 28 ++--
camel/providers/local/camel-maildir-store.c | 20 ++-
camel/providers/local/camel-mbox-store.c | 15 ++-
camel/providers/local/camel-mh-store.c | 5 +-
camel/providers/local/camel-spool-folder.c | 5 +-
camel/providers/local/camel-spool-store.c | 47 ++++--
camel/providers/nntp/camel-nntp-folder.c | 7 +-
camel/providers/nntp/camel-nntp-store.c | 108 ++++++++-----
camel/providers/nntp/camel-nntp-summary.c | 12 +-
camel/providers/pop3/camel-pop3-store.c | 127 +++++++++------
camel/providers/smtp/camel-smtp-transport.c | 96 +++++++-----
configure.ac | 2 +-
docs/reference/camel/camel-sections.txt | 2 +
docs/reference/camel/tmpl/camel-service.sgml | 18 ++
44 files changed, 899 insertions(+), 490 deletions(-)
---
diff --git a/camel/camel-disco-folder.c b/camel/camel-disco-folder.c
index 1d96fb9..6227a03 100644
--- a/camel/camel-disco-folder.c
+++ b/camel/camel-disco-folder.c
@@ -99,19 +99,25 @@ static void
cdf_folder_changed (CamelFolder *folder,
CamelFolderChangeInfo *changes)
{
+ CamelService *parent_service;
CamelStore *parent_store;
+ CamelURL *url;
gboolean offline_sync;
parent_store = camel_folder_get_parent_store (folder);
+ parent_service = CAMEL_SERVICE (parent_store);
+ url = camel_service_get_camel_url (parent_service);
+
offline_sync = camel_disco_folder_get_offline_sync (
CAMEL_DISCO_FOLDER (folder));
if (changes->uid_added->len > 0 && (offline_sync
- || camel_url_get_param (CAMEL_SERVICE (parent_store)->url, "offline_sync"))) {
- CamelSession *session = CAMEL_SERVICE (parent_store)->session;
+ || camel_url_get_param (url, "offline_sync"))) {
+ CamelSession *session;
struct _cdf_sync_msg *m;
+ session = camel_service_get_session (parent_service);
m = camel_session_thread_msg_new (session, &cdf_sync_ops, sizeof (*m));
m->changes = camel_folder_change_info_new ();
camel_folder_change_info_cat (m->changes, changes);
diff --git a/camel/camel-disco-store.c b/camel/camel-disco-store.c
index fd085f4..d6e6306 100644
--- a/camel/camel-disco-store.c
+++ b/camel/camel-disco-store.c
@@ -231,14 +231,18 @@ disco_store_get_folder_info_sync (CamelStore *store,
info = class->get_folder_info_offline (
store, top, flags, cancellable, error);
if (!(flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED))
- CAMEL_CHECK_GERROR (store, get_folder_info_offline, info != NULL, error);
+ CAMEL_CHECK_GERROR (
+ store, get_folder_info_offline,
+ info != NULL, error);
return info;
case CAMEL_DISCO_STORE_RESYNCING:
info = class->get_folder_info_resyncing (
store, top, flags, cancellable, error);
if (!(flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED))
- CAMEL_CHECK_GERROR (store, get_folder_info_resyncing, info != NULL, error);
+ CAMEL_CHECK_GERROR (
+ store, get_folder_info_resyncing,
+ info != NULL, error);
return info;
}
@@ -251,17 +255,19 @@ disco_store_set_status (CamelDiscoStore *disco_store,
GCancellable *cancellable,
GError **error)
{
- CamelService *service = CAMEL_SERVICE (disco_store);
+ CamelService *service;
+ CamelSession *session;
gboolean network_available;
if (disco_store->status == status)
return TRUE;
- /* Sync the folder fully if we've been told to sync online for this store or this folder
- and we're going offline */
+ /* Sync the folder fully if we've been told to sync online
+ * for this store or this folder and we're going offline. */
- network_available =
- camel_session_get_network_available (service->session);
+ service = CAMEL_SERVICE (disco_store);
+ session = camel_service_get_session (service);
+ network_available = camel_session_get_network_available (session);
if (network_available) {
if (disco_store->status == CAMEL_DISCO_STORE_ONLINE
@@ -269,9 +275,11 @@ disco_store_set_status (CamelDiscoStore *disco_store,
if (((CamelStore *)disco_store)->folders) {
GPtrArray *folders;
CamelFolder *folder;
+ CamelURL *url;
gint i, sync;
- sync = camel_url_get_param(((CamelService *)disco_store)->url, "offline_sync") != NULL;
+ url = camel_service_get_camel_url (service);
+ sync = camel_url_get_param (url, "offline_sync") != NULL;
folders = camel_object_bag_list (((CamelStore *)disco_store)->folders);
for (i=0;i<folders->len;i++) {
@@ -333,12 +341,17 @@ camel_disco_store_init (CamelDiscoStore *disco_store)
CamelDiscoStoreStatus
camel_disco_store_status (CamelDiscoStore *store)
{
- CamelService *service = CAMEL_SERVICE (store);
+ CamelService *service;
+ CamelSession *session;
+
+ g_return_val_if_fail (
+ CAMEL_IS_DISCO_STORE (store), CAMEL_DISCO_STORE_ONLINE);
- g_return_val_if_fail (CAMEL_IS_DISCO_STORE (store), CAMEL_DISCO_STORE_ONLINE);
+ service = CAMEL_SERVICE (store);
+ session = camel_service_get_session (service);
if (store->status != CAMEL_DISCO_STORE_OFFLINE
- && !camel_session_get_online (service->session))
+ && !camel_session_get_online (session))
store->status = CAMEL_DISCO_STORE_OFFLINE;
return store->status;
@@ -428,21 +441,26 @@ camel_disco_store_prepare_for_offline (CamelDiscoStore *disco_store,
GError **error)
{
CamelService *service;
+ CamelSession *session;
g_return_if_fail (CAMEL_IS_DISCO_STORE (disco_store));
service = CAMEL_SERVICE (disco_store);
+ session = camel_service_get_session (service);
- /* Sync the folder fully if we've been told to sync online for this store or this folder */
+ /* Sync the folder fully if we've been told to
+ * sync online for this store or this folder. */
- if (camel_session_get_network_available (service->session)) {
+ if (camel_session_get_network_available (session)) {
if (disco_store->status == CAMEL_DISCO_STORE_ONLINE) {
if (((CamelStore *)disco_store)->folders) {
GPtrArray *folders;
CamelFolder *folder;
+ CamelURL *url;
gint i, sync;
- sync = camel_url_get_param(((CamelService *)disco_store)->url, "offline_sync") != NULL;
+ url = camel_service_get_camel_url (service);
+ sync = camel_url_get_param (url, "offline_sync") != NULL;
folders = camel_object_bag_list (((CamelStore *)disco_store)->folders);
for (i=0;i<folders->len;i++) {
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 577852c..8234fce 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -1558,7 +1558,7 @@ cfs_try_release_memory (CamelFolderSummary *s)
}
parent_store = camel_folder_get_parent_store (s->folder);
- session = CAMEL_SERVICE (parent_store)->session;
+ session = camel_service_get_session (CAMEL_SERVICE (parent_store));
if (time (NULL) - s->cache_load_time < SUMMARY_CACHE_DROP)
return TRUE;
@@ -1707,6 +1707,7 @@ static gint
cfs_reload_from_db (CamelFolderSummary *s, GError **error)
{
CamelDB *cdb;
+ CamelSession *session;
CamelStore *parent_store;
const gchar *folder_name;
gint ret = 0;
@@ -1718,22 +1719,26 @@ cfs_reload_from_db (CamelFolderSummary *s, GError **error)
folder_name = camel_folder_get_full_name (s->folder);
parent_store = camel_folder_get_parent_store (s->folder);
+ session = camel_service_get_session (CAMEL_SERVICE (parent_store));
cdb = parent_store->cdb_r;
/* FIXME FOR SANKAR: No need to pass the address of summary here. */
data.summary = s;
data.add = FALSE;
- ret = camel_db_read_message_info_records (cdb, folder_name, (gpointer)&data, camel_read_mir_callback, NULL);
+ ret = camel_db_read_message_info_records (
+ cdb, folder_name, (gpointer) &data,
+ camel_read_mir_callback, NULL);
cfs_schedule_info_release_timer (s);
if (s->priv->need_preview) {
struct _preview_update_msg *m;
- m = camel_session_thread_msg_new (((CamelService *)parent_store)->session, &preview_update_ops, sizeof (*m));
+ m = camel_session_thread_msg_new (
+ session, &preview_update_ops, sizeof (*m));
m->folder = s->folder;
m->error = NULL;
- camel_session_thread_queue (((CamelService *)parent_store)->session, &m->msg, 0);
+ camel_session_thread_queue (session, &m->msg, 0);
}
return ret == 0 ? 0 : -1;
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index 48967bd..d3f2787 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -207,7 +207,7 @@ filter_filter (CamelSession *session,
full_name = camel_folder_get_full_name (m->folder);
parent_store = camel_folder_get_parent_store (m->folder);
- csp = CAMEL_SERVICE (parent_store)->session->junk_plugin;
+ csp = session->junk_plugin;
if (m->junk) {
/* Translators: The %s is replaced with a folder name where the operation is running. */
@@ -1386,7 +1386,7 @@ folder_changed (CamelFolder *folder,
g_return_if_fail (info != NULL);
parent_store = camel_folder_get_parent_store (folder);
- session = CAMEL_SERVICE (parent_store)->session;
+ session = camel_service_get_session (CAMEL_SERVICE (parent_store));
camel_folder_lock (folder, CAMEL_FOLDER_CHANGE_LOCK);
if (folder->priv->frozen) {
@@ -1862,6 +1862,7 @@ const gchar *
camel_folder_get_uri (CamelFolder *folder)
{
CamelService *service;
+ CamelProvider *provider;
CamelStore *parent_store;
const gchar *full_name;
CamelURL *url;
@@ -1875,11 +1876,13 @@ camel_folder_get_uri (CamelFolder *folder)
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
+
service = CAMEL_SERVICE (parent_store);
+ provider = camel_service_get_provider (service);
- url = camel_url_copy (service->url);
+ url = camel_url_copy (camel_service_get_camel_url (service));
- if (service->provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH) {
+ if (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH) {
camel_url_set_fragment (url, full_name);
} else {
gchar *path = g_strdup_printf ("/%s", full_name);
diff --git a/camel/camel-offline-folder.c b/camel/camel-offline-folder.c
index 321dd7e..27e8f83 100644
--- a/camel/camel-offline-folder.c
+++ b/camel/camel-offline-folder.c
@@ -120,19 +120,24 @@ offline_folder_changed (CamelFolder *folder,
{
CamelStore *parent_store;
CamelService *service;
+ CamelSession *session;
+ CamelURL *url;
gboolean offline_sync;
parent_store = camel_folder_get_parent_store (folder);
+
service = CAMEL_SERVICE (parent_store);
+ url = camel_service_get_camel_url (service);
+ session = camel_service_get_session (service);
offline_sync = camel_offline_folder_get_offline_sync (
CAMEL_OFFLINE_FOLDER (folder));
- if (changes->uid_added->len > 0 && (offline_sync || camel_url_get_param (service->url, "sync_offline"))) {
- CamelSession *session = service->session;
+ if (changes->uid_added->len > 0 && (offline_sync || camel_url_get_param (url, "sync_offline"))) {
struct _offline_downsync_msg *m;
- m = camel_session_thread_msg_new (session, &offline_downsync_ops, sizeof (*m));
+ m = camel_session_thread_msg_new (
+ session, &offline_downsync_ops, sizeof (*m));
m->changes = camel_folder_change_info_new ();
camel_folder_change_info_cat (m->changes, changes);
m->folder = g_object_ref (folder);
diff --git a/camel/camel-offline-store.c b/camel/camel-offline-store.c
index b5b9a35..eb4e608 100644
--- a/camel/camel-offline-store.c
+++ b/camel/camel-offline-store.c
@@ -109,6 +109,7 @@ camel_offline_store_set_online_sync (CamelOfflineStore *store,
GError **error)
{
CamelService *service = CAMEL_SERVICE (store);
+ CamelSession *session;
gboolean network_available;
g_return_val_if_fail (CAMEL_IS_OFFLINE_STORE (store), FALSE);
@@ -116,8 +117,9 @@ camel_offline_store_set_online_sync (CamelOfflineStore *store,
if (store->priv->online == online)
return TRUE;
- network_available =
- camel_session_get_network_available (service->session);
+ service = CAMEL_SERVICE (store);
+ session = camel_service_get_session (service);
+ network_available = camel_session_get_network_available (session);
if (store->priv->online) {
/* network available -> network unavailable */
@@ -125,9 +127,11 @@ camel_offline_store_set_online_sync (CamelOfflineStore *store,
if (((CamelStore *) store)->folders) {
GPtrArray *folders;
CamelFolder *folder;
+ CamelURL *url;
gint i, sync;
- sync = camel_url_get_param (((CamelService *) store)->url, "sync_offline") != NULL;
+ url = camel_service_get_camel_url (service);
+ sync = camel_url_get_param (url, "sync_offline") != NULL;
folders = camel_object_bag_list (((CamelStore *) store)->folders);
for (i = 0; i < folders->len; i++) {
@@ -180,19 +184,23 @@ camel_offline_store_prepare_for_offline_sync (CamelOfflineStore *store,
GError **error)
{
CamelService *service;
+ CamelSession *session;
g_return_val_if_fail (CAMEL_IS_OFFLINE_STORE (store), FALSE);
service = CAMEL_SERVICE (store);
+ session = camel_service_get_session (service);
- if (camel_session_get_network_available (service->session)) {
+ if (camel_session_get_network_available (session)) {
if (store->priv->online) {
if (((CamelStore *) store)->folders) {
GPtrArray *folders;
CamelFolder *folder;
+ CamelURL *url;
gint i, sync;
- sync = camel_url_get_param (((CamelService *) store)->url, "sync_offline") != NULL;
+ url = camel_service_get_camel_url (service);
+ sync = camel_url_get_param (url, "sync_offline") != NULL;
folders = camel_object_bag_list (((CamelStore *) store)->folders);
for (i = 0; i < folders->len; i++) {
diff --git a/camel/camel-sasl-cram-md5.c b/camel/camel-sasl-cram-md5.c
index 1bf4800..66fd351 100644
--- a/camel/camel-sasl-cram-md5.c
+++ b/camel/camel-sasl-cram-md5.c
@@ -61,6 +61,7 @@ sasl_cram_md5_challenge_sync (CamelSasl *sasl,
{
CamelService *service;
GChecksum *checksum;
+ CamelURL *url;
guint8 *digest;
gsize length;
gchar *passwd;
@@ -75,7 +76,9 @@ sasl_cram_md5_challenge_sync (CamelSasl *sasl,
return NULL;
service = camel_sasl_get_service (sasl);
- g_return_val_if_fail (service->url->passwd != NULL, NULL);
+
+ url = camel_service_get_camel_url (service);
+ g_return_val_if_fail (url->passwd != NULL, NULL);
length = g_checksum_type_get_length (G_CHECKSUM_MD5);
digest = g_alloca (length);
@@ -83,7 +86,7 @@ sasl_cram_md5_challenge_sync (CamelSasl *sasl,
memset (ipad, 0, sizeof (ipad));
memset (opad, 0, sizeof (opad));
- passwd = service->url->passwd;
+ passwd = url->passwd;
pw_len = strlen (passwd);
if (pw_len <= 64) {
memcpy (ipad, passwd, pw_len);
@@ -117,7 +120,7 @@ sasl_cram_md5_challenge_sync (CamelSasl *sasl,
hex = g_checksum_get_string (checksum);
ret = g_byte_array_new ();
- g_byte_array_append (ret, (guint8 *) service->url->user, strlen (service->url->user));
+ g_byte_array_append (ret, (guint8 *) url->user, strlen (url->user));
g_byte_array_append (ret, (guint8 *) " ", 1);
g_byte_array_append (ret, (guint8 *) hex, strlen (hex));
diff --git a/camel/camel-sasl-digest-md5.c b/camel/camel-sasl-digest-md5.c
index 5324f81..526cb82 100644
--- a/camel/camel-sasl-digest-md5.c
+++ b/camel/camel-sasl-digest-md5.c
@@ -791,6 +791,7 @@ sasl_digest_md5_challenge_sync (CamelSasl *sasl,
CamelSaslDigestMd5 *sasl_digest = CAMEL_SASL_DIGEST_MD5 (sasl);
struct _CamelSaslDigestMd5Private *priv = sasl_digest->priv;
CamelService *service;
+ CamelURL *url;
struct _param *rspauth;
GByteArray *ret = NULL;
gboolean abort = FALSE;
@@ -806,7 +807,9 @@ sasl_digest_md5_challenge_sync (CamelSasl *sasl,
service = camel_sasl_get_service (sasl);
service_name = camel_sasl_get_service_name (sasl);
- g_return_val_if_fail (service->url->passwd != NULL, NULL);
+
+ url = camel_service_get_camel_url (service);
+ g_return_val_if_fail (url->passwd != NULL, NULL);
switch (priv->state) {
case STATE_AUTH:
@@ -841,17 +844,16 @@ sasl_digest_md5_challenge_sync (CamelSasl *sasl,
memset (&hints, 0, sizeof (hints));
hints.ai_flags = AI_CANONNAME;
ai = camel_getaddrinfo (
- service->url->host ?
- service->url->host : "localhost",
+ url->host ? url->host : "localhost",
NULL, &hints, cancellable, NULL);
if (ai && ai->ai_canonname)
ptr = ai->ai_canonname;
else
ptr = "localhost.localdomain";
- priv->response = generate_response (priv->challenge, ptr, service_name,
- service->url->user,
- service->url->passwd);
+ priv->response = generate_response (
+ priv->challenge, ptr, service_name,
+ url->user, url->passwd);
if (ai)
camel_freeaddrinfo (ai);
ret = digest_response (priv->response);
@@ -894,7 +896,7 @@ sasl_digest_md5_challenge_sync (CamelSasl *sasl,
return NULL;
}
- compute_response (priv->response, service->url->passwd, FALSE, out);
+ compute_response (priv->response, url->passwd, FALSE, out);
if (memcmp (out, rspauth->value, 32) != 0) {
g_free (rspauth->name);
g_free (rspauth->value);
diff --git a/camel/camel-sasl-gssapi.c b/camel/camel-sasl-gssapi.c
index fac8c83..9be82cf 100644
--- a/camel/camel-sasl-gssapi.c
+++ b/camel/camel-sasl-gssapi.c
@@ -258,6 +258,7 @@ sasl_gssapi_challenge_sync (CamelSasl *sasl,
{
CamelSaslGssapiPrivate *priv;
CamelService *service;
+ CamelURL *url;
OM_uint32 major, minor, flags, time;
gss_buffer_desc inbuf, outbuf;
GByteArray *challenge = NULL;
@@ -274,13 +275,14 @@ sasl_gssapi_challenge_sync (CamelSasl *sasl,
service = camel_sasl_get_service (sasl);
service_name = camel_sasl_get_service_name (sasl);
+ url = camel_service_get_camel_url (service);
+
switch (priv->state) {
case GSSAPI_STATE_INIT:
memset (&hints, 0, sizeof (hints));
hints.ai_flags = AI_CANONNAME;
ai = camel_getaddrinfo (
- service->url->host ?
- service->url->host : "localhost",
+ url->host ? url->host : "localhost",
NULL, &hints, cancellable, error);
if (ai == NULL)
return NULL;
@@ -333,7 +335,7 @@ sasl_gssapi_challenge_sync (CamelSasl *sasl,
if (major == (OM_uint32)GSS_S_FAILURE &&
(minor == (OM_uint32)KRB5KRB_AP_ERR_TKT_EXPIRED ||
minor == (OM_uint32)KRB5KDC_ERR_NEVER_VALID) &&
- send_dbus_message (service->url->user))
+ send_dbus_message (url->user))
goto challenge;
gssapi_set_exception (major, minor, error);
@@ -387,11 +389,11 @@ sasl_gssapi_challenge_sync (CamelSasl *sasl,
return NULL;
}
- inbuf.length = 4 + strlen (service->url->user);
+ inbuf.length = 4 + strlen (url->user);
inbuf.value = str = g_malloc (inbuf.length);
memcpy (inbuf.value, outbuf.value, 4);
str[0] = DESIRED_SECURITY_LAYER;
- memcpy (str + 4, service->url->user, inbuf.length - 4);
+ memcpy (str + 4, url->user, inbuf.length - 4);
#ifndef HAVE_HEIMDAL_KRB5
gss_release_buffer (&minor, &outbuf);
diff --git a/camel/camel-sasl-login.c b/camel/camel-sasl-login.c
index ef16d1b..c5ef80b 100644
--- a/camel/camel-sasl-login.c
+++ b/camel/camel-sasl-login.c
@@ -66,7 +66,8 @@ sasl_login_challenge_sync (CamelSasl *sasl,
priv = CAMEL_SASL_LOGIN (sasl)->priv;
service = camel_sasl_get_service (sasl);
- url = service->url;
+
+ url = camel_service_get_camel_url (service);
g_return_val_if_fail (url->passwd != NULL, NULL);
/* Need to wait for the server */
diff --git a/camel/camel-sasl-ntlm.c b/camel/camel-sasl-ntlm.c
index f51d305..012fd8f 100644
--- a/camel/camel-sasl-ntlm.c
+++ b/camel/camel-sasl-ntlm.c
@@ -673,17 +673,19 @@ sasl_ntlm_challenge_sync (CamelSasl *sasl,
CamelSaslNTLMPrivate *priv = ntlm->priv;
#endif
CamelService *service;
+ CamelURL *url;
GByteArray *ret;
gchar *user;
guchar nonce[8], hash[21], lm_resp[24], nt_resp[24];
GString *domain = NULL;
service = camel_sasl_get_service (sasl);
+ url = camel_service_get_camel_url (service);
ret = g_byte_array_new ();
#ifndef G_OS_WIN32
- if (priv->helper_stream && !service->url->passwd) {
+ if (priv->helper_stream && !url->passwd) {
guchar *data;
gsize length = 0;
char buf[1024];
@@ -758,26 +760,25 @@ sasl_ntlm_challenge_sync (CamelSasl *sasl,
g_checksum_get_digest (md5, digest, &digest_len);
g_checksum_free (md5);
- ntlm_nt_hash (service->url->passwd, (gchar *) hash);
+ ntlm_nt_hash (url->passwd, (gchar *) hash);
ntlm_calc_response (hash, digest, nt_resp);
} else {
/* NTLM1 */
memcpy (nonce, token->data + NTLM_CHALLENGE_NONCE_OFFSET, 8);
- ntlm_lanmanager_hash (service->url->passwd, (gchar *) hash);
+ ntlm_lanmanager_hash (url->passwd, (gchar *) hash);
ntlm_calc_response (hash, nonce, lm_resp);
- ntlm_nt_hash (service->url->passwd, (gchar *) hash);
+ ntlm_nt_hash (url->passwd, (gchar *) hash);
ntlm_calc_response (hash, nonce, nt_resp);
}
/* If a domain is supplied as part of the username, use it */
- user = strchr (service->url->user, '\\');
+ user = strchr (url->user, '\\');
if (user) {
- domain = g_string_new_len (service->url->user,
- user - service->url->user);
+ domain = g_string_new_len (url->user, user - url->user);
user++;
} else
- user = service->url->user;
+ user = url->user;
/* Otherwise, fall back to the domain of the server, if possible */
if (domain == NULL)
@@ -823,13 +824,15 @@ exit:
return ret;
}
-static gboolean sasl_ntlm_try_empty_password_sync (CamelSasl *sasl,
- GCancellable *cancellable,
- GError **error)
+static gboolean
+sasl_ntlm_try_empty_password_sync (CamelSasl *sasl,
+ GCancellable *cancellable,
+ GError **error)
{
#ifndef G_OS_WIN32
CamelStream *stream = camel_stream_process_new ();
- CamelService *service = camel_sasl_get_service (sasl);
+ CamelService *service;
+ CamelURL *url;
CamelSaslNTLM *ntlm = CAMEL_SASL_NTLM (sasl);
CamelSaslNTLMPrivate *priv = ntlm->priv;
gchar *user;
@@ -841,19 +844,25 @@ static gboolean sasl_ntlm_try_empty_password_sync (CamelSasl *sasl,
if (access (NTLM_AUTH_HELPER, X_OK))
return FALSE;
- user = strchr (service->url->user, '\\');
+ service = camel_sasl_get_service (sasl);
+ url = camel_service_get_camel_url (service);
+
+ user = strchr (url->user, '\\');
if (user) {
- command = g_strdup_printf ("%s --helper-protocol ntlmssp-client-1 "
- "--use-cached-creds --username '%s' "
- "--domain '%.*s'", NTLM_AUTH_HELPER,
- user + 1, (int)(user - service->url->user),
- service->url->user);
+ command = g_strdup_printf (
+ "%s --helper-protocol ntlmssp-client-1 "
+ "--use-cached-creds --username '%s' "
+ "--domain '%.*s'", NTLM_AUTH_HELPER,
+ user + 1, (int)(user - url->user),
+ url->user);
} else {
- command = g_strdup_printf ("%s --helper-protocol ntlmssp-client-1 "
- "--use-cached-creds --username '%s'",
- NTLM_AUTH_HELPER, service->url->user);
+ command = g_strdup_printf (
+ "%s --helper-protocol ntlmssp-client-1 "
+ "--use-cached-creds --username '%s'",
+ NTLM_AUTH_HELPER, url->user);
}
- ret = camel_stream_process_connect (CAMEL_STREAM_PROCESS (stream), command, NULL);
+ ret = camel_stream_process_connect (
+ CAMEL_STREAM_PROCESS (stream), command, NULL);
g_free (command);
if (ret) {
g_object_unref (stream);
diff --git a/camel/camel-sasl-plain.c b/camel/camel-sasl-plain.c
index 9609581..d59c54a 100644
--- a/camel/camel-sasl-plain.c
+++ b/camel/camel-sasl-plain.c
@@ -58,7 +58,8 @@ sasl_plain_challenge_sync (CamelSasl *sasl,
CamelURL *url;
service = camel_sasl_get_service (sasl);
- url = service->url;
+
+ url = camel_service_get_camel_url (service);
g_return_val_if_fail (url->passwd != NULL, NULL);
/* FIXME: make sure these are "UTF8-SAFE" */
diff --git a/camel/camel-sasl-popb4smtp.c b/camel/camel-sasl-popb4smtp.c
index c279c01..24caa99 100644
--- a/camel/camel-sasl-popb4smtp.c
+++ b/camel/camel-sasl-popb4smtp.c
@@ -72,7 +72,7 @@ sasl_popb4smtp_challenge_sync (CamelSasl *sasl,
time_t now, *timep;
service = camel_sasl_get_service (sasl);
- session = service->session;
+ session = camel_service_get_session (service);
camel_sasl_set_authenticated (sasl, FALSE);
popuri = camel_session_get_password (
diff --git a/camel/camel-service.c b/camel/camel-service.c
index 888ec49..68efbb3 100644
--- a/camel/camel-service.c
+++ b/camel/camel-service.c
@@ -43,6 +43,13 @@
#define w(x)
struct _CamelServicePrivate {
+ CamelSession *session;
+ CamelProvider *provider;
+ CamelURL *url;
+
+ GCancellable *connect_op;
+ CamelServiceConnectionStatus status;
+
GStaticRecMutex connect_lock; /* for locking connection operations */
GStaticMutex connect_op_lock; /* for locking the connection_op */
};
@@ -54,15 +61,15 @@ service_finalize (GObject *object)
{
CamelService *service = CAMEL_SERVICE (object);
- if (service->status == CAMEL_SERVICE_CONNECTED)
+ if (service->priv->status == CAMEL_SERVICE_CONNECTED)
CAMEL_SERVICE_GET_CLASS (service)->disconnect_sync (
service, TRUE, NULL, NULL);
- if (service->url)
- camel_url_free (service->url);
+ if (service->priv->url)
+ camel_url_free (service->priv->url);
- if (service->session)
- g_object_unref (service->session);
+ if (service->priv->session)
+ g_object_unref (service->priv->session);
g_static_rec_mutex_free (&service->priv->connect_lock);
g_static_mutex_free (&service->priv->connect_op_lock);
@@ -94,11 +101,11 @@ service_construct (CamelService *service,
goto fail;
}
- service->provider = provider;
- service->url = camel_url_copy (url);
- service->session = g_object_ref (session);
+ service->priv->provider = provider;
+ service->priv->url = camel_url_copy (url);
+ service->priv->session = g_object_ref (session);
- service->status = CAMEL_SERVICE_DISCONNECTED;
+ service->priv->status = CAMEL_SERVICE_DISCONNECTED;
return TRUE;
@@ -127,8 +134,8 @@ service_get_name (CamelService *service,
static gchar *
service_get_path (CamelService *service)
{
- CamelProvider *prov = service->provider;
- CamelURL *url = service->url;
+ CamelProvider *prov = service->priv->provider;
+ CamelURL *url = service->priv->url;
GString *gpath;
gchar *path;
@@ -136,7 +143,7 @@ service_get_path (CamelService *service)
* current set of services.
*/
- gpath = g_string_new (service->provider->protocol);
+ gpath = g_string_new (service->priv->provider->protocol);
if (CAMEL_PROVIDER_ALLOWS (prov, CAMEL_URL_PART_USER)) {
if (CAMEL_PROVIDER_ALLOWS (prov, CAMEL_URL_PART_HOST)) {
g_string_append_printf (gpath, "/%s %s",
@@ -170,7 +177,7 @@ service_get_path (CamelService *service)
static void
service_cancel_connect (CamelService *service)
{
- g_cancellable_cancel (service->connect_op);
+ g_cancellable_cancel (service->priv->connect_op);
}
static gboolean
@@ -246,7 +253,7 @@ camel_service_error_quark (void)
/**
* camel_service_construct:
- * @service: a #CamelService object
+ * @service: a #CamelService
* @session: the #CamelSession for @service
* @provider: the #CamelProvider associated with @service
* @url: the default URL for the service (may be %NULL)
@@ -280,7 +287,7 @@ camel_service_construct (CamelService *service,
/**
* camel_service_cancel_connect:
- * @service: a #CamelService object
+ * @service: a #CamelService
*
* If @service is currently attempting to connect to or disconnect
* from a server, this causes it to stop and fail. Otherwise it is a
@@ -297,14 +304,14 @@ camel_service_cancel_connect (CamelService *service)
g_return_if_fail (class->cancel_connect != NULL);
camel_service_lock (service, CAMEL_SERVICE_CONNECT_OP_LOCK);
- if (service->connect_op)
+ if (service->priv->connect_op)
class->cancel_connect (service);
camel_service_unlock (service, CAMEL_SERVICE_CONNECT_OP_LOCK);
}
/**
* camel_service_get_name:
- * @service: a #CamelService object
+ * @service: a #CamelService
* @brief: whether or not to use a briefer form
*
* This gets the name of the service in a "friendly" (suitable for
@@ -321,7 +328,7 @@ camel_service_get_name (CamelService *service,
CamelServiceClass *class;
g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL);
- g_return_val_if_fail (service->url, NULL);
+ g_return_val_if_fail (service->priv->url, NULL);
class = CAMEL_SERVICE_GET_CLASS (service);
g_return_val_if_fail (class->get_name != NULL, NULL);
@@ -331,7 +338,7 @@ camel_service_get_name (CamelService *service,
/**
* camel_service_get_path:
- * @service: a #CamelService object
+ * @service: a #CamelService
*
* This gets a valid UNIX relative path describing @service, which
* is guaranteed to be different from the path returned for any
@@ -347,7 +354,7 @@ camel_service_get_path (CamelService *service)
CamelServiceClass *class;
g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL);
- g_return_val_if_fail (service->url, NULL);
+ g_return_val_if_fail (service->priv->url, NULL);
class = CAMEL_SERVICE_GET_CLASS (service);
g_return_val_if_fail (class->get_path != NULL, NULL);
@@ -357,7 +364,7 @@ camel_service_get_path (CamelService *service)
/**
* camel_service_get_session:
- * @service: a #CamelService object
+ * @service: a #CamelService
*
* Gets the #CamelSession associated with the service.
*
@@ -368,12 +375,12 @@ camel_service_get_session (CamelService *service)
{
g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL);
- return service->session;
+ return service->priv->session;
}
/**
* camel_service_get_provider:
- * @service: a #CamelService object
+ * @service: a #CamelService
*
* Gets the #CamelProvider associated with the service.
*
@@ -384,12 +391,30 @@ camel_service_get_provider (CamelService *service)
{
g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL);
- return service->provider;
+ return service->priv->provider;
+}
+
+/**
+ * camel_service_get_camel_url:
+ * @service: a #CamelService
+ *
+ * Returns the #CamelURL representing @service.
+ *
+ * Returns: the #CamelURL representing @service
+ *
+ * Since: 3.2
+ **/
+CamelURL *
+camel_service_get_camel_url (CamelService *service)
+{
+ g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL);
+
+ return service->priv->url;
}
/**
* camel_service_get_url:
- * @service: a #CamelService object
+ * @service: a #CamelService
*
* Gets the URL representing @service. The returned URL must be
* freed when it is no longer needed. For security reasons, this
@@ -400,14 +425,18 @@ camel_service_get_provider (CamelService *service)
gchar *
camel_service_get_url (CamelService *service)
{
+ CamelURL *url;
+
g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL);
- return camel_url_to_string (service->url, CAMEL_URL_HIDE_PASSWORD);
+ url = camel_service_get_camel_url (service);
+
+ return camel_url_to_string (url, CAMEL_URL_HIDE_PASSWORD);
}
/**
* camel_service_connect_sync:
- * @service: a #CamelService object
+ * @service: a #CamelService
* @error: return location for a #GError, or %NULL
*
* Connect to the service using the parameters it was initialized
@@ -424,15 +453,15 @@ camel_service_connect_sync (CamelService *service,
gboolean ret = FALSE;
g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE);
- g_return_val_if_fail (service->session != NULL, FALSE);
- g_return_val_if_fail (service->url != NULL, FALSE);
+ g_return_val_if_fail (service->priv->session != NULL, FALSE);
+ g_return_val_if_fail (service->priv->url != NULL, FALSE);
class = CAMEL_SERVICE_GET_CLASS (service);
g_return_val_if_fail (class->connect_sync != NULL, FALSE);
camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
- if (service->status == CAMEL_SERVICE_CONNECTED) {
+ if (service->priv->status == CAMEL_SERVICE_CONNECTED) {
camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
return TRUE;
}
@@ -440,19 +469,20 @@ camel_service_connect_sync (CamelService *service,
/* Register a separate operation for connecting, so that
* the offline code can cancel it. */
camel_service_lock (service, CAMEL_SERVICE_CONNECT_OP_LOCK);
- service->connect_op = camel_operation_new ();
- op = service->connect_op;
+ service->priv->connect_op = camel_operation_new ();
+ op = service->priv->connect_op;
camel_service_unlock (service, CAMEL_SERVICE_CONNECT_OP_LOCK);
- service->status = CAMEL_SERVICE_CONNECTING;
- ret = class->connect_sync (service, service->connect_op, error);
+ service->priv->status = CAMEL_SERVICE_CONNECTING;
+ ret = class->connect_sync (service, service->priv->connect_op, error);
CAMEL_CHECK_GERROR (service, connect_sync, ret, error);
- service->status = ret ? CAMEL_SERVICE_CONNECTED : CAMEL_SERVICE_DISCONNECTED;
+ service->priv->status =
+ ret ? CAMEL_SERVICE_CONNECTED : CAMEL_SERVICE_DISCONNECTED;
camel_service_lock (service, CAMEL_SERVICE_CONNECT_OP_LOCK);
g_object_unref (op);
- if (op == service->connect_op)
- service->connect_op = NULL;
+ if (op == service->priv->connect_op)
+ service->priv->connect_op = NULL;
camel_service_unlock (service, CAMEL_SERVICE_CONNECT_OP_LOCK);
camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
@@ -462,7 +492,7 @@ camel_service_connect_sync (CamelService *service,
/**
* camel_service_disconnect_sync:
- * @service: a #CamelService object
+ * @service: a #CamelService
* @clean: whether or not to try to disconnect cleanly
* @error: return location for a #GError, or %NULL
*
@@ -486,37 +516,56 @@ camel_service_disconnect_sync (CamelService *service,
camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
- if (service->status != CAMEL_SERVICE_DISCONNECTED
- && service->status != CAMEL_SERVICE_DISCONNECTING) {
+ if (service->priv->status != CAMEL_SERVICE_DISCONNECTED
+ && service->priv->status != CAMEL_SERVICE_DISCONNECTING) {
GCancellable *op;
camel_service_lock (service, CAMEL_SERVICE_CONNECT_OP_LOCK);
- service->connect_op = camel_operation_new ();
- op = service->connect_op;
+ service->priv->connect_op = camel_operation_new ();
+ op = service->priv->connect_op;
camel_service_unlock (service, CAMEL_SERVICE_CONNECT_OP_LOCK);
- service->status = CAMEL_SERVICE_DISCONNECTING;
+ service->priv->status = CAMEL_SERVICE_DISCONNECTING;
res = class->disconnect_sync (
- service, clean, service->connect_op, error);
+ service, clean, service->priv->connect_op, error);
CAMEL_CHECK_GERROR (service, disconnect_sync, res, error);
- service->status = CAMEL_SERVICE_DISCONNECTED;
+ service->priv->status = CAMEL_SERVICE_DISCONNECTED;
camel_service_lock (service, CAMEL_SERVICE_CONNECT_OP_LOCK);
g_object_unref (op);
- if (op == service->connect_op)
- service->connect_op = NULL;
+ if (op == service->priv->connect_op)
+ service->priv->connect_op = NULL;
camel_service_unlock (service, CAMEL_SERVICE_CONNECT_OP_LOCK);
}
camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
- service->status = CAMEL_SERVICE_DISCONNECTED;
+ service->priv->status = CAMEL_SERVICE_DISCONNECTED;
return res;
}
/**
+ * camel_service_get_connection_status:
+ * @service: a #CamelService
+ *
+ * Returns the connection status for @service.
+ *
+ * Returns: the connection status
+ *
+ * Since: 3.2
+ **/
+CamelServiceConnectionStatus
+camel_service_get_connection_status (CamelService *service)
+{
+ g_return_val_if_fail (
+ CAMEL_IS_SERVICE (service), CAMEL_SERVICE_DISCONNECTED);
+
+ return service->priv->status;
+}
+
+/**
* camel_service_query_auth_types_sync:
- * @service: a #CamelService object
+ * @service: a #CamelService
* @cancellable: optional #GCancellable object, or %NULL
* @error: return location for a #GError, or %NULL
*
diff --git a/camel/camel-service.h b/camel/camel-service.h
index 7eb673d..fd37ce0 100644
--- a/camel/camel-service.h
+++ b/camel/camel-service.h
@@ -102,12 +102,6 @@ typedef enum {
struct _CamelService {
CamelObject parent;
CamelServicePrivate *priv;
-
- struct _CamelSession *session;
- CamelProvider *provider;
- CamelServiceConnectionStatus status;
- GCancellable *connect_op;
- CamelURL *url;
};
struct _CamelServiceClass {
@@ -158,6 +152,7 @@ gchar * camel_service_get_path (CamelService *service);
CamelProvider * camel_service_get_provider (CamelService *service);
struct _CamelSession *
camel_service_get_session (CamelService *service);
+CamelURL * camel_service_get_camel_url (CamelService *service);
gchar * camel_service_get_url (CamelService *service);
void camel_service_cancel_connect (CamelService *service);
gboolean camel_service_connect_sync (CamelService *service,
@@ -165,6 +160,9 @@ gboolean camel_service_connect_sync (CamelService *service,
gboolean camel_service_disconnect_sync (CamelService *service,
gboolean clean,
GError **error);
+CamelServiceConnectionStatus
+ camel_service_get_connection_status
+ (CamelService *service);
GList * camel_service_query_auth_types_sync
(CamelService *service,
GCancellable *cancellable,
diff --git a/camel/camel-session.c b/camel/camel-session.c
index 4f0c296..9146d8d 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -512,21 +512,23 @@ camel_session_get_service_connected (CamelSession *session,
CamelProviderType type,
GError **error)
{
- CamelService *svc;
+ CamelService *service;
+ CamelServiceConnectionStatus status;
- svc = camel_session_get_service (session, url_string, type, error);
- if (svc == NULL)
+ service = camel_session_get_service (session, url_string, type, error);
+ if (service == NULL)
return NULL;
/* FIXME This blocks. Need to take a GCancellable. */
- if (svc->status != CAMEL_SERVICE_CONNECTED) {
- if (!camel_service_connect_sync (svc, error)) {
- g_object_unref (svc);
+ status = camel_service_get_connection_status (service);
+ if (status != CAMEL_SERVICE_CONNECTED) {
+ if (!camel_service_connect_sync (service, error)) {
+ g_object_unref (service);
return NULL;
}
}
- return svc;
+ return service;
}
/**
diff --git a/camel/camel-store.c b/camel/camel-store.c
index a8ecde8..b4a87ad 100644
--- a/camel/camel-store.c
+++ b/camel/camel-store.c
@@ -274,18 +274,18 @@ store_construct (CamelService *service,
if (!service_class->construct (service, session, provider, url, error))
return FALSE;
- store_db_path = g_build_filename (service->url->path, CAMEL_DB_FILE, NULL);
+ store_db_path = g_build_filename (url->path, CAMEL_DB_FILE, NULL);
- if (!service->url->path || strlen (store_db_path) < 2) {
+ if (!url->path || strlen (store_db_path) < 2) {
store_path = camel_session_get_storage_path (session, service, error);
g_free (store_db_path);
store_db_path = g_build_filename (store_path, CAMEL_DB_FILE, NULL);
}
- if (!g_file_test (service->url->path ? service->url->path : store_path, G_FILE_TEST_EXISTS)) {
+ if (!g_file_test (url->path ? url->path : store_path, G_FILE_TEST_EXISTS)) {
/* Cache might be blown. Recreate. */
- g_mkdir_with_parents (service->url->path ? service->url->path : store_path, S_IRWXU);
+ g_mkdir_with_parents (url->path ? url->path : store_path, S_IRWXU);
}
g_free (store_path);
@@ -1613,6 +1613,7 @@ add_special_info (CamelStore *store,
CamelFolderInfoFlags flags)
{
CamelFolderInfo *fi, *vinfo, *parent;
+ CamelProvider *provider;
gchar *uri, *path;
CamelURL *url;
@@ -1625,9 +1626,11 @@ add_special_info (CamelStore *store,
parent = fi;
}
+ provider = camel_service_get_provider (CAMEL_SERVICE (store));
+
/* create our vTrash/vJunk URL */
url = camel_url_new (info->uri, NULL);
- if (((CamelService *) store)->provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH) {
+ if (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH) {
camel_url_set_fragment (url, name);
} else {
path = g_strdup_printf ("/%s", name);
@@ -2024,7 +2027,7 @@ camel_store_folder_uri_equal (CamelStore *store,
class = CAMEL_STORE_GET_CLASS (store);
g_return_val_if_fail (class->compare_folder_name != NULL, FALSE);
- provider = ((CamelService *) store)->provider;
+ provider = camel_service_get_provider (CAMEL_SERVICE (store));
if (!(url0 = camel_url_new (uri0, NULL)))
return FALSE;
@@ -2397,8 +2400,14 @@ camel_store_get_folder_info_sync (CamelStore *store,
}
if (camel_debug_start("store:folder_info")) {
- gchar *url = camel_url_to_string (((CamelService *)store)->url, CAMEL_URL_HIDE_ALL);
- printf("Get folder info(%p:%s, '%s') =\n", (gpointer) store, url, top?top:"<null>");
+ CamelURL *curl;
+ gchar *url;
+
+ curl = camel_service_get_camel_url (CAMEL_SERVICE (store));
+ url = camel_url_to_string (curl, CAMEL_URL_HIDE_ALL);
+ printf (
+ "Get folder info(%p:%s, '%s') =\n",
+ (gpointer) store, url, top ? top : "<null>");
g_free (url);
dump_fi (info, 2);
camel_debug_end ();
diff --git a/camel/camel-vee-folder.c b/camel/camel-vee-folder.c
index 4bd1abd..8b4a233 100644
--- a/camel/camel-vee-folder.c
+++ b/camel/camel-vee-folder.c
@@ -1896,7 +1896,7 @@ vee_folder_folder_changed (CamelVeeFolder *vee_folder,
return;
parent_store = camel_folder_get_parent_store (CAMEL_FOLDER (vee_folder));
- session = CAMEL_SERVICE (parent_store)->session;
+ session = camel_service_get_session (CAMEL_SERVICE (parent_store));
m = camel_session_thread_msg_new (session, &folder_changed_ops, sizeof (*m));
m->changes = camel_folder_change_info_new ();
@@ -2045,8 +2045,10 @@ camel_vee_folder_new (CamelStore *parent_store, const gchar *full, guint32 flags
if (vf) {
CamelObject *object = CAMEL_OBJECT (vf);
+ CamelURL *url;
- tmp = g_strdup_printf ("%s/%s.cmeta", ((CamelService *)parent_store)->url->path, full);
+ url = camel_service_get_camel_url (CAMEL_SERVICE (parent_store));
+ tmp = g_strdup_printf ("%s/%s.cmeta", url->path, full);
camel_object_set_state_filename (object, tmp);
g_free (tmp);
if (camel_object_state_read (object) == -1) {
diff --git a/camel/camel-vee-store.c b/camel/camel-vee-store.c
index 7220da1..4ebed62 100644
--- a/camel/camel-vee-store.c
+++ b/camel/camel-vee-store.c
@@ -65,6 +65,7 @@ change_folder (CamelStore *store,
{
CamelFolderInfo *fi;
const gchar *tmp;
+ CamelURL *service_url;
CamelURL *url;
fi = camel_folder_info_new ();
@@ -76,7 +77,8 @@ change_folder (CamelStore *store,
tmp++;
fi->name = g_strdup (tmp);
url = camel_url_new ("vfolder:", NULL);
- camel_url_set_path (url, ((CamelService *)store)->url->path);
+ service_url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+ camel_url_set_path (url, service_url->path);
if (flags & CHANGE_NOSELECT)
camel_url_set_param (url, "noselect", "yes");
camel_url_set_fragment (url, name);
@@ -246,6 +248,7 @@ vee_store_get_folder_info_sync (CamelStore *store,
if (add) {
CamelStore *parent_store;
+ CamelURL *service_url;
/* ensures unread is correct */
if ((flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0)
@@ -257,7 +260,9 @@ vee_store_get_folder_info_sync (CamelStore *store,
info = camel_folder_info_new ();
url = camel_url_new ("vfolder:", NULL);
- camel_url_set_path (url, ((CamelService *) parent_store)->url->path);
+ service_url = camel_service_get_camel_url (
+ CAMEL_SERVICE (parent_store));
+ camel_url_set_path (url, service_url->path);
camel_url_set_fragment (url, full_name);
info->uri = camel_url_to_string (url, 0);
camel_url_free (url);
@@ -311,9 +316,12 @@ vee_store_get_folder_info_sync (CamelStore *store,
/* and always add UNMATCHED, if scanning from top/etc */
/* FIXME[disk-summary] comment it out well */
if ((top == NULL || top[0] == 0 || strncmp (top, CAMEL_UNMATCHED_NAME, strlen (CAMEL_UNMATCHED_NAME)) == 0)) {
+ CamelURL *service_url;
+
info = camel_folder_info_new ();
url = camel_url_new ("vfolder:", NULL);
- camel_url_set_path (url, ((CamelService *)store)->url->path);
+ service_url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+ camel_url_set_path (url, service_url->path);
camel_url_set_fragment (url, CAMEL_UNMATCHED_NAME);
info->uri = camel_url_to_string (url, 0);
camel_url_free (url);
diff --git a/camel/providers/groupwise/camel-groupwise-folder.c b/camel/providers/groupwise/camel-groupwise-folder.c
index 51f45be..2982f4e 100644
--- a/camel/providers/groupwise/camel-groupwise-folder.c
+++ b/camel/providers/groupwise/camel-groupwise-folder.c
@@ -928,9 +928,12 @@ camel_gw_folder_new (CamelStore *store,
{
CamelFolder *folder;
CamelGroupwiseFolder *gw_folder;
+ CamelURL *url;
gchar *summary_file, *state_file, *journal_file;
gchar *short_name;
+ url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+
short_name = strrchr (folder_name, '/');
if (short_name)
short_name++;
@@ -976,7 +979,7 @@ camel_gw_folder_new (CamelStore *store,
}
if (!strcmp (folder_name, "Mailbox")) {
- if (camel_url_get_param (((CamelService *) store)->url, "filter"))
+ if (camel_url_get_param (url, "filter"))
folder->folder_flags |= CAMEL_FOLDER_FILTER_RECENT;
}
@@ -1007,6 +1010,8 @@ update_update (CamelSession *session,
EGwConnectionStatus status;
CamelGroupwiseStore *gw_store;
CamelStore *parent_store;
+ CamelService *service;
+ CamelServiceConnectionStatus conn_status;
GList *item_list, *items_full_list = NULL, *last_element=NULL;
gint cursor = 0;
const gchar *position = E_GW_CURSOR_POSITION_END;
@@ -1015,13 +1020,18 @@ update_update (CamelSession *session,
parent_store = camel_folder_get_parent_store (m->folder);
gw_store = CAMEL_GROUPWISE_STORE (parent_store);
+ service = CAMEL_SERVICE (gw_store);
+
/* Hold the connect_lock.
In case if user went offline, don't do anything.
m->cnc would have become invalid, as the store disconnect unrefs it.
*/
- camel_service_lock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (gw_store)) ||
- ((CamelService *)gw_store)->status == CAMEL_SERVICE_DISCONNECTED) {
+ camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
+
+ conn_status = camel_service_get_connection_status (service);
+ if (!camel_offline_store_get_online (
+ CAMEL_OFFLINE_STORE (gw_store)) ||
+ conn_status == CAMEL_SERVICE_DISCONNECTED) {
goto end1;
}
@@ -1044,7 +1054,8 @@ update_update (CamelSession *session,
while (!done) {
if (camel_application_is_exiting) {
- camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+ camel_service_unlock (
+ service, CAMEL_SERVICE_REC_CONNECT_LOCK);
return;
}
@@ -1076,7 +1087,7 @@ update_update (CamelSession *session,
}
e_gw_connection_destroy_cursor (m->cnc, m->container_id, cursor);
- camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+ camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
/* Take out only the first part in the list until the @ since it is guaranteed
to be unique only until that symbol */
@@ -1102,7 +1113,7 @@ update_update (CamelSession *session,
return;
end1:
- camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+ camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
camel_operation_pop_message (msg->cancellable);
if (items_full_list) {
g_list_foreach (items_full_list, (GFunc)g_free, NULL);
@@ -1221,6 +1232,7 @@ groupwise_refresh_folder (CamelFolder *folder,
CamelGroupwiseFolder *gw_folder;
CamelGroupwiseSummary *summary = (CamelGroupwiseSummary *)folder->summary;
EGwConnection *cnc;
+ CamelService *service;
CamelSession *session;
CamelStore *parent_store;
gboolean is_proxy;
@@ -1239,7 +1251,8 @@ groupwise_refresh_folder (CamelFolder *folder,
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
- session = CAMEL_SERVICE (parent_store)->session;
+ service = CAMEL_SERVICE (parent_store);
+ session = camel_service_get_session (service);
is_proxy = (parent_store->flags & CAMEL_STORE_PROXY);
gw_folder = CAMEL_GROUPWISE_FOLDER (folder);
@@ -1270,7 +1283,7 @@ groupwise_refresh_folder (CamelFolder *folder,
gw_folder->need_refresh = TRUE;
}
- camel_service_lock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+ camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
if (!camel_groupwise_store_connected (gw_store, cancellable, error))
goto end1;
@@ -1359,7 +1372,7 @@ groupwise_refresh_folder (CamelFolder *folder,
update_summary_string (folder, new_sync_time);
}
- camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+ camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
is_locked = FALSE;
/*
@@ -1390,7 +1403,7 @@ end2:
g_free (container_id);
end1:
if (is_locked)
- camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+ camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
return;
}
@@ -2381,7 +2394,7 @@ groupwise_folder_constructed (GObject *object)
folder = CAMEL_FOLDER (object);
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
- url = CAMEL_SERVICE (parent_store)->url;
+ url = camel_service_get_camel_url (CAMEL_SERVICE (parent_store));
description = g_strdup_printf (
"%s %s:%s", url->user, url->host, full_name);
diff --git a/camel/providers/groupwise/camel-groupwise-store.c b/camel/providers/groupwise/camel-groupwise-store.c
index 25946f1..7f2e06f 100644
--- a/camel/providers/groupwise/camel-groupwise-store.c
+++ b/camel/providers/groupwise/camel-groupwise-store.c
@@ -78,9 +78,11 @@ static gint match_path (const gchar *path, const gchar *name);
G_DEFINE_TYPE (CamelGroupwiseStore, camel_groupwise_store, CAMEL_TYPE_OFFLINE_STORE)
static gboolean
-groupwise_store_construct (CamelService *service, CamelSession *session,
- CamelProvider *provider, CamelURL *url,
- GError **error)
+groupwise_store_construct (CamelService *service,
+ CamelSession *session,
+ CamelProvider *provider,
+ CamelURL *url,
+ GError **error)
{
CamelServiceClass *service_class;
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (service);
@@ -121,9 +123,9 @@ groupwise_store_construct (CamelService *service, CamelSession *session,
priv->user = g_strdup (url->user);
/*base url*/
- priv->base_url = camel_url_to_string (service->url, (CAMEL_URL_HIDE_PASSWORD |
- CAMEL_URL_HIDE_PARAMS |
- CAMEL_URL_HIDE_AUTH) );
+ priv->base_url = camel_url_to_string (
+ url, CAMEL_URL_HIDE_PASSWORD |
+ CAMEL_URL_HIDE_PARAMS | CAMEL_URL_HIDE_AUTH);
/*soap port*/
property_value = camel_url_get_param (url, "soap_port");
@@ -175,30 +177,34 @@ groupwise_auth_loop (CamelService *service,
CamelStore *store = CAMEL_STORE (service);
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (store);
CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
+ CamelURL *url;
gboolean authenticated = FALSE;
gchar *uri;
guint32 prompt_flags = CAMEL_SESSION_PASSWORD_SECRET;
EGwConnectionErrors errors = {E_GW_CONNECTION_STATUS_INVALID_OBJECT, NULL};
+ url = camel_service_get_camel_url (service);
+
if (priv->use_ssl && !g_str_equal (priv->use_ssl, "never"))
uri = g_strconcat ("https://", priv->server_name, ":", priv->port, "/soap", NULL);
else
uri = g_strconcat ("http://", priv->server_name, ":", priv->port, "/soap", NULL);
- service->url->passwd = NULL;
+ url->passwd = NULL;
while (!authenticated) {
- if (!service->url->passwd && !(store->flags & CAMEL_STORE_PROXY)) {
+ if (!url->passwd && !(store->flags & CAMEL_STORE_PROXY)) {
gchar *prompt;
prompt = camel_session_build_password_prompt (
- "GroupWise", service->url->user, service->url->host);
- service->url->passwd =
- camel_session_get_password (session, service, "Groupwise",
- prompt, "password", prompt_flags, error);
+ "GroupWise", url->user, url->host);
+ url->passwd =
+ camel_session_get_password (
+ session, service, "Groupwise", prompt,
+ "password", prompt_flags, error);
g_free (prompt);
- if (!service->url->passwd) {
+ if (!url->passwd) {
g_set_error (
error, G_IO_ERROR,
G_IO_ERROR_CANCELLED,
@@ -207,18 +213,18 @@ groupwise_auth_loop (CamelService *service,
}
}
- priv->cnc = e_gw_connection_new_with_error_handler (uri, priv->user, service->url->passwd, &errors);
+ priv->cnc = e_gw_connection_new_with_error_handler (uri, priv->user, url->passwd, &errors);
if (!E_IS_GW_CONNECTION(priv->cnc) && priv->use_ssl && g_str_equal (priv->use_ssl, "when-possible")) {
gchar *http_uri = g_strconcat ("http://", uri + 8, NULL);
- priv->cnc = e_gw_connection_new (http_uri, priv->user, service->url->passwd);
+ priv->cnc = e_gw_connection_new (http_uri, priv->user, url->passwd);
g_free (http_uri);
}
if (!E_IS_GW_CONNECTION (priv->cnc)) {
if (errors.status == E_GW_CONNECTION_STATUS_INVALID_PASSWORD) {
/* We need to un-cache the password before prompting again */
prompt_flags |= CAMEL_SESSION_PASSWORD_REPROMPT;
- g_free (service->url->passwd);
- service->url->passwd = NULL;
+ g_free (url->passwd);
+ url->passwd = NULL;
} else {
g_set_error (
error, CAMEL_SERVICE_ERROR,
@@ -292,17 +298,25 @@ groupwise_connect_sync (CamelService *service,
CamelGroupwiseStore *store = CAMEL_GROUPWISE_STORE (service);
CamelGroupwiseStorePrivate *priv = store->priv;
CamelGroupwiseStoreNamespace *ns;
- CamelSession *session = service->session;
+ CamelServiceConnectionStatus status;
+ CamelProvider *provider;
+ CamelSession *session;
+ CamelURL *url;
d("in groupwise store connect\n");
- if (service->status == CAMEL_SERVICE_DISCONNECTED)
+ url = camel_service_get_camel_url (service);
+ session = camel_service_get_session (service);
+ provider = camel_service_get_provider (service);
+ status = camel_service_get_connection_status (service);
+
+ if (status == CAMEL_SERVICE_DISCONNECTED)
return FALSE;
if (!priv) {
store->priv = g_new0 (CamelGroupwiseStorePrivate, 1);
priv = store->priv;
- camel_service_construct (service, service->session, service->provider, service->url, error);
+ camel_service_construct (service, session, provider, url, error);
}
camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
@@ -318,7 +332,6 @@ groupwise_connect_sync (CamelService *service,
return FALSE;
}
- service->status = CAMEL_SERVICE_CONNECTED;
camel_offline_store_set_online_sync (
CAMEL_OFFLINE_STORE (store), TRUE, cancellable, NULL);
@@ -981,6 +994,7 @@ groupwise_folders_sync (CamelGroupwiseStore *store,
CamelFolderInfo *info = NULL, *hfi = NULL;
GHashTable *present;
CamelStoreInfo *si = NULL;
+ CamelURL *service_url;
gint count, i;
status = e_gw_connection_get_container_list (priv->cnc, "folders", &folder_list);
@@ -994,12 +1008,13 @@ groupwise_folders_sync (CamelGroupwiseStore *store,
temp_list = folder_list;
list = folder_list;
- url = camel_url_to_string (CAMEL_SERVICE (store)->url,
- (CAMEL_URL_HIDE_PASSWORD|
- CAMEL_URL_HIDE_PARAMS|
- CAMEL_URL_HIDE_AUTH) );
+ service_url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+
+ url = camel_url_to_string (
+ service_url, CAMEL_URL_HIDE_PASSWORD |
+ CAMEL_URL_HIDE_PARAMS | CAMEL_URL_HIDE_AUTH);
- if ( url[strlen (url) - 1] != '/') {
+ if (url[strlen (url) - 1] != '/') {
temp_url = g_strconcat (url, "/", NULL);
g_free ((gchar *)url);
url = temp_url;
@@ -1376,11 +1391,17 @@ groupwise_store_rename_folder_sync (CamelStore *store,
gchar *
groupwise_get_name (CamelService *service, gboolean brief)
{
+ CamelURL *url;
+
+ url = camel_service_get_camel_url (service);
+
if (brief)
- return g_strdup_printf(_("GroupWise server %s"), service->url->host);
+ return g_strdup_printf (
+ _("GroupWise server %s"), url->host);
else
- return g_strdup_printf(_("GroupWise service for %s on %s"),
- service->url->user, service->url->host);
+ return g_strdup_printf (
+ _("GroupWise service for %s on %s"),
+ url->user, url->host);
}
const gchar *
@@ -1442,10 +1463,14 @@ groupwise_store_get_trash_folder_sync (CamelStore *store,
static gboolean
groupwise_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, GError **error)
{
+ CamelURL *url;
gboolean res;
- res = CAMEL_STORE_CLASS (camel_groupwise_store_parent_class)->can_refresh_folder (store, info, error) ||
- (camel_url_get_param (((CamelService *)store)->url, "check_all") != NULL);
+ url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+
+ res = CAMEL_STORE_CLASS (camel_groupwise_store_parent_class)->
+ can_refresh_folder (store, info, error) ||
+ (camel_url_get_param (url, "check_all") != NULL);
return res;
}
diff --git a/camel/providers/groupwise/camel-groupwise-transport.c b/camel/providers/groupwise/camel-groupwise-transport.c
index 3b5336b..6f2876d 100644
--- a/camel/providers/groupwise/camel-groupwise-transport.c
+++ b/camel/providers/groupwise/camel-groupwise-transport.c
@@ -42,14 +42,18 @@ static gchar *
groupwise_transport_get_name (CamelService *service,
gboolean brief)
{
+ CamelURL *url;
+
+ url = camel_service_get_camel_url (service);
+
if (brief)
return g_strdup_printf (
_("GroupWise server %s"),
- service->url->host);
+ url->host);
else
return g_strdup_printf (
_("GroupWise mail delivery via %s"),
- service->url->host);
+ url->host);
}
static gboolean
@@ -69,7 +73,9 @@ groupwise_send_to_sync (CamelTransport *transport,
GError **error)
{
CamelService *service;
- CamelStore *store = NULL;
+ CamelSession *session;
+ CamelStore *store = NULL;
+ CamelURL *service_url;
CamelGroupwiseStore *groupwise_store = NULL;
CamelGroupwiseStorePrivate *priv = NULL;
EGwItem *item ,*temp_item=NULL;
@@ -89,15 +95,17 @@ groupwise_send_to_sync (CamelTransport *transport,
}
service = CAMEL_SERVICE (transport);
- url = camel_url_to_string (service->url,
- (CAMEL_URL_HIDE_PASSWORD |
- CAMEL_URL_HIDE_PARAMS |
- CAMEL_URL_HIDE_AUTH) );
+ session = camel_service_get_session (service);
+ service_url = camel_service_get_camel_url (service);
+
+ url = camel_url_to_string (
+ service_url, CAMEL_URL_HIDE_PASSWORD |
+ CAMEL_URL_HIDE_PARAMS | CAMEL_URL_HIDE_AUTH);
camel_operation_push_message (cancellable, _("Sending Message") );
/*camel groupwise store and cnc*/
- store = camel_session_get_store (service->session, url, NULL);
+ store = camel_session_get_store (session, url, NULL);
g_free (url);
if (!store) {
g_warning ("ERROR: Could not get a pointer to the store");
diff --git a/camel/providers/imap/camel-imap-command.c b/camel/providers/imap/camel-imap-command.c
index 23017ac..8194ff3 100644
--- a/camel/providers/imap/camel-imap-command.c
+++ b/camel/providers/imap/camel-imap-command.c
@@ -387,13 +387,24 @@ camel_imap_command_response (CamelImapStore *store,
else if (!g_ascii_strncasecmp (respbuf, "* OK [ALERT]", 12)
|| !g_ascii_strncasecmp (respbuf, "* NO [ALERT]", 12)
|| !g_ascii_strncasecmp (respbuf, "* BAD [ALERT]", 13)) {
+ CamelService *service;
+ CamelSession *session;
+ CamelURL *url;
gchar *msg;
/* for imap ALERT codes, account user host */
- /* we might get a ']' from a BAD response since we +12, but who cares? */
- msg = g_strdup_printf(_("Alert from IMAP server %s %s:\n%s"),
- ((CamelService *)store)->url->user, ((CamelService *)store)->url->host, respbuf+12);
- camel_session_alert_user (((CamelService *)store)->session, CAMEL_SESSION_ALERT_WARNING, msg, FALSE);
+ /* we might get a ']' from a BAD response since we +12,
+ * but who cares? */
+ service = CAMEL_SERVICE (store);
+ url = camel_service_get_camel_url (service);
+ session = camel_service_get_session (service);
+
+ msg = g_strdup_printf(
+ _("Alert from IMAP server %s %s:\n%s"),
+ url->user, url->host, respbuf + 12);
+ camel_session_alert_user (
+ session, CAMEL_SESSION_ALERT_WARNING,
+ msg, FALSE);
g_free (msg);
}
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index 83751c1..c4bd8c5 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -242,7 +242,7 @@ imap_folder_constructed (GObject *object)
folder = CAMEL_FOLDER (object);
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
- url = CAMEL_SERVICE (parent_store)->url;
+ url = camel_service_get_camel_url (CAMEL_SERVICE (parent_store));
description = g_strdup_printf (
"%s %s:%s", url->user, url->host, full_name);
@@ -1497,6 +1497,7 @@ static gboolean
is_google_account (CamelStore *store)
{
CamelService *service;
+ CamelURL *url;
g_return_val_if_fail (store != NULL, FALSE);
g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE);
@@ -1504,9 +1505,11 @@ is_google_account (CamelStore *store)
service = CAMEL_SERVICE (store);
g_return_val_if_fail (service != NULL, FALSE);
- return service->url && service->url->host && (
- host_ends_with (service->url->host, "gmail.com") ||
- host_ends_with (service->url->host, "googlemail.com"));
+ url = camel_service_get_camel_url (service);
+
+ return url != NULL && url->host != NULL && (
+ host_ends_with (url->host, "gmail.com") ||
+ host_ends_with (url->host, "googlemail.com"));
}
static void
@@ -3892,6 +3895,7 @@ imap_update_summary (CamelFolder *folder,
GError **error)
{
CamelStore *parent_store;
+ CamelService *service;
CamelImapStore *store;
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
GPtrArray *fetch_data = NULL, *messages = NULL, *needheaders;
@@ -3907,6 +3911,7 @@ imap_update_summary (CamelFolder *folder,
parent_store = camel_folder_get_parent_store (folder);
store = CAMEL_IMAP_STORE (parent_store);
+ service = CAMEL_SERVICE (store);
if (store->server_level >= IMAP_LEVEL_IMAP4REV1) {
if (store->headers == IMAP_FETCH_ALL_HEADERS)
@@ -4008,7 +4013,7 @@ imap_update_summary (CamelFolder *folder,
if (type == CAMEL_IMAP_RESPONSE_ERROR || camel_application_is_exiting) {
if (type != CAMEL_IMAP_RESPONSE_ERROR && type != CAMEL_IMAP_RESPONSE_TAGGED)
- camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+ camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
goto lose;
}
@@ -4081,7 +4086,7 @@ imap_update_summary (CamelFolder *folder,
camel_operation_pop_message (cancellable);
if (type != CAMEL_IMAP_RESPONSE_ERROR && type != CAMEL_IMAP_RESPONSE_TAGGED)
- camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+ camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
goto lose;
}
@@ -4155,7 +4160,7 @@ imap_update_summary (CamelFolder *folder,
/* Just do this to build the junk required headers to be built*/
jdata.data = data;
jdata.mi = (CamelMessageInfoBase *) mi;
- g_hash_table_foreach ((GHashTable *)camel_session_get_junk_headers (((CamelService *) store)->session), (GHFunc) construct_junk_headers, &jdata);
+ g_hash_table_foreach ((GHashTable *)camel_session_get_junk_headers (camel_service_get_session (service)), (GHFunc) construct_junk_headers, &jdata);
g_datalist_clear (&data);
}
g_ptr_array_free (fetch_data, TRUE);
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index 902feee..74c1fc8 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -221,6 +221,7 @@ connect_to_server (CamelService *service,
{
CamelImapStore *store = (CamelImapStore *) service;
CamelSession *session;
+ CamelURL *url;
gchar *socks_host;
gint socks_port;
CamelImapResponse *response;
@@ -230,18 +231,21 @@ connect_to_server (CamelService *service,
gboolean clean_quit = TRUE;
gchar *buf;
+ url = camel_service_get_camel_url (service);
+ session = camel_service_get_session (service);
+
if (ssl_mode != MODE_CLEAR) {
#ifdef CAMEL_HAVE_SSL
if (ssl_mode == MODE_TLS)
- tcp_stream = camel_tcp_stream_ssl_new_raw (service->session, service->url->host, STARTTLS_FLAGS);
+ tcp_stream = camel_tcp_stream_ssl_new_raw (session, url->host, STARTTLS_FLAGS);
else
- tcp_stream = camel_tcp_stream_ssl_new (service->session, service->url->host, SSL_PORT_FLAGS);
+ tcp_stream = camel_tcp_stream_ssl_new (session, url->host, SSL_PORT_FLAGS);
#else
g_set_error (
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_UNAVAILABLE,
_("Could not connect to %s: %s"),
- service->url->host, _("SSL unavailable"));
+ url->host, _("SSL unavailable"));
return FALSE;
@@ -249,7 +253,6 @@ connect_to_server (CamelService *service,
} else
tcp_stream = camel_tcp_stream_raw_new ();
- session = camel_service_get_session (service);
camel_session_get_socks_proxy (session, &socks_host, &socks_port);
if (socks_host) {
@@ -262,7 +265,7 @@ connect_to_server (CamelService *service,
fallback_port, cancellable, error) == -1) {
g_prefix_error (
error, _("Could not connect to %s: "),
- service->url->host);
+ url->host);
g_object_unref (tcp_stream);
return FALSE;
}
@@ -368,7 +371,7 @@ connect_to_server (CamelService *service,
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to connect to IMAP server %s in secure mode: %s"),
- service->url->host, _("STARTTLS not supported"));
+ url->host, _("STARTTLS not supported"));
goto exception;
}
@@ -388,14 +391,14 @@ connect_to_server (CamelService *service,
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to connect to IMAP server %s in secure mode: %s"),
- service->url->host, _("SSL negotiations failed"));
+ url->host, _("SSL negotiations failed"));
goto exception;
}
#else
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to connect to IMAP server %s in secure mode: %s"),
- service->url->host, _("SSL is not available in this build"));
+ url->host, _("SSL is not available in this build"));
goto exception;
#endif /* CAMEL_HAVE_SSL */
@@ -422,7 +425,7 @@ connect_to_server (CamelService *service,
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to connect to IMAP server %s in secure mode: %s"),
- service->url->host, _("Unknown error"));
+ url->host, _("Unknown error"));
goto exception;
}
@@ -464,27 +467,30 @@ connect_to_server_process (CamelService *service,
{
CamelImapStore *store = (CamelImapStore *) service;
CamelStream *cmd_stream;
+ CamelURL *url;
gint ret, i = 0;
gchar *buf;
gchar *cmd_copy;
gchar *full_cmd;
gchar *child_env[7];
+ url = camel_service_get_camel_url (service);
+
/* Put full details in the environment, in case the connection
program needs them */
- buf = camel_url_to_string (service->url, 0);
+ buf = camel_url_to_string (url, 0);
child_env[i++] = g_strdup_printf("URL=%s", buf);
g_free (buf);
- child_env[i++] = g_strdup_printf("URLHOST=%s", service->url->host);
- if (service->url->port)
- child_env[i++] = g_strdup_printf("URLPORT=%d", service->url->port);
- if (service->url->user)
- child_env[i++] = g_strdup_printf("URLUSER=%s", service->url->user);
- if (service->url->passwd)
- child_env[i++] = g_strdup_printf("URLPASSWD=%s", service->url->passwd);
- if (service->url->path)
- child_env[i++] = g_strdup_printf("URLPATH=%s", service->url->path);
+ child_env[i++] = g_strdup_printf("URLHOST=%s", url->host);
+ if (url->port)
+ child_env[i++] = g_strdup_printf("URLPORT=%d", url->port);
+ if (url->user)
+ child_env[i++] = g_strdup_printf("URLUSER=%s", url->user);
+ if (url->passwd)
+ child_env[i++] = g_strdup_printf("URLPASSWD=%s", url->passwd);
+ if (url->path)
+ child_env[i++] = g_strdup_printf("URLPATH=%s", url->path);
child_env[i] = NULL;
/* Now do %h, %u, etc. substitution in cmd */
@@ -513,10 +519,10 @@ connect_to_server_process (CamelService *service,
switch (pc[1]) {
case 'h':
- var = service->url->host;
+ var = url->host;
break;
case 'u':
- var = service->url->user;
+ var = url->user;
break;
}
if (!var) {
@@ -614,6 +620,7 @@ connect_to_server_wrapper (CamelService *service,
GCancellable *cancellable,
GError **error)
{
+ CamelURL *url;
const gchar *ssl_mode;
gint mode, i;
const gchar *serv;
@@ -621,13 +628,17 @@ connect_to_server_wrapper (CamelService *service,
#ifndef G_OS_WIN32
const gchar *command;
+#endif
+
+ url = camel_service_get_camel_url (service);
- if (camel_url_get_param(service->url, "use_command")
- && (command = camel_url_get_param(service->url, "command")))
+#ifndef G_OS_WIN32
+ if (camel_url_get_param (url, "use_command")
+ && (command = camel_url_get_param (url, "command")))
return connect_to_server_process (service, command, cancellable, error);
#endif
- if ((ssl_mode = camel_url_get_param (service->url, "use_ssl"))) {
+ if ((ssl_mode = camel_url_get_param (url, "use_ssl"))) {
for (i = 0; ssl_options[i].value; i++)
if (!strcmp (ssl_options[i].value, ssl_mode))
break;
@@ -640,14 +651,14 @@ connect_to_server_wrapper (CamelService *service,
fallback_port = IMAP_PORT;
}
- if (service->url->port) {
+ if (url->port) {
serv = g_alloca (16);
- sprintf ((gchar *)serv, "%d", service->url->port);
+ sprintf ((gchar *)serv, "%d", url->port);
fallback_port = 0;
}
return connect_to_server (
- service, service->url->host, serv,
+ service, url->host, serv,
fallback_port, mode, cancellable, error);
}
@@ -657,14 +668,18 @@ try_auth (CamelImapStore *store,
GCancellable *cancellable,
GError **error)
{
- CamelService *service = CAMEL_SERVICE (store);
+ CamelService *service;
CamelImapResponse *response;
+ CamelURL *url;
gchar *resp;
gchar *sasl_resp;
- response = camel_imap_command (store, NULL, cancellable, error,
- "AUTHENTICATE %s",
- service->url->authmech);
+ service = CAMEL_SERVICE (store);
+ url = camel_service_get_camel_url (service);
+
+ response = camel_imap_command (
+ store, NULL, cancellable, error,
+ "AUTHENTICATE %s", url->authmech);
if (!response) {
g_object_unref (sasl);
return FALSE;
@@ -722,44 +737,45 @@ imap_auth_loop (CamelService *service,
CamelServiceAuthType *authtype = NULL;
CamelImapResponse *response;
CamelSasl *sasl = NULL;
+ CamelURL *url;
gchar *errbuf = NULL;
gboolean authenticated = FALSE;
const gchar *auth_domain;
guint32 prompt_flags = CAMEL_SESSION_PASSWORD_SECRET;
- auth_domain = camel_url_get_param (service->url, "auth-domain");
+ url = camel_service_get_camel_url (service);
+ auth_domain = camel_url_get_param (url, "auth-domain");
if (store->preauthed) {
if (camel_verbose_debug)
fprintf(stderr, "Server %s has preauthenticated us.\n",
- service->url->host);
+ url->host);
return TRUE;
}
- if (service->url->authmech) {
- if (!g_hash_table_lookup (store->authtypes, service->url->authmech)) {
+ if (url->authmech) {
+ if (!g_hash_table_lookup (store->authtypes, url->authmech)) {
g_set_error (
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("IMAP server %s does not support requested "
"authentication type %s"),
- service->url->host,
- service->url->authmech);
+ url->host, url->authmech);
return FALSE;
}
- authtype = camel_sasl_authtype (service->url->authmech);
+ authtype = camel_sasl_authtype (url->authmech);
if (!authtype) {
g_set_error (
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("No support for authentication type %s"),
- service->url->authmech);
+ url->authmech);
return FALSE;
}
- sasl = camel_sasl_new ("imap", service->url->authmech,
- CAMEL_SERVICE (store));
+ sasl = camel_sasl_new (
+ "imap", url->authmech, service);
if (!sasl) {
nosasl:
g_set_error (
@@ -783,23 +799,23 @@ imap_auth_loop (CamelService *service,
if (errbuf) {
/* We need to un-cache the password before prompting again */
prompt_flags |= CAMEL_SESSION_PASSWORD_REPROMPT;
- g_free (service->url->passwd);
- service->url->passwd = NULL;
+ g_free (url->passwd);
+ url->passwd = NULL;
}
- if (!service->url->passwd) {
+ if (!url->passwd) {
gchar *base_prompt;
gchar *full_prompt;
base_prompt = camel_session_build_password_prompt (
- "IMAP", service->url->user, service->url->host);
+ "IMAP", url->user, url->host);
if (errbuf != NULL)
full_prompt = g_strconcat (errbuf, base_prompt, NULL);
else
full_prompt = g_strdup (base_prompt);
- service->url->passwd = camel_session_get_password (
+ url->passwd = camel_session_get_password (
session, service, auth_domain, full_prompt,
"password", prompt_flags, error);
@@ -808,7 +824,7 @@ imap_auth_loop (CamelService *service,
g_free (errbuf);
errbuf = NULL;
- if (!service->url->passwd) {
+ if (!url->passwd) {
g_set_error (
error, G_IO_ERROR,
G_IO_ERROR_CANCELLED,
@@ -829,18 +845,17 @@ imap_auth_loop (CamelService *service,
if (authtype) {
if (!sasl)
- sasl = camel_sasl_new ("imap", service->url->authmech,
- CAMEL_SERVICE (store));
+ sasl = camel_sasl_new (
+ "imap", url->authmech, service);
if (!sasl)
goto nosasl;
authenticated = try_auth (store, sasl, cancellable,
&local_error);
sasl = NULL;
} else {
- response = camel_imap_command (store, NULL, cancellable, &local_error,
- "LOGIN %S %S",
- service->url->user,
- service->url->passwd);
+ response = camel_imap_command (
+ store, NULL, cancellable, &local_error,
+ "LOGIN %S %S", url->user, url->passwd);
if (response) {
camel_imap_response_free (store, response);
authenticated = TRUE;
@@ -928,9 +943,9 @@ imap_store_construct (CamelService *service,
return FALSE;
/* FIXME */
- imap_store->base_url = camel_url_to_string (service->url, (CAMEL_URL_HIDE_PASSWORD |
- CAMEL_URL_HIDE_PARAMS |
- CAMEL_URL_HIDE_AUTH));
+ imap_store->base_url = camel_url_to_string (
+ url, CAMEL_URL_HIDE_PASSWORD |
+ CAMEL_URL_HIDE_PARAMS | CAMEL_URL_HIDE_AUTH);
imap_store->parameters = 0;
if (camel_url_get_param (url, "use_lsub"))
@@ -1013,14 +1028,17 @@ static gchar *
imap_store_get_name (CamelService *service,
gboolean brief)
{
+ CamelURL *url;
+
+ url = camel_service_get_camel_url (service);
+
if (brief)
return g_strdup_printf (
- _("IMAP server %s"),
- service->url->host);
+ _("IMAP server %s"), url->host);
else
return g_strdup_printf (
_("IMAP service for %s on %s"),
- service->url->user, service->url->host);
+ url->user, url->host);
}
static gboolean
@@ -2760,6 +2778,11 @@ imap_store_get_folder_info_sync (CamelStore *store,
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
CamelFolderInfo *tree = NULL;
+ CamelService *service;
+ CamelSession *session;
+
+ service = CAMEL_SERVICE (store);
+ session = camel_service_get_session (service);
/* If we have a list of folders already, use that, but if we haven't
updated for a while, then trigger an asynchronous rescan. Otherwise
@@ -2784,19 +2807,23 @@ imap_store_get_folder_info_sync (CamelStore *store,
now = time (NULL);
ref = now > imap_store->refresh_stamp+60*60*1;
if (ref) {
- camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+ camel_service_lock (
+ service, CAMEL_SERVICE_REC_CONNECT_LOCK);
ref = now > imap_store->refresh_stamp+60*60*1;
if (ref) {
struct _refresh_msg *m;
imap_store->refresh_stamp = now;
- m = camel_session_thread_msg_new (((CamelService *)store)->session, &refresh_ops, sizeof (*m));
+ m = camel_session_thread_msg_new (
+ session, &refresh_ops, sizeof (*m));
m->store = g_object_ref (store);
m->error = NULL;
- camel_session_thread_queue (((CamelService *)store)->session, &m->msg, 0);
+ camel_session_thread_queue (
+ session, &m->msg, 0);
}
- camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+ camel_service_unlock (
+ service, CAMEL_SERVICE_REC_CONNECT_LOCK);
}
} else {
gchar *pattern;
@@ -3191,12 +3218,17 @@ imap_can_refresh_folder (CamelStore *store,
CamelFolderInfo *info,
GError **error)
{
+ CamelURL *url;
gboolean res;
GError *local_error = NULL;
- res = CAMEL_STORE_CLASS (camel_imap_store_parent_class)->can_refresh_folder (store, info, &local_error) ||
- (camel_url_get_param (((CamelService *)store)->url, "check_all") != NULL) ||
- (camel_url_get_param (((CamelService *)store)->url, "check_lsub") != NULL && (info->flags & CAMEL_FOLDER_SUBSCRIBED) != 0);
+ url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+
+ res = CAMEL_STORE_CLASS (camel_imap_store_parent_class)->
+ can_refresh_folder (store, info, &local_error) ||
+ (camel_url_get_param (url, "check_all") != NULL) ||
+ (camel_url_get_param (url, "check_lsub") != NULL &&
+ (info->flags & CAMEL_FOLDER_SUBSCRIBED) != 0);
if (!res && local_error == NULL && CAMEL_IS_IMAP_STORE (store)) {
CamelStoreInfo *si;
diff --git a/camel/providers/imap/camel-imap-wrapper.c b/camel/providers/imap/camel-imap-wrapper.c
index 8f5130b..fe8db14 100644
--- a/camel/providers/imap/camel-imap-wrapper.c
+++ b/camel/providers/imap/camel-imap-wrapper.c
@@ -159,12 +159,15 @@ camel_imap_wrapper_new (CamelImapFolder *imap_folder,
CamelImapWrapper *imap_wrapper;
CamelStore *store;
CamelStream *stream;
+ CamelURL *url;
gboolean sync_offline = FALSE;
store = camel_folder_get_parent_store (CAMEL_FOLDER (imap_folder));
+ url = camel_service_get_camel_url (CAMEL_SERVICE (store));
sync_offline =
- camel_url_get_param (((CamelService *) store)->url, "sync_offline") != NULL ||
- camel_offline_folder_get_offline_sync (CAMEL_OFFLINE_FOLDER (imap_folder));
+ camel_url_get_param (url, "sync_offline") != NULL ||
+ camel_offline_folder_get_offline_sync (
+ CAMEL_OFFLINE_FOLDER (imap_folder));
imap_wrapper = g_object_new (CAMEL_TYPE_IMAP_WRAPPER, NULL);
camel_data_wrapper_set_mime_type_field (CAMEL_DATA_WRAPPER (imap_wrapper), type);
diff --git a/camel/providers/imapx/camel-imapx-conn-manager.c b/camel/providers/imapx/camel-imapx-conn-manager.c
index 4134907..47829f7 100644
--- a/camel/providers/imapx/camel-imapx-conn-manager.c
+++ b/camel/providers/imapx/camel-imapx-conn-manager.c
@@ -243,19 +243,24 @@ imapx_create_new_connection (CamelIMAPXConnManager *con_man,
{
CamelIMAPXServer *conn;
CamelStore *store = con_man->priv->store;
+ CamelService *service;
+ CamelURL *url;
ConnectionInfo *cinfo = NULL;
+ service = CAMEL_SERVICE (store);
+ url = camel_service_get_camel_url (service);
+
CON_LOCK (con_man);
- camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+ camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
- conn = camel_imapx_server_new (CAMEL_STORE (store), CAMEL_SERVICE (store)->url);
+ conn = camel_imapx_server_new (store, url);
if (camel_imapx_server_connect (conn, cancellable, error)) {
g_object_ref (conn);
} else {
g_object_unref (conn);
- camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+ camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
CON_UNLOCK (con_man);
return NULL;
@@ -264,7 +269,7 @@ imapx_create_new_connection (CamelIMAPXConnManager *con_man,
g_signal_connect (conn, "shutdown", G_CALLBACK (imapx_conn_shutdown), con_man);
g_signal_connect (conn, "select_changed", G_CALLBACK (imapx_conn_update_select), con_man);
- camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+ camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
cinfo = g_new0 (ConnectionInfo, 1);
cinfo->conn = conn;
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 8f49b67..7a0e6ab 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -3012,13 +3012,17 @@ imapx_reconnect (CamelIMAPXServer *is,
{
CamelIMAPXCommand *ic;
gchar *errbuf = NULL;
- CamelService *service = (CamelService *) is->store;
+ CamelService *service;
+ CamelURL *url;
const gchar *auth_domain = NULL;
gboolean authenticated = FALSE;
CamelServiceAuthType *authtype = NULL;
guint32 prompt_flags = CAMEL_SESSION_PASSWORD_SECRET;
gboolean need_password = FALSE;
+ service = CAMEL_SERVICE (is->store);
+ url = camel_service_get_camel_url (service);
+
while (!authenticated) {
CamelSasl *sasl = NULL;
@@ -3030,8 +3034,8 @@ imapx_reconnect (CamelIMAPXServer *is,
} else if (errbuf) {
/* We need to un-cache the password before prompting again */
prompt_flags |= CAMEL_SESSION_PASSWORD_REPROMPT;
- g_free (service->url->passwd);
- service->url->passwd = NULL;
+ g_free (url->passwd);
+ url->passwd = NULL;
}
if (!imapx_connect_to_server (is, cancellable, error))
@@ -3040,26 +3044,25 @@ imapx_reconnect (CamelIMAPXServer *is,
if (is->state == IMAPX_AUTHENTICATED)
goto preauthed;
- if (!authtype && service->url->authmech) {
- if (!g_hash_table_lookup (is->cinfo->auth_types, service->url->authmech)) {
+ if (!authtype && url->authmech) {
+ if (!g_hash_table_lookup (is->cinfo->auth_types, url->authmech)) {
g_set_error (
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("IMAP server %s does not support requested "
"authentication type %s"),
- service->url->host,
- service->url->authmech);
+ url->host, url->authmech);
goto exception;
}
- authtype = camel_sasl_authtype (service->url->authmech);
+ authtype = camel_sasl_authtype (url->authmech);
if (!authtype) {
noauth:
g_set_error (
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("No support for authentication type %s"),
- service->url->authmech);
+ url->authmech);
goto exception;
}
}
@@ -3077,29 +3080,30 @@ imapx_reconnect (CamelIMAPXServer *is,
} else
need_password = TRUE;
- if (need_password && service->url->passwd == NULL) {
+ if (need_password && url->passwd == NULL) {
gchar *base_prompt;
gchar *full_prompt;
base_prompt = camel_session_build_password_prompt (
- "IMAP", service->url->user, service->url->host);
+ "IMAP", url->user, url->host);
if (errbuf != NULL)
full_prompt = g_strconcat (errbuf, base_prompt, NULL);
else
full_prompt = g_strdup (base_prompt);
- auth_domain = camel_url_get_param (service->url, "auth-domain");
- service->url->passwd = camel_session_get_password (is->session, (CamelService *)is->store,
- auth_domain,
- full_prompt, "password", prompt_flags, error);
+ auth_domain = camel_url_get_param (url, "auth-domain");
+ url->passwd = camel_session_get_password (
+ is->session, (CamelService *)is->store,
+ auth_domain, full_prompt, "password",
+ prompt_flags, error);
g_free (base_prompt);
g_free (full_prompt);
g_free (errbuf);
errbuf = NULL;
- if (!service->url->passwd) {
+ if (!url->passwd) {
g_set_error (
error, G_IO_ERROR,
G_IO_ERROR_CANCELLED,
@@ -3117,8 +3121,7 @@ imapx_reconnect (CamelIMAPXServer *is,
} else {
ic = camel_imapx_command_new (
is, "LOGIN", NULL, cancellable,
- "LOGIN %s %s", service->url->user,
- service->url->passwd);
+ "LOGIN %s %s", url->user, url->passwd);
}
imapx_command_run (is, ic);
@@ -5097,10 +5100,15 @@ camel_imapx_server_init (CamelIMAPXServer *is)
CamelIMAPXServer *
camel_imapx_server_new (CamelStore *store, CamelURL *url)
{
+ CamelService *service;
+ CamelSession *session;
CamelIMAPXServer *is;
+ service = CAMEL_SERVICE (store);
+ session = camel_service_get_session (service);
+
is = g_object_new (CAMEL_TYPE_IMAPX_SERVER, NULL);
- is->session = g_object_ref (CAMEL_SERVICE (store)->session);
+ is->session = g_object_ref (session);
is->store = store;
is->url = camel_url_copy (url);
diff --git a/camel/providers/imapx/camel-imapx-store.c b/camel/providers/imapx/camel-imapx-store.c
index d3b9c8c..5ccb1b4 100644
--- a/camel/providers/imapx/camel-imapx-store.c
+++ b/camel/providers/imapx/camel-imapx-store.c
@@ -143,7 +143,11 @@ imapx_store_finalize (GObject *object)
}
static gboolean
-imapx_construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, GError **error)
+imapx_construct (CamelService *service,
+ CamelSession *session,
+ CamelProvider *provider,
+ CamelURL *url,
+ GError **error)
{
gchar *summary;
CamelIMAPXStore *store = (CamelIMAPXStore *)service;
@@ -153,10 +157,10 @@ imapx_construct (CamelService *service, CamelSession *session, CamelProvider *pr
if (!service_class->construct (service, session, provider, url, error))
return FALSE;
- store->base_url = camel_url_to_string (service->url, (CAMEL_URL_HIDE_PASSWORD |
- CAMEL_URL_HIDE_PARAMS |
- CAMEL_URL_HIDE_AUTH));
- imapx_parse_receiving_options (store, service->url);
+ store->base_url = camel_url_to_string (
+ url, CAMEL_URL_HIDE_PASSWORD |
+ CAMEL_URL_HIDE_PARAMS | CAMEL_URL_HIDE_AUTH);
+ imapx_parse_receiving_options (store, url);
store->summary = camel_imapx_store_summary_new ();
store->storage_path = camel_session_get_storage_path (session, service, error);
@@ -167,7 +171,8 @@ imapx_construct (CamelService *service, CamelSession *session, CamelProvider *pr
summary = g_build_filename(store->storage_path, ".ev-store-summary", NULL);
camel_store_summary_set_filename ((CamelStoreSummary *)store->summary, summary);
/* FIXME: need to remove params, passwords, etc */
- camel_store_summary_set_uri_base ((CamelStoreSummary *)store->summary, service->url);
+ camel_store_summary_set_uri_base (
+ (CamelStoreSummary *)store->summary, url);
camel_store_summary_load ((CamelStoreSummary *)store->summary);
g_free (summary);
@@ -178,11 +183,17 @@ imapx_construct (CamelService *service, CamelSession *session, CamelProvider *pr
static gchar *
imapx_get_name (CamelService *service, gboolean brief)
{
+ CamelURL *url;
+
+ url = camel_service_get_camel_url (service);
+
if (brief)
- return g_strdup_printf (_("IMAP server %s"), service->url->host);
+ return g_strdup_printf (
+ _("IMAP server %s"), url->host);
else
- return g_strdup_printf (_("IMAP service for %s on %s"),
- service->url->user, service->url->host);
+ return g_strdup_printf (
+ _("IMAP service for %s on %s"),
+ url->user, url->host);
}
CamelIMAPXServer *
@@ -265,6 +276,7 @@ imapx_query_auth_types_sync (CamelService *service,
{
CamelIMAPXStore *istore = CAMEL_IMAPX_STORE (service);
CamelServiceAuthType *authtype;
+ CamelURL *url;
GList *sasl_types, *t, *next;
gboolean connected;
CamelIMAPXServer *server;
@@ -279,7 +291,8 @@ imapx_query_auth_types_sync (CamelService *service,
camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
- server = camel_imapx_server_new ((CamelStore *)istore, service->url);
+ url = camel_service_get_camel_url (service);
+ server = camel_imapx_server_new ((CamelStore *)istore, url);
connected = server->stream != NULL;
if (!connected)
@@ -1068,17 +1081,23 @@ discover_inbox (CamelStore *store,
}
static gboolean
-imapx_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, GError **error)
+imapx_can_refresh_folder (CamelStore *store,
+ CamelFolderInfo *info,
+ GError **error)
{
CamelStoreClass *store_class;
+ CamelURL *url;
gboolean res;
GError *local_error = NULL;
store_class = CAMEL_STORE_CLASS (camel_imapx_store_parent_class);
+ url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+
res = store_class->can_refresh_folder (store, info, &local_error) ||
- (camel_url_get_param (((CamelService *)store)->url, "check_all") != NULL) ||
- (camel_url_get_param (((CamelService *)store)->url, "check_lsub") != NULL && (info->flags & CAMEL_FOLDER_SUBSCRIBED) != 0);
+ (camel_url_get_param (url, "check_all") != NULL) ||
+ (camel_url_get_param (url, "check_lsub") != NULL &&
+ (info->flags & CAMEL_FOLDER_SUBSCRIBED) != 0);
if (!res && local_error == NULL && CAMEL_IS_IMAPX_STORE (store)) {
CamelStoreInfo *si;
@@ -1148,9 +1167,12 @@ imapx_store_get_folder_info_sync (CamelStore *store,
{
CamelIMAPXStore *istore = (CamelIMAPXStore *)store;
CamelFolderInfo * fi= NULL;
+ CamelSession *session;
gboolean initial_setup = FALSE;
gchar *pattern;
+ session = camel_service_get_session (CAMEL_SERVICE (store));
+
if (top == NULL)
top = "";
@@ -1173,9 +1195,9 @@ imapx_store_get_folder_info_sync (CamelStore *store,
struct _imapx_refresh_msg *m;
istore->last_refresh_time = time (NULL);
- m = camel_session_thread_msg_new (((CamelService *)store)->session, &imapx_refresh_ops, sizeof (*m));
+ m = camel_session_thread_msg_new (session, &imapx_refresh_ops, sizeof (*m));
m->store = g_object_ref (store);
- camel_session_thread_queue (((CamelService *)store)->session, &m->msg, 0);
+ camel_session_thread_queue (session, &m->msg, 0);
}
fi = get_folder_info_offline (store, top, flags, error);
diff --git a/camel/providers/local/camel-local-folder.c b/camel/providers/local/camel-local-folder.c
index b872b66..9bf4f37 100644
--- a/camel/providers/local/camel-local-folder.c
+++ b/camel/providers/local/camel-local-folder.c
@@ -163,7 +163,7 @@ local_folder_constructed (GObject *object)
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
- url = CAMEL_SERVICE (parent_store)->url;
+ url = camel_service_get_camel_url (CAMEL_SERVICE (parent_store));
if (url->path == NULL)
return;
@@ -520,7 +520,7 @@ camel_local_folder_construct (CamelLocalFolder *lf,
parent_store = camel_folder_get_parent_store (folder);
ls = CAMEL_LOCAL_STORE (parent_store);
- url = CAMEL_SERVICE (parent_store)->url;
+ url = camel_service_get_camel_url (CAMEL_SERVICE (parent_store));
root_dir_path = camel_local_store_get_toplevel_dir (ls);
/* strip the trailing '/' which is always present */
diff --git a/camel/providers/local/camel-local-store.c b/camel/providers/local/camel-local-store.c
index 6803135..7d81a29 100644
--- a/camel/providers/local/camel-local-store.c
+++ b/camel/providers/local/camel-local-store.c
@@ -119,24 +119,28 @@ construct (CamelService *service,
if (!service_class->construct (service, session, provider, url, error))
return FALSE;
- len = strlen (service->url->path);
- if (!G_IS_DIR_SEPARATOR (service->url->path[len - 1]))
- local_store->toplevel_dir = g_strdup_printf ("%s/", service->url->path);
+ len = strlen (url->path);
+ if (!G_IS_DIR_SEPARATOR (url->path[len - 1]))
+ local_store->toplevel_dir = g_strdup_printf ("%s/", url->path);
else
- local_store->toplevel_dir = g_strdup (service->url->path);
+ local_store->toplevel_dir = g_strdup (url->path);
local_store->is_main_store = FALSE;
local_store_path = g_build_filename (e_get_user_data_dir (), "mail", "local", NULL);
local_store_uri = g_filename_to_uri (local_store_path, NULL, NULL);
if (local_store_uri) {
- CamelProvider *provider = service->provider;
+ CamelProvider *provider;
CamelURL *local_store_url = camel_url_new (local_store_uri, NULL);
- camel_url_set_protocol (local_store_url, service->url->protocol);
- camel_url_set_host (local_store_url, service->url->host);
+ provider = camel_service_get_provider (service);
+ camel_url_set_protocol (local_store_url, url->protocol);
+ camel_url_set_host (local_store_url, url->host);
- local_store->is_main_store = (provider && provider->url_equal) ? provider->url_equal (service->url, local_store_url) : camel_url_equal (service->url, local_store_url);
+ local_store->is_main_store =
+ provider && provider->url_equal ?
+ provider->url_equal (url, local_store_url) :
+ camel_url_equal (url, local_store_url);
camel_url_free (local_store_url);
}
@@ -485,9 +489,12 @@ local_store_delete_folder_sync (CamelStore *store,
{
CamelFolderInfo *fi;
CamelFolder *lf;
+ CamelURL *url;
gchar *name;
gchar *str;
+ url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+
/* remove metadata only */
name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name);
str = g_strdup_printf("%s.ibex", name);
@@ -536,8 +543,9 @@ local_store_delete_folder_sync (CamelStore *store,
fi = camel_folder_info_new ();
fi->full_name = g_strdup (folder_name);
fi->name = g_path_get_basename (folder_name);
- fi->uri = g_strdup_printf ("%s:%s#%s", ((CamelService *) store)->url->protocol,
- CAMEL_LOCAL_STORE (store)->toplevel_dir, folder_name);
+ fi->uri = g_strdup_printf (
+ "%s:%s#%s", url->protocol,
+ CAMEL_LOCAL_STORE (store)->toplevel_dir, folder_name);
fi->unread = -1;
camel_store_folder_deleted (store, fi);
diff --git a/camel/providers/local/camel-maildir-store.c b/camel/providers/local/camel-maildir-store.c
index b39ef1f..1f07d3d 100644
--- a/camel/providers/local/camel-maildir-store.c
+++ b/camel/providers/local/camel-maildir-store.c
@@ -489,13 +489,17 @@ scan_dirs (CamelStore *store,
GCancellable *cancellable,
GError **error)
{
- const gchar *root = ((CamelService *)store)->url->path;
+ CamelURL *service_url;
+ const gchar *root;
GPtrArray *folders;
gint res = -1;
DIR *dir;
struct dirent *d;
gchar *meta_path = NULL;
+ service_url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+ root = service_url->path;
+
folders = g_ptr_array_new ();
if (!g_ascii_strcasecmp ((*topfi)->full_name, "Inbox"))
g_ptr_array_add (folders, (*topfi));
@@ -604,11 +608,13 @@ maildir_store_get_folder_info_sync (CamelStore *store,
GError **error)
{
CamelFolderInfo *fi = NULL;
- CamelLocalStore *local_store = (CamelLocalStore *)store;
+ CamelURL *service_url;
CamelURL *url;
- url = camel_url_new("maildir:", NULL);
- camel_url_set_path (url, ((CamelService *)local_store)->url->path);
+ service_url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+
+ url = camel_url_new ("maildir:", NULL);
+ camel_url_set_path (url, service_url->path);
if (top == NULL || top[0] == 0) {
/* create a dummy "." parent inbox, use to scan, then put back at the top level */
@@ -787,13 +793,17 @@ static gint
scan_old_dir_info (CamelStore *store, CamelFolderInfo *topfi, GError **error)
{
CamelDList queue = CAMEL_DLIST_INITIALISER (queue);
+ CamelURL *url;
struct _scan_node *sn;
- const gchar *root = ((CamelService *)store)->url->path;
+ const gchar *root;
gchar *tmp;
GHashTable *visited;
struct stat st;
gint res = -1;
+ url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+ root = url->path;
+
visited = g_hash_table_new (scan_hash, scan_equal);
sn = g_malloc0 (sizeof (*sn));
diff --git a/camel/providers/local/camel-mbox-store.c b/camel/providers/local/camel-mbox-store.c
index 6e5d013..0c732ce 100644
--- a/camel/providers/local/camel-mbox-store.c
+++ b/camel/providers/local/camel-mbox-store.c
@@ -449,7 +449,8 @@ mbox_store_get_folder_info_sync (CamelStore *store,
g_hash_table_insert (visited, inode, inode);
#endif
- url = camel_url_copy (((CamelService *) store)->url);
+ url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+ url = camel_url_copy (url);
fi = scan_dir (store, url, visited, NULL, path, NULL, flags, error);
g_hash_table_foreach (visited, inode_free, NULL);
g_hash_table_destroy (visited);
@@ -469,7 +470,8 @@ mbox_store_get_folder_info_sync (CamelStore *store,
basename = g_path_get_basename (top);
- url = camel_url_copy (((CamelService *) store)->url);
+ url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+ url = camel_url_copy (url);
camel_url_set_fragment (url, top);
fi = camel_folder_info_new ();
@@ -596,9 +598,12 @@ mbox_store_delete_folder_sync (CamelStore *store,
{
CamelFolderInfo *fi;
CamelFolder *lf;
+ CamelURL *url;
gchar *name, *path;
struct stat st;
+ url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+
name = camel_local_store_get_full_path (store, folder_name);
path = g_strdup_printf("%s.sbd", name);
@@ -735,7 +740,7 @@ mbox_store_delete_folder_sync (CamelStore *store,
fi = camel_folder_info_new ();
fi->full_name = g_strdup (folder_name);
fi->name = g_path_get_basename (folder_name);
- fi->uri = g_strdup_printf("mbox:%s#%s",((CamelService *) store)->url->path, folder_name);
+ fi->uri = g_strdup_printf ("mbox:%s#%s", url->path, folder_name);
fi->unread = -1;
camel_store_folder_deleted (store, fi);
@@ -764,8 +769,8 @@ mbox_store_rename_folder_sync (CamelStore *store,
/* try to rollback failures, has obvious races */
- oldibex = camel_local_store_get_meta_path(store, old, ".ibex");
- newibex = camel_local_store_get_meta_path(store, new, ".ibex");
+ oldibex = camel_local_store_get_meta_path (store, old, ".ibex");
+ newibex = camel_local_store_get_meta_path (store, new, ".ibex");
newdir = g_path_get_dirname (newibex);
if (g_mkdir_with_parents (newdir, 0700) == -1) {
diff --git a/camel/providers/local/camel-mh-store.c b/camel/providers/local/camel-mh-store.c
index fdc324b..de41092 100644
--- a/camel/providers/local/camel-mh-store.c
+++ b/camel/providers/local/camel-mh-store.c
@@ -523,9 +523,10 @@ mh_store_get_folder_info_sync (CamelStore *store,
CamelURL *url;
gchar *root;
- root = ((CamelService *)store)->url->path;
+ url = camel_service_get_camel_url (CAMEL_SERVICE (store));
- url = camel_url_copy (((CamelService *) store)->url);
+ root = url->path;
+ url = camel_url_copy (url);
/* use .folders if we are supposed to */
if (((CamelMhStore *)store)->flags & CAMEL_MH_DOTFOLDERS) {
diff --git a/camel/providers/local/camel-spool-folder.c b/camel/providers/local/camel-spool-folder.c
index 8063002..48e1a48 100644
--- a/camel/providers/local/camel-spool-folder.c
+++ b/camel/providers/local/camel-spool-folder.c
@@ -138,8 +138,11 @@ camel_spool_folder_new (CamelStore *parent_store,
GError **error)
{
CamelFolder *folder;
+ CamelURL *url;
gchar *basename;
+ url = camel_service_get_camel_url (CAMEL_SERVICE (parent_store));
+
basename = g_path_get_basename (full_name);
folder = g_object_new (
@@ -155,7 +158,7 @@ camel_spool_folder_new (CamelStore *parent_store,
folder = (CamelFolder *)camel_local_folder_construct (
(CamelLocalFolder *)folder, flags, cancellable, error);
if (folder) {
- if (camel_url_get_param(((CamelService *)parent_store)->url, "xstatus"))
+ if (camel_url_get_param (url, "xstatus"))
camel_mbox_summary_xstatus ((CamelMboxSummary *)folder->summary, TRUE);
}
diff --git a/camel/providers/local/camel-spool-store.c b/camel/providers/local/camel-spool-store.c
index 00fbd2d..539d1c2 100644
--- a/camel/providers/local/camel-spool-store.c
+++ b/camel/providers/local/camel-spool-store.c
@@ -81,7 +81,8 @@ spool_new_fi (CamelStore *store,
name = full;
fi = camel_folder_info_new ();
- url = camel_url_copy (((CamelService *)store)->url);
+ url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+ url = camel_url_copy (url);
camel_url_set_fragment (url, full);
fi->uri = camel_url_to_string (url, 0);
camel_url_free (url);
@@ -260,10 +261,13 @@ get_folder_info_elm (CamelStore *store,
{
CamelFolderInfo *fi = NULL;
GHashTable *visited;
+ CamelURL *url;
visited = g_hash_table_new (inode_hash, inode_equal);
- if (scan_dir (store, visited, ((CamelService *)store)->url->path, top, flags, NULL, &fi, cancellable, error) == -1 && fi != NULL) {
+ url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+
+ if (scan_dir (store, visited, url->path, top, flags, NULL, &fi, cancellable, error) == -1 && fi != NULL) {
camel_store_free_folder_info_full (store, fi);
fi = NULL;
}
@@ -311,21 +315,21 @@ spool_store_construct (CamelService *service,
if (!service_class->construct (service, session, provider, url, error))
return FALSE;
- if (service->url->path[0] != '/') {
+ if (url->path[0] != '/') {
g_set_error (
error, CAMEL_STORE_ERROR,
CAMEL_STORE_ERROR_NO_FOLDER,
_("Store root %s is not an absolute path"),
- service->url->path);
+ url->path);
return FALSE;
}
- if (g_stat (service->url->path, &st) == -1) {
+ if (g_stat (url->path, &st) == -1) {
g_set_error (
error, G_IO_ERROR,
g_io_error_from_errno (errno),
_("Spool '%s' cannot be opened: %s"),
- service->url->path, g_strerror (errno));
+ url->path, g_strerror (errno));
return FALSE;
}
@@ -339,7 +343,7 @@ spool_store_construct (CamelService *service,
error, CAMEL_STORE_ERROR,
CAMEL_STORE_ERROR_NO_FOLDER,
_("Spool '%s' is not a regular file or directory"),
- service->url->path);
+ url->path);
return FALSE;
}
@@ -350,11 +354,19 @@ static gchar *
spool_store_get_name (CamelService *service,
gboolean brief)
{
+ CamelURL *url;
+
+ url = camel_service_get_camel_url (service);
+
if (brief)
- return g_strdup (service->url->path);
+ return g_strdup (url->path);
else
- return g_strdup_printf (((CamelSpoolStore *)service)->type == CAMEL_SPOOL_STORE_MBOX?
- _("Spool mail file %s"):_("Spool folder tree %s"), service->url->path);
+ return g_strdup_printf (
+ ((CamelSpoolStore *)service)->type ==
+ CAMEL_SPOOL_STORE_MBOX ?
+ _("Spool mail file %s") :
+ _("Spool folder tree %s"),
+ url->path);
}
static void
@@ -377,11 +389,14 @@ spool_store_get_folder_sync (CamelStore *store,
GError **error)
{
CamelFolder *folder = NULL;
+ CamelURL *url;
struct stat st;
gchar *name;
d(printf("opening folder %s on path %s\n", folder_name, path));
+ url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+
/* we only support an 'INBOX' in mbox mode */
if (((CamelSpoolStore *)store)->type == CAMEL_SPOOL_STORE_MBOX) {
if (strcmp(folder_name, "INBOX") != 0) {
@@ -389,7 +404,7 @@ spool_store_get_folder_sync (CamelStore *store,
error, CAMEL_STORE_ERROR,
CAMEL_STORE_ERROR_NO_FOLDER,
_("Folder '%s/%s' does not exist."),
- ((CamelService *)store)->url->path, folder_name);
+ url->path, folder_name);
} else {
folder = camel_spool_folder_new (store, folder_name, flags, cancellable, error);
}
@@ -509,15 +524,21 @@ spool_store_get_meta_path (CamelLocalStore *ls,
const gchar *full_name,
const gchar *ext)
{
- gchar *root = camel_session_get_storage_path (((CamelService *)ls)->session, (CamelService *)ls, NULL);
+ CamelService *service;
+ CamelSession *session;
+ gchar *root;
gchar *path, *key;
+ service = CAMEL_SERVICE (ls);
+ session = camel_service_get_session (service);
+ root = camel_session_get_storage_path (session, service, NULL);
+
if (root == NULL)
return NULL;
g_mkdir_with_parents (root, 0700);
key = camel_file_util_safe_filename (full_name);
- path = g_strdup_printf("%s/%s%s", root, key, ext);
+ path = g_strdup_printf ("%s/%s%s", root, key, ext);
g_free (key);
g_free (root);
diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c
index 9c2b3ac..f5651d0 100644
--- a/camel/providers/nntp/camel-nntp-folder.c
+++ b/camel/providers/nntp/camel-nntp-folder.c
@@ -656,11 +656,14 @@ camel_nntp_folder_new (CamelStore *parent,
CamelNNTPFolder *nntp_folder;
gchar *root;
CamelService *service;
+ CamelSession *session;
CamelStoreInfo *si;
gboolean subscribed = TRUE;
- service = (CamelService *) parent;
- root = camel_session_get_storage_path (service->session, service, error);
+ service = CAMEL_SERVICE (parent);
+ session = camel_service_get_session (service);
+
+ root = camel_session_get_storage_path (session, service, error);
if (root == NULL)
return NULL;
diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c
index e15a960..ab83a77 100644
--- a/camel/providers/nntp/camel-nntp-store.c
+++ b/camel/providers/nntp/camel-nntp-store.c
@@ -61,13 +61,18 @@ camel_nntp_try_authenticate (CamelNNTPStore *store,
GCancellable *cancellable,
GError **error)
{
- CamelService *service = (CamelService *) store;
- CamelSession *session = camel_service_get_session (service);
+ CamelService *service;
+ CamelSession *session;
+ CamelURL *url;
gint ret;
gchar *line = NULL;
GError *local_error = NULL;
- if (!service->url->user) {
+ service = CAMEL_SERVICE (store);
+ url = camel_service_get_camel_url (service);
+ session = camel_service_get_session (service);
+
+ if (!url->user) {
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Authentication requested but no username provided"));
@@ -75,11 +80,11 @@ camel_nntp_try_authenticate (CamelNNTPStore *store,
}
/* if nessecary, prompt for the password */
- if (!service->url->passwd) {
+ if (!url->passwd) {
gchar *prompt, *base;
retry:
base = camel_session_build_password_prompt (
- "NNTP", service->url->user, service->url->host);
+ "NNTP", url->user, url->host);
if (line) {
gchar *top = g_markup_printf_escaped (
_("Cannot authenticate to server: %s"), line);
@@ -91,22 +96,22 @@ camel_nntp_try_authenticate (CamelNNTPStore *store,
base = NULL;
}
- service->url->passwd =
+ url->passwd =
camel_session_get_password (session, service, NULL,
prompt, "password", CAMEL_SESSION_PASSWORD_SECRET | (store->password_reprompt ? CAMEL_SESSION_PASSWORD_REPROMPT : 0), error);
g_free (prompt);
g_free (base);
- if (!service->url->passwd)
+ if (!url->passwd)
return -1;
store->password_reprompt = FALSE;
}
/* now, send auth info (currently, only authinfo user/pass is supported) */
- ret = camel_nntp_raw_command(store, cancellable, &local_error, &line, "authinfo user %s", service->url->user);
+ ret = camel_nntp_raw_command(store, cancellable, &local_error, &line, "authinfo user %s", url->user);
if (ret == NNTP_AUTH_CONTINUE)
- ret = camel_nntp_raw_command(store, cancellable, &local_error, &line, "authinfo pass %s", service->url->passwd);
+ ret = camel_nntp_raw_command(store, cancellable, &local_error, &line, "authinfo pass %s", url->passwd);
if (ret != NNTP_AUTH_ACCEPTED) {
if (ret != -1) {
@@ -118,8 +123,8 @@ camel_nntp_try_authenticate (CamelNNTPStore *store,
/* To force password reprompt */
store->password_reprompt = TRUE;
- g_free (service->url->passwd);
- service->url->passwd = NULL;
+ g_free (url->passwd);
+ url->passwd = NULL;
goto retry;
}
return -1;
@@ -318,6 +323,7 @@ connect_to_server (CamelService *service,
CamelNNTPStore *store = (CamelNNTPStore *) service;
CamelDiscoStore *disco_store = (CamelDiscoStore*) service;
CamelSession *session;
+ CamelURL *url;
gchar *socks_host;
gint socks_port;
CamelStream *tcp_stream;
@@ -326,28 +332,30 @@ connect_to_server (CamelService *service,
guint len;
gchar *path;
+ url = camel_service_get_camel_url (service);
+ session = camel_service_get_session (service);
+
camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
if (ssl_mode != MODE_CLEAR) {
#ifdef CAMEL_HAVE_SSL
if (ssl_mode == MODE_TLS) {
- tcp_stream = camel_tcp_stream_ssl_new_raw (service->session, service->url->host, STARTTLS_FLAGS);
+ tcp_stream = camel_tcp_stream_ssl_new_raw (session, url->host, STARTTLS_FLAGS);
} else {
- tcp_stream = camel_tcp_stream_ssl_new (service->session, service->url->host, SSL_PORT_FLAGS);
+ tcp_stream = camel_tcp_stream_ssl_new (session, url->host, SSL_PORT_FLAGS);
}
#else
g_set_error (
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_UNAVAILABLE,
_("Could not connect to %s: %s"),
- service->url->host, _("SSL unavailable"));
+ url->host, _("SSL unavailable"));
goto fail;
#endif /* CAMEL_HAVE_SSL */
} else {
tcp_stream = camel_tcp_stream_raw_new ();
}
- session = camel_service_get_session (service);
camel_session_get_socks_proxy (session, &socks_host, &socks_port);
if (socks_host) {
@@ -360,7 +368,7 @@ connect_to_server (CamelService *service,
fallback_port, cancellable, error) == -1) {
g_prefix_error (
error, _("Could not connect to %s: "),
- service->url->host);
+ url->host);
g_object_unref (tcp_stream);
goto fail;
@@ -373,7 +381,7 @@ connect_to_server (CamelService *service,
if (camel_nntp_stream_line (store->stream, &buf, &len, cancellable, error) == -1) {
g_prefix_error (
error, _("Could not read greeting from %s: "),
- service->url->host);
+ url->host);
g_object_unref (store->stream);
store->stream = NULL;
@@ -386,7 +394,7 @@ connect_to_server (CamelService *service,
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("NNTP server %s returned error code %d: %s"),
- service->url->host, len, buf);
+ url->host, len, buf);
g_object_unref (store->stream);
store->stream = NULL;
@@ -395,8 +403,7 @@ connect_to_server (CamelService *service,
}
/* if we have username, try it here */
- if (service->url->user != NULL
- && service->url->user[0]
+ if (url->user != NULL && url->user[0]
&& camel_nntp_try_authenticate (store, cancellable, error) != NNTP_AUTH_ACCEPTED)
goto fail;
@@ -443,13 +450,16 @@ nntp_connect_online (CamelService *service,
GError **error)
{
CamelNNTPStore *store = CAMEL_NNTP_STORE (service);
+ CamelURL *url;
const gchar *ssl_mode;
gint mode, i;
gchar *serv;
gint fallback_port;
GError *local_error = NULL;
- if ((ssl_mode = camel_url_get_param (service->url, "use_ssl"))) {
+ url = camel_service_get_camel_url (service);
+
+ if ((ssl_mode = camel_url_get_param (url, "use_ssl"))) {
for (i = 0; ssl_options[i].value; i++)
if (!strcmp (ssl_options[i].value, ssl_mode))
break;
@@ -462,14 +472,14 @@ nntp_connect_online (CamelService *service,
fallback_port = NNTP_PORT;
}
- if (service->url->port) {
+ if (url->port) {
serv = g_alloca (16);
- sprintf (serv, "%d", service->url->port);
+ sprintf (serv, "%d", url->port);
fallback_port = 0;
}
if (!connect_to_server (
- service, service->url->host, serv,
+ service, url->host, serv,
fallback_port, mode, cancellable, error))
return FALSE;
@@ -493,7 +503,7 @@ nntp_connect_online (CamelService *service,
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
return connect_to_server (
- service, service->url->host, serv,
+ service, url->host, serv,
fallback_port, mode, cancellable, error);
}
@@ -576,10 +586,14 @@ nntp_disconnect_offline (CamelService *service,
static gchar *
nntp_store_get_name (CamelService *service, gboolean brief)
{
+ CamelURL *url;
+
+ url = camel_service_get_camel_url (service);
+
if (brief)
- return g_strdup_printf ("%s", service->url->host);
+ return g_strdup_printf ("%s", url->host);
else
- return g_strdup_printf (_("USENET News via %s"), service->url->host);
+ return g_strdup_printf (_("USENET News via %s"), url->host);
}
@@ -652,13 +666,17 @@ nntp_newsgroup_name_short (const gchar *name)
*/
static CamelFolderInfo *
-nntp_folder_info_from_store_info (CamelNNTPStore *store, gboolean short_notation, CamelStoreInfo *si)
+nntp_folder_info_from_store_info (CamelNNTPStore *store,
+ gboolean short_notation,
+ CamelStoreInfo *si)
{
- CamelURL *base_url = ((CamelService *) store)->url;
+ CamelURL *base_url;
CamelFolderInfo *fi;
CamelURL *url;
gchar *path;
+ base_url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+
fi = camel_folder_info_new ();
fi->full_name = g_strdup (si->path);
@@ -682,11 +700,13 @@ nntp_folder_info_from_store_info (CamelNNTPStore *store, gboolean short_notation
static CamelFolderInfo *
nntp_folder_info_from_name (CamelNNTPStore *store, gboolean short_notation, const gchar *name)
{
- CamelURL *base_url = ((CamelService *)store)->url;
+ CamelURL *base_url;
CamelFolderInfo *fi;
CamelURL *url;
gchar *path;
+ base_url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+
fi = camel_folder_info_new ();
fi->full_name = g_strdup (name);
@@ -711,12 +731,14 @@ static CamelNNTPStoreInfo *
nntp_store_info_update (CamelNNTPStore *store, gchar *line)
{
CamelStoreSummary *summ = (CamelStoreSummary *)store->summary;
- CamelURL *base_url = ((CamelService *)store)->url;
+ CamelURL *base_url;
CamelNNTPStoreInfo *si, *fsi;
CamelURL *url;
gchar *relpath, *tmp;
guint32 last = 0, first = 0, new = 0;
+ base_url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+
tmp = strchr (line, ' ');
if (tmp)
*tmp++ = 0;
@@ -914,7 +936,10 @@ nntp_push_to_hierarchy (CamelURL *base_url, CamelFolderInfo *root, CamelFolderIn
* get folder info, using the information in our StoreSummary
*/
static CamelFolderInfo *
-nntp_store_get_cached_folder_info (CamelNNTPStore *store, const gchar *orig_top, guint flags, GError **error)
+nntp_store_get_cached_folder_info (CamelNNTPStore *store,
+ const gchar *orig_top,
+ guint flags,
+ GError **error)
{
gint i;
gint subscribed_or_flag = (flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED) ? 0 : 1,
@@ -923,11 +948,14 @@ nntp_store_get_cached_folder_info (CamelNNTPStore *store, const gchar *orig_top,
is_folder_list = flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIPTION_LIST;
CamelStoreInfo *si;
CamelFolderInfo *first = NULL, *last = NULL, *fi = NULL;
+ CamelURL *url;
GHashTable *known; /* folder name to folder info */
gchar *tmpname;
gchar *top = g_strconcat(orig_top?orig_top:"", ".", NULL);
gint toplen = strlen (top);
+ url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+
known = g_hash_table_new (g_str_hash, g_str_equal);
for (i = 0; (si = camel_store_summary_index ((CamelStoreSummary *) store->summary, i)); i++) {
@@ -976,7 +1004,7 @@ nntp_store_get_cached_folder_info (CamelNNTPStore *store, const gchar *orig_top,
if (is_folder_list) {
/* create a folder hierarchy rather than a flat list */
- first = nntp_push_to_hierarchy (((CamelService *)store)->url, first, fi, known);
+ first = nntp_push_to_hierarchy (url, first, fi, known);
} else {
if (last)
last->next = fi;
@@ -1335,9 +1363,11 @@ nntp_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, GError **erro
/* construction function in which we set some basic store properties */
static gboolean
-nntp_construct (CamelService *service, CamelSession *session,
- CamelProvider *provider, CamelURL *url,
- GError **error)
+nntp_construct (CamelService *service,
+ CamelSession *session,
+ CamelProvider *provider,
+ CamelURL *url,
+ GError **error)
{
CamelServiceClass *service_class;
CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (service);
@@ -1355,9 +1385,9 @@ nntp_construct (CamelService *service, CamelSession *session,
return FALSE;
/* FIXME */
- nntp_store->base_url = camel_url_to_string (service->url, (CAMEL_URL_HIDE_PASSWORD |
- CAMEL_URL_HIDE_PARAMS |
- CAMEL_URL_HIDE_AUTH));
+ nntp_store->base_url = camel_url_to_string (
+ url, CAMEL_URL_HIDE_PASSWORD |
+ CAMEL_URL_HIDE_PARAMS | CAMEL_URL_HIDE_AUTH);
tmp = g_build_filename (nntp_store->storage_path, ".ev-store-summary", NULL);
nntp_store->summary = camel_nntp_store_summary_new ();
diff --git a/camel/providers/nntp/camel-nntp-summary.c b/camel/providers/nntp/camel-nntp-summary.c
index 081b237..33d0e0c 100644
--- a/camel/providers/nntp/camel-nntp-summary.c
+++ b/camel/providers/nntp/camel-nntp-summary.c
@@ -217,6 +217,7 @@ add_range_xover (CamelNNTPSummary *cns,
{
CamelFolderSummary *s;
CamelMessageInfoBase *mi;
+ CamelURL *url;
struct _camel_header_raw *headers = NULL;
gchar *line, *tab;
guint len;
@@ -228,9 +229,10 @@ add_range_xover (CamelNNTPSummary *cns,
s = (CamelFolderSummary *)cns;
summary_table = camel_folder_summary_get_hashtable (s);
+ url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+
camel_operation_push_message (
- cancellable, _("%s: Scanning new messages"),
- ((CamelService *)store)->url->host);
+ cancellable, _("%s: Scanning new messages"), url->host);
if ((store->capabilities & NNTP_CAPABILITY_OVER) != 0)
ret = camel_nntp_raw_command_auth (store, cancellable, error, &line, "over %r", low, high);
@@ -331,6 +333,7 @@ add_range_head (CamelNNTPSummary *cns,
GError **error)
{
CamelFolderSummary *s;
+ CamelURL *url;
gint ret = -1;
gchar *line, *msgid;
guint i, n, count, total;
@@ -344,9 +347,10 @@ add_range_head (CamelNNTPSummary *cns,
mp = camel_mime_parser_new ();
+ url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+
camel_operation_push_message (
- cancellable, _("%s: Scanning new messages"),
- ((CamelService *)store)->url->host);
+ cancellable, _("%s: Scanning new messages"), url->host);
count = 0;
total = high-low+1;
diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c
index 7c0b7b4..51e1f96 100644
--- a/camel/providers/pop3/camel-pop3-store.c
+++ b/camel/providers/pop3/camel-pop3-store.c
@@ -112,6 +112,7 @@ connect_to_server (CamelService *service,
{
CamelPOP3Store *store = CAMEL_POP3_STORE (service);
CamelSession *session;
+ CamelURL *url;
gchar *socks_host;
gint socks_port;
CamelStream *tcp_stream;
@@ -121,26 +122,28 @@ connect_to_server (CamelService *service,
gint ret;
const gchar *param;
+ url = camel_service_get_camel_url (service);
+ session = camel_service_get_session (service);
+
if (ssl_mode != MODE_CLEAR) {
#ifdef CAMEL_HAVE_SSL
if (ssl_mode == MODE_TLS) {
- tcp_stream = camel_tcp_stream_ssl_new_raw (service->session, service->url->host, STARTTLS_FLAGS);
+ tcp_stream = camel_tcp_stream_ssl_new_raw (session, url->host, STARTTLS_FLAGS);
} else {
- tcp_stream = camel_tcp_stream_ssl_new (service->session, service->url->host, SSL_PORT_FLAGS);
+ tcp_stream = camel_tcp_stream_ssl_new (session, url->host, SSL_PORT_FLAGS);
}
#else
g_set_error (
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_UNAVAILABLE,
_("Could not connect to %s: %s"),
- service->url->host, _("SSL unavailable"));
+ url->host, _("SSL unavailable"));
return FALSE;
#endif /* CAMEL_HAVE_SSL */
} else
tcp_stream = camel_tcp_stream_raw_new ();
- session = camel_service_get_session (service);
camel_session_get_socks_proxy (session, &socks_host, &socks_port);
if (socks_host) {
@@ -164,13 +167,13 @@ connect_to_server (CamelService *service,
return FALSE;
}
- if (camel_url_get_param (service->url, "disable_extensions"))
+ if (camel_url_get_param (url, "disable_extensions"))
flags |= CAMEL_POP3_ENGINE_DISABLE_EXTENSIONS;
- store->keep_on_server = camel_url_get_param (service->url, "keep_on_server") != NULL;
- store->delete_expunged = camel_url_get_param (service->url, "delete_expunged") != NULL;
+ store->keep_on_server = camel_url_get_param (url, "keep_on_server") != NULL;
+ store->delete_expunged = camel_url_get_param (url, "delete_expunged") != NULL;
- if ((param = camel_url_get_param (service->url, "delete_after")))
+ if ((param = camel_url_get_param (url, "delete_after")))
store->delete_after = atoi (param);
else
store->delete_after = 0;
@@ -179,7 +182,7 @@ connect_to_server (CamelService *service,
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to read a valid greeting from POP server %s"),
- service->url->host);
+ url->host);
g_object_unref (tcp_stream);
return FALSE;
}
@@ -197,7 +200,7 @@ connect_to_server (CamelService *service,
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to connect to POP server %s in secure mode: %s"),
- service->url->host, _("STLS not supported by server"));
+ url->host, _("STLS not supported by server"));
goto stls_exception;
}
@@ -216,7 +219,7 @@ connect_to_server (CamelService *service,
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
/* Translators: Last %s is an optional explanation beginning with ": " separator */
_("Failed to connect to POP server %s in secure mode%s"),
- service->url->host, (tmp != NULL) ? tmp : "");
+ url->host, (tmp != NULL) ? tmp : "");
g_free (tmp);
goto stls_exception;
}
@@ -228,14 +231,14 @@ connect_to_server (CamelService *service,
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to connect to POP server %s in secure mode: %s"),
- service->url->host, _("TLS negotiations failed"));
+ url->host, _("TLS negotiations failed"));
goto stls_exception;
}
#else
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to connect to POP server %s in secure mode: %s"),
- service->url->host, _("TLS is not available in this build"));
+ url->host, _("TLS is not available in this build"));
goto stls_exception;
#endif /* CAMEL_HAVE_SSL */
@@ -268,12 +271,15 @@ connect_to_server_wrapper (CamelService *service,
GCancellable *cancellable,
GError **error)
{
+ CamelURL *url;
const gchar *ssl_mode;
gint mode, i;
gchar *serv;
gint fallback_port;
- if ((ssl_mode = camel_url_get_param (service->url, "use_ssl"))) {
+ url = camel_service_get_camel_url (service);
+
+ if ((ssl_mode = camel_url_get_param (url, "use_ssl"))) {
for (i = 0; ssl_options[i].value; i++)
if (!strcmp (ssl_options[i].value, ssl_mode))
break;
@@ -286,14 +292,14 @@ connect_to_server_wrapper (CamelService *service,
fallback_port = POP3S_PORT;
}
- if (service->url->port) {
+ if (url->port) {
serv = g_alloca (16);
- sprintf (serv, "%d", service->url->port);
+ sprintf (serv, "%d", url->port);
fallback_port = 0;
}
return connect_to_server (
- service, service->url->host, serv,
+ service, url->host, serv,
fallback_port, mode, cancellable, error);
}
@@ -304,19 +310,24 @@ try_sasl (CamelPOP3Store *store,
GError **error)
{
CamelPOP3Stream *stream = store->engine->stream;
+ CamelService *service;
+ CamelURL *url;
guchar *line, *resp;
CamelSasl *sasl;
guint len;
gint ret;
- sasl = camel_sasl_new("pop", mech, (CamelService *)store);
+ service = CAMEL_SERVICE (store);
+ url = camel_service_get_camel_url (service);
+
+ sasl = camel_sasl_new ("pop", mech, service);
if (sasl == NULL) {
g_set_error (
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_URL_INVALID,
_("Unable to connect to POP server %s: "
"No support for requested authentication mechanism."),
- CAMEL_SERVICE (store)->url->host);
+ url->host);
return -1;
}
@@ -338,8 +349,7 @@ try_sasl (CamelPOP3Store *store,
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
/* Translators: Last %s is an optional explanation beginning with ": " separator */
_("SASL '%s' Login failed for POP server %s%s"),
- mech, CAMEL_SERVICE (store)->url->host,
- (tmp != NULL) ? tmp : "");
+ mech, url->host, (tmp != NULL) ? tmp : "");
g_free (tmp);
goto done;
@@ -356,7 +366,7 @@ try_sasl (CamelPOP3Store *store,
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("Cannot login to POP server %s: "
"SASL Protocol error"),
- CAMEL_SERVICE (store)->url->host);
+ url->host);
goto done;
}
@@ -372,7 +382,7 @@ try_sasl (CamelPOP3Store *store,
ioerror:
g_prefix_error (
error, _("Failed to authenticate on POP server %s: "),
- CAMEL_SERVICE (store)->url->host);
+ url->host);
done:
g_object_unref (sasl);
@@ -388,13 +398,16 @@ pop3_try_authenticate (CamelService *service,
{
CamelPOP3Store *store = (CamelPOP3Store *)service;
CamelPOP3Command *pcu = NULL, *pcp = NULL;
+ CamelURL *url;
gint status;
+ url = camel_service_get_camel_url (service);
+
/* override, testing only */
/*printf("Forcing authmech to 'login'\n");
- service->url->authmech = g_strdup("LOGIN");*/
+ url->authmech = g_strdup("LOGIN");*/
- if (!service->url->passwd) {
+ if (!url->passwd) {
gchar *base_prompt;
gchar *full_prompt;
guint32 flags = CAMEL_SESSION_PASSWORD_SECRET;
@@ -403,28 +416,32 @@ pop3_try_authenticate (CamelService *service,
flags |= CAMEL_SESSION_PASSWORD_REPROMPT;
base_prompt = camel_session_build_password_prompt (
- "POP", service->url->user, service->url->host);
+ "POP", url->user, url->host);
if (errmsg != NULL)
full_prompt = g_strconcat (errmsg, base_prompt, NULL);
else
full_prompt = g_strdup (base_prompt);
- service->url->passwd = camel_session_get_password (
+ url->passwd = camel_session_get_password (
camel_service_get_session (service), service,
NULL, full_prompt, "password", flags, error);
g_free (base_prompt);
g_free (full_prompt);
- if (!service->url->passwd)
+ if (!url->passwd)
return -1;
}
- if (!service->url->authmech) {
+ if (!url->authmech) {
/* pop engine will take care of pipelining ability */
- pcu = camel_pop3_engine_command_new(store->engine, 0, NULL, NULL, "USER %s\r\n", service->url->user);
- pcp = camel_pop3_engine_command_new(store->engine, 0, NULL, NULL, "PASS %s\r\n", service->url->passwd);
- } else if (strcmp(service->url->authmech, "+APOP") == 0 && store->engine->apop) {
+ pcu = camel_pop3_engine_command_new (
+ store->engine, 0, NULL, NULL,
+ "USER %s\r\n", url->user);
+ pcp = camel_pop3_engine_command_new (
+ store->engine, 0, NULL, NULL,
+ "PASS %s\r\n", url->passwd);
+ } else if (strcmp (url->authmech, "+APOP") == 0 && store->engine->apop) {
gchar *secret, *md5asc, *d;
d = store->engine->apop;
@@ -439,18 +456,19 @@ pop3_try_authenticate (CamelService *service,
_("Unable to connect to POP server %s: "
"Invalid APOP ID received. Impersonation "
"attack suspected. Please contact your admin."),
- CAMEL_SERVICE (store)->url->host);
+ url->host);
return 0;
}
d++;
}
- secret = g_alloca (strlen (store->engine->apop)+strlen (service->url->passwd)+1);
- sprintf(secret, "%s%s", store->engine->apop, service->url->passwd);
+ secret = g_alloca (strlen (store->engine->apop) + strlen (url->passwd)+1);
+ sprintf(secret, "%s%s", store->engine->apop, url->passwd);
md5asc = g_compute_checksum_for_string (G_CHECKSUM_MD5, secret, -1);
- pcp = camel_pop3_engine_command_new(store->engine, 0, NULL, NULL, "APOP %s %s\r\n",
- service->url->user, md5asc);
+ pcp = camel_pop3_engine_command_new (
+ store->engine, 0, NULL, NULL, "APOP %s %s\r\n",
+ url->user, md5asc);
g_free (md5asc);
} else {
CamelServiceAuthType *auth;
@@ -459,9 +477,9 @@ pop3_try_authenticate (CamelService *service,
l = store->engine->auth;
while (l) {
auth = l->data;
- if (strcmp (auth->authproto, service->url->authmech) == 0)
+ if (strcmp (auth->authproto, url->authmech) == 0)
return try_sasl (
- store, service->url->authmech,
+ store, url->authmech,
cancellable, error);
l = l->next;
}
@@ -471,7 +489,7 @@ pop3_try_authenticate (CamelService *service,
CAMEL_SERVICE_ERROR_URL_INVALID,
_("Unable to connect to POP server %s: "
"No support for requested authentication mechanism."),
- CAMEL_SERVICE (store)->url->host);
+ url->host);
return 0;
}
@@ -491,7 +509,7 @@ pop3_try_authenticate (CamelService *service,
g_io_error_from_errno (errno),
_("Unable to connect to POP server %s.\n"
"Error sending password: %s"),
- CAMEL_SERVICE (store)->url->host, errno ?
+ url->host, errno ?
g_strerror (errno) : _("Unknown error"));
}
} else if (pcu && pcu->state != CAMEL_POP3_COMMAND_OK) {
@@ -504,8 +522,7 @@ pop3_try_authenticate (CamelService *service,
/* Translators: Last %s is an optional explanation beginning with ": " separator */
_("Unable to connect to POP server %s.\n"
"Error sending username%s"),
- CAMEL_SERVICE (store)->url->host,
- (tmp != NULL) ? tmp : "");
+ url->host, (tmp != NULL) ? tmp : "");
g_free (tmp);
} else if (pcp->state != CAMEL_POP3_COMMAND_OK) {
gchar *tmp;
@@ -517,8 +534,7 @@ pop3_try_authenticate (CamelService *service,
/* Translators: Last %s is an optional explanation beginning with ": " separator */
_("Unable to connect to POP server %s.\n"
"Error sending password%s"),
- CAMEL_SERVICE (store)->url->host,
- (tmp != NULL) ? tmp : "");
+ url->host, (tmp != NULL) ? tmp : "");
g_free (tmp);
}
@@ -553,15 +569,17 @@ static gchar *
pop3_store_get_name (CamelService *service,
gboolean brief)
{
+ CamelURL *url;
+
+ url = camel_service_get_camel_url (service);
+
if (brief)
return g_strdup_printf (
- _("POP3 server %s"),
- service->url->host);
+ _("POP3 server %s"), url->host);
else
return g_strdup_printf (
_("POP3 server for %s on %s"),
- service->url->user,
- service->url->host);
+ url->user, url->host);
}
static gboolean
@@ -572,9 +590,11 @@ pop3_store_connect_sync (CamelService *service,
CamelPOP3Store *store = (CamelPOP3Store *)service;
gboolean reprompt = FALSE;
CamelSession *session;
+ CamelURL *url;
gchar *errbuf = NULL;
GError *local_error = NULL;
+ url = camel_service_get_camel_url (service);
session = camel_service_get_session (service);
if (store->cache == NULL) {
@@ -611,8 +631,8 @@ pop3_store_connect_sync (CamelService *service,
g_clear_error (&local_error);
- g_free (service->url->passwd);
- service->url->passwd = NULL;
+ g_free (url->passwd);
+ url->passwd = NULL;
reprompt = TRUE;
} else
break;
@@ -670,6 +690,7 @@ pop3_store_query_auth_types_sync (CamelService *service,
{
CamelServiceClass *service_class;
CamelPOP3Store *store = CAMEL_POP3_STORE (service);
+ CamelURL *url;
GList *types = NULL;
GError *local_error = NULL;
@@ -683,6 +704,8 @@ pop3_store_query_auth_types_sync (CamelService *service,
return NULL;
}
+ url = camel_service_get_camel_url (service);
+
if (connect_to_server_wrapper (service, cancellable, NULL)) {
types = g_list_concat (types, g_list_copy (store->engine->auth));
pop3_store_disconnect_sync (service, TRUE, cancellable, NULL);
@@ -691,7 +714,7 @@ pop3_store_query_auth_types_sync (CamelService *service,
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_UNAVAILABLE,
_("Could not connect to POP server %s"),
- service->url->host);
+ url->host);
}
return types;
diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c
index b95dd57..40c95e9 100644
--- a/camel/providers/smtp/camel-smtp-transport.c
+++ b/camel/providers/smtp/camel-smtp-transport.c
@@ -124,6 +124,7 @@ connect_to_server (CamelService *service,
{
CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service);
CamelSession *session;
+ CamelURL *url;
gchar *socks_host;
gint socks_port;
CamelStream *tcp_stream;
@@ -137,19 +138,22 @@ connect_to_server (CamelService *service,
transport->flags = 0;
transport->authtypes = NULL;
+ url = camel_service_get_camel_url (service);
+ session = camel_service_get_session (service);
+
if (ssl_mode != MODE_CLEAR) {
#ifdef CAMEL_HAVE_SSL
if (ssl_mode == MODE_TLS) {
- tcp_stream = camel_tcp_stream_ssl_new_raw (service->session, service->url->host, STARTTLS_FLAGS);
+ tcp_stream = camel_tcp_stream_ssl_new_raw (session, url->host, STARTTLS_FLAGS);
} else {
- tcp_stream = camel_tcp_stream_ssl_new (service->session, service->url->host, SSL_PORT_FLAGS);
+ tcp_stream = camel_tcp_stream_ssl_new (session, url->host, SSL_PORT_FLAGS);
}
#else
g_set_error (
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_UNAVAILABLE,
_("Could not connect to %s: %s"),
- service->url->host, _("SSL unavailable"));
+ url->host, _("SSL unavailable"));
return FALSE;
#endif /* CAMEL_HAVE_SSL */
@@ -157,7 +161,6 @@ connect_to_server (CamelService *service,
tcp_stream = camel_tcp_stream_raw_new ();
}
- session = camel_service_get_session (service);
camel_session_get_socks_proxy (session, &socks_host, &socks_port);
if (socks_host) {
@@ -235,7 +238,7 @@ connect_to_server (CamelService *service,
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to connect to SMTP server %s in secure mode: %s"),
- service->url->host, _("STARTTLS not supported"));
+ url->host, _("STARTTLS not supported"));
goto exception_cleanup;
}
@@ -275,14 +278,14 @@ connect_to_server (CamelService *service,
error, G_IO_ERROR,
g_io_error_from_errno (errno),
_("Failed to connect to SMTP server %s in secure mode: %s"),
- service->url->host, g_strerror (errno));
+ url->host, g_strerror (errno));
goto exception_cleanup;
}
#else
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to connect to SMTP server %s in secure mode: %s"),
- service->url->host, _("SSL is not available in this build"));
+ url->host, _("SSL is not available in this build"));
goto exception_cleanup;
#endif /* CAMEL_HAVE_SSL */
@@ -314,12 +317,15 @@ connect_to_server_wrapper (CamelService *service,
GCancellable *cancellable,
GError **error)
{
+ CamelURL *url;
const gchar *ssl_mode;
gint mode, i;
gchar *serv;
gint fallback_port;
- if ((ssl_mode = camel_url_get_param (service->url, "use_ssl"))) {
+ url = camel_service_get_camel_url (service);
+
+ if ((ssl_mode = camel_url_get_param (url, "use_ssl"))) {
for (i = 0; ssl_options[i].value; i++)
if (!strcmp (ssl_options[i].value, ssl_mode))
break;
@@ -332,14 +338,14 @@ connect_to_server_wrapper (CamelService *service,
fallback_port = SMTP_PORT;
}
- if (service->url->port) {
+ if (url->port) {
serv = g_alloca (16);
- sprintf (serv, "%d", service->url->port);
+ sprintf (serv, "%d", url->port);
fallback_port = 0;
}
return connect_to_server (
- service, service->url->host, serv,
+ service, url->host, serv,
fallback_port, mode, cancellable, error);
}
@@ -352,14 +358,18 @@ authtypes_free (gpointer key, gpointer value, gpointer data)
static gchar *
smtp_get_name (CamelService *service, gboolean brief)
{
+ CamelURL *url;
+
+ url = camel_service_get_camel_url (service);
+
if (brief)
return g_strdup_printf (
_("SMTP server %s"),
- service->url->host);
+ url->host);
else
return g_strdup_printf (
_("SMTP mail delivery via %s"),
- service->url->host);
+ url->host);
}
static gboolean
@@ -369,10 +379,13 @@ smtp_connect_sync (CamelService *service,
{
CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service);
CamelSasl *sasl = NULL;
+ CamelURL *url;
gboolean has_authtypes;
+ url = camel_service_get_camel_url (service);
+
/* We (probably) need to check popb4smtp before we connect ... */
- if (service->url->authmech && !strcmp (service->url->authmech, "POPB4SMTP")) {
+ if (url->authmech && !strcmp (url->authmech, "POPB4SMTP")) {
gint truth;
GByteArray *chal;
CamelSasl *sasl;
@@ -395,36 +408,36 @@ smtp_connect_sync (CamelService *service,
/* check to see if AUTH is required, if so...then AUTH ourselves */
has_authtypes = transport->authtypes ? g_hash_table_size (transport->authtypes) > 0 : FALSE;
- if (service->url->authmech && (transport->flags & CAMEL_SMTP_TRANSPORT_IS_ESMTP) && has_authtypes) {
+ if (url->authmech && (transport->flags & CAMEL_SMTP_TRANSPORT_IS_ESMTP) && has_authtypes) {
CamelSession *session = camel_service_get_session (service);
CamelServiceAuthType *authtype;
gboolean authenticated = FALSE;
guint32 password_flags;
gchar *errbuf = NULL;
- if (!g_hash_table_lookup (transport->authtypes, service->url->authmech)) {
+ if (!g_hash_table_lookup (transport->authtypes, url->authmech)) {
g_set_error (
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("SMTP server %s does not support "
"requested authentication type %s."),
- service->url->host, service->url->authmech);
+ url->host, url->authmech);
camel_service_disconnect_sync (service, TRUE, NULL);
return FALSE;
}
- authtype = camel_sasl_authtype (service->url->authmech);
+ authtype = camel_sasl_authtype (url->authmech);
if (!authtype) {
g_set_error (
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("No support for authentication type %s"),
- service->url->authmech);
+ url->authmech);
camel_service_disconnect_sync (service, TRUE, NULL);
return FALSE;
}
- sasl = camel_sasl_new ("smtp", service->url->authmech,
+ sasl = camel_sasl_new ("smtp", url->authmech,
CAMEL_SERVICE (transport));
if (!sasl) {
@@ -456,23 +469,23 @@ smtp_connect_sync (CamelService *service,
if (errbuf) {
/* We need to un-cache the password before prompting again */
password_flags |= CAMEL_SESSION_PASSWORD_REPROMPT;
- g_free (service->url->passwd);
- service->url->passwd = NULL;
+ g_free (url->passwd);
+ url->passwd = NULL;
}
- if (!service->url->passwd) {
+ if (!url->passwd) {
gchar *base_prompt;
gchar *full_prompt;
base_prompt = camel_session_build_password_prompt (
- "SMTP", service->url->user, service->url->host);
+ "SMTP", url->user, url->host);
if (errbuf != NULL)
full_prompt = g_strconcat (errbuf, base_prompt, NULL);
else
full_prompt = g_strdup (base_prompt);
- service->url->passwd = camel_session_get_password (
+ url->passwd = camel_session_get_password (
session, service, NULL, full_prompt,
"password", password_flags, error);
@@ -481,14 +494,14 @@ smtp_connect_sync (CamelService *service,
g_free (errbuf);
errbuf = NULL;
- if (!service->url->passwd) {
+ if (!url->passwd) {
camel_service_disconnect_sync (
service, TRUE, NULL);
return FALSE;
}
}
if (!sasl)
- sasl = camel_sasl_new ("smtp", service->url->authmech,
+ sasl = camel_sasl_new ("smtp", url->authmech,
CAMEL_SERVICE (transport));
if (!sasl)
goto nosasl;
@@ -498,8 +511,8 @@ smtp_connect_sync (CamelService *service,
if (!authenticated) {
if (g_cancellable_is_cancelled (cancellable) ||
g_error_matches (local_error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE)) {
- g_free (service->url->passwd);
- service->url->passwd = NULL;
+ g_free (url->passwd);
+ url->passwd = NULL;
if (local_error)
g_clear_error (&local_error);
@@ -513,8 +526,8 @@ smtp_connect_sync (CamelService *service,
local_error ? local_error->message : _("Unknown error"));
g_clear_error (&local_error);
- g_free (service->url->passwd);
- service->url->passwd = NULL;
+ g_free (url->passwd);
+ url->passwd = NULL;
}
}
@@ -577,6 +590,7 @@ smtp_query_auth_types_sync (CamelService *service,
{
CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service);
CamelServiceAuthType *authtype;
+ CamelProvider *provider;
GList *types, *t, *next;
if (!connect_to_server_wrapper (service, cancellable, error))
@@ -587,7 +601,9 @@ smtp_query_auth_types_sync (CamelService *service,
return NULL;
}
- types = g_list_copy (service->provider->authtypes);
+ provider = camel_service_get_provider (service);
+ types = g_list_copy (provider->authtypes);
+
for (t = types; t; t = next) {
authtype = t->data;
next = t->next;
@@ -1152,10 +1168,12 @@ smtp_auth (CamelSmtpTransport *transport,
GError **error)
{
CamelService *service;
+ CamelURL *url;
gchar *cmdbuf, *respbuf = NULL, *challenge;
gboolean auth_challenge = FALSE;
service = CAMEL_SERVICE (transport);
+ url = camel_service_get_camel_url (service);
camel_operation_push_message (cancellable, _("SMTP Authentication"));
@@ -1163,12 +1181,12 @@ smtp_auth (CamelSmtpTransport *transport,
sasl, NULL, cancellable, error);
if (challenge) {
auth_challenge = TRUE;
- cmdbuf = g_strdup_printf ("AUTH %s %s\r\n",
- service->url->authmech, challenge);
+ cmdbuf = g_strdup_printf (
+ "AUTH %s %s\r\n", url->authmech, challenge);
g_free (challenge);
} else {
- cmdbuf = g_strdup_printf ("AUTH %s\r\n",
- service->url->authmech);
+ cmdbuf = g_strdup_printf (
+ "AUTH %s\r\n", url->authmech);
}
d(fprintf (stderr, "sending : %s", cmdbuf));
@@ -1206,7 +1224,7 @@ smtp_auth (CamelSmtpTransport *transport,
"authentication mechanism is broken. Please report this to the\n"
"appropriate vendor and suggest that they re-read rfc2554 again\n"
"for the first time (specifically Section 4).\n",
- service->url->authmech));
+ url->authmech));
}
/* eat whtspc */
@@ -1247,8 +1265,8 @@ smtp_auth (CamelSmtpTransport *transport,
/* If our authentication data was rejected, destroy the
* password so that the user gets prompted to try again. */
if (strncmp (respbuf, "535", 3) == 0) {
- g_free (service->url->passwd);
- service->url->passwd = NULL;
+ g_free (url->passwd);
+ url->passwd = NULL;
}
/* Catch any other errors. */
diff --git a/configure.ac b/configure.ac
index e664fcd..9c1bee8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -102,7 +102,7 @@ LIBEGROUPWISE_CURRENT=13
LIBEGROUPWISE_REVISION=1
LIBEGROUPWISE_AGE=0
-LIBCAMEL_CURRENT=24
+LIBCAMEL_CURRENT=25
LIBCAMEL_REVISION=0
LIBCAMEL_AGE=0
diff --git a/docs/reference/camel/camel-sections.txt b/docs/reference/camel/camel-sections.txt
index 49e09ad..1ab9804 100644
--- a/docs/reference/camel/camel-sections.txt
+++ b/docs/reference/camel/camel-sections.txt
@@ -1881,10 +1881,12 @@ camel_service_get_name
camel_service_get_path
camel_service_get_provider
camel_service_get_session
+camel_service_get_camel_url
camel_service_get_url
camel_service_cancel_connect
camel_service_connect_sync
camel_service_disconnect_sync
+camel_service_get_connection_status
camel_service_query_auth_types_sync
CamelServiceLock
camel_service_lock
diff --git a/docs/reference/camel/tmpl/camel-service.sgml b/docs/reference/camel/tmpl/camel-service.sgml
index 8f7f083..2716896 100644
--- a/docs/reference/camel/tmpl/camel-service.sgml
+++ b/docs/reference/camel/tmpl/camel-service.sgml
@@ -114,6 +114,15 @@ CamelService
@Returns:
+<!-- ##### FUNCTION camel_service_get_camel_url ##### -->
+<para>
+
+</para>
+
+ service:
+ Returns:
+
+
<!-- ##### FUNCTION camel_service_get_url ##### -->
<para>
@@ -152,6 +161,15 @@ CamelService
@Returns:
+<!-- ##### FUNCTION camel_service_get_connection_status ##### -->
+<para>
+
+</para>
+
+ service:
+ Returns:
+
+
<!-- ##### FUNCTION camel_service_query_auth_types_sync ##### -->
<para>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]