[evolution-groupwise] Adapt to CamelNetworkSettings changes.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-groupwise] Adapt to CamelNetworkSettings changes.
- Date: Mon, 24 Oct 2011 17:13:56 +0000 (UTC)
commit 720739d2cdbae97a418ac13d171f20f0239a7b28
Author: Matthew Barnes <mbarnes redhat com>
Date: Thu Oct 20 22:56:44 2011 -0400
Adapt to CamelNetworkSettings changes.
src/camel/camel-groupwise-folder.c | 18 +++++--
src/camel/camel-groupwise-provider.c | 2 +-
src/camel/camel-groupwise-settings.c | 82 ++++++++++++++++++++++++++++++-
src/camel/camel-groupwise-store.c | 89 +++++++++++++++------------------
src/camel/camel-groupwise-transport.c | 17 ++++--
src/plugins/install-shared.c | 16 ++++++-
src/plugins/share-folder-common.c | 6 +--
7 files changed, 164 insertions(+), 66 deletions(-)
---
diff --git a/src/camel/camel-groupwise-folder.c b/src/camel/camel-groupwise-folder.c
index 432eb7b..356ac88 100644
--- a/src/camel/camel-groupwise-folder.c
+++ b/src/camel/camel-groupwise-folder.c
@@ -2432,19 +2432,29 @@ groupwise_folder_dispose (GObject *object)
static void
groupwise_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-groupwise-provider.c b/src/camel/camel-groupwise-provider.c
index b159c5c..b61c8bb 100644
--- a/src/camel/camel-groupwise-provider.c
+++ b/src/camel/camel-groupwise-provider.c
@@ -131,7 +131,7 @@ camel_provider_module_init (void)
gboolean use_imap = g_getenv ("USE_IMAP") != NULL;
if (use_imap)
- imap_provider = camel_provider_get("imapx://", NULL);
+ imap_provider = camel_provider_get("imapx", NULL);
groupwise_provider.url_hash = groupwise_url_hash;
groupwise_provider.url_equal = groupwise_url_equal;
diff --git a/src/camel/camel-groupwise-settings.c b/src/camel/camel-groupwise-settings.c
index 0bb8f7f..0617a34 100644
--- a/src/camel/camel-groupwise-settings.c
+++ b/src/camel/camel-groupwise-settings.c
@@ -31,11 +31,15 @@ struct _CamelGroupwiseSettingsPrivate {
enum {
PROP_0,
+ PROP_AUTH_MECHANISM,
PROP_CHECK_ALL,
PROP_FILTER_JUNK,
PROP_FILTER_JUNK_INBOX,
+ PROP_HOST,
+ PROP_PORT,
PROP_SECURITY_METHOD,
- PROP_SOAP_PORT
+ PROP_SOAP_PORT,
+ PROP_USER
};
G_DEFINE_TYPE_WITH_CODE (
@@ -52,6 +56,12 @@ groupwise_settings_set_property (GObject *object,
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_groupwise_settings_set_check_all (
CAMEL_GROUPWISE_SETTINGS (object),
@@ -70,6 +80,18 @@ groupwise_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_PORT:
+ camel_network_settings_set_port (
+ CAMEL_NETWORK_SETTINGS (object),
+ g_value_get_uint (value));
+ return;
+
case PROP_SECURITY_METHOD:
camel_network_settings_set_security_method (
CAMEL_NETWORK_SETTINGS (object),
@@ -81,6 +103,12 @@ groupwise_settings_set_property (GObject *object,
CAMEL_GROUPWISE_SETTINGS (object),
g_value_get_string (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);
@@ -93,6 +121,13 @@ groupwise_settings_get_property (GObject *object,
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,
@@ -114,6 +149,20 @@ groupwise_settings_get_property (GObject *object,
CAMEL_GROUPWISE_SETTINGS (object)));
return;
+ case PROP_HOST:
+ g_value_set_string (
+ value,
+ camel_network_settings_get_host (
+ CAMEL_NETWORK_SETTINGS (object)));
+ return;
+
+ case PROP_PORT:
+ g_value_set_uint (
+ value,
+ camel_network_settings_get_port (
+ CAMEL_NETWORK_SETTINGS (object)));
+ return;
+
case PROP_SECURITY_METHOD:
g_value_set_enum (
value,
@@ -127,6 +176,13 @@ groupwise_settings_get_property (GObject *object,
camel_groupwise_settings_get_soap_port (
CAMEL_GROUPWISE_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);
@@ -143,6 +199,12 @@ camel_groupwise_settings_class_init (CamelGroupwiseSettingsClass *class)
object_class->set_property = groupwise_settings_set_property;
object_class->get_property = groupwise_settings_get_property;
+ /* 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,
@@ -182,6 +244,18 @@ camel_groupwise_settings_class_init (CamelGroupwiseSettingsClass *class)
/* Inherited from CamelNetworkSettings. */
g_object_class_override_property (
object_class,
+ PROP_HOST,
+ "host");
+
+ /* Inherited from CamelNetworkSettings. */
+ g_object_class_override_property (
+ object_class,
+ PROP_PORT,
+ "port");
+
+ /* Inherited from CamelNetworkSettings. */
+ g_object_class_override_property (
+ object_class,
PROP_SECURITY_METHOD,
"security-method");
@@ -196,6 +270,12 @@ camel_groupwise_settings_class_init (CamelGroupwiseSettingsClass *class)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
+
+ /* Inherited from CamelNetworkSettings. */
+ g_object_class_override_property (
+ object_class,
+ PROP_USER,
+ "user");
}
static void
diff --git a/src/camel/camel-groupwise-store.c b/src/camel/camel-groupwise-store.c
index 34cfb96..4108b6d 100644
--- a/src/camel/camel-groupwise-store.c
+++ b/src/camel/camel-groupwise-store.c
@@ -58,9 +58,6 @@
const gchar * CREATE_CURSOR_VIEW = "peek id default recipient threading hasAttachment subject status priority startDate created delivered size recurrenceKey";
struct _CamelGroupwiseStorePrivate {
- gchar *server_name;
- gchar *user;
-
GHashTable *id_hash; /*get names from ids */
GHashTable *name_hash;/*get ids from names */
GHashTable *parent_hash;
@@ -101,18 +98,21 @@ check_for_connection (CamelService *service,
GCancellable *cancellable,
GError **error)
{
- CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (service);
- CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
+ CamelNetworkSettings *network_settings;
CamelSettings *settings;
+ const gchar *host;
struct addrinfo hints, *ai;
GError *local_error = NULL;
settings = camel_service_get_settings (service);
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
+
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = PF_UNSPEC;
- ai = camel_getaddrinfo(priv->server_name, "groupwise", &hints, cancellable, &local_error);
+ ai = camel_getaddrinfo(host, "groupwise", &hints, cancellable, &local_error);
if (ai == NULL && g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
gchar *port_string;
const gchar *soap_port;
@@ -124,7 +124,7 @@ check_for_connection (CamelService *service,
port_string = g_strdup(soap_port);
ai = camel_getaddrinfo (
- priv->server_name, port_string, &hints,
+ host, port_string, &hints,
cancellable, &local_error);
g_free (port_string);
}
@@ -244,14 +244,6 @@ groupwise_disconnect_cleanup (CamelService *service,
}
if (priv) {
- if (priv->user) {
- g_free (priv->user);
- priv->user = NULL;
- }
- if (priv->server_name) {
- g_free (priv->server_name);
- priv->server_name = NULL;
- }
if (priv->port) {
g_free (priv->port);
priv->port = NULL;
@@ -1255,17 +1247,23 @@ gchar *
groupwise_get_name (CamelService *service,
gboolean brief)
{
- CamelURL *url;
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
+ const gchar *host;
+ const gchar *user;
- url = camel_service_get_camel_url (service);
+ 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);
if (brief)
return g_strdup_printf (
- _("GroupWise server %s"), url->host);
+ _("GroupWise server %s"), host);
else
return g_strdup_printf (
- _("GroupWise service for %s on %s"),
- url->user, url->host);
+ _("GroupWise service for %s on %s"), user, host);
}
const gchar *
@@ -1421,8 +1419,6 @@ groupwise_store_finalize (GObject *object)
groupwise_store = CAMEL_GROUPWISE_STORE (object);
- g_free (groupwise_store->priv->user);
- g_free (groupwise_store->priv->server_name);
g_free (groupwise_store->root_container);
if (groupwise_store->priv->id_hash != NULL)
@@ -1445,12 +1441,15 @@ groupwise_store_authenticate_sync (CamelService *service,
GError **error)
{
CamelStore *store = CAMEL_STORE (service);
- CamelSettings *settings;
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (store);
CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
- CamelNetworkSecurityMethod security_method;
+ CamelNetworkSettings *network_settings;
+ CamelNetworkSecurityMethod method;
CamelAuthenticationResult result;
+ CamelSettings *settings;
gchar *uri;
+ const gchar *host;
+ const gchar *user;
const gchar *scheme;
const gchar *password;
EGwConnectionErrors errors = {E_GW_CONNECTION_STATUS_INVALID_OBJECT, NULL};
@@ -1467,22 +1466,24 @@ groupwise_store_authenticate_sync (CamelService *service,
return CAMEL_AUTHENTICATION_ERROR;
}
- security_method = camel_network_settings_get_security_method (
- CAMEL_NETWORK_SETTINGS (settings));
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
+ user = camel_network_settings_get_user (network_settings);
+ method = camel_network_settings_get_security_method (network_settings);
soap_port = camel_groupwise_settings_get_soap_port (
CAMEL_GROUPWISE_SETTINGS (settings));
- if (security_method == CAMEL_NETWORK_SECURITY_METHOD_NONE)
+ if (method == CAMEL_NETWORK_SECURITY_METHOD_NONE)
scheme = "http";
else
scheme = "https";
uri = g_strdup_printf (
- "%s://%s:%s/soap", scheme, priv->server_name, soap_port);
+ "%s://%s:%s/soap", scheme, host, soap_port);
priv->cnc = e_gw_connection_new_with_error_handler (
- uri, priv->user, password, &errors);
+ uri, user, password, &errors);
g_free (uri);
@@ -1513,11 +1514,9 @@ groupwise_store_initable_init (GInitable *initable,
CamelService *transport;
CamelService *service;
CamelSession *session;
- CamelURL *url;
const gchar *user_data_dir;
const gchar *store_uid;
gchar *transport_uid;
- gchar *uri_string;
gchar *path = NULL;
groupwise_store = CAMEL_GROUPWISE_STORE (initable);
@@ -1527,17 +1526,9 @@ groupwise_store_initable_init (GInitable *initable,
return FALSE;
service = CAMEL_SERVICE (initable);
- url = camel_service_get_camel_url (service);
session = camel_service_get_session (service);
user_data_dir = camel_service_get_user_data_dir (service);
- if (!(url->host || url->user)) {
- g_set_error (
- error, CAMEL_SERVICE_ERROR,
- CAMEL_SERVICE_ERROR_INVALID,
- _("Host or user not available in url"));
- }
-
/*store summary*/
path = g_alloca (strlen (user_data_dir) + 32);
sprintf (path, "%s/.summary", user_data_dir);
@@ -1546,10 +1537,6 @@ groupwise_store_initable_init (GInitable *initable,
camel_store_summary_touch ((CamelStoreSummary *) groupwise_store->summary);
camel_store_summary_load ((CamelStoreSummary *) groupwise_store->summary);
- /*host and user*/
- groupwise_store->priv->server_name = g_strdup (url->host);
- groupwise_store->priv->user = g_strdup (url->user);
-
/*Hash Table*/
groupwise_store->priv->id_hash =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
@@ -1565,19 +1552,25 @@ groupwise_store_initable_init (GInitable *initable,
store_uid = camel_service_get_uid (service);
transport_uid = g_strconcat (store_uid, "-transport", NULL);
- uri_string = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
transport = camel_session_add_service (
- session, transport_uid, uri_string,
+ session, transport_uid, "groupwise",
CAMEL_PROVIDER_TRANSPORT, error);
g_free (transport_uid);
- g_free (uri_string);
- if (transport != NULL)
+ if (transport != NULL) {
+ /* Share settings with the store. */
+ g_object_bind_property (
+ groupwise_store, "settings",
+ transport, "settings",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE);
+
camel_groupwise_transport_set_store (
CAMEL_GROUPWISE_TRANSPORT (transport),
groupwise_store);
+ }
return (transport != NULL);
}
@@ -1632,8 +1625,6 @@ camel_groupwise_store_init (CamelGroupwiseStore *groupwise_store)
CamelGroupwiseStorePrivate);
d("in groupwise store init\n");
- groupwise_store->priv->server_name = NULL;
- groupwise_store->priv->user = NULL;
groupwise_store->priv->cnc = NULL;
groupwise_store->current_folder = NULL;
}
diff --git a/src/camel/camel-groupwise-transport.c b/src/camel/camel-groupwise-transport.c
index 84b9a1e..10e9585 100644
--- a/src/camel/camel-groupwise-transport.c
+++ b/src/camel/camel-groupwise-transport.c
@@ -30,6 +30,7 @@
#include <glib/gi18n-lib.h>
+#include "camel-groupwise-settings.h"
#include "camel-groupwise-store.h"
#include "camel-groupwise-transport.h"
#include "camel-groupwise-utils.h"
@@ -67,18 +68,21 @@ static gchar *
groupwise_transport_get_name (CamelService *service,
gboolean brief)
{
- CamelURL *url;
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
+ const gchar *host;
- url = camel_service_get_camel_url (service);
+ settings = camel_service_get_settings (service);
+
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
if (brief)
return g_strdup_printf (
- _("GroupWise server %s"),
- url->host);
+ _("GroupWise server %s"), host);
else
return g_strdup_printf (
- _("GroupWise mail delivery via %s"),
- url->host);
+ _("GroupWise mail delivery via %s"), host);
}
static gboolean
@@ -196,6 +200,7 @@ camel_groupwise_transport_class_init (CamelGroupwiseTransportClass *class)
object_class->dispose = groupwise_transport_dispose;
service_class = CAMEL_SERVICE_CLASS (class);
+ service_class->settings_type = CAMEL_TYPE_GROUPWISE_SETTINGS;
service_class->get_name = groupwise_transport_get_name;
service_class->connect_sync = groupwise_transport_connect_sync;
diff --git a/src/plugins/install-shared.c b/src/plugins/install-shared.c
index de3db40..713f0bd 100644
--- a/src/plugins/install-shared.c
+++ b/src/plugins/install-shared.c
@@ -105,7 +105,9 @@ install_folder_response (EMFolderSelector *emfs,
container_id = get_container_id (cnc, parent_name);
if (e_gw_connection_accept_shared_folder (cnc, folder_name, container_id, (gchar *) item_id, NULL) == E_GW_CONNECTION_STATUS_OK) {
+ gchar *protocol;
const gchar *uid;
+ const gchar *cp = NULL;
/* FIXME Not passing a GCancellable or GError here. */
folder = camel_store_get_folder_sync (
@@ -126,7 +128,19 @@ install_folder_response (EMFolderSelector *emfs,
uri = account->source->url;
em_folder_tree_model_remove_store (
model, store);
- provider = camel_provider_get (uri, NULL);
+
+ if (uri != NULL)
+ cp = strchr (uri, ':');
+
+ if (cp == NULL) {
+ g_strfreev (names);
+ return;
+ }
+
+ protocol = g_strndup (uri, cp - uri);
+ provider = camel_provider_get (protocol, NULL);
+ g_free (protocol);
+
if (provider == NULL) {
g_strfreev (names);
return;
diff --git a/src/plugins/share-folder-common.c b/src/plugins/share-folder-common.c
index 8095dab..a5aa323 100644
--- a/src/plugins/share-folder-common.c
+++ b/src/plugins/share-folder-common.c
@@ -439,7 +439,6 @@ get_cnc (CamelStore *store)
const gchar *uri, *server_name, *user;
CamelService *service;
CamelSettings *settings;
- CamelURL *url;
CamelNetworkSecurityMethod security_method;
const gchar *scheme;
const gchar *password;
@@ -449,14 +448,13 @@ get_cnc (CamelStore *store)
return NULL;
service = CAMEL_SERVICE (store);
- url = camel_service_get_camel_url (service);
password = camel_service_get_password (service);
settings = camel_service_get_settings (service);
- server_name = g_strdup (url->host);
- user = g_strdup (url->user);
g_object_get (
settings,
+ "user", &user,
+ "host", &server_name,
"soap-port", &soap_port,
"security-method", &security_method,
NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]