[evolution-mapi] Adapt to CamelNetworkSettings changes.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-mapi] Adapt to CamelNetworkSettings changes.
- Date: Mon, 24 Oct 2011 17:14:05 +0000 (UTC)
commit e13ea8f8d933960b064b75991e4fb4d8bdcf97aa
Author: Matthew Barnes <mbarnes redhat com>
Date: Thu Oct 20 23:32:08 2011 -0400
Adapt to CamelNetworkSettings changes.
.../exchange-mapi-account-listener.c | 57 ++++++++----
.../exchange-mapi-account-listener.h | 4 +-
.../exchange-mapi-account-settings.c | 13 ++--
src/camel/camel-mapi-folder.c | 18 +++-
src/camel/camel-mapi-store.c | 35 +++++---
src/camel/camel-mapi-transport.c | 15 +++-
src/libexchangemapi/camel-mapi-settings.c | 94 ++++++++++++++++++--
7 files changed, 178 insertions(+), 58 deletions(-)
---
diff --git a/src/account-setup-eplugin/exchange-mapi-account-listener.c b/src/account-setup-eplugin/exchange-mapi-account-listener.c
index f6a4743..b277bb2 100644
--- a/src/account-setup-eplugin/exchange-mapi-account-listener.c
+++ b/src/account-setup-eplugin/exchange-mapi-account-listener.c
@@ -392,9 +392,12 @@ add_cal_esource (EAccount *account, GSList *folders, ExchangeMAPIFolderType fold
g_object_unref (client);
}
-void exchange_mapi_add_esource (CamelURL *url, const gchar *folder_name, const gchar *fid, gint folder_type)
+void exchange_mapi_add_esource (CamelService *service, const gchar *folder_name, const gchar *fid, gint folder_type)
{
- CamelMapiSettings *settings;
+ CamelNetworkSettings *network_settings;
+ CamelOfflineSettings *offline_settings;
+ CamelMapiSettings *mapi_settings;
+ CamelSettings *settings;
ESourceList *source_list = NULL;
ESourceGroup *group = NULL;
const gchar *conf_key = NULL, *kerberos = NULL;
@@ -403,9 +406,10 @@ void exchange_mapi_add_esource (CamelURL *url, const gchar *folder_name, const g
ESource *source = NULL;
gchar *relative_uri = NULL;
gchar *base_uri = NULL;
+ const gchar *host;
+ const gchar *user;
- if (url == NULL)
- return;
+ g_return_if_fail (CAMEL_IS_SERVICE (service));
if (folder_type == MAPI_FOLDER_TYPE_APPOINTMENT)
conf_key = CALENDAR_SOURCES;
@@ -422,9 +426,15 @@ void exchange_mapi_add_esource (CamelURL *url, const gchar *folder_name, const g
return;
}
+ settings = camel_service_get_settings (service);
+
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
+ user = camel_network_settings_get_user (network_settings);
+
client = gconf_client_get_default ();
source_list = e_source_list_new_for_gconf (client, conf_key);
- base_uri = g_strdup_printf ("%s%s %s/", MAPI_URI_PREFIX, url->user, url->host);
+ base_uri = g_strdup_printf ("%s%s %s/", MAPI_URI_PREFIX, user, host);
group = e_source_list_peek_group_by_base_uri (source_list, base_uri);
sources = e_source_group_peek_sources (group);
for (; sources != NULL; sources = g_slist_next (sources)) {
@@ -440,29 +450,27 @@ void exchange_mapi_add_esource (CamelURL *url, const gchar *folder_name, const g
}
}
- settings = g_object_new (CAMEL_TYPE_MAPI_SETTINGS, NULL);
- camel_settings_load_from_url (CAMEL_SETTINGS (settings), url);
+ mapi_settings = CAMEL_MAPI_SETTINGS (settings);
+ offline_settings = CAMEL_OFFLINE_SETTINGS (settings);
relative_uri = g_strconcat (";", fid, NULL);
- kerberos = camel_mapi_settings_get_kerberos (settings) ? "required" : NULL;
+ kerberos = camel_mapi_settings_get_kerberos (mapi_settings) ? "required" : NULL;
source = e_source_new (folder_name, relative_uri);
e_source_set_property (source, "auth", "1");
e_source_set_property (source, "auth-type", "plain/password");
- e_source_set_property (source, "username", url->user);
- e_source_set_property (source, "host", url->host);
- e_source_set_property (source, "profile", camel_mapi_settings_get_profile (settings));
- e_source_set_property (source, "domain", camel_mapi_settings_get_domain (settings));
- e_source_set_property (source, "realm", camel_mapi_settings_get_realm (settings));
+ e_source_set_property (source, "username", user);
+ e_source_set_property (source, "host", host);
+ e_source_set_property (source, "profile", camel_mapi_settings_get_profile (mapi_settings));
+ e_source_set_property (source, "domain", camel_mapi_settings_get_domain (mapi_settings));
+ e_source_set_property (source, "realm", camel_mapi_settings_get_realm (mapi_settings));
e_source_set_property (source, "folder-id", fid);
- e_source_set_property (source, "offline_sync", camel_offline_settings_get_stay_synchronized (CAMEL_OFFLINE_SETTINGS (settings)) ? "1" : "0");
+ e_source_set_property (source, "offline_sync", camel_offline_settings_get_stay_synchronized (offline_settings) ? "1" : "0");
e_source_set_property (source, "public", "yes");
e_source_set_property (source, "delete", "yes");
SET_KRB_SSO(source, kerberos);
e_source_group_add_source (group, source, -1);
- g_object_unref (settings);
-
g_object_unref (source);
g_free (relative_uri);
@@ -477,17 +485,20 @@ void exchange_mapi_add_esource (CamelURL *url, const gchar *folder_name, const g
g_object_unref (client);
}
-void exchange_mapi_remove_esource (CamelURL *url, const gchar * folder_name, const gchar *fid, gint folder_type)
+void exchange_mapi_remove_esource (CamelService *service, const gchar * folder_name, const gchar *fid, gint folder_type)
{
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
ESourceList *source_list = NULL;
ESourceGroup *group = NULL;
const gchar *conf_key = NULL;
GConfClient* client;
GSList *sources=NULL;
gchar *base_uri = NULL;
+ const gchar *host;
+ const gchar *user;
- if (url == NULL)
- return;
+ g_return_if_fail (CAMEL_IS_SERVICE (service));
if (folder_type == MAPI_FOLDER_TYPE_APPOINTMENT)
conf_key = CALENDAR_SOURCES;
@@ -504,9 +515,15 @@ void exchange_mapi_remove_esource (CamelURL *url, const gchar * folder_name, con
return;
}
+ settings = camel_service_get_settings (service);
+
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
+ user = camel_network_settings_get_user (network_settings);
+
client = gconf_client_get_default ();
source_list = e_source_list_new_for_gconf (client, conf_key);
- base_uri = g_strdup_printf ("%s%s %s/", MAPI_URI_PREFIX, url->user, url->host);
+ base_uri = g_strdup_printf ("%s%s %s/", MAPI_URI_PREFIX, user, host);
group = e_source_list_peek_group_by_base_uri (source_list, base_uri);
sources = e_source_group_peek_sources (group);
diff --git a/src/account-setup-eplugin/exchange-mapi-account-listener.h b/src/account-setup-eplugin/exchange-mapi-account-listener.h
index 6b52982..588affc 100644
--- a/src/account-setup-eplugin/exchange-mapi-account-listener.h
+++ b/src/account-setup-eplugin/exchange-mapi-account-listener.h
@@ -47,8 +47,8 @@ struct _ExchangeMAPIAccountListenerClass {
GObjectClass parent_class;
};
-void exchange_mapi_add_esource (CamelURL *url, const gchar *folder_name, const gchar *fid, gint folder_type);
-void exchange_mapi_remove_esource (CamelURL *url, const gchar *folder_name, const gchar *fid, gint folder_type);
+void exchange_mapi_add_esource (CamelService *service, const gchar *folder_name, const gchar *fid, gint folder_type);
+void exchange_mapi_remove_esource (CamelService *service, const gchar *folder_name, const gchar *fid, gint folder_type);
GType exchange_mapi_account_listener_get_type (void);
ExchangeMAPIAccountListener * exchange_mapi_account_listener_new (void);
diff --git a/src/account-setup-eplugin/exchange-mapi-account-settings.c b/src/account-setup-eplugin/exchange-mapi-account-settings.c
index 15c5e68..ad6be9c 100644
--- a/src/account-setup-eplugin/exchange-mapi-account-settings.c
+++ b/src/account-setup-eplugin/exchange-mapi-account-settings.c
@@ -259,14 +259,13 @@ action_folder_size_cb (GtkAction *action,
store = camel_folder_get_parent_store (folder);
}
- if (store && CAMEL_IS_SERVICE (store)) {
- CamelService *service = CAMEL_SERVICE (store);
- CamelURL *url;
+ if (CAMEL_IS_SERVICE (store)) {
+ CamelService *service;
+ CamelSettings *settings;
- url = camel_service_get_camel_url (service);
-
- if (url)
- profile = g_strdup (camel_url_get_param (url, "profile"));
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
+ g_object_get (settings, "profile", &profile, NULL);
}
}
}
diff --git a/src/camel/camel-mapi-folder.c b/src/camel/camel-mapi-folder.c
index 5c7316a..5a8e374 100644
--- a/src/camel/camel-mapi-folder.c
+++ b/src/camel/camel-mapi-folder.c
@@ -1038,19 +1038,29 @@ mapi_folder_dispose (GObject *object)
static void
mapi_folder_constructed (GObject *object)
{
- CamelFolder *folder;
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
CamelStore *parent_store;
- CamelURL *url;
+ CamelService *service;
+ CamelFolder *folder;
const gchar *full_name;
+ const gchar *host;
+ const gchar *user;
gchar *description;
folder = CAMEL_FOLDER (object);
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
- url = camel_service_get_camel_url (CAMEL_SERVICE (parent_store));
+
+ service = CAMEL_SERVICE (parent_store);
+ settings = camel_service_get_settings (service);
+
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
+ user = camel_network_settings_get_user (network_settings);
description = g_strdup_printf (
- "%s %s:%s", url->user, url->host, full_name);
+ "%s %s:%s", user, host, full_name);
camel_folder_set_description (folder, description);
g_free (description);
}
diff --git a/src/camel/camel-mapi-store.c b/src/camel/camel-mapi-store.c
index 21f10eb..9b84963 100644
--- a/src/camel/camel-mapi-store.c
+++ b/src/camel/camel-mapi-store.c
@@ -1476,11 +1476,11 @@ mapi_store_subscribe_folder_sync (CamelSubscribable *subscribable,
camel_subscribable_folder_subscribed (subscribable, fi);
camel_folder_info_free (fi);
} else {
- CamelURL *url;
+ CamelService *service;
guint folder_type = mapi_folders_hash_table_type_lookup (mapi_store, folder_name);
- url = camel_service_get_camel_url (CAMEL_SERVICE (mapi_store));
- exchange_mapi_add_esource (url, use_folder_name, fid, folder_type);
+ service = CAMEL_SERVICE (mapi_store);
+ exchange_mapi_add_esource (service, use_folder_name, fid, folder_type);
}
camel_store_summary_info_free((CamelStoreSummary *)mapi_store->summary, si);
return TRUE;
@@ -1492,6 +1492,7 @@ mapi_store_unsubscribe_folder_sync (CamelSubscribable *subscribable,
GCancellable *cancellable,
GError **error)
{
+ CamelService *service;
CamelFolderInfo *fi;
CamelStoreInfo *si;
gchar *parent_name = NULL;
@@ -1499,9 +1500,8 @@ mapi_store_unsubscribe_folder_sync (CamelSubscribable *subscribable,
gchar *f_name = NULL;
CamelMapiStore *mapi_store = CAMEL_MAPI_STORE (subscribable);
- CamelURL *url;
- url = camel_service_get_camel_url (CAMEL_SERVICE (mapi_store));
+ service = CAMEL_SERVICE (mapi_store);
fid = camel_mapi_store_folder_id_lookup(mapi_store, folder_name);
si = camel_store_summary_path((CamelStoreSummary *)mapi_store->summary, folder_name);
if (si) {
@@ -1530,7 +1530,7 @@ mapi_store_unsubscribe_folder_sync (CamelSubscribable *subscribable,
camel_folder_info_free (fi);
} else {
guint folder_type = mapi_folders_hash_table_type_lookup (mapi_store, use_folder_name);
- exchange_mapi_remove_esource(url, folder_name, fid, folder_type);
+ exchange_mapi_remove_esource (service, folder_name, fid, folder_type);
}
camel_store_summary_info_free ((CamelStoreSummary *)mapi_store->summary, si);
@@ -1667,18 +1667,25 @@ mapi_store_constructed (GObject *object)
static char *
mapi_get_name(CamelService *service, gboolean brief)
{
- CamelURL *url;
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
+ const gchar *host;
+ const gchar *user;
+
+ settings = camel_service_get_settings (service);
- url = camel_service_get_camel_url (service);
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
+ user = camel_network_settings_get_user (network_settings);
if (brief) {
/* Translators: The %s is replaced with a server's host name */
- return g_strdup_printf(_("Exchange MAPI server %s"), url->host);
+ return g_strdup_printf(_("Exchange MAPI server %s"), host);
} else {
/*To translators : Example string : Exchange MAPI service for
_username_ on _server host name__*/
return g_strdup_printf(_("Exchange MAPI service for %s on %s"),
- url->user, url->host);
+ user, host);
}
}
@@ -1771,20 +1778,20 @@ mapi_authenticate_sync (CamelService *service,
{
CamelAuthenticationResult result;
CamelMapiStore *store = CAMEL_MAPI_STORE (service);
- CamelURL *url;
CamelSettings *settings;
CamelMapiSettings *mapi_settings;
+ CamelNetworkSettings *network_settings;
ExchangeMapiProfileData empd = { 0 };
const gchar *profile;
const gchar *password;
GError *mapi_error = NULL;
- url = camel_service_get_camel_url (service);
settings = camel_service_get_settings (service);
mapi_settings = CAMEL_MAPI_SETTINGS (settings);
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
- empd.server = url->host;
- empd.username = url->user;
+ empd.server = camel_network_settings_get_host (network_settings);
+ empd.username = camel_network_settings_get_user (network_settings);
exchange_mapi_util_profiledata_from_settings (&empd, mapi_settings);
profile = camel_mapi_settings_get_profile (mapi_settings);
diff --git a/src/camel/camel-mapi-transport.c b/src/camel/camel-mapi-transport.c
index ba31a6d..5dd7fb3 100644
--- a/src/camel/camel-mapi-transport.c
+++ b/src/camel/camel-mapi-transport.c
@@ -145,17 +145,24 @@ mapi_send_to_sync (CamelTransport *transport,
static gchar *
mapi_transport_get_name(CamelService *service, gboolean brief)
{
- CamelURL *url;
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
+ const gchar *host;
+ const gchar *user;
+
+ settings = camel_service_get_settings (service);
- url = camel_service_get_camel_url (service);
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
+ user = camel_network_settings_get_user (network_settings);
if (brief) {
/* Translators: The %s is replaced with a server's host name */
- return g_strdup_printf (_("Exchange MAPI server %s"), url->host);
+ return g_strdup_printf (_("Exchange MAPI server %s"), host);
} else {
/* Translators: The first %s is replaced with a user name, the second with a server's host name */
return g_strdup_printf (_("Exchange MAPI service for %s on %s"),
- url->user, url->host);
+ user, host);
}
}
diff --git a/src/libexchangemapi/camel-mapi-settings.c b/src/libexchangemapi/camel-mapi-settings.c
index e875744..7f9c55e 100644
--- a/src/libexchangemapi/camel-mapi-settings.c
+++ b/src/libexchangemapi/camel-mapi-settings.c
@@ -35,14 +35,18 @@ struct _CamelMapiSettingsPrivate {
enum {
PROP_0,
+ PROP_AUTH_MECHANISM,
PROP_CHECK_ALL,
PROP_DOMAIN,
PROP_FILTER_JUNK,
PROP_FILTER_JUNK_INBOX,
+ PROP_HOST,
PROP_KERBEROS,
+ PROP_PORT,
PROP_PROFILE,
PROP_REALM,
- PROP_SECURITY_METHOD
+ PROP_SECURITY_METHOD,
+ PROP_USER
};
G_DEFINE_TYPE_WITH_CODE (
@@ -54,11 +58,17 @@ G_DEFINE_TYPE_WITH_CODE (
static void
mapi_settings_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_AUTH_MECHANISM:
+ camel_network_settings_set_auth_mechanism (
+ CAMEL_NETWORK_SETTINGS (object),
+ g_value_get_string (value));
+ return;
+
case PROP_CHECK_ALL:
camel_mapi_settings_set_check_all (
CAMEL_MAPI_SETTINGS (object),
@@ -83,12 +93,24 @@ mapi_settings_set_property (GObject *object,
g_value_get_boolean (value));
return;
+ case PROP_HOST:
+ camel_network_settings_set_host (
+ CAMEL_NETWORK_SETTINGS (object),
+ g_value_get_string (value));
+ return;
+
case PROP_KERBEROS:
camel_mapi_settings_set_kerberos (
CAMEL_MAPI_SETTINGS (object),
g_value_get_boolean (value));
return;
+ case PROP_PORT:
+ camel_network_settings_set_port (
+ CAMEL_NETWORK_SETTINGS (object),
+ g_value_get_uint (value));
+ return;
+
case PROP_PROFILE:
camel_mapi_settings_set_profile (
CAMEL_MAPI_SETTINGS (object),
@@ -106,6 +128,12 @@ mapi_settings_set_property (GObject *object,
CAMEL_NETWORK_SETTINGS (object),
g_value_get_enum (value));
return;
+
+ case PROP_USER:
+ camel_network_settings_set_user (
+ CAMEL_NETWORK_SETTINGS (object),
+ g_value_get_string (value));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -113,11 +141,18 @@ mapi_settings_set_property (GObject *object,
static void
mapi_settings_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_AUTH_MECHANISM:
+ g_value_set_string (
+ value,
+ camel_network_settings_get_auth_mechanism (
+ CAMEL_NETWORK_SETTINGS (object)));
+ return;
+
case PROP_CHECK_ALL:
g_value_set_boolean (
value,
@@ -146,6 +181,13 @@ mapi_settings_get_property (GObject *object,
CAMEL_MAPI_SETTINGS (object)));
return;
+ case PROP_HOST:
+ g_value_set_string (
+ value,
+ camel_network_settings_get_host (
+ CAMEL_NETWORK_SETTINGS (object)));
+ return;
+
case PROP_KERBEROS:
g_value_set_boolean (
value,
@@ -153,6 +195,13 @@ mapi_settings_get_property (GObject *object,
CAMEL_MAPI_SETTINGS (object)));
return;
+ case PROP_PORT:
+ g_value_set_uint (
+ value,
+ camel_network_settings_get_port (
+ CAMEL_NETWORK_SETTINGS (object)));
+ return;
+
case PROP_PROFILE:
g_value_set_string (
value,
@@ -173,6 +222,13 @@ mapi_settings_get_property (GObject *object,
camel_network_settings_get_security_method (
CAMEL_NETWORK_SETTINGS (object)));
return;
+
+ case PROP_USER:
+ g_value_set_string (
+ value,
+ camel_network_settings_get_user (
+ CAMEL_NETWORK_SETTINGS (object)));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -203,6 +259,12 @@ camel_mapi_settings_class_init (CamelMapiSettingsClass *class)
object_class->get_property = mapi_settings_get_property;
object_class->finalize = mapi_settings_finalize;
+ /* Inherited from CamelNetworkSettings. */
+ g_object_class_override_property (
+ object_class,
+ PROP_AUTH_MECHANISM,
+ "auth-mechanism");
+
g_object_class_install_property (
object_class,
PROP_CHECK_ALL,
@@ -251,6 +313,12 @@ camel_mapi_settings_class_init (CamelMapiSettingsClass *class)
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
+ /* Inherited from CamelNetworkSettings. */
+ g_object_class_override_property (
+ object_class,
+ PROP_HOST,
+ "host");
+
g_object_class_install_property (
object_class,
PROP_KERBEROS,
@@ -263,6 +331,12 @@ camel_mapi_settings_class_init (CamelMapiSettingsClass *class)
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
+ /* Inherited from CamelNetworkSettings. */
+ g_object_class_override_property (
+ object_class,
+ PROP_PORT,
+ "port");
+
g_object_class_install_property (
object_class,
PROP_PROFILE,
@@ -292,6 +366,12 @@ camel_mapi_settings_class_init (CamelMapiSettingsClass *class)
object_class,
PROP_SECURITY_METHOD,
"security-method");
+
+ /* Inherited from CamelNetworkSettings. */
+ g_object_class_override_property (
+ object_class,
+ PROP_USER,
+ "user");
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]