[evolution-groupwise] Add CamelGroupwiseSettings.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-groupwise] Add CamelGroupwiseSettings.
- Date: Mon, 15 Aug 2011 16:05:56 +0000 (UTC)
commit e0225e76b8866de42b5e3b42fb5a4436c076d6b2
Author: Matthew Barnes <mbarnes redhat com>
Date: Thu Aug 11 12:19:16 2011 -0400
Add CamelGroupwiseSettings.
CamelGroupwiseSettings replaces the various URL parameters used in
CamelGroupwiseStore with equivalent GObject properties.
Adapt the groupwise module to use CamelSettings.
src/camel/Makefile.am | 16 +-
src/camel/camel-groupwise-folder.c | 16 ++-
src/camel/camel-groupwise-provider.c | 12 +-
src/camel/camel-groupwise-settings.c | 283 ++++++++++++++++++++++++++++++++++
src/camel/camel-groupwise-settings.h | 83 ++++++++++
src/camel/camel-groupwise-store.c | 91 ++++++-----
src/plugins/Makefile.am | 16 +-
src/plugins/camel-gw-listener.c | 265 +++++++++++++++++++++++++-------
src/plugins/proxy-login.c | 72 ++++++---
src/plugins/proxy.c | 38 +++--
src/plugins/send-options.c | 37 +++--
src/plugins/share-folder-common.c | 66 ++++-----
12 files changed, 784 insertions(+), 211 deletions(-)
---
diff --git a/src/camel/Makefile.am b/src/camel/Makefile.am
index 94f4131..2869f5c 100644
--- a/src/camel/Makefile.am
+++ b/src/camel/Makefile.am
@@ -18,20 +18,22 @@ libcamelgroupwise_la_CPPFLAGS = \
-DG_LOG_DOMAIN=\"camel-groupwise-provider\"
libcamelgroupwise_la_SOURCES = \
- camel-groupwise-folder.c \
+ camel-groupwise-folder.c \
camel-groupwise-folder.h \
camel-groupwise-provider.c \
- camel-groupwise-journal.c \
- camel-groupwise-store.c \
- camel-groupwise-summary.c \
- camel-groupwise-store-summary.c \
+ camel-groupwise-journal.c \
+ camel-groupwise-settings.c \
+ camel-groupwise-store.c \
+ camel-groupwise-summary.c \
+ camel-groupwise-store-summary.c \
camel-groupwise-utils.c \
- camel-groupwise-transport.c
+ camel-groupwise-transport.c
-noinst_HEADERS = \
+noinst_HEADERS = \
camel-groupwise-folder.h \
camel-groupwise-journal.h \
camel-groupwise-private.h \
+ camel-groupwise-settings.h \
camel-groupwise-store.h \
camel-groupwise-summary.h \
camel-groupwise-store-summary.h \
diff --git a/src/camel/camel-groupwise-folder.c b/src/camel/camel-groupwise-folder.c
index 844b80e..4d10f83 100644
--- a/src/camel/camel-groupwise-folder.c
+++ b/src/camel/camel-groupwise-folder.c
@@ -927,13 +927,19 @@ camel_gw_folder_new (CamelStore *store,
GCancellable *cancellable,
GError **error)
{
+ CamelService *service;
+ CamelSettings *settings;
CamelFolder *folder;
CamelGroupwiseFolder *gw_folder;
- CamelURL *url;
+ gboolean filter_inbox;
gchar *summary_file, *state_file, *journal_file;
gchar *short_name;
- url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+ 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)
@@ -979,10 +985,8 @@ camel_gw_folder_new (CamelStore *store,
return NULL;
}
- if (!strcmp (folder_name, "Mailbox")) {
- if (camel_url_get_param (url, "filter"))
- folder->folder_flags |= CAMEL_FOLDER_FILTER_RECENT;
- }
+ if (strcmp (folder_name, "Mailbox") == 0 && filter_inbox)
+ folder->folder_flags |= CAMEL_FOLDER_FILTER_RECENT;
gw_folder->search = camel_folder_search_new ();
if (!gw_folder->search) {
diff --git a/src/camel/camel-groupwise-provider.c b/src/camel/camel-groupwise-provider.c
index 4150275..9a46fd5 100644
--- a/src/camel/camel-groupwise-provider.c
+++ b/src/camel/camel-groupwise-provider.c
@@ -46,18 +46,18 @@ static CamelProviderConfEntry groupwise_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, "general", NULL, N_("Options") },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "filter", NULL,
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "filter-inbox", NULL,
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 J_unk 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 messages in the IN_BOX folder"), "0" },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "sync_offline", NULL,
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "stay-synchronized", NULL,
N_("Automatically synchroni_ze account locally"), "0" },
{ CAMEL_PROVIDER_CONF_SECTION_END },
@@ -65,7 +65,7 @@ static CamelProviderConfEntry groupwise_conf_entries[] = {
{CAMEL_PROVIDER_CONF_SECTION_START, "soapport", NULL,
N_("SOAP Settings") },
- { CAMEL_PROVIDER_CONF_ENTRY, "soap_port", NULL,
+ { CAMEL_PROVIDER_CONF_ENTRY, "soap-port", NULL,
N_("Post Office Agent SOAP _Port:"), "7191" },
{ CAMEL_PROVIDER_CONF_HIDDEN, "auth-domain", NULL,
diff --git a/src/camel/camel-groupwise-settings.c b/src/camel/camel-groupwise-settings.c
new file mode 100644
index 0000000..d4f2426
--- /dev/null
+++ b/src/camel/camel-groupwise-settings.c
@@ -0,0 +1,283 @@
+/*
+ * camel-groupwise-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-groupwise-settings.h"
+
+#define CAMEL_GROUPWISE_SETTINGS_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), CAMEL_TYPE_GROUPWISE_SETTINGS, CamelGroupwiseSettingsPrivate))
+
+struct _CamelGroupwiseSettingsPrivate {
+ gboolean check_all;
+ gboolean filter_junk;
+ gboolean filter_junk_inbox;
+ guint16 soap_port;
+};
+
+enum {
+ PROP_0,
+ PROP_CHECK_ALL,
+ PROP_FILTER_JUNK,
+ PROP_FILTER_JUNK_INBOX,
+ PROP_SECURITY_METHOD,
+ PROP_SOAP_PORT
+};
+
+G_DEFINE_TYPE_WITH_CODE (
+ CamelGroupwiseSettings,
+ camel_groupwise_settings,
+ CAMEL_TYPE_OFFLINE_SETTINGS,
+ G_IMPLEMENT_INTERFACE (
+ CAMEL_TYPE_NETWORK_SETTINGS, NULL))
+
+static void
+groupwise_settings_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_CHECK_ALL:
+ camel_groupwise_settings_set_check_all (
+ CAMEL_GROUPWISE_SETTINGS (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_FILTER_JUNK:
+ camel_groupwise_settings_set_filter_junk (
+ CAMEL_GROUPWISE_SETTINGS (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_FILTER_JUNK_INBOX:
+ camel_groupwise_settings_set_filter_junk_inbox (
+ CAMEL_GROUPWISE_SETTINGS (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_SECURITY_METHOD:
+ camel_network_settings_set_security_method (
+ CAMEL_NETWORK_SETTINGS (object),
+ g_value_get_enum (value));
+ return;
+
+ case PROP_SOAP_PORT:
+ camel_groupwise_settings_set_soap_port (
+ CAMEL_GROUPWISE_SETTINGS (object),
+ g_value_get_uint (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+groupwise_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_groupwise_settings_get_check_all (
+ CAMEL_GROUPWISE_SETTINGS (object)));
+ return;
+
+ case PROP_FILTER_JUNK:
+ g_value_set_boolean (
+ value,
+ camel_groupwise_settings_get_filter_junk (
+ CAMEL_GROUPWISE_SETTINGS (object)));
+ return;
+
+ case PROP_FILTER_JUNK_INBOX:
+ g_value_set_boolean (
+ value,
+ camel_groupwise_settings_get_filter_junk_inbox (
+ CAMEL_GROUPWISE_SETTINGS (object)));
+ return;
+
+ case PROP_SECURITY_METHOD:
+ g_value_set_enum (
+ value,
+ camel_network_settings_get_security_method (
+ CAMEL_NETWORK_SETTINGS (object)));
+ return;
+
+ case PROP_SOAP_PORT:
+ g_value_set_uint (
+ value,
+ camel_groupwise_settings_get_soap_port (
+ CAMEL_GROUPWISE_SETTINGS (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+camel_groupwise_settings_class_init (CamelGroupwiseSettingsClass *class)
+{
+ GObjectClass *object_class;
+
+ g_type_class_add_private (class, sizeof (CamelGroupwiseSettingsPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = groupwise_settings_set_property;
+ object_class->get_property = groupwise_settings_get_property;
+
+ 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_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));
+
+ /* Inherited from CamelNetworkSettings. */
+ g_object_class_override_property (
+ object_class,
+ PROP_SECURITY_METHOD,
+ "security-method");
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SOAP_PORT,
+ g_param_spec_uint (
+ "soap-port",
+ "SOAP Port",
+ "Post Office Agent SOAP Port",
+ 0,
+ G_MAXUINT16,
+ 7191,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+}
+
+static void
+camel_groupwise_settings_init (CamelGroupwiseSettings *settings)
+{
+ settings->priv = CAMEL_GROUPWISE_SETTINGS_GET_PRIVATE (settings);
+}
+
+gboolean
+camel_groupwise_settings_get_check_all (CamelGroupwiseSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_GROUPWISE_SETTINGS (settings), FALSE);
+
+ return settings->priv->check_all;
+}
+
+void
+camel_groupwise_settings_set_check_all (CamelGroupwiseSettings *settings,
+ gboolean check_all)
+{
+ g_return_if_fail (CAMEL_IS_GROUPWISE_SETTINGS (settings));
+
+ settings->priv->check_all = check_all;
+
+ g_object_notify (G_OBJECT (settings), "check-all");
+}
+
+gboolean
+camel_groupwise_settings_get_filter_junk (CamelGroupwiseSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_GROUPWISE_SETTINGS (settings), FALSE);
+
+ return settings->priv->filter_junk;
+}
+
+void
+camel_groupwise_settings_set_filter_junk (CamelGroupwiseSettings *settings,
+ gboolean filter_junk)
+{
+ g_return_if_fail (CAMEL_IS_GROUPWISE_SETTINGS (settings));
+
+ settings->priv->filter_junk = filter_junk;
+
+ g_object_notify (G_OBJECT (settings), "filter-junk");
+}
+
+gboolean
+camel_groupwise_settings_get_filter_junk_inbox (CamelGroupwiseSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_GROUPWISE_SETTINGS (settings), FALSE);
+
+ return settings->priv->filter_junk_inbox;
+}
+
+void
+camel_groupwise_settings_set_filter_junk_inbox (CamelGroupwiseSettings *settings,
+ gboolean filter_junk_inbox)
+{
+ g_return_if_fail (CAMEL_IS_GROUPWISE_SETTINGS (settings));
+
+ settings->priv->filter_junk_inbox = filter_junk_inbox;
+
+ g_object_notify (G_OBJECT (settings), "filter-junk-inbox");
+}
+
+guint16
+camel_groupwise_settings_get_soap_port (CamelGroupwiseSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_GROUPWISE_SETTINGS (settings), 0);
+
+ return settings->priv->soap_port;
+}
+
+void
+camel_groupwise_settings_set_soap_port (CamelGroupwiseSettings *settings,
+ guint16 soap_port)
+{
+ g_return_if_fail (CAMEL_IS_GROUPWISE_SETTINGS (settings));
+
+ settings->priv->soap_port = soap_port;
+
+ g_object_notify (G_OBJECT (settings), "soap-port");
+}
diff --git a/src/camel/camel-groupwise-settings.h b/src/camel/camel-groupwise-settings.h
new file mode 100644
index 0000000..f329fa9
--- /dev/null
+++ b/src/camel/camel-groupwise-settings.h
@@ -0,0 +1,83 @@
+/*
+ * camel-groupwise-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_GROUPWISE_SETTINGS_H
+#define CAMEL_GROUPWISE_SETTINGS_H
+
+#include <camel/camel.h>
+
+/* Standard GObject macros */
+#define CAMEL_TYPE_GROUPWISE_SETTINGS \
+ (camel_groupwise_settings_get_type ())
+#define CAMEL_GROUPWISE_SETTINGS(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), CAMEL_TYPE_GROUPWISE_SETTINGS, CamelGroupwiseSettings))
+#define CAMEL_GROUPWISE_SETTINGS_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), CAMEL_TYPE_GROUPWISE_SETTINGS, CamelGroupwiseSettingsClass))
+#define CAMEL_IS_GROUPWISE_SETTINGS(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), CAMEL_TYPE_GROUPWISE_SETTINGS))
+#define CAMEL_IS_GROUPWISE_SETTINGS_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), CAMEL_TYPE_GROUPWISE_SETTINGS))
+#define CAMEL_GROUPWISE_SETTINGS_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), CAMEL_TYPE_GROUPWISE_SETTINGS, CamelGroupwiseSettingsClass))
+
+G_BEGIN_DECLS
+
+typedef struct _CamelGroupwiseSettings CamelGroupwiseSettings;
+typedef struct _CamelGroupwiseSettingsClass CamelGroupwiseSettingsClass;
+typedef struct _CamelGroupwiseSettingsPrivate CamelGroupwiseSettingsPrivate;
+
+struct _CamelGroupwiseSettings {
+ CamelOfflineSettings parent;
+ CamelGroupwiseSettingsPrivate *priv;
+};
+
+struct _CamelGroupwiseSettingsClass {
+ CamelOfflineSettingsClass parent_class;
+};
+
+GType camel_groupwise_settings_get_type
+ (void) G_GNUC_CONST;
+gboolean camel_groupwise_settings_get_check_all
+ (CamelGroupwiseSettings *settings);
+void camel_groupwise_settings_set_check_all
+ (CamelGroupwiseSettings *settings,
+ gboolean check_all);
+gboolean camel_groupwise_settings_get_filter_junk
+ (CamelGroupwiseSettings *settings);
+void camel_groupwise_settings_set_filter_junk
+ (CamelGroupwiseSettings *settings,
+ gboolean filter_junk);
+gboolean camel_groupwise_settings_get_filter_junk_inbox
+ (CamelGroupwiseSettings *settings);
+void camel_groupwise_settings_set_filter_junk_inbox
+ (CamelGroupwiseSettings *settings,
+ gboolean filter_junk_inbox);
+guint16 camel_groupwise_settings_get_soap_port
+ (CamelGroupwiseSettings *settings);
+void camel_groupwise_settings_set_soap_port
+ (CamelGroupwiseSettings *settings,
+ guint16 soap_port);
+
+G_END_DECLS
+
+#endif /* CAMEL_GROUPWISE_SETTINGS_H */
diff --git a/src/camel/camel-groupwise-store.c b/src/camel/camel-groupwise-store.c
index 543d2c3..07062b3 100644
--- a/src/camel/camel-groupwise-store.c
+++ b/src/camel/camel-groupwise-store.c
@@ -38,6 +38,7 @@
#include <glib/gstdio.h>
#include "camel-groupwise-folder.h"
+#include "camel-groupwise-settings.h"
#include "camel-groupwise-store-summary.h"
#include "camel-groupwise-store.h"
#include "camel-groupwise-summary.h"
@@ -58,9 +59,7 @@ const gchar * CREATE_CURSOR_VIEW = "peek id default recipient threading hasAttac
struct _CamelGroupwiseStorePrivate {
gchar *server_name;
- gchar *port;
gchar *user;
- gchar *use_ssl;
gchar *base_url;
@@ -105,20 +104,35 @@ groupwise_auth_loop (CamelService *service,
{
CamelSession *session = camel_service_get_session (service);
CamelStore *store = CAMEL_STORE (service);
+ CamelSettings *settings;
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (store);
CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
+ CamelNetworkSecurityMethod security_method;
CamelURL *url;
gboolean authenticated = FALSE;
gchar *uri;
guint32 prompt_flags = CAMEL_SESSION_PASSWORD_SECRET;
+ const gchar *scheme;
EGwConnectionErrors errors = {E_GW_CONNECTION_STATUS_INVALID_OBJECT, NULL};
+ guint16 soap_port;
url = camel_service_get_camel_url (service);
+ settings = camel_service_get_settings (service);
- if (priv->use_ssl && !g_str_equal (priv->use_ssl, "never"))
- uri = g_strconcat ("https://", priv->server_name, ":", priv->port, "/soap", NULL);
+ security_method = camel_network_settings_get_security_method (
+ CAMEL_NETWORK_SETTINGS (settings));
+
+ soap_port = camel_groupwise_settings_get_soap_port (
+ CAMEL_GROUPWISE_SETTINGS (settings));
+
+ if (security_method == CAMEL_NETWORK_SECURITY_METHOD_NONE)
+ scheme = "http";
else
- uri = g_strconcat ("http://", priv->server_name, ":", priv->port, "/soap", NULL);
+ scheme = "https";
+
+ uri = g_strdup_printf (
+ "%s://%s:%u/soap", scheme, priv->server_name, soap_port);
+
url->passwd = NULL;
while (!authenticated) {
@@ -144,11 +158,7 @@ groupwise_auth_loop (CamelService *service,
}
priv->cnc = e_gw_connection_new_with_error_handler (uri, priv->user, url->passwd, &errors);
- if (!E_IS_GW_CONNECTION(priv->cnc) && priv->use_ssl && g_str_equal (priv->use_ssl, "when-possible")) {
- gchar *http_uri = g_strconcat ("http://", uri + 8, NULL);
- priv->cnc = e_gw_connection_new (http_uri, priv->user, url->passwd);
- g_free (http_uri);
- }
+
if (!E_IS_GW_CONNECTION (priv->cnc)) {
if (errors.status == E_GW_CONNECTION_STATUS_INVALID_PASSWORD) {
/* We need to un-cache the password before prompting again */
@@ -179,16 +189,30 @@ check_for_connection (CamelService *service,
{
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (service);
CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
+ CamelSettings *settings;
struct addrinfo hints, *ai;
GError *local_error = NULL;
+ settings = camel_service_get_settings (service);
+
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);
- if (ai == NULL && priv->port != NULL && g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ if (ai == NULL && g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ gchar *port_string;
+ guint16 soap_port;
+
g_clear_error (&local_error);
- ai = camel_getaddrinfo (priv->server_name, priv->port, &hints, cancellable, &local_error);
+
+ soap_port = camel_groupwise_settings_get_soap_port (
+ CAMEL_GROUPWISE_SETTINGS (settings));
+
+ port_string = g_strdup_printf ("%u", soap_port);
+ ai = camel_getaddrinfo (
+ priv->server_name, port_string, &hints,
+ cancellable, &local_error);
+ g_free (port_string);
}
if (ai == NULL) {
@@ -1375,18 +1399,22 @@ groupwise_store_get_trash_folder_sync (CamelStore *store,
}
static gboolean
-groupwise_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, GError **error)
+groupwise_can_refresh_folder (CamelStore *store,
+ CamelFolderInfo *info,
+ GError **error)
{
- CamelURL *url;
- gboolean res;
+ CamelService *service;
+ CamelSettings *settings;
+ gboolean check_all;
- url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
- res = CAMEL_STORE_CLASS (camel_groupwise_store_parent_class)->
- can_refresh_folder (store, info, error) ||
- (camel_url_get_param (url, "check_all") != NULL);
+ check_all = camel_groupwise_settings_get_check_all (
+ CAMEL_GROUPWISE_SETTINGS (settings));
- return res;
+ return CAMEL_STORE_CLASS (camel_groupwise_store_parent_class)->
+ can_refresh_folder (store, info, error) || check_all;
}
/*
@@ -1470,8 +1498,6 @@ groupwise_store_finalize (GObject *object)
g_free (groupwise_store->priv->user);
g_free (groupwise_store->priv->server_name);
- g_free (groupwise_store->priv->port);
- g_free (groupwise_store->priv->use_ssl);
g_free (groupwise_store->priv->base_url);
g_free (groupwise_store->root_container);
@@ -1498,7 +1524,6 @@ groupwise_store_initable_init (GInitable *initable,
CamelService *service;
CamelSession *session;
CamelURL *url;
- const gchar *property_value;
const gchar *user_data_dir;
const gchar *store_uid;
gchar *transport_uid;
@@ -1540,19 +1565,6 @@ groupwise_store_initable_init (GInitable *initable,
url, CAMEL_URL_HIDE_PASSWORD |
CAMEL_URL_HIDE_PARAMS | CAMEL_URL_HIDE_AUTH);
- /*soap port*/
- property_value = camel_url_get_param (url, "soap_port");
- if (property_value == NULL)
- groupwise_store->priv->port = g_strdup ("7191");
- else if (strlen (property_value) == 0)
- groupwise_store->priv->port = g_strdup ("7191");
- else
- groupwise_store->priv->port = g_strdup (property_value);
-
- /*filter*/
- if (camel_url_get_param (url, "filter"))
- CAMEL_STORE (groupwise_store)->flags |= CAMEL_STORE_FILTER_INBOX;
-
/*Hash Table*/
groupwise_store->priv->id_hash =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
@@ -1561,10 +1573,6 @@ groupwise_store_initable_init (GInitable *initable,
groupwise_store->priv->parent_hash =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- /*ssl*/
- groupwise_store->priv->use_ssl =
- g_strdup (camel_url_get_param (url, "use_ssl"));
-
CAMEL_STORE (groupwise_store)->flags &= ~CAMEL_STORE_VJUNK;
CAMEL_STORE (groupwise_store)->flags &= ~CAMEL_STORE_VTRASH;
@@ -1603,6 +1611,7 @@ camel_groupwise_store_class_init (CamelGroupwiseStoreClass *class)
object_class->finalize = groupwise_store_finalize;
service_class = CAMEL_SERVICE_CLASS (class);
+ service_class->settings_type = CAMEL_TYPE_GROUPWISE_SETTINGS;
service_class->get_name = groupwise_get_name;
service_class->connect_sync = groupwise_connect_sync;
service_class->disconnect_sync = groupwise_disconnect_sync;
@@ -1638,8 +1647,6 @@ camel_groupwise_store_init (CamelGroupwiseStore *groupwise_store)
d("in groupwise store init\n");
groupwise_store->priv->server_name = NULL;
- groupwise_store->priv->port = NULL;
- groupwise_store->priv->use_ssl = NULL;
groupwise_store->priv->user = NULL;
groupwise_store->priv->cnc = NULL;
groupwise_store->current_folder = NULL;
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index bdb2937..c78e1a6 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -26,23 +26,24 @@ plugin_LTLIBRARIES = liborg-gnome-groupwise-features.la
liborg_gnome_groupwise_features_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
-I$(top_srcdir) \
- -I$(top_srcdir)/src/server \
- -I$(top_builddir)/src/plugins \
- $(EVOLUTION_PLUGIN_CFLAGS) \
+ -I$(top_srcdir)/src/camel \
+ -I$(top_srcdir)/src/server \
+ -I$(top_builddir)/src/plugins \
+ $(EVOLUTION_PLUGIN_CFLAGS) \
$(EVOLUTION_SHELL_CFLAGS) \
$(LIBECAL_CFLAGS) \
- $(LIBEBACKEND_CFLAGS) \
- $(LIBEDATASERVER_CFLAGS) \
+ $(LIBEBACKEND_CFLAGS) \
+ $(LIBEDATASERVER_CFLAGS) \
$(EVOLUTION_MAIL_CFLAGS) \
$(EVOLUTION_CALENDAR_CFLAGS) \
$(EVOLUTION_ADDRESSBOOK_CFLAGS) \
$(CAMEL_GROUPWISE_CFLAGS) \
$(GNOME_PLATFORM_CFLAGS) \
- $(E_DATA_SERVER_CFLAGS) \
+ $(E_DATA_SERVER_CFLAGS) \
$(DEBUG_CFLAGS) \
$(CAMEL_CFLAGS) \
-DEVOLUTION_UIDIR=\""$(uidir)"\" \
- -DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\"
+ -DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\"
liborg_gnome_groupwise_features_la_SOURCES = \
gw-ui.h \
@@ -71,6 +72,7 @@ liborg_gnome_groupwise_features_la_SOURCES = \
liborg_gnome_groupwise_features_la_LIBADD= \
$(top_builddir)/src/server/libegroupwise-1.2.la \
+ $(top_builddir)/src/camel/libcamelgroupwise.la \
$(EVOLUTION_SHELL_LIBS) \
$(EVOLUTION_PLUGIN_LIBS) \
$(LIBECAL_LIBS) \
diff --git a/src/plugins/camel-gw-listener.c b/src/plugins/camel-gw-listener.c
index 5a02f26..2021efd 100644
--- a/src/plugins/camel-gw-listener.c
+++ b/src/plugins/camel-gw-listener.c
@@ -25,6 +25,7 @@
#endif
#include "camel-gw-listener.h"
+#include "camel-groupwise-settings.h"
#include <string.h>
#include <glib/gi18n.h>
#include <camel/camel.h>
@@ -170,20 +171,28 @@ lookup_account_info (const gchar *key)
#define SELECTED_NOTES "/apps/evolution/calendar/memos/selected_memos"
static void
-add_esource (const gchar *conf_key, GwAccountInfo *info, const gchar *source_name, CamelURL *url, const gchar * parent_id_name, gboolean can_create)
+add_esource (const gchar *conf_key,
+ GwAccountInfo *info,
+ const gchar *source_name,
+ CamelURL *url,
+ const gchar *parent_id_name,
+ gboolean can_create)
{
+ CamelSettings *settings;
ESourceList *source_list;
ESourceGroup *group;
ESource *source;
GConfClient* client;
GSList *ids, *temp;
+ CamelNetworkSecurityMethod security_method;
const gchar *source_selection_key;
gchar *relative_uri;
- const gchar *soap_port;
- const gchar * use_ssl;
+ const gchar *use_ssl;
const gchar *poa_address;
- const gchar *offline_sync;
const gchar *group_name;
+ guint16 soap_port;
+ gboolean stay_synchronized;
+ gchar *port_string;
poa_address = url->host;
if (!poa_address || strlen (poa_address) ==0)
@@ -191,14 +200,31 @@ add_esource (const gchar *conf_key, GwAccountInfo *info, const gchar *source_na
group_name = info->name;
- soap_port = camel_url_get_param (url, "soap_port");
+ settings = g_object_new (CAMEL_TYPE_GROUPWISE_SETTINGS, NULL);
+ camel_settings_load_from_url (settings, url);
- if (!soap_port || strlen (soap_port) == 0)
- soap_port = "7191";
+ g_object_get (
+ settings,
+ "soap-port", &soap_port,
+ "stay-synchronized", &stay_synchronized,
+ "security-method", &security_method,
+ NULL);
- use_ssl = camel_url_get_param (url, "use_ssl");
+ g_object_unref (settings);
- offline_sync = camel_url_get_param (url, "offline_sync");
+ switch (security_method) {
+ case CAMEL_NETWORK_SECURITY_METHOD_NONE:
+ use_ssl = "never";
+ break;
+ case CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT:
+ use_ssl = "always";
+ break;
+ case CAMEL_NETWORK_SECURITY_METHOD_STARTTLS_ON_STANDARD_PORT:
+ use_ssl = "when-possible";
+ break;
+ default:
+ g_return_if_reached ();
+ }
client = gconf_client_get_default ();
source_list = e_source_list_new_for_gconf (client, conf_key);
@@ -210,14 +236,18 @@ add_esource (const gchar *conf_key, GwAccountInfo *info, const gchar *source_na
if (!can_create)
e_source_group_set_property (group, "create_source", "no");
+ port_string = g_strdup_printf ("%u", soap_port);
+
relative_uri = g_strdup_printf ("%s %s/", url->user, poa_address);
source = e_source_new (source_name, relative_uri);
e_source_set_property (source, "auth", "1");
e_source_set_property (source, "username", url->user);
- e_source_set_property (source, "port", soap_port);
+ e_source_set_property (source, "port", port_string);
e_source_set_property (source, "auth-domain", "Groupwise");
e_source_set_property (source, "use_ssl", use_ssl);
+ g_free (port_string);
+
if (info->auto_check) {
gchar *str = g_strdup_printf ("%d", info->auto_check_time);
@@ -226,7 +256,9 @@ add_esource (const gchar *conf_key, GwAccountInfo *info, const gchar *source_na
} else
e_source_set_property (source, "refresh", NULL);
- e_source_set_property (source, "offline_sync", offline_sync ? "1" : "0" );
+ e_source_set_property (
+ source, "offline_sync",
+ stay_synchronized ? "1" : "0" );
e_source_set_property (source, "delete", "no");
if (parent_id_name) {
e_source_set_property (source, "parent_id_name", parent_id_name);
@@ -347,9 +379,15 @@ modify_esource (const gchar * conf_key, GwAccountInfo *old_account_info, EAccoun
CamelURL *url;
gboolean found_group;
GConfClient* client;
+ CamelSettings *settings;
+ CamelNetworkSecurityMethod security_method;
const gchar *poa_address;
const gchar *new_poa_address;
- const gchar * new_group_name = a->name;
+ const gchar *new_group_name = a->name;
+ const gchar *use_ssl;
+ guint16 soap_port;
+ gboolean stay_synchronized;
+ gchar *port_string;
url = camel_url_new (old_account_info->source_url, NULL);
poa_address = url->host;
@@ -364,6 +402,34 @@ modify_esource (const gchar * conf_key, GwAccountInfo *old_account_info, EAccoun
found_group = FALSE;
+ settings = g_object_new (CAMEL_TYPE_GROUPWISE_SETTINGS, NULL);
+ camel_settings_load_from_url (settings, new_url);
+
+ g_object_get (
+ settings,
+ "soap-port", &soap_port,
+ "stay-synchronized", &stay_synchronized,
+ "security-method", &security_method,
+ NULL);
+
+ g_object_unref (settings);
+
+ switch (security_method) {
+ case CAMEL_NETWORK_SECURITY_METHOD_NONE:
+ use_ssl = "never";
+ break;
+ case CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT:
+ use_ssl = "always";
+ break;
+ case CAMEL_NETWORK_SECURITY_METHOD_STARTTLS_ON_STANDARD_PORT:
+ use_ssl = "when-possible";
+ break;
+ default:
+ g_return_if_reached ();
+ }
+
+ port_string = g_strdup_printf ("%u", soap_port);
+
for (; groups != NULL && !found_group; groups = g_slist_next (groups)) {
ESourceGroup *group = E_SOURCE_GROUP (groups->data);
@@ -385,9 +451,9 @@ modify_esource (const gchar * conf_key, GwAccountInfo *old_account_info, EAccoun
e_source_group_set_name (group, new_group_name);
e_source_set_relative_uri (source, new_relative_uri);
e_source_set_property (source, "username", new_url->user);
- e_source_set_property (source, "port", camel_url_get_param (new_url,"soap_port"));
- e_source_set_property (source, "use_ssl", camel_url_get_param (url, "use_ssl"));
- e_source_set_property (source, "offline_sync", camel_url_get_param (url, "offline_sync") ? "1" : "0");
+ e_source_set_property (source, "port", port_string);
+ e_source_set_property (source, "use_ssl", use_ssl);
+ e_source_set_property (source, "offline_sync", stay_synchronized ? "1" : "0");
if (a->source->auto_check) {
gchar *str = g_strdup_printf ("%d", a->source->auto_check_time);
@@ -409,6 +475,8 @@ modify_esource (const gchar * conf_key, GwAccountInfo *old_account_info, EAccoun
}
}
+ g_free (port_string);
+
g_object_unref (list);
g_object_unref (client);
camel_url_free (url);
@@ -461,21 +529,23 @@ remove_calendar_tasks_sources (GwAccountInfo *info)
static GList*
get_addressbook_names_from_server (gchar *source_url)
{
+ CamelSettings *settings;
gchar *key;
EGwConnection *cnc;
gchar *password;
GList *book_list = NULL;
gint status, count = 0;
- const gchar *soap_port;
CamelURL *url;
gboolean remember;
gchar *failed_auth = NULL;
gchar *prompt;
gchar *password_prompt;
gchar *uri;
- const gchar *use_ssl;
const gchar *poa_address;
guint32 flags = E_PASSWORDS_REMEMBER_FOREVER|E_PASSWORDS_SECRET;
+ CamelNetworkSecurityMethod security_method;
+ const gchar *scheme;
+ guint16 soap_port;
url = camel_url_new (source_url, NULL);
if (url == NULL) {
@@ -485,17 +555,25 @@ get_addressbook_names_from_server (gchar *source_url)
if (!poa_address || strlen (poa_address) ==0)
return NULL;
- soap_port = camel_url_get_param (url, "soap_port");
- if (!soap_port || strlen (soap_port) == 0)
- soap_port = "7191";
- use_ssl = camel_url_get_param (url, "use_ssl");
+ settings = g_object_new (CAMEL_TYPE_GROUPWISE_SETTINGS, NULL);
+ camel_settings_load_from_url (settings, url);
+
+ g_object_get (
+ settings,
+ "soap-port", &soap_port,
+ "security-method", &security_method,
+ NULL);
- key = g_strdup_printf ("groupwise://%s %s/", url->user, poa_address);
+ g_object_unref (settings);
- if (use_ssl && g_str_equal (use_ssl, "always"))
- uri = g_strdup_printf ("https://%s:%s/soap", poa_address, soap_port);
+ if (security_method == CAMEL_NETWORK_SECURITY_METHOD_NONE)
+ scheme = "http";
else
- uri = g_strdup_printf ("http://%s:%s/soap", poa_address, soap_port);
+ scheme = "https";
+
+ key = g_strdup_printf ("groupwise://%s %s/", url->user, poa_address);
+
+ uri = g_strdup_printf ("%s://%s:%u/soap", scheme, poa_address, soap_port);
cnc = NULL;
@@ -576,17 +654,21 @@ add_proxy_sources (GwAccountInfo *info, const gchar *parent_name)
static gboolean
add_addressbook_sources (EAccount *account)
{
+ CamelSettings *settings;
CamelURL *url;
ESourceList *list;
ESourceGroup *group;
ESource *source;
gchar *base_uri;
- const gchar *soap_port;
GList *books_list, *temp_list;
GConfClient* client;
- const gchar * use_ssl;
+ const gchar *use_ssl;
const gchar *poa_address;
gboolean is_frequent_contacts = FALSE, is_writable = FALSE;
+ CamelNetworkSecurityMethod security_method;
+ gboolean stay_synchronized;
+ gchar *port_string;
+ guint16 soap_port;
url = camel_url_new (account->source->url, NULL);
if (url == NULL) {
@@ -597,10 +679,32 @@ add_addressbook_sources (EAccount *account)
if (!poa_address || strlen (poa_address) ==0)
return FALSE;
- soap_port = camel_url_get_param (url, "soap_port");
- if (!soap_port || strlen (soap_port) == 0)
- soap_port = "7191";
- use_ssl = camel_url_get_param (url, "use_ssl");
+ settings = g_object_new (CAMEL_TYPE_GROUPWISE_SETTINGS, NULL);
+ camel_settings_load_from_url (settings, url);
+
+ g_object_get (
+ settings,
+ "soap-port", &soap_port,
+ "security-method", &security_method,
+ "stay-synchronized", &stay_synchronized,
+ NULL);
+
+ g_object_unref (settings);
+
+ switch (security_method) {
+ case CAMEL_NETWORK_SECURITY_METHOD_NONE:
+ use_ssl = "never";
+ break;
+ case CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT:
+ use_ssl = "always";
+ break;
+ case CAMEL_NETWORK_SECURITY_METHOD_STARTTLS_ON_STANDARD_PORT:
+ use_ssl = "when-possible";
+ break;
+ default:
+ g_return_val_if_reached (FALSE);
+ }
+
base_uri = g_strdup_printf ("groupwise://%s %s", url->user, poa_address);
client = gconf_client_get_default ();
list = e_source_list_new_for_gconf (client, "/apps/evolution/addressbook/sources" );
@@ -609,6 +713,9 @@ add_addressbook_sources (EAccount *account)
temp_list = books_list;
if (!temp_list)
return FALSE;
+
+ port_string = g_strdup_printf ("%u", soap_port);
+
for (; temp_list != NULL; temp_list = g_list_next (temp_list)) {
const gchar *book_name = e_gw_container_get_name (E_GW_CONTAINER (temp_list->data));
/* is_writable is set to TRUE if the book has isPersonal property,
@@ -630,7 +737,7 @@ add_addressbook_sources (EAccount *account)
source = e_source_new (book_name, g_strconcat (";",book_name, NULL));
e_source_set_property (source, "auth", "plain/password");
e_source_set_property (source, "auth-domain", "Groupwise");
- e_source_set_property (source, "port", soap_port);
+ e_source_set_property (source, "port", port_string);
e_source_set_property(source, "user", url->user);
/* mark system address book for offline usage */
/* FIXME: add isPersonal flag to container and use that isFrequentContact
@@ -640,8 +747,9 @@ add_addressbook_sources (EAccount *account)
if (!is_writable)
e_source_set_property (source, "offline_sync", "1");
else
- 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 (!is_writable)
e_source_set_property (source, "completion", "true");
if (is_frequent_contacts)
@@ -650,6 +758,9 @@ add_addressbook_sources (EAccount *account)
e_source_group_add_source (group, source, -1);
g_object_unref (source);
}
+
+ g_free (port_string);
+
e_source_list_add_group (list, group, -1);
e_source_list_sync (list, NULL);
g_object_unref (group);
@@ -666,8 +777,10 @@ add_addressbook_sources (EAccount *account)
}
static void
-modify_addressbook_sources ( EAccount *account, GwAccountInfo *existing_account_info )
+modify_addressbook_sources (EAccount *account,
+ GwAccountInfo *existing_account_info )
{
+ CamelSettings *settings;
CamelURL *url;
ESourceList *list;
ESourceGroup *group;
@@ -676,12 +789,14 @@ modify_addressbook_sources ( EAccount *account, GwAccountInfo *existing_account_
gboolean delete_group;
gchar *old_base_uri;
gchar *new_base_uri;
- const gchar *soap_port;
const gchar *use_ssl;
GSList *sources;
ESource *source;
GConfClient *client;
const gchar *poa_address;
+ CamelNetworkSecurityMethod security_method;
+ gchar *port_string;
+ guint16 soap_port;
url = camel_url_new (existing_account_info->source_url, NULL);
if (url == NULL) {
@@ -701,11 +816,35 @@ modify_addressbook_sources ( EAccount *account, GwAccountInfo *existing_account_
poa_address = url->host;
if (!poa_address || strlen (poa_address) ==0)
return;
+
+ settings = g_object_new (CAMEL_TYPE_GROUPWISE_SETTINGS, NULL);
+ camel_settings_load_from_url (settings, url);
+
+ g_object_get (
+ settings,
+ "soap-port", &soap_port,
+ "security-method", &security_method,
+ NULL);
+
+ g_object_unref (settings);
+
+ switch (security_method) {
+ case CAMEL_NETWORK_SECURITY_METHOD_NONE:
+ use_ssl = "never";
+ break;
+ case CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT:
+ use_ssl = "always";
+ break;
+ case CAMEL_NETWORK_SECURITY_METHOD_STARTTLS_ON_STANDARD_PORT:
+ use_ssl = "when-possible";
+ break;
+ default:
+ g_return_if_reached ();
+ }
+
+ port_string = g_strdup_printf ("%u", soap_port);
+
new_base_uri = g_strdup_printf ("groupwise://%s %s", url->user, poa_address);
- soap_port = camel_url_get_param (url, "soap_port");
- if (!soap_port || strlen (soap_port) == 0)
- soap_port = "7191";
- use_ssl = camel_url_get_param (url, "use_ssl");
client = gconf_client_get_default ();
list = e_source_list_new_for_gconf (client, "/apps/evolution/addressbook/sources" );
@@ -725,7 +864,7 @@ modify_addressbook_sources ( EAccount *account, GwAccountInfo *existing_account_
sources = e_source_group_peek_sources (group);
for (; sources != NULL; sources = g_slist_next (sources)) {
source = E_SOURCE (sources->data);
- e_source_set_property (source, "port", soap_port);
+ e_source_set_property (source, "port", port_string);
e_source_set_property (source, "use_ssl", use_ssl);
}
@@ -734,6 +873,9 @@ modify_addressbook_sources ( EAccount *account, GwAccountInfo *existing_account_
}
}
+
+ g_free (port_string);
+
if (found_group && delete_group) {
e_source_list_remove_group (list, group);
e_source_list_sync (list, NULL);
@@ -746,7 +888,6 @@ modify_addressbook_sources ( EAccount *account, GwAccountInfo *existing_account_
g_object_unref (list);
camel_url_free (url);
g_object_unref (client);
-
}
static void
@@ -852,9 +993,7 @@ account_changed (EAccountList *account_listener, EAccount *account)
{
gboolean is_gw_account;
CamelURL *old_url, *new_url;
- const gchar *old_soap_port, *new_soap_port;
GwAccountInfo *existing_account_info;
- const gchar *old_use_ssl, *new_use_ssl;
const gchar *old_poa_address, *new_poa_address;
is_gw_account = is_groupwise_account (account);
@@ -881,6 +1020,11 @@ account_changed (EAccountList *account_listener, EAccount *account)
g_free (existing_account_info);
} else if (existing_account_info != NULL && is_gw_account) {
+ CamelSettings *settings;
+ CamelNetworkSecurityMethod old_security_method;
+ CamelNetworkSecurityMethod new_security_method;
+ guint16 old_soap_port;
+ guint16 new_soap_port;
if (!account->enabled) {
account_removed (account_listener, account);
@@ -890,26 +1034,39 @@ account_changed (EAccountList *account_listener, EAccount *account)
/* some info of groupwise account is changed . update the sources with new info if required */
old_url = camel_url_new (existing_account_info->source_url, NULL);
old_poa_address = old_url->host;
- old_soap_port = camel_url_get_param (old_url, "soap_port");
- old_use_ssl = camel_url_get_param (old_url, "use_ssl");
+
+ settings = g_object_new (CAMEL_TYPE_GROUPWISE_SETTINGS, NULL);
+ camel_settings_load_from_url (settings, old_url);
+
+ g_object_get (
+ settings,
+ "soap-port", &old_soap_port,
+ "security-method", &old_security_method,
+ NULL);
+
+ g_object_unref (settings);
+
new_url = camel_url_new (account->source->url, NULL);
new_poa_address = new_url->host;
if (!new_poa_address || strlen (new_poa_address) ==0)
return;
- new_soap_port = camel_url_get_param (new_url, "soap_port");
+ settings = g_object_new (CAMEL_TYPE_GROUPWISE_SETTINGS, NULL);
+ camel_settings_load_from_url (settings, new_url);
- if (!new_soap_port || strlen (new_soap_port) == 0)
- new_soap_port = "7191";
+ g_object_get (
+ settings,
+ "soap-port", &new_soap_port,
+ "security-method", &new_security_method,
+ NULL);
- new_use_ssl = camel_url_get_param (new_url, "use_ssl");
+ g_object_unref (settings);
if ((old_poa_address && strcmp (old_poa_address, new_poa_address))
- || (old_soap_port && strcmp (old_soap_port, new_soap_port))
- || strcmp (old_url->user, new_url->user)
- || (!old_use_ssl)
- || strcmp (old_use_ssl, new_use_ssl)) {
+ || old_soap_port != new_soap_port
+ || strcmp (old_url->user, new_url->user)
+ || old_security_method != new_security_method) {
account_removed (account_listener, account);
account_added (account_listener, account);
diff --git a/src/plugins/proxy-login.c b/src/plugins/proxy-login.c
index d890f52..6dcf629 100644
--- a/src/plugins/proxy-login.c
+++ b/src/plugins/proxy-login.c
@@ -50,6 +50,7 @@
#include "gw-ui.h"
#include "proxy-login.h"
+#include "camel-groupwise-settings.h"
#define GW(name) e_builder_get_widget (priv->builder, name)
@@ -176,12 +177,18 @@ proxy_login_new (void)
}
static gint
-proxy_get_password (EAccount *account, gchar **user_name, gchar **password)
+proxy_get_password (EAccount *account,
+ gchar **user_name,
+ gchar **password)
{
+ CamelSettings *settings;
const gchar *failed_auth;
gchar *uri, *key, *prompt;
CamelURL *url;
- const gchar *poa_address, *use_ssl = NULL, *soap_port;
+ CamelNetworkSecurityMethod security_method;
+ const gchar *poa_address;
+ const gchar *scheme;
+ guint16 soap_port;
url = camel_url_new (account->source->url, NULL);
if (url == NULL)
@@ -191,17 +198,25 @@ proxy_get_password (EAccount *account, gchar **user_name, gchar **password)
if (!poa_address || strlen (poa_address) ==0)
return 0;
- soap_port = camel_url_get_param (url, "soap_port");
- if (!soap_port || strlen (soap_port) == 0)
- soap_port = "7191";
- use_ssl = camel_url_get_param (url, "use_ssl");
+ settings = g_object_new (CAMEL_TYPE_GROUPWISE_SETTINGS, NULL);
+ camel_settings_load_from_url (settings, url);
- key = g_strdup_printf ("groupwise://%s %s/", url->user, poa_address);
+ g_object_get (
+ settings,
+ "soap-port", &soap_port,
+ "security-method", &security_method,
+ NULL);
- if (use_ssl && !g_str_equal (use_ssl, "never"))
- uri = g_strdup_printf ("https://%s:%s/soap", poa_address, soap_port);
+ g_object_unref (settings);
+
+ if (security_method == CAMEL_NETWORK_SECURITY_METHOD_NONE)
+ scheme = "http";
else
- uri = g_strdup_printf ("http://%s:%s/soap", poa_address, soap_port);
+ scheme = "https";
+
+ key = g_strdup_printf ("groupwise://%s %s/", url->user, poa_address);
+
+ uri = g_strdup_printf ("%s://%s:%u/soap", scheme, poa_address, soap_port);
failed_auth = "";
@@ -219,13 +234,17 @@ proxy_get_password (EAccount *account, gchar **user_name, gchar **password)
}
static EGwConnection *
-proxy_login_get_cnc (EAccount *account, GtkWindow *password_dlg_parrent)
+proxy_login_get_cnc (EAccount *account,
+ GtkWindow *password_dlg_parrent)
{
+ CamelSettings *settings;
EGwConnection *cnc;
CamelURL *url;
+ CamelNetworkSecurityMethod security_method;
const gchar *failed_auth;
gchar *uri = NULL, *key = NULL, *prompt = NULL, *password = NULL;
- const gchar *use_ssl = NULL, *soap_port;
+ const gchar *scheme;
+ guint16 soap_port;
gboolean remember;
url = camel_url_new (account->source->url, NULL);
@@ -234,16 +253,24 @@ proxy_login_get_cnc (EAccount *account, GtkWindow *password_dlg_parrent)
if (!url->host || strlen (url->host) ==0)
return NULL;
- soap_port = camel_url_get_param (url, "soap_port");
- if (!soap_port || strlen (soap_port) == 0)
- soap_port = "7191";
- use_ssl = camel_url_get_param (url, "use_ssl");
+ settings = g_object_new (CAMEL_TYPE_GROUPWISE_SETTINGS, NULL);
+ camel_settings_load_from_url (settings, url);
+
+ g_object_get (
+ settings,
+ "soap-port", &soap_port,
+ "security-method", &security_method,
+ NULL);
- key = g_strdup_printf ("groupwise://%s %s/", url->user, url->host);
- if (use_ssl && !g_str_equal (use_ssl, "never"))
- uri = g_strdup_printf ("https://%s:%s/soap", url->host, soap_port);
+ g_object_unref (settings);
+
+ if (security_method == CAMEL_NETWORK_SECURITY_METHOD_NONE)
+ scheme = "http";
else
- uri = g_strdup_printf ("http://%s:%s/soap", url->host, soap_port);
+ scheme = "https";
+
+ key = g_strdup_printf ("groupwise://%s %s/", url->user, url->host);
+ uri = g_strdup_printf ("%s://%s:%u/soap", scheme, url->host, soap_port);
failed_auth = "";
cnc = NULL;
@@ -259,11 +286,6 @@ proxy_login_get_cnc (EAccount *account, GtkWindow *password_dlg_parrent)
g_free (prompt);
cnc = e_gw_connection_new (uri, url->user, password);
- if (!E_IS_GW_CONNECTION(cnc) && use_ssl && g_str_equal (use_ssl, "when-possible")) {
- gchar *http_uri = g_strconcat ("http://", uri + 8, NULL);
- cnc = e_gw_connection_new (http_uri, url->user, password);
- g_free (http_uri);
- }
g_free (key);
g_free (password);
diff --git a/src/plugins/proxy.c b/src/plugins/proxy.c
index a21da4a..81286c8 100644
--- a/src/plugins/proxy.c
+++ b/src/plugins/proxy.c
@@ -50,6 +50,8 @@
#include <proxy.h>
#include <string.h>
+#include "camel-groupwise-settings.h"
+
#define GW(name) e_builder_get_widget (priv->builder, name)
#define ACCOUNT_PICTURE 0
@@ -461,12 +463,16 @@ proxy_dialog_initialize_widgets (EAccount *account)
static EGwConnection *
proxy_get_cnc (EAccount *account, GtkWindow *parent_window)
{
+ CamelSettings *settings;
EGwConnection *cnc;
const gchar *failed_auth;
gchar *uri, *key, *prompt, *password = NULL;
CamelURL *url;
- const gchar *poa_address, *use_ssl, *soap_port;
+ CamelNetworkSecurityMethod security_method;
+ const gchar *poa_address;
+ const gchar *scheme;
gboolean remember;
+ guint16 soap_port;
url = camel_url_new (account->source->url, NULL);
if (url == NULL)
@@ -475,17 +481,25 @@ proxy_get_cnc (EAccount *account, GtkWindow *parent_window)
if (!poa_address || strlen (poa_address) ==0)
return NULL;
- soap_port = camel_url_get_param (url, "soap_port");
- if (!soap_port || strlen (soap_port) == 0)
- soap_port = "7191";
- use_ssl = camel_url_get_param (url, "use_ssl");
+ settings = g_object_new (CAMEL_TYPE_GROUPWISE_SETTINGS, NULL);
+ camel_settings_load_from_url (settings, url);
- key = g_strdup_printf ("groupwise://%s %s/", url->user, poa_address);
+ g_object_get (
+ settings,
+ "soap-port", &soap_port,
+ "security-method", &security_method,
+ NULL);
- if (use_ssl && !g_str_equal (use_ssl, "never"))
- uri = g_strdup_printf ("https://%s:%s/soap", poa_address, soap_port);
+ g_object_unref (settings);
+
+ if (security_method == CAMEL_NETWORK_SECURITY_METHOD_NONE)
+ scheme = "http";
else
- uri = g_strdup_printf ("http://%s:%s/soap", poa_address, soap_port);
+ scheme = "https";
+
+ key = g_strdup_printf ("groupwise://%s %s/", url->user, poa_address);
+
+ uri = g_strdup_printf ("%s://%s:%u/soap", scheme, poa_address, soap_port);
failed_auth = "";
cnc = NULL;
@@ -500,13 +514,9 @@ proxy_get_cnc (EAccount *account, GtkWindow *parent_window)
g_free (prompt);
cnc = e_gw_connection_new (uri, url->user, password);
- if (!E_IS_GW_CONNECTION(cnc) && use_ssl && g_str_equal (use_ssl, "when-possible")) {
- gchar *http_uri = g_strconcat ("http://", uri + 8, NULL);
- cnc = e_gw_connection_new (http_uri, url->user, password);
- g_free (http_uri);
- }
camel_url_free (url);
+
return cnc;
}
diff --git a/src/plugins/send-options.c b/src/plugins/send-options.c
index 7ed37c2..c66243d 100644
--- a/src/plugins/send-options.c
+++ b/src/plugins/send-options.c
@@ -27,6 +27,7 @@
#include <string.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
+#include "camel-groupwise-settings.h"
#include "mail/em-account-editor.h"
#include "mail/em-config.h"
#include "libedataserver/e-account.h"
@@ -52,12 +53,16 @@ void send_options_abort (EPlugin *epl, EConfigHookItemFactoryData *data);
static EGwConnection *
get_cnc (GtkWindow *parent_window)
{
+ CamelSettings *settings;
EGwConnection *cnc;
const gchar *failed_auth;
gchar *uri, *key, *prompt, *password = NULL;
CamelURL *url;
- const gchar *poa_address, *use_ssl, *soap_port;
+ CamelNetworkSecurityMethod security_method;
+ const gchar *poa_address;
+ const gchar *scheme;
gboolean remember;
+ guint16 soap_port;
url = camel_url_new (account->source->url, NULL);
if (url == NULL)
@@ -66,17 +71,25 @@ get_cnc (GtkWindow *parent_window)
if (!poa_address || strlen (poa_address) ==0)
return NULL;
- soap_port = camel_url_get_param (url, "soap_port");
- if (!soap_port || strlen (soap_port) == 0)
- soap_port = "7191";
- use_ssl = camel_url_get_param (url, "use_ssl");
+ settings = g_object_new (CAMEL_TYPE_GROUPWISE_SETTINGS, NULL);
+ camel_settings_load_from_url (settings, url);
- key = g_strdup_printf ("groupwise://%s %s/", url->user, poa_address);
+ g_object_set (
+ settings,
+ "soap-port", &soap_port,
+ "security-method", &security_method,
+ NULL);
+
+ g_object_unref (settings);
- if (use_ssl && !g_str_equal (use_ssl, "never"))
- uri = g_strdup_printf ("https://%s:%s/soap", poa_address, soap_port);
+ if (security_method == CAMEL_NETWORK_SECURITY_METHOD_NONE)
+ scheme = "http";
else
- uri = g_strdup_printf ("http://%s:%s/soap", poa_address, soap_port);
+ scheme = "https";
+
+ key = g_strdup_printf ("groupwise://%s %s/", url->user, poa_address);
+
+ uri = g_strdup_printf ("%s://%s:%u/soap", scheme, poa_address, soap_port);
failed_auth = "";
cnc = NULL;
@@ -91,13 +104,9 @@ get_cnc (GtkWindow *parent_window)
g_free (prompt);
cnc = e_gw_connection_new (uri, url->user, password);
- if (!E_IS_GW_CONNECTION(cnc) && use_ssl && g_str_equal (use_ssl, "when-possible")) {
- gchar *http_uri = g_strconcat ("http://", uri + 8, NULL);
- cnc = e_gw_connection_new (http_uri, url->user, password);
- g_free (http_uri);
- }
camel_url_free (url);
+
return cnc;
}
diff --git a/src/plugins/share-folder-common.c b/src/plugins/share-folder-common.c
index ccac39f..0fdfb5f 100644
--- a/src/plugins/share-folder-common.c
+++ b/src/plugins/share-folder-common.c
@@ -423,44 +423,38 @@ org_gnome_shared_folder_factory (EPlugin *ep, EConfigHookItemFactoryData *hook_d
EGwConnection *
get_cnc (CamelStore *store)
{
- EGwConnection *cnc;
- const gchar *uri, *property_value, *server_name, *user, *port;
- gchar *use_ssl;
- CamelService *service;
- CamelURL *url;
-
- if (!store)
- return NULL;
-
- service = CAMEL_SERVICE (store);
- url = camel_service_get_camel_url (service);
- server_name = g_strdup (url->host);
- user = g_strdup (url->user);
- property_value = camel_url_get_param (url, "soap_port");
- use_ssl = g_strdup (camel_url_get_param (url, "use_ssl"));
- if (property_value == NULL)
- port = g_strdup ("7191");
- else if (strlen (property_value) == 0)
- port = g_strdup ("7191");
- else
- port = g_strdup (property_value);
-
- if (use_ssl && !g_str_equal (use_ssl, "never"))
- uri = g_strconcat ("https://", server_name, ":", port, "/soap", NULL);
- else
- uri = g_strconcat ("http://", server_name, ":", port, "/soap", NULL);
-
- cnc = e_gw_connection_new (uri, user, url->passwd);
- if (!E_IS_GW_CONNECTION(cnc) && use_ssl && g_str_equal (use_ssl, "when-possible")) {
- gchar *http_uri = g_strconcat ("http://", uri + 8, NULL);
- cnc = e_gw_connection_new (http_uri, user, url->passwd);
- g_free (http_uri);
- }
- g_free (use_ssl);
- use_ssl = NULL;
+ const gchar *uri, *server_name, *user;
+ CamelService *service;
+ CamelSettings *settings;
+ CamelURL *url;
+ CamelNetworkSecurityMethod security_method;
+ const gchar *scheme;
+ guint16 soap_port;
+
+ if (!store)
+ return NULL;
+
+ service = CAMEL_SERVICE (store);
+ url = camel_service_get_camel_url (service);
+ settings = camel_service_get_settings (service);
+ server_name = g_strdup (url->host);
+ user = g_strdup (url->user);
+
+ g_object_get (
+ settings,
+ "soap-port", &soap_port,
+ "security-method", &security_method,
+ NULL);
+
+ if (security_method == CAMEL_NETWORK_SECURITY_METHOD_NONE)
+ scheme = "http";
+ else
+ scheme = "https";
- return cnc;
+ uri = g_strdup_printf (
+ "%s://%s:%u/soap", scheme, server_name, soap_port);
+ return e_gw_connection_new (uri, user, url->passwd);
}
gchar *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]