[evolution-mapi] Add CamelMapiSettings.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-mapi] Add CamelMapiSettings.
- Date: Mon, 15 Aug 2011 16:06:04 +0000 (UTC)
commit be514b67e8c6ca7d613f693219723ff6bea597d0
Author: Matthew Barnes <mbarnes redhat com>
Date: Sun Aug 14 08:17:25 2011 -0400
Add CamelMapiSettings.
CamelMapiSettings replaces the various URL parameters used in
CamelMapiStore with equivalent GObject properties.
Adapt the mapi module to use CamelSettings.
.../exchange-mapi-account-listener.c | 155 +++++---
.../exchange-mapi-account-setup.c | 214 ++++------
src/camel/camel-mapi-folder.c | 10 +-
src/camel/camel-mapi-provider.c | 10 +-
src/camel/camel-mapi-store.c | 49 +--
src/camel/camel-mapi-store.h | 1 -
src/camel/camel-mapi-transport.c | 12 +-
src/libexchangemapi/Makefile.am | 2 +
src/libexchangemapi/camel-mapi-settings.c | 445 ++++++++++++++++++++
src/libexchangemapi/camel-mapi-settings.h | 92 ++++
src/libexchangemapi/exchange-mapi-connection.c | 16 +-
src/libexchangemapi/exchange-mapi-utils.c | 36 +-
src/libexchangemapi/exchange-mapi-utils.h | 4 +-
13 files changed, 805 insertions(+), 241 deletions(-)
---
diff --git a/src/account-setup-eplugin/exchange-mapi-account-listener.c b/src/account-setup-eplugin/exchange-mapi-account-listener.c
index c7949f5..db65aeb 100644
--- a/src/account-setup-eplugin/exchange-mapi-account-listener.c
+++ b/src/account-setup-eplugin/exchange-mapi-account-listener.c
@@ -58,7 +58,7 @@
G_DEFINE_TYPE (ExchangeMAPIAccountListener, exchange_mapi_account_listener, G_TYPE_OBJECT)
-static gboolean create_profile_entry (CamelURL *url, EAccount *account);
+static gboolean create_profile_entry (CamelURL *url, EAccount *account, CamelMapiSettings *settings);
struct _ExchangeMAPIAccountListenerPrivate {
GConfClient *gconf_client;
@@ -226,15 +226,28 @@ find_source_by_fid (GSList *sources, const gchar *fid)
#define ADDRESSBOOK_SOURCES "/apps/evolution/addressbook/sources"
static void
-add_cal_esource (EAccount *account, GSList *folders, ExchangeMAPIFolderType folder_type, CamelURL *url, mapi_id_t trash_fid)
+add_cal_esource (EAccount *account, GSList *folders, ExchangeMAPIFolderType folder_type, CamelURL *url, CamelSettings *settings, mapi_id_t trash_fid)
{
+ CamelMapiSettings *mapi_settings;
ESourceList *source_list = NULL;
ESourceGroup *group = NULL;
- const gchar *conf_key = NULL, *source_selection_key = NULL, *kerberos;
+ const gchar *conf_key = NULL, *source_selection_key = NULL;
GConfClient* client;
GSList *ids, *temp_list, *old_sources = NULL;
gchar *base_uri = NULL;
gboolean is_new_group = FALSE;
+ const gchar *profile;
+ const gchar *domain;
+ const gchar *realm;
+ const gchar *kerberos;
+ gboolean stay_synchronized;
+
+ mapi_settings = CAMEL_MAPI_SETTINGS (settings);
+ profile = camel_mapi_settings_get_profile (mapi_settings);
+ domain = camel_mapi_settings_get_domain (mapi_settings);
+ realm = camel_mapi_settings_get_realm (mapi_settings);
+ kerberos = camel_mapi_settings_get_kerberos (mapi_settings) ? "required" : NULL;
+ stay_synchronized = camel_offline_settings_get_stay_synchronized (CAMEL_OFFLINE_SETTINGS (settings));
if (folder_type == MAPI_FOLDER_TYPE_APPOINTMENT) {
conf_key = CALENDAR_SOURCES;
@@ -271,10 +284,9 @@ add_cal_esource (EAccount *account, GSList *folders, ExchangeMAPIFolderType fold
e_source_group_set_property (group, "create_source", "yes");
e_source_group_set_property (group, "username", url->user);
e_source_group_set_property (group, "host", url->host);
- e_source_group_set_property (group, "profile", camel_url_get_param (url, "profile"));
- e_source_group_set_property (group, "domain", camel_url_get_param (url, "domain"));
- e_source_group_set_property (group, "realm", camel_url_get_param (url, "realm"));
- kerberos = camel_url_get_param (url, "kerberos");
+ e_source_group_set_property (group, "profile", profile);
+ e_source_group_set_property (group, "domain", domain);
+ e_source_group_set_property (group, "realm", realm);
e_source_group_set_property (group, "kerberos", kerberos);
/* We set these because on new folder creation - these are required. */
@@ -309,16 +321,15 @@ add_cal_esource (EAccount *account, GSList *folders, ExchangeMAPIFolderType fold
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_url_get_param (url, "profile"));
- e_source_set_property (source, "domain", camel_url_get_param (url, "domain"));
- e_source_set_property (source, "realm", camel_url_get_param (url, "realm"));
+ e_source_set_property (source, "profile", profile);
+ e_source_set_property (source, "domain", domain);
+ e_source_set_property (source, "realm", realm);
e_source_set_property (source, "folder-id", fid);
e_source_set_property (source, "public", "no");
SET_KRB_SSO(source, kerberos);
if (is_new_source)
- e_source_set_property (source, "offline_sync",
- camel_url_get_param (url, "offline_sync") ? "1" : "0");
+ e_source_set_property (source, "offline_sync", stay_synchronized ? "1" : "0");
if (folder->is_default)
e_source_set_property (source, "delete", "no");
@@ -383,6 +394,7 @@ add_cal_esource (EAccount *account, GSList *folders, ExchangeMAPIFolderType fold
void exchange_mapi_add_esource (CamelURL *url, const gchar *folder_name, const gchar *fid, gint folder_type)
{
+ CamelMapiSettings *settings;
ESourceList *source_list = NULL;
ESourceGroup *group = NULL;
const gchar *conf_key = NULL, *kerberos = NULL;
@@ -428,25 +440,29 @@ 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);
+
relative_uri = g_strconcat (";", fid, NULL);
- kerberos = camel_url_get_param (url, "kerberos");
+ kerberos = camel_mapi_settings_get_kerberos (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_url_get_param (url, "profile"));
- e_source_set_property (source, "domain", camel_url_get_param (url, "domain"));
- e_source_set_property (source, "realm", camel_url_get_param (url, "realm"));
+ 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, "folder-id", fid);
- e_source_set_property (source, "offline_sync",
- camel_url_get_param (url, "offline_sync") ? "1" : "0");
+ e_source_set_property (source, "offline_sync", camel_offline_settings_get_stay_synchronized (CAMEL_OFFLINE_SETTINGS (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);
@@ -585,10 +601,16 @@ add_calendar_sources (EAccount *account, GSList *folders, mapi_id_t trash_fid)
url = camel_url_new (account->source->url, NULL);
if (url) {
- add_cal_esource (account, folders, MAPI_FOLDER_TYPE_APPOINTMENT, url, trash_fid);
- add_cal_esource (account, folders, MAPI_FOLDER_TYPE_TASK, url, trash_fid);
- add_cal_esource (account, folders, MAPI_FOLDER_TYPE_MEMO, url, trash_fid);
+ CamelSettings *settings;
+ settings = g_object_new (CAMEL_TYPE_MAPI_SETTINGS, NULL);
+ camel_settings_load_from_url (settings, url);
+
+ add_cal_esource (account, folders, MAPI_FOLDER_TYPE_APPOINTMENT, url, settings, trash_fid);
+ add_cal_esource (account, folders, MAPI_FOLDER_TYPE_TASK, url, settings, trash_fid);
+ add_cal_esource (account, folders, MAPI_FOLDER_TYPE_MEMO, url, settings, trash_fid);
+
+ g_object_unref (settings);
camel_url_free (url);
}
}
@@ -636,6 +658,7 @@ static gboolean
add_addressbook_sources (EAccount *account, GSList *folders, mapi_id_t trash_fid)
{
CamelURL *url;
+ CamelMapiSettings *settings;
ESourceList *list;
ESourceGroup *group;
ESource *source;
@@ -643,13 +666,26 @@ add_addressbook_sources (EAccount *account, GSList *folders, mapi_id_t trash_fid
GSList *temp_list, *old_sources = NULL;
GConfClient* client;
gboolean is_new_group = FALSE;
- const gchar *kerberos = NULL;
+ const gchar *profile;
+ const gchar *domain;
+ const gchar *realm;
+ const gchar *kerberos;
+ gboolean stay_synchronized;
url = camel_url_new (account->source->url, NULL);
if (url == NULL) {
return FALSE;
}
+ settings = g_object_new (CAMEL_TYPE_MAPI_SETTINGS, NULL);
+ camel_settings_load_from_url (CAMEL_SETTINGS (settings), url);
+
+ profile = camel_mapi_settings_get_profile (settings);
+ domain = camel_mapi_settings_get_domain (settings);
+ realm = camel_mapi_settings_get_realm (settings);
+ kerberos = camel_mapi_settings_get_kerberos (settings) ? "required" : NULL;
+ stay_synchronized = camel_offline_settings_get_stay_synchronized (CAMEL_OFFLINE_SETTINGS (settings));
+
base_uri = g_strdup_printf ("mapi://%s %s/", url->user, url->host);
client = gconf_client_get_default ();
list = e_source_list_new_for_gconf (client, "/apps/evolution/addressbook/sources" );
@@ -667,13 +703,12 @@ add_addressbook_sources (EAccount *account, GSList *folders, mapi_id_t trash_fid
is_new_group = TRUE;
old_sources = NULL;
}
- kerberos = camel_url_get_param (url, "kerberos");
e_source_group_set_property (group, "user", NULL);
e_source_group_set_property (group, "username", url->user);
e_source_group_set_property (group, "host", url->host);
- e_source_group_set_property (group, "profile", camel_url_get_param (url, "profile"));
- e_source_group_set_property (group, "domain", camel_url_get_param (url, "domain"));
- e_source_group_set_property (group, "realm", camel_url_get_param (url, "realm"));
+ e_source_group_set_property (group, "profile", profile);
+ e_source_group_set_property (group, "domain", domain);
+ e_source_group_set_property (group, "realm", realm);
e_source_group_set_property (group, "kerberos", kerberos);
for (temp_list = folders; temp_list != NULL; temp_list = g_slist_next (temp_list)) {
@@ -701,16 +736,15 @@ add_addressbook_sources (EAccount *account, GSList *folders, mapi_id_t trash_fid
e_source_set_property(source, "user", NULL);
e_source_set_property(source, "username", url->user);
e_source_set_property(source, "host", url->host);
- e_source_set_property(source, "profile", camel_url_get_param (url, "profile"));
- e_source_set_property(source, "domain", camel_url_get_param (url, "domain"));
- e_source_set_property(source, "realm", camel_url_get_param (url, "realm"));
+ e_source_set_property(source, "profile", profile);
+ e_source_set_property(source, "domain", domain);
+ e_source_set_property(source, "realm", realm);
e_source_set_property(source, "folder-id", fid);
e_source_set_property (source, "public", "no");
SET_KRB_SSO(source, kerberos);
if (is_new_source) {
- e_source_set_property (source, "offline_sync",
- camel_url_get_param (url, "offline_sync") ? "1" : "0");
+ e_source_set_property (source, "offline_sync", stay_synchronized ? "1" : "0");
e_source_set_property (source, "completion", "true");
}
@@ -765,11 +799,9 @@ add_addressbook_sources (EAccount *account, GSList *folders, mapi_id_t trash_fid
//FIXME: Offline handling
e_source_set_property(source, "user", NULL);
e_source_set_property(source, "username", url->user);
- e_source_set_property(source, "host", camel_url_get_param (url, "ad_server"));
- e_source_set_property(source, "view-limit", camel_url_get_param (url, "ad_limit"));
- e_source_set_property(source, "profile", camel_url_get_param (url, "profile"));
- e_source_set_property(source, "domain", camel_url_get_param (url, "domain"));
- e_source_set_property(source, "realm", camel_url_get_param (url, "realm"));
+ e_source_set_property(source, "profile", profile);
+ e_source_set_property(source, "domain", domain);
+ e_source_set_property(source, "realm", realm);
SET_KRB_SSO(source, kerberos);
if (is_new_source) {
@@ -803,6 +835,8 @@ add_addressbook_sources (EAccount *account, GSList *folders, mapi_id_t trash_fid
if (!e_source_list_sync (list, NULL))
g_warning ("%s: Failed to sync source list", G_STRFUNC);
+ g_object_unref (settings);
+
g_object_unref (group);
g_object_unref (list);
g_object_unref (client);
@@ -1008,23 +1042,31 @@ static void
update_account_sources_async (gpointer worker_data, gboolean cancelled, gpointer user_data)
{
CamelURL *url;
+ CamelSettings *settings;
ExchangeMapiConnection *conn;
EAccount *account = worker_data;
gboolean can_create_profile = GPOINTER_TO_INT (user_data) ? TRUE : FALSE;
+ const gchar *profile;
url = camel_url_new (account->source->url, NULL);
g_return_if_fail (url != NULL);
- conn = exchange_mapi_connection_find (camel_url_get_param (url, "profile"));
+ settings = g_object_new (CAMEL_TYPE_MAPI_SETTINGS, NULL);
+ camel_settings_load_from_url (settings, url);
+
+ profile = camel_mapi_settings_get_profile (CAMEL_MAPI_SETTINGS (settings));
+
+ conn = exchange_mapi_connection_find (profile);
if (!conn && can_create_profile) {
/* connect to the server when not connected yet */
- if (!create_profile_entry (url, account)) {
+ if (!create_profile_entry (url, account, CAMEL_MAPI_SETTINGS (settings))) {
camel_url_free (url);
+ g_object_unref (settings);
g_warning ("%s: Failed to create MAPI profile for '%s'", G_STRFUNC, account->name);
return;
}
- conn = exchange_mapi_connection_find (camel_url_get_param (url, "profile"));
+ conn = exchange_mapi_connection_find (profile);
}
if (conn) {
@@ -1033,7 +1075,7 @@ update_account_sources_async (gpointer worker_data, gboolean cancelled, gpointer
struct create_sources_data *csd;
csd = g_new0 (struct create_sources_data, 1);
- csd->profile_name = g_strdup (camel_url_get_param (url, "profile"));
+ csd->profile_name = g_strdup (profile);
csd->account = g_object_ref (account);
g_timeout_add_seconds (1, check_for_account_conn_cb, csd);
@@ -1041,6 +1083,7 @@ update_account_sources_async (gpointer worker_data, gboolean cancelled, gpointer
camel_url_free (url);
g_object_unref (account);
+ g_object_unref (settings);
}
static void
@@ -1124,7 +1167,7 @@ mapi_account_removed (EAccountList *account_listener, EAccount *account)
}
static gboolean
-create_profile_entry (CamelURL *url, EAccount *account)
+create_profile_entry (CamelURL *url, EAccount *account, CamelMapiSettings *settings)
{
gboolean status = FALSE;
guint8 attempts = 0;
@@ -1133,7 +1176,9 @@ create_profile_entry (CamelURL *url, EAccount *account)
if (!e_shell_get_online (e_shell_get_default ()))
return FALSE;
- exchange_mapi_util_profiledata_from_camelurl (&empd, url);
+ empd.server = url->host;
+ empd.username = url->user;
+ exchange_mapi_util_profiledata_from_settings (&empd, settings);
while (!status && attempts <= 3) {
gchar *key = NULL;
@@ -1199,7 +1244,7 @@ check_equal (const gchar *a, const gchar *b)
static gboolean
mapi_camel_url_equal (CamelURL *a, CamelURL *b)
{
- const gchar *params[] = { "profile", "domain", "realm", "kerberos", "ad_limit", "ad_server" };
+ const gchar *params[] = { "profile", "domain", "realm", "kerberos" };
guint n_params = G_N_ELEMENTS (params), i;
gboolean retval = TRUE;
@@ -1222,6 +1267,7 @@ mapi_account_changed_async (gpointer worker_data, gboolean cancelled, gpointer u
EAccountList *account_listener = worker_data;
EAccount *account = user_data;
ExchangeMapiProfileData empd = { 0 };
+ CamelSettings *settings;
g_return_if_fail (account_listener != NULL);
g_return_if_fail (account != NULL);
@@ -1236,18 +1282,23 @@ mapi_account_changed_async (gpointer worker_data, gboolean cancelled, gpointer u
new_url = camel_url_new (account->source->url, NULL);
+ settings = g_object_new (CAMEL_TYPE_MAPI_SETTINGS, NULL);
+ camel_settings_load_from_url (settings, new_url);
+
if (existing_account_info == NULL && isa_mapi_account) {
/* some account of other type is changed to MAPI */
- if (create_profile_entry (new_url, account)) {
+ if (create_profile_entry (new_url, account, CAMEL_MAPI_SETTINGS (settings))) {
/* Things are successful */
gchar *profname = NULL, *uri = NULL;
ExchangeMAPIAccountListener *config_listener = exchange_mapi_accounts_peek_config_listener();
- exchange_mapi_util_profiledata_from_camelurl (&empd,
- new_url);
+ empd.server = new_url->host;
+ empd.username = new_url->user;
+ exchange_mapi_util_profiledata_from_settings (&empd, CAMEL_MAPI_SETTINGS (settings));
profname = exchange_mapi_util_profile_name (&empd,
FALSE);
- camel_url_set_param(new_url, "profile", profname);
+ camel_mapi_settings_set_profile (CAMEL_MAPI_SETTINGS (settings), profname);
+ camel_settings_save_to_url (settings, new_url);
g_free (profname);
uri = camel_url_to_string(new_url, 0);
@@ -1274,14 +1325,17 @@ mapi_account_changed_async (gpointer worker_data, gboolean cancelled, gpointer u
} else if (!mapi_camel_url_equal (old_url, new_url) || (existing_account_info->enabled != account->enabled)) {
/* Some or all of the account info changed OR the account has been moved from a disabled state to enabled state */
mapi_account_removed (account_listener, account);
- if (create_profile_entry (new_url, account)) {
+ if (create_profile_entry (new_url, account, CAMEL_MAPI_SETTINGS (settings))) {
/* Things are successful */
gchar *profname = NULL, *uri = NULL;
ExchangeMAPIAccountListener *config_listener = exchange_mapi_accounts_peek_config_listener();
- exchange_mapi_util_profiledata_from_camelurl (&empd, new_url);
+ empd.server = new_url->host;
+ empd.username = new_url->user;
+ exchange_mapi_util_profiledata_from_settings (&empd, CAMEL_MAPI_SETTINGS (settings));
profname = exchange_mapi_util_profile_name (&empd, FALSE);
- camel_url_set_param(new_url, "profile", profname);
+ camel_mapi_settings_set_profile (CAMEL_MAPI_SETTINGS (settings), profname);
+ camel_settings_save_to_url (settings, new_url);
g_free (profname);
uri = camel_url_to_string(new_url, 0);
@@ -1302,6 +1356,7 @@ mapi_account_changed_async (gpointer worker_data, gboolean cancelled, gpointer u
if (old_url)
camel_url_free (old_url);
+ g_object_unref (settings);
camel_url_free (new_url);
g_object_unref (account_listener);
diff --git a/src/account-setup-eplugin/exchange-mapi-account-setup.c b/src/account-setup-eplugin/exchange-mapi-account-setup.c
index 914850f..24fcbc7 100644
--- a/src/account-setup-eplugin/exchange-mapi-account-setup.c
+++ b/src/account-setup-eplugin/exchange-mapi-account-setup.c
@@ -105,6 +105,41 @@ tree_selection_changed (GtkTreeSelection *selection, GtkDialog *dialog)
gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_ACCEPT, gtk_tree_selection_get_selected (selection, NULL, NULL));
}
+static gboolean
+transform_security_method_to_boolean (GBinding *binding,
+ const GValue *source_value,
+ GValue *target_value,
+ gpointer not_used)
+{
+ CamelNetworkSecurityMethod security_method;
+ gboolean use_ssl;
+
+ security_method = g_value_get_enum (source_value);
+ use_ssl = (security_method != CAMEL_NETWORK_SECURITY_METHOD_NONE);
+ g_value_set_boolean (target_value, use_ssl);
+
+ return TRUE;
+}
+
+static gboolean
+transform_boolean_to_security_method (GBinding *binding,
+ const GValue *source_value,
+ GValue *target_value,
+ gpointer not_used)
+{
+ CamelNetworkSecurityMethod security_method;
+ gboolean use_ssl;
+
+ use_ssl = g_value_get_boolean (source_value);
+ if (use_ssl)
+ security_method = CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT;
+ else
+ security_method = CAMEL_NETWORK_SECURITY_METHOD_NONE;
+ g_value_set_enum (target_value, security_method);
+
+ return TRUE;
+}
+
/* Callback for ProcessNetworkProfile. If we have more than one username,
we need to let the user select. */
static uint32_t
@@ -233,6 +268,7 @@ validate_credentials (GtkWidget *widget, EConfig *config)
CamelURL *url = NULL;
gchar *key = NULL;
ExchangeMapiProfileData empd = { 0 };
+ CamelMapiSettings *mapi_settings;
GError *error = NULL;
if (!e_shell_get_online (e_shell_get_default ())) {
@@ -241,6 +277,7 @@ validate_credentials (GtkWidget *widget, EConfig *config)
}
url = camel_url_new (e_account_get_string (target_account->modified_account, E_ACCOUNT_SOURCE_URL), NULL);
+ mapi_settings = CAMEL_MAPI_SETTINGS (target_account->settings);
/* Silently remove domain part from a username when user enters it as such.
This change will be visible in the UI on new edit open. */
@@ -253,7 +290,10 @@ validate_credentials (GtkWidget *widget, EConfig *config)
g_free (tmp);
}
- exchange_mapi_util_profiledata_from_camelurl (&empd, url);
+ empd.server = url->host;
+ empd.username = url->user;
+ exchange_mapi_util_profiledata_from_settings (&empd, mapi_settings);
+
if (!empd.username || !*(empd.username)
|| !empd.server || !*(empd.server)
|| ((!empd.domain || !*(empd.domain))
@@ -300,18 +340,13 @@ validate_credentials (GtkWidget *widget, EConfig *config)
if (status) {
/* Things are successful */
- gchar *profname = NULL, *uri = NULL;
+ gchar *profname = NULL;
profname = exchange_mapi_util_profile_name (&empd,
FALSE);
- camel_url_set_param (url, "profile", profname);
+ camel_mapi_settings_set_profile (mapi_settings, profname);
g_free (profname);
- uri = camel_url_to_string(url, 0);
- e_account_set_string (target_account->modified_account, E_ACCOUNT_SOURCE_URL, uri);
- e_account_set_string (target_account->modified_account, E_ACCOUNT_TRANSPORT_URL, uri);
- g_free (uri);
-
e_notice (NULL, GTK_MESSAGE_INFO, "%s", _("Authentication finished successfully."));
} else {
gchar *e;
@@ -338,110 +373,17 @@ validate_credentials (GtkWidget *widget, EConfig *config)
camel_url_free (url);
}
-static void
-domain_entry_changed(GtkWidget *entry, EConfig *config)
-{
- EMConfigTargetAccount *target = (EMConfigTargetAccount *)(config->target);
- CamelURL *url = NULL;
- const gchar *domain = NULL;
- gchar *url_string = NULL;
-
- url = camel_url_new (e_account_get_string(target->modified_account, E_ACCOUNT_SOURCE_URL), NULL);
- domain = gtk_entry_get_text (GTK_ENTRY(entry));
-
- if (domain && domain[0])
- camel_url_set_param (url, "domain", domain);
- else
- camel_url_set_param (url, "domain", NULL);
-
- url_string = camel_url_to_string (url, 0);
- e_account_set_string (target->modified_account, E_ACCOUNT_SOURCE_URL, url_string);
- e_account_set_string (target->modified_account, E_ACCOUNT_TRANSPORT_URL, url_string);
- g_free (url_string);
-
- camel_url_free (url);
-}
-
-static void
-realm_entry_changed (GtkWidget *entry, EConfig *config)
-{
- EMConfigTargetAccount *target = (EMConfigTargetAccount *)(config->target);
- CamelURL *url = NULL;
- const gchar *realm = NULL;
- gchar *url_string = NULL;
-
- url = camel_url_new (e_account_get_string(target->modified_account, E_ACCOUNT_SOURCE_URL), NULL);
- realm = gtk_entry_get_text (GTK_ENTRY(entry));
-
- if (realm && realm[0])
- camel_url_set_param (url, "realm", realm);
- else
- camel_url_set_param (url, "realm", NULL);
-
- url_string = camel_url_to_string (url, 0);
- e_account_set_string (target->modified_account, E_ACCOUNT_SOURCE_URL, url_string);
- e_account_set_string (target->modified_account, E_ACCOUNT_TRANSPORT_URL, url_string);
- g_free (url_string);
-
- camel_url_free (url);
-}
-
-static void
-krb_sso_check_toggled (GtkWidget *check, EConfig *config)
-{
- EMConfigTargetAccount *target = (EMConfigTargetAccount *)(config->target);
- CamelURL *url = NULL;
- gchar *url_string = NULL;
-
- url = camel_url_new (e_account_get_string (target->modified_account, E_ACCOUNT_SOURCE_URL), NULL);
-
- camel_url_set_param (url, "kerberos", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)) ? "required" : NULL);
-
- url_string = camel_url_to_string (url, 0);
- e_account_set_string (target->modified_account, E_ACCOUNT_SOURCE_URL, url_string);
- e_account_set_string (target->modified_account, E_ACCOUNT_TRANSPORT_URL, url_string);
- g_free (url_string);
-
- camel_url_free (url);
-}
-
-static void
-secure_check_toggled (GtkWidget *check, EConfig *config)
-{
- EMConfigTargetAccount *target = (EMConfigTargetAccount *)(config->target);
- CamelURL *url = NULL;
- gchar *url_string = NULL;
-
- url = camel_url_new (e_account_get_string (target->modified_account, E_ACCOUNT_SOURCE_URL), NULL);
-
- camel_url_set_param (url, "ssl", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)) ? "1" : NULL);
-
- url_string = camel_url_to_string (url, 0);
- e_account_set_string (target->modified_account, E_ACCOUNT_SOURCE_URL, url_string);
- e_account_set_string (target->modified_account, E_ACCOUNT_TRANSPORT_URL, url_string);
- g_free (url_string);
-
- camel_url_free (url);
-}
-
-static void
-widget_sanitizer_cb (GtkToggleButton *button, GtkWidget *widget)
-{
- g_return_if_fail (GTK_IS_TOGGLE_BUTTON (button));
- g_return_if_fail (GTK_IS_WIDGET (button));
-
- gtk_widget_set_sensitive (widget, gtk_toggle_button_get_active (button));
-}
-
GtkWidget *
org_gnome_exchange_mapi_account_setup (EPlugin *epl, EConfigHookItemFactoryData *data)
{
EMConfigTargetAccount *target_account;
+ CamelSettings *settings;
CamelURL *url;
GtkWidget *hgrid = NULL;
gint row;
target_account = (EMConfigTargetAccount *)data->config->target;
+ settings = target_account->settings;
url = camel_url_new(e_account_get_string(target_account->modified_account, E_ACCOUNT_SOURCE_URL), NULL);
/* is NULL on New Account creation */
@@ -455,10 +397,6 @@ org_gnome_exchange_mapi_account_setup (EPlugin *epl, EConfigHookItemFactoryData
GtkWidget *auth_button;
GtkWidget *secure_conn;
GtkWidget *krb_sso;
- const gchar *domain_value = camel_url_get_param (url, "domain");
- const gchar *realm_value = camel_url_get_param (url, "realm");
- const gchar *use_ssl = camel_url_get_param (url, "ssl");
- const gchar *kerberos = camel_url_get_param (url, "kerberos");
g_object_get (data->parent, "n-rows", &row, NULL);
@@ -469,10 +407,12 @@ org_gnome_exchange_mapi_account_setup (EPlugin *epl, EConfigHookItemFactoryData
domain_name = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), domain_name);
- if (domain_value && *domain_value)
- gtk_entry_set_text (GTK_ENTRY (domain_name), domain_value);
gtk_container_add (GTK_CONTAINER (hgrid), domain_name);
- g_signal_connect (domain_name, "changed", G_CALLBACK(domain_entry_changed), data->config);
+ g_object_bind_property (
+ settings, "domain",
+ domain_name, "text",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE);
auth_button = gtk_button_new_with_mnemonic (_("_Authenticate"));
gtk_container_add (GTK_CONTAINER (hgrid), auth_button);
@@ -484,15 +424,26 @@ org_gnome_exchange_mapi_account_setup (EPlugin *epl, EConfigHookItemFactoryData
row++;
secure_conn = gtk_check_button_new_with_mnemonic (_("_Use secure connection"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (secure_conn), use_ssl && g_str_equal (use_ssl, "1"));
- g_signal_connect (secure_conn, "toggled", G_CALLBACK (secure_check_toggled), data->config);
gtk_widget_show (secure_conn);
gtk_table_attach (GTK_TABLE (data->parent), GTK_WIDGET (secure_conn), 1, 2, row, row + 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+ g_object_bind_property_full (
+ settings, "security-method",
+ secure_conn, "active",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE,
+ transform_security_method_to_boolean,
+ transform_boolean_to_security_method,
+ NULL, (GDestroyNotify) NULL);
+
row++;
krb_sso = gtk_check_button_new_with_mnemonic (_("_Kerberos authentication"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (krb_sso), kerberos && g_str_equal (kerberos, "required"));
- g_signal_connect (krb_sso, "toggled", G_CALLBACK (krb_sso_check_toggled), data->config);
+
+ g_object_bind_property (
+ settings, "kerberos",
+ krb_sso, "active",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE);
gtk_widget_show (krb_sso);
gtk_table_attach (GTK_TABLE (data->parent), GTK_WIDGET (krb_sso), 1, 2, row, row + 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
@@ -500,20 +451,28 @@ org_gnome_exchange_mapi_account_setup (EPlugin *epl, EConfigHookItemFactoryData
label = gtk_label_new_with_mnemonic (_("_Realm name:"));
gtk_widget_show (label);
+ g_object_bind_property (
+ settings, "kerberos",
+ label, "sensitive",
+ G_BINDING_SYNC_CREATE);
+
realm_name = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), realm_name);
- if (realm_value && *realm_value)
- gtk_entry_set_text (GTK_ENTRY (realm_name), realm_value);
gtk_widget_show (realm_name);
- g_signal_connect (realm_name, "changed", G_CALLBACK(realm_entry_changed), data->config);
- gtk_table_attach (GTK_TABLE (data->parent), label, 0, 1, row, row + 1, 0, 0, 0, 0);
- gtk_table_attach (GTK_TABLE (data->parent), GTK_WIDGET (realm_name), 1, 2, row, row + 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
- g_signal_connect (krb_sso, "toggled", G_CALLBACK (widget_sanitizer_cb), label);
- g_signal_connect (krb_sso, "toggled", G_CALLBACK (widget_sanitizer_cb), realm_name);
+ g_object_bind_property (
+ settings, "realm",
+ realm_name, "text",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE);
+
+ g_object_bind_property (
+ settings, "kerberos",
+ realm_name, "sensitive",
+ G_BINDING_SYNC_CREATE);
- widget_sanitizer_cb (GTK_TOGGLE_BUTTON (krb_sso), label);
- widget_sanitizer_cb (GTK_TOGGLE_BUTTON (krb_sso), realm_name);
+ gtk_table_attach (GTK_TABLE (data->parent), label, 0, 1, row, row + 1, 0, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE (data->parent), GTK_WIDGET (realm_name), 1, 2, row, row + 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
}
camel_url_free (url);
@@ -531,14 +490,13 @@ org_gnome_exchange_mapi_check_options(EPlugin *epl, EConfigHookPageCheckData *da
E_ACCOUNT_SOURCE_URL), NULL);
if (url && url->protocol && g_ascii_strcasecmp (url->protocol, "mapi") == 0) {
- const gchar *prof = NULL;
+ const gchar *profile = NULL;
/* We assume that if the profile is set, then the setting is valid. */
- prof = camel_url_get_param (url, "profile");
+ profile = camel_mapi_settings_get_profile (CAMEL_MAPI_SETTINGS (target->settings));
- /*Profile not set. Do not proceed with account creation.*/
- if (!(prof && *prof))
- status = FALSE;
+ /* Profile not set. Do not proceed with account creation.*/
+ status = (profile != NULL && *profile != '\0');
}
if (url)
diff --git a/src/camel/camel-mapi-folder.c b/src/camel/camel-mapi-folder.c
index 4b4b806..bac74a9 100644
--- a/src/camel/camel-mapi-folder.c
+++ b/src/camel/camel-mapi-folder.c
@@ -1849,10 +1849,18 @@ camel_mapi_folder_new (CamelStore *store, const gchar *folder_name, const gchar
CamelFolder *folder = NULL;
CamelMapiFolder *mapi_folder;
CamelMapiStore *mapi_store = (CamelMapiStore *) store;
+ CamelService *service;
+ CamelSettings *settings;
gchar *summary_file, *state_file;
const gchar *short_name;
CamelStoreInfo *si;
+ gboolean filter_inbox;
+
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
+
+ filter_inbox = camel_store_settings_get_filter_inbox (CAMEL_STORE_SETTINGS (settings));
short_name = strrchr (folder_name, '/');
if (short_name)
@@ -1903,7 +1911,7 @@ camel_mapi_folder_new (CamelStore *store, const gchar *folder_name, const gchar
/* return NULL; */
/* } */
- if ((store->flags & CAMEL_STORE_FILTER_INBOX) != 0) {
+ if (filter_inbox) {
CamelFolderInfo *fi;
fi = camel_store_get_folder_info_sync (store, folder_name, 0, NULL, NULL);
diff --git a/src/camel/camel-mapi-provider.c b/src/camel/camel-mapi-provider.c
index 18e9588..2a12214 100644
--- a/src/camel/camel-mapi-provider.c
+++ b/src/camel/camel-mapi-provider.c
@@ -42,20 +42,20 @@ static gint mapi_url_equal (gconstpointer, gconstpointer);
static CamelProviderConfEntry mapi_conf_entries[] = {
{ CAMEL_PROVIDER_CONF_SECTION_START, "mailcheck", NULL,
N_("Checking for new mail") },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "check_all", NULL,
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "check-all", NULL,
N_("C_heck for new messages in all folders"), "1" },
{ CAMEL_PROVIDER_CONF_SECTION_END },
{ CAMEL_PROVIDER_CONF_SECTION_START, "generals", NULL,
N_("Options") },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "sync_offline", NULL,
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "stay-synchronized", NULL,
N_("Automatically synchroni_ze account locally"), "0" },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "filter", NULL,
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "filter-inbox", NULL,
/* i18n: copy from evolution:camel-imap-provider.c */
N_("_Apply filters to new messages in Inbox on this server"), "0" },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "filter_junk", NULL,
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "filter-junk", NULL,
N_("Check new messages for _Junk contents"), "0" },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "filter_junk_inbox", "filter_junk",
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "filter-junk-inbox", "filter-junk",
N_("Only check for Junk messag_es in the Inbox folder"), "0" },
{ CAMEL_PROVIDER_CONF_SECTION_END },
diff --git a/src/camel/camel-mapi-store.c b/src/camel/camel-mapi-store.c
index b14ecb8..a168cd7 100644
--- a/src/camel/camel-mapi-store.c
+++ b/src/camel/camel-mapi-store.c
@@ -35,6 +35,7 @@
#include "camel-mapi-store.h"
#include "camel-mapi-folder.h"
+#include "camel-mapi-settings.h"
#include "camel-mapi-store-summary.h"
#include "camel-mapi-summary.h"
#include "camel-mapi-notifications.h"
@@ -52,7 +53,6 @@
#define d(x) printf("%s:%s:%s \n", G_STRLOC, G_STRFUNC, x)
struct _CamelMapiStorePrivate {
- gchar *profile;
ExchangeMapiConnection *conn;
gchar *base_url;
@@ -832,7 +832,6 @@ mapi_store_finalize (GObject *object)
priv = CAMEL_MAPI_STORE (object)->priv;
- g_free (priv->profile);
g_free (priv->base_url);
if (priv->id_hash != NULL)
@@ -875,17 +874,19 @@ mapi_store_can_refresh_folder (CamelStore *store,
GError **error)
{
CamelService *service;
- CamelURL *url;
+ CamelSettings *settings;
+ gboolean check_all;
/* skip unselectable folders from automatic refresh */
if (info && (info->flags & CAMEL_FOLDER_NOSELECT) != 0)
return FALSE;
service = CAMEL_SERVICE (store);
- url = camel_service_get_camel_url (service);
+ settings = camel_service_get_settings (service);
+
+ check_all = camel_mapi_settings_get_check_all (CAMEL_MAPI_SETTINGS (settings));
- return CAMEL_STORE_CLASS(camel_mapi_store_parent_class)->can_refresh_folder (store, info, error) ||
- (camel_url_get_param (url, "check_all") != NULL);
+ return CAMEL_STORE_CLASS(camel_mapi_store_parent_class)->can_refresh_folder (store, info, error) || check_all;
}
static gboolean
@@ -1526,6 +1527,7 @@ camel_mapi_store_class_init (CamelMapiStoreClass *class)
object_class->constructed = mapi_store_constructed;
service_class = CAMEL_SERVICE_CLASS (class);
+ service_class->settings_type = CAMEL_TYPE_MAPI_SETTINGS;
service_class->get_name = mapi_get_name;
service_class->connect_sync = mapi_connect_sync;
service_class->disconnect_sync = mapi_disconnect_sync;
@@ -1568,7 +1570,6 @@ mapi_store_constructed (GObject *object)
CamelStore *store = CAMEL_STORE (object);
CamelMapiStorePrivate *priv = mapi_store->priv;
CamelService *service;
- CamelURL *url;
const gchar *user_data_dir;
gchar *path = NULL;
@@ -1576,7 +1577,6 @@ mapi_store_constructed (GObject *object)
G_OBJECT_CLASS (camel_mapi_store_parent_class)->constructed (object);
service = CAMEL_SERVICE (object);
- url = camel_service_get_camel_url (service);
user_data_dir = camel_service_get_user_data_dir (service);
/*store summary*/
@@ -1589,9 +1589,6 @@ mapi_store_constructed (GObject *object)
camel_store_summary_touch ((CamelStoreSummary *)mapi_store->summary);
camel_store_summary_load ((CamelStoreSummary *) mapi_store->summary);
- /*user and profile*/
- priv->profile = g_strdup (camel_url_get_param(url, "profile"));
-
/*base url*/
priv->base_url = camel_url_to_string (
camel_service_get_camel_url (service),
@@ -1599,10 +1596,6 @@ mapi_store_constructed (GObject *object)
CAMEL_URL_HIDE_PARAMS |
CAMEL_URL_HIDE_AUTH);
- /*filter*/
- if (camel_url_get_param (url, "filter"))
- store->flags |= CAMEL_STORE_FILTER_INBOX;
-
/*Hash Table*/
priv->id_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); /* folder ID to folder Full name */
priv->name_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); /* folder Full name to folder ID */
@@ -1672,13 +1665,23 @@ mapi_auth_loop (CamelService *service, GError **error)
{
CamelMapiStore *store = CAMEL_MAPI_STORE (service);
CamelURL *url;
+ CamelSettings *settings;
+ CamelMapiSettings *mapi_settings;
ExchangeMapiProfileData empd = { 0 };
gchar *errbuf = NULL;
gboolean authenticated = FALSE, ret, krb_requested = FALSE;
+ const gchar *profile;
url = camel_service_get_camel_url (service);
- exchange_mapi_util_profiledata_from_camelurl (&empd, url);
+ settings = camel_service_get_settings (service);
+ mapi_settings = CAMEL_MAPI_SETTINGS (settings);
+
+ empd.server = url->host;
+ empd.username = url->user;
+ exchange_mapi_util_profiledata_from_settings (&empd, mapi_settings);
+
+ profile = camel_mapi_settings_get_profile (mapi_settings);
url->passwd = NULL;
@@ -1705,7 +1708,7 @@ mapi_auth_loop (CamelService *service, GError **error)
return FALSE;
}
- store->priv->conn = exchange_mapi_connection_new (store->priv->profile, url->passwd, &mapi_error);
+ store->priv->conn = exchange_mapi_connection_new (profile, url->passwd, &mapi_error);
if (!store->priv->conn || !exchange_mapi_connection_connected (store->priv->conn)) {
if (mapi_error) {
errbuf = g_strdup_printf (_("Unable to authenticate to Exchange MAPI server: %s"), mapi_error->message);
@@ -2079,18 +2082,6 @@ camel_mapi_store_folder_lookup (CamelMapiStore *mapi_store, const gchar *folder_
return g_hash_table_lookup (priv->id_hash, folder_id);
}
-const gchar *
-camel_mapi_store_get_profile_name (CamelMapiStore *mapi_store)
-{
- CamelMapiStorePrivate *priv;
-
- g_return_val_if_fail (CAMEL_IS_MAPI_STORE (mapi_store), NULL);
-
- priv = mapi_store->priv;
-
- return priv->profile;
-}
-
ExchangeMapiConnection *
camel_mapi_store_get_exchange_connection (CamelMapiStore *mapi_store)
{
diff --git a/src/camel/camel-mapi-store.h b/src/camel/camel-mapi-store.h
index ddf2a44..b5a383c 100644
--- a/src/camel/camel-mapi-store.h
+++ b/src/camel/camel-mapi-store.h
@@ -93,7 +93,6 @@ gboolean camel_mapi_store_connected(CamelMapiStore *, GError **);
const gchar * camel_mapi_store_folder_id_lookup (CamelMapiStore *mapi_store, const gchar *folder_name);
const gchar * camel_mapi_store_folder_lookup (CamelMapiStore *mapi_store, const gchar *folder_id);
-const gchar * camel_mapi_store_get_profile_name (CamelMapiStore *mapi_store);
const gchar *camel_mapi_store_system_folder_fid (CamelMapiStore *mapi_store, guint folder_type);
const gchar *camel_mapi_store_folder_id_lookup_offline (CamelMapiStore *mapi_store, const gchar *folder_name);
const gchar * mapi_folders_hash_table_name_lookup (CamelMapiStore *store, const gchar *fid, gboolean use_cache);
diff --git a/src/camel/camel-mapi-transport.c b/src/camel/camel-mapi-transport.c
index 6ef715a..e3da886 100644
--- a/src/camel/camel-mapi-transport.c
+++ b/src/camel/camel-mapi-transport.c
@@ -39,6 +39,7 @@
#include <ctype.h>
#include <errno.h>
+#include "camel-mapi-settings.h"
#include "camel-mapi-store.h"
#include "camel-mapi-folder.h"
#include "camel-mapi-store-summary.h"
@@ -92,7 +93,9 @@ mapi_send_to_sync (CamelTransport *transport,
const gchar *namep;
const gchar *addressp;
mapi_id_t st = 0;
- CamelURL *url;
+ CamelService *service;
+ CamelSettings *settings;
+ const gchar *profile;
GError *mapi_error = NULL;
if (!camel_internet_address_get((CamelInternetAddress *)from, 0, &namep, &addressp)) {
@@ -101,10 +104,11 @@ mapi_send_to_sync (CamelTransport *transport,
g_return_val_if_fail (CAMEL_IS_SERVICE (transport), FALSE);
- url = camel_service_get_camel_url (CAMEL_SERVICE (transport));
- g_return_val_if_fail (url != NULL, FALSE);
+ service = CAMEL_SERVICE (transport);
+ settings = camel_service_get_settings (service);
+ profile = camel_mapi_settings_get_profile (CAMEL_MAPI_SETTINGS (settings));
- conn = exchange_mapi_connection_find (camel_url_get_param (url, "profile"));
+ conn = exchange_mapi_connection_find (profile);
if (!conn) {
g_set_error (
error, CAMEL_SERVICE_ERROR,
diff --git a/src/libexchangemapi/Makefile.am b/src/libexchangemapi/Makefile.am
index 4bfcf6b..6c69849 100644
--- a/src/libexchangemapi/Makefile.am
+++ b/src/libexchangemapi/Makefile.am
@@ -17,6 +17,8 @@ mapidata_DATA = \
tz-ical-to-mapi
libexchangemapi_1_0_la_SOURCES = \
+ camel-mapi-settings.c \
+ camel-mapi-settings.h \
exchange-mapi-defs.h \
exchange-mapi-folder.c \
exchange-mapi-folder.h \
diff --git a/src/libexchangemapi/camel-mapi-settings.c b/src/libexchangemapi/camel-mapi-settings.c
new file mode 100644
index 0000000..e875744
--- /dev/null
+++ b/src/libexchangemapi/camel-mapi-settings.c
@@ -0,0 +1,445 @@
+/*
+ * camel-mapi-settings.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "camel-mapi-settings.h"
+
+#define CAMEL_MAPI_SETTINGS_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), CAMEL_TYPE_MAPI_SETTINGS, CamelMapiSettingsPrivate))
+
+struct _CamelMapiSettingsPrivate {
+ gboolean check_all;
+ gboolean filter_junk;
+ gboolean filter_junk_inbox;
+ gboolean kerberos;
+
+ gchar *domain;
+ gchar *profile;
+ gchar *realm;
+};
+
+enum {
+ PROP_0,
+ PROP_CHECK_ALL,
+ PROP_DOMAIN,
+ PROP_FILTER_JUNK,
+ PROP_FILTER_JUNK_INBOX,
+ PROP_KERBEROS,
+ PROP_PROFILE,
+ PROP_REALM,
+ PROP_SECURITY_METHOD
+};
+
+G_DEFINE_TYPE_WITH_CODE (
+ CamelMapiSettings,
+ camel_mapi_settings,
+ CAMEL_TYPE_OFFLINE_SETTINGS,
+ G_IMPLEMENT_INTERFACE (
+ CAMEL_TYPE_NETWORK_SETTINGS, NULL))
+
+static void
+mapi_settings_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_CHECK_ALL:
+ camel_mapi_settings_set_check_all (
+ CAMEL_MAPI_SETTINGS (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_DOMAIN:
+ camel_mapi_settings_set_domain (
+ CAMEL_MAPI_SETTINGS (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_FILTER_JUNK:
+ camel_mapi_settings_set_filter_junk (
+ CAMEL_MAPI_SETTINGS (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_FILTER_JUNK_INBOX:
+ camel_mapi_settings_set_filter_junk_inbox (
+ CAMEL_MAPI_SETTINGS (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_KERBEROS:
+ camel_mapi_settings_set_kerberos (
+ CAMEL_MAPI_SETTINGS (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_PROFILE:
+ camel_mapi_settings_set_profile (
+ CAMEL_MAPI_SETTINGS (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_REALM:
+ camel_mapi_settings_set_realm (
+ CAMEL_MAPI_SETTINGS (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_SECURITY_METHOD:
+ camel_network_settings_set_security_method (
+ CAMEL_NETWORK_SETTINGS (object),
+ g_value_get_enum (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mapi_settings_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_CHECK_ALL:
+ g_value_set_boolean (
+ value,
+ camel_mapi_settings_get_check_all (
+ CAMEL_MAPI_SETTINGS (object)));
+ return;
+
+ case PROP_DOMAIN:
+ g_value_set_string (
+ value,
+ camel_mapi_settings_get_domain (
+ CAMEL_MAPI_SETTINGS (object)));
+ return;
+
+ case PROP_FILTER_JUNK:
+ g_value_set_boolean (
+ value,
+ camel_mapi_settings_get_filter_junk (
+ CAMEL_MAPI_SETTINGS (object)));
+ return;
+
+ case PROP_FILTER_JUNK_INBOX:
+ g_value_set_boolean (
+ value,
+ camel_mapi_settings_get_filter_junk_inbox (
+ CAMEL_MAPI_SETTINGS (object)));
+ return;
+
+ case PROP_KERBEROS:
+ g_value_set_boolean (
+ value,
+ camel_mapi_settings_get_kerberos (
+ CAMEL_MAPI_SETTINGS (object)));
+ return;
+
+ case PROP_PROFILE:
+ g_value_set_string (
+ value,
+ camel_mapi_settings_get_profile (
+ CAMEL_MAPI_SETTINGS (object)));
+ return;
+
+ case PROP_REALM:
+ g_value_set_string (
+ value,
+ camel_mapi_settings_get_realm (
+ CAMEL_MAPI_SETTINGS (object)));
+ return;
+
+ case PROP_SECURITY_METHOD:
+ g_value_set_enum (
+ value,
+ camel_network_settings_get_security_method (
+ CAMEL_NETWORK_SETTINGS (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mapi_settings_finalize (GObject *object)
+{
+ CamelMapiSettingsPrivate *priv;
+
+ priv = CAMEL_MAPI_SETTINGS_GET_PRIVATE (object);
+
+ g_free (priv->profile);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (camel_mapi_settings_parent_class)->finalize (object);
+}
+
+static void
+camel_mapi_settings_class_init (CamelMapiSettingsClass *class)
+{
+ GObjectClass *object_class;
+
+ g_type_class_add_private (class, sizeof (CamelMapiSettingsPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = mapi_settings_set_property;
+ object_class->get_property = mapi_settings_get_property;
+ object_class->finalize = mapi_settings_finalize;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_CHECK_ALL,
+ g_param_spec_boolean (
+ "check-all",
+ "Check All",
+ "Check all folders for new messages",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_DOMAIN,
+ g_param_spec_string (
+ "domain",
+ "Domain",
+ "Windows domain",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_FILTER_JUNK,
+ g_param_spec_boolean (
+ "filter-junk",
+ "Filter Junk",
+ "Whether to filter junk from all folders",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_FILTER_JUNK_INBOX,
+ g_param_spec_boolean (
+ "filter-junk-inbox",
+ "Filter Junk Inbox",
+ "Whether to filter junk from Inbox only",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_KERBEROS,
+ g_param_spec_boolean (
+ "kerberos",
+ "Kerberos",
+ "Use Kerberos authentication",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_PROFILE,
+ g_param_spec_string (
+ "profile",
+ "Profile",
+ "OpenChange user profile",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_REALM,
+ g_param_spec_string (
+ "realm",
+ "Realm",
+ "Kerberos realm",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ /* Inherited from CamelNetworkSettings. */
+ g_object_class_override_property (
+ object_class,
+ PROP_SECURITY_METHOD,
+ "security-method");
+}
+
+static void
+camel_mapi_settings_init (CamelMapiSettings *settings)
+{
+ settings->priv = CAMEL_MAPI_SETTINGS_GET_PRIVATE (settings);
+}
+
+gboolean
+camel_mapi_settings_get_check_all (CamelMapiSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_MAPI_SETTINGS (settings), FALSE);
+
+ return settings->priv->check_all;
+}
+
+void
+camel_mapi_settings_set_check_all (CamelMapiSettings *settings,
+ gboolean check_all)
+{
+ g_return_if_fail (CAMEL_IS_MAPI_SETTINGS (settings));
+
+ settings->priv->check_all = check_all;
+
+ g_object_notify (G_OBJECT (settings), "check-all");
+}
+
+const gchar *
+camel_mapi_settings_get_domain (CamelMapiSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_MAPI_SETTINGS (settings), NULL);
+
+ return settings->priv->domain;
+}
+
+void
+camel_mapi_settings_set_domain (CamelMapiSettings *settings,
+ const gchar *domain)
+{
+ g_return_if_fail (CAMEL_IS_MAPI_SETTINGS (settings));
+
+ /* The value should never be NULL. */
+ if (domain == NULL)
+ domain = "";
+
+ g_free (settings->priv->domain);
+ settings->priv->domain = g_strdup (domain);
+
+ g_object_notify (G_OBJECT (settings), "domain");
+}
+
+gboolean
+camel_mapi_settings_get_filter_junk (CamelMapiSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_MAPI_SETTINGS (settings), FALSE);
+
+ return settings->priv->filter_junk;
+}
+
+void
+camel_mapi_settings_set_filter_junk (CamelMapiSettings *settings,
+ gboolean filter_junk)
+{
+ g_return_if_fail (CAMEL_IS_MAPI_SETTINGS (settings));
+
+ settings->priv->filter_junk = filter_junk;
+
+ g_object_notify (G_OBJECT (settings), "filter-junk");
+}
+
+gboolean
+camel_mapi_settings_get_filter_junk_inbox (CamelMapiSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_MAPI_SETTINGS (settings), FALSE);
+
+ return settings->priv->filter_junk_inbox;
+}
+
+void
+camel_mapi_settings_set_filter_junk_inbox (CamelMapiSettings *settings,
+ gboolean filter_junk_inbox)
+{
+ g_return_if_fail (CAMEL_IS_MAPI_SETTINGS (settings));
+
+ settings->priv->filter_junk_inbox = filter_junk_inbox;
+
+ g_object_notify (G_OBJECT (settings), "filter-junk-inbox");
+}
+
+gboolean
+camel_mapi_settings_get_kerberos (CamelMapiSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_MAPI_SETTINGS (settings), FALSE);
+
+ return settings->priv->kerberos;
+}
+
+void
+camel_mapi_settings_set_kerberos (CamelMapiSettings *settings,
+ gboolean kerberos)
+{
+ g_return_if_fail (CAMEL_IS_MAPI_SETTINGS (settings));
+
+ settings->priv->kerberos = kerberos;
+
+ g_object_notify (G_OBJECT (settings), "kerberos");
+}
+
+const gchar *
+camel_mapi_settings_get_profile (CamelMapiSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_MAPI_SETTINGS (settings), NULL);
+
+ return settings->priv->profile;
+}
+
+void
+camel_mapi_settings_set_profile (CamelMapiSettings *settings,
+ const gchar *profile)
+{
+ g_return_if_fail (CAMEL_IS_MAPI_SETTINGS (settings));
+
+ g_free (settings->priv->profile);
+ settings->priv->profile = g_strdup (profile);
+
+ g_object_notify (G_OBJECT (settings), "profile");
+}
+
+const gchar *
+camel_mapi_settings_get_realm (CamelMapiSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_MAPI_SETTINGS (settings), NULL);
+
+ return settings->priv->realm;
+}
+
+void
+camel_mapi_settings_set_realm (CamelMapiSettings *settings,
+ const gchar *realm)
+{
+ g_return_if_fail (CAMEL_IS_MAPI_SETTINGS (settings));
+
+ /* The value should never be NULL. */
+ if (realm == NULL)
+ realm = "";
+
+ g_free (settings->priv->realm);
+ settings->priv->realm = g_strdup (realm);
+
+ g_object_notify (G_OBJECT (settings), "realm");
+}
diff --git a/src/libexchangemapi/camel-mapi-settings.h b/src/libexchangemapi/camel-mapi-settings.h
new file mode 100644
index 0000000..4db13cd
--- /dev/null
+++ b/src/libexchangemapi/camel-mapi-settings.h
@@ -0,0 +1,92 @@
+/*
+ * camel-mapi-settings.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef CAMEL_MAPI_SETTINGS_H
+#define CAMEL_MAPI_SETTINGS_H
+
+#include <camel/camel.h>
+
+/* Standard GObject macros */
+#define CAMEL_TYPE_MAPI_SETTINGS \
+ (camel_mapi_settings_get_type ())
+#define CAMEL_MAPI_SETTINGS(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), CAMEL_TYPE_MAPI_SETTINGS, CamelMapiSettings))
+#define CAMEL_MAPI_SETTINGS_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), CAMEL_TYPE_MAPI_SETTINGS, CamelMapiSettingsClass))
+#define CAMEL_IS_MAPI_SETTINGS(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), CAMEL_TYPE_MAPI_SETTINGS))
+#define CAMEL_IS_MAPI_SETTINGS_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), CAMEL_TYPE_MAPI_SETTINGS))
+#define CAMEL_MAPI_SETTINGS_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), CAMEL_TYPE_MAPI_SETTINGS, CamelMapiSettingsClass))
+
+G_BEGIN_DECLS
+
+typedef struct _CamelMapiSettings CamelMapiSettings;
+typedef struct _CamelMapiSettingsClass CamelMapiSettingsClass;
+typedef struct _CamelMapiSettingsPrivate CamelMapiSettingsPrivate;
+
+struct _CamelMapiSettings {
+ CamelOfflineSettings parent;
+ CamelMapiSettingsPrivate *priv;
+};
+
+struct _CamelMapiSettingsClass {
+ CamelOfflineSettingsClass parent_class;
+};
+
+GType camel_mapi_settings_get_type
+ (void) G_GNUC_CONST;
+gboolean camel_mapi_settings_get_check_all
+ (CamelMapiSettings *settings);
+void camel_mapi_settings_set_check_all
+ (CamelMapiSettings *settings,
+ gboolean check_all);
+const gchar * camel_mapi_settings_get_domain (CamelMapiSettings *settings);
+void camel_mapi_settings_set_domain (CamelMapiSettings *settings,
+ const gchar *domain);
+gboolean camel_mapi_settings_get_filter_junk
+ (CamelMapiSettings *settings);
+void camel_mapi_settings_set_filter_junk
+ (CamelMapiSettings *settings,
+ gboolean filter_junk);
+gboolean camel_mapi_settings_get_filter_junk_inbox
+ (CamelMapiSettings *settings);
+void camel_mapi_settings_set_filter_junk_inbox
+ (CamelMapiSettings *settings,
+ gboolean filter_junk_inbox);
+gboolean camel_mapi_settings_get_kerberos
+ (CamelMapiSettings *settings);
+void camel_mapi_settings_set_kerberos
+ (CamelMapiSettings *settings,
+ gboolean kerberos);
+const gchar * camel_mapi_settings_get_profile (CamelMapiSettings *settings);
+void camel_mapi_settings_set_profile (CamelMapiSettings *settings,
+ const gchar *profile);
+const gchar * camel_mapi_settings_get_realm (CamelMapiSettings *settings);
+void camel_mapi_settings_set_realm (CamelMapiSettings *settings,
+ const gchar *realm);
+
+G_END_DECLS
+
+#endif /* CAMEL_MAPI_SETTINGS_H */
diff --git a/src/libexchangemapi/exchange-mapi-connection.c b/src/libexchangemapi/exchange-mapi-connection.c
index 9ddc906..39114c9 100644
--- a/src/libexchangemapi/exchange-mapi-connection.c
+++ b/src/libexchangemapi/exchange-mapi-connection.c
@@ -3670,8 +3670,18 @@ try_create_profile_main_thread_cb (struct tcp_data *data)
EAccount *account = E_ACCOUNT (e_iterator_get (iter));
if (account && account->source && account->source->url && g_ascii_strncasecmp (account->source->url, "mapi://", 7) == 0) {
CamelURL *url = camel_url_new (e_account_get_string (account, E_ACCOUNT_SOURCE_URL), NULL);
- exchange_mapi_util_profiledata_from_camelurl (&empd,
- url);
+ CamelSettings *settings;
+ const gchar *url_string;
+
+ url_string = e_account_get_string (account, E_ACCOUNT_SOURCE_URL);
+ url = camel_url_new (url_string, NULL);
+
+ settings = g_object_new (CAMEL_TYPE_MAPI_SETTINGS, NULL);
+ camel_settings_load_from_url (settings, url);
+
+ empd.server = url->host;
+ empd.username = url->user;
+ exchange_mapi_util_profiledata_from_settings (&empd, CAMEL_MAPI_SETTINGS (settings));
/* cast away the const, but promise not to touch it */
empd.password = (gchar*)data->password;
@@ -3683,6 +3693,7 @@ try_create_profile_main_thread_cb (struct tcp_data *data)
data->has_profile = mapi_profile_create (&empd, NULL, NULL, NULL, FALSE);
g_free (profname);
+ g_object_unref (settings);
camel_url_free (url);
break;
}
@@ -3690,6 +3701,7 @@ try_create_profile_main_thread_cb (struct tcp_data *data)
g_free (profname);
}
+ g_object_unref (settings);
camel_url_free (url);
}
}
diff --git a/src/libexchangemapi/exchange-mapi-utils.c b/src/libexchangemapi/exchange-mapi-utils.c
index 813fee3..569864a 100644
--- a/src/libexchangemapi/exchange-mapi-utils.c
+++ b/src/libexchangemapi/exchange-mapi-utils.c
@@ -824,32 +824,30 @@ exchange_crlf_to_lf (const gchar *in)
}
/**
- * exchange_mapi_util_profiledata_from_camelurl:
+ * exchange_mapi_util_profiledata_from_settings:
* @empd: destination for profile settings
- * @url: CamelURL with account settings
+ * @settings: a #CamelMapiSettings
*
* Sets the members of an ExchangeMapiProfileData instance to
- * reflect the account settings listed in the corresponding
- * CamelURL pointer.
+ * reflect the account settings in @settings.
*
- * @note: no allocation is done, so do not free the CamelUrl pointer and
- * the respective underlying pointers until you no longer need the
+ * @note: no allocation is done, so do not finalize @settings and the
+ * respective underlying pointers until you no longer need the
* profile data.
**/
void
-exchange_mapi_util_profiledata_from_camelurl (ExchangeMapiProfileData *empd, const CamelURL *url)
+exchange_mapi_util_profiledata_from_settings (ExchangeMapiProfileData *empd, CamelMapiSettings *settings)
{
- const gchar *use_ssl = NULL, *use_krb = NULL;
- CamelURL *promise_its_const = (CamelURL*)url; /* :) */
- empd->username = promise_its_const->user;
- empd->server = promise_its_const->host;
-
- use_ssl = camel_url_get_param (promise_its_const, "ssl");
- empd->use_ssl = (use_ssl && g_str_equal (use_ssl, "1"));
- empd->domain = camel_url_get_param (promise_its_const, "domain");
- use_krb = camel_url_get_param (promise_its_const, "kerberos");
- empd->krb_sso = (use_krb && g_str_equal (use_krb, "required"));
- empd->krb_realm = camel_url_get_param (promise_its_const, "realm");
+ CamelNetworkSettings *network_settings;
+ CamelNetworkSecurityMethod security_method;
+
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ security_method = camel_network_settings_get_security_method (network_settings);
+
+ empd->use_ssl = (security_method != CAMEL_NETWORK_SECURITY_METHOD_NONE);
+ empd->domain = camel_mapi_settings_get_domain (settings);
+ empd->krb_sso = camel_mapi_settings_get_kerberos (settings);
+ empd->krb_realm = camel_mapi_settings_get_realm (settings);
}
gboolean
diff --git a/src/libexchangemapi/exchange-mapi-utils.h b/src/libexchangemapi/exchange-mapi-utils.h
index eb21165..3e79623 100644
--- a/src/libexchangemapi/exchange-mapi-utils.h
+++ b/src/libexchangemapi/exchange-mapi-utils.h
@@ -24,9 +24,9 @@
#ifndef EXCHANGE_MAPI_UTILS_H
#define EXCHANGE_MAPI_UTILS_H
+#include "camel-mapi-settings.h"
#include "exchange-mapi-debug.h"
#include "exchange-mapi-connection.h"
-#include <camel/camel.h>
gchar * exchange_mapi_util_mapi_id_to_string (mapi_id_t id);
gboolean exchange_mapi_util_mapi_id_from_string (const gchar *str, mapi_id_t *id);
@@ -58,7 +58,7 @@ gboolean exchange_mapi_util_recip_entryid_decode (ExchangeMapiConnection *conn,
gchar *exchange_lf_to_crlf (const gchar *in);
gchar *exchange_crlf_to_lf (const gchar *in);
-void exchange_mapi_util_profiledata_from_camelurl (ExchangeMapiProfileData *empd, const CamelURL *url);
+void exchange_mapi_util_profiledata_from_settings (ExchangeMapiProfileData *empd, CamelMapiSettings *settings);
gchar *exchange_mapi_util_profile_name (const ExchangeMapiProfileData *empd, gboolean migrate);
gboolean exchange_mapi_util_trigger_krb_auth (const ExchangeMapiProfileData *empd, GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]