[evolution-data-server] Move remaining CamelURL elements to CamelSettings.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Move remaining CamelURL elements to CamelSettings.
- Date: Mon, 24 Oct 2011 17:13:31 +0000 (UTC)
commit ffa02a8e2238b662ec9b77b212737cb56a744507
Author: Matthew Barnes <mbarnes redhat com>
Date: Thu Oct 20 17:24:04 2011 -0400
Move remaining CamelURL elements to CamelSettings.
This is a continuation of the CamelSettings work I started in 3.1.
CamelService no longer stores a CamelURL. The URL components are being
moved to CamelSettings.
For network services, the host, port, user and authentication mechanism
URL components now live in CamelNetworkSettings.
For local services, the path URL component (aka, the file path to the
root of the local mail store) now lives in CamelLocalSettings.
For now these new settings are configured the same as other settings:
through camel_settings_load_from_url(). But again, that function will
be dropped as soon as we move to key files for account data storage.
Also:
- Remove camel_service_get_url(), which is no longer used.
- camel_session_add_service() now takes a protocol name instead of a
URL string. The protocol name must match a registered CamelProvider.
- camel_service_get_camel_url() is renamed camel_service_new_camel_url().
It now returns a new CamelURL which must be freed with camel_url_free().
The returned CamelURL is built from user, host, port and path settings,
and does not have any parameters. You MUST access settings through
CamelSettings now.
- CamelServices need to be prepared for CamelSettings values changing or
even the entire CamelSettings object being replaced at any time. Most
services were already prepared, but I caught a few services caching
settings during initialization. Always consult CamelSettings when a
setting value is needed so the service is acting on a fresh value.
- Camel's SONAME is hereby bumped (yet again) for 3.3.2.
camel/Makefile.am | 2 +
camel/camel-local-settings.c | 173 ++++++++++++
camel/camel-local-settings.h | 78 ++++++
camel/camel-network-service.c | 28 +-
camel/camel-network-settings.c | 244 +++++++++++++++++
camel/camel-network-settings.h | 20 ++
camel/camel-provider.c | 33 +--
camel/camel-provider.h | 2 +-
camel/camel-sasl-cram-md5.c | 15 +-
camel/camel-sasl-digest-md5.c | 23 ++-
camel/camel-sasl-gssapi.c | 28 ++-
camel/camel-sasl-login.c | 17 +-
camel/camel-sasl-ntlm.c | 50 +++--
camel/camel-sasl-plain.c | 17 +-
camel/camel-service.c | 244 +++++++----------
camel/camel-service.h | 4 +-
camel/camel-session.c | 58 ++---
camel/camel-session.h | 2 +-
camel/camel-settings.c | 58 ++++
camel/camel-vee-folder.c | 22 +--
camel/camel.h | 1 +
camel/providers/imap/camel-imap-command.c | 30 ++-
camel/providers/imap/camel-imap-folder.c | 31 ++-
camel/providers/imap/camel-imap-settings.c | 80 ++++++
camel/providers/imap/camel-imap-store.c | 178 ++++++++-----
camel/providers/imapx/camel-imapx-conn-manager.c | 4 +-
camel/providers/imapx/camel-imapx-server.c | 78 ++++--
camel/providers/imapx/camel-imapx-server.h | 4 +-
camel/providers/imapx/camel-imapx-settings.c | 80 ++++++
camel/providers/imapx/camel-imapx-store.c | 20 +-
camel/providers/local/camel-local-folder.c | 51 +++--
camel/providers/local/camel-local-store.c | 152 ++++++++----
camel/providers/local/camel-local-store.h | 3 -
camel/providers/local/camel-maildir-store.c | 195 +++++++++-----
camel/providers/local/camel-mbox-store.c | 31 ++-
camel/providers/local/camel-mh-settings.c | 2 +-
camel/providers/local/camel-mh-settings.h | 4 +-
camel/providers/local/camel-mh-store.c | 90 ++++---
camel/providers/local/camel-spool-settings.c | 2 +-
camel/providers/local/camel-spool-settings.h | 4 +-
camel/providers/local/camel-spool-store.c | 286 ++++++++++++--------
camel/providers/nntp/camel-nntp-settings.c | 82 ++++++-
camel/providers/nntp/camel-nntp-store.c | 44 ++-
camel/providers/nntp/camel-nntp-summary.c | 26 ++-
camel/providers/pop3/camel-pop3-settings.c | 82 ++++++-
camel/providers/pop3/camel-pop3-store.c | 86 ++++---
camel/providers/smtp/camel-smtp-settings.c | 82 ++++++-
camel/providers/smtp/camel-smtp-transport.c | 40 ++-
configure.ac | 2 +-
.../libedata-cal/tmpl/e-cal-backend-sync.sgml | 10 +-
.../calendar/libedata-cal/tmpl/e-data-cal.sgml | 10 +-
docs/reference/camel/camel-docs.sgml | 1 +
docs/reference/camel/camel-sections.txt | 31 ++-
.../reference/camel/tmpl/camel-local-settings.sgml | 48 ++++
.../camel/tmpl/camel-network-settings.sgml | 92 +++++++
docs/reference/camel/tmpl/camel-service.sgml | 40 ++--
docs/reference/camel/tmpl/camel-unused.sgml | 22 ++
57 files changed, 2330 insertions(+), 812 deletions(-)
---
diff --git a/camel/Makefile.am b/camel/Makefile.am
index e849431..5d90f3a 100644
--- a/camel/Makefile.am
+++ b/camel/Makefile.am
@@ -79,6 +79,7 @@ libcamel_1_2_la_SOURCES = \
camel-internet-address.c \
camel-junk-filter.c \
camel-list-utils.c \
+ camel-local-settings.c \
camel-lock.c \
camel-medium.c \
camel-memchunk.c \
@@ -199,6 +200,7 @@ libcamelinclude_HEADERS = \
camel-internet-address.h \
camel-junk-filter.h \
camel-list-utils.h \
+ camel-local-settings.h \
camel-lock-client.h \
camel-lock-helper.h \
camel-lock.h \
diff --git a/camel/camel-local-settings.c b/camel/camel-local-settings.c
new file mode 100644
index 0000000..d55e4ac
--- /dev/null
+++ b/camel/camel-local-settings.c
@@ -0,0 +1,173 @@
+/*
+ * camel-local-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-local-settings.h"
+
+#include <string.h>
+
+#define CAMEL_LOCAL_SETTINGS_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), CAMEL_TYPE_LOCAL_SETTINGS, CamelLocalSettingsPrivate))
+
+struct _CamelLocalSettingsPrivate {
+ gchar *path;
+};
+
+enum {
+ PROP_0,
+ PROP_PATH
+};
+
+G_DEFINE_TYPE (
+ CamelLocalSettings,
+ camel_local_settings,
+ CAMEL_TYPE_STORE_SETTINGS)
+
+static void
+local_settings_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_PATH:
+ camel_local_settings_set_path (
+ CAMEL_LOCAL_SETTINGS (object),
+ g_value_get_string (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+local_settings_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_PATH:
+ g_value_set_string (
+ value,
+ camel_local_settings_get_path (
+ CAMEL_LOCAL_SETTINGS (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+local_settings_finalize (GObject *object)
+{
+ CamelLocalSettingsPrivate *priv;
+
+ priv = CAMEL_LOCAL_SETTINGS_GET_PRIVATE (object);
+
+ g_free (priv->path);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (camel_local_settings_parent_class)->finalize (object);
+}
+
+static void
+camel_local_settings_class_init (CamelLocalSettingsClass *class)
+{
+ GObjectClass *object_class;
+
+ g_type_class_add_private (class, sizeof (CamelLocalSettingsPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = local_settings_set_property;
+ object_class->get_property = local_settings_get_property;
+ object_class->finalize = local_settings_finalize;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_PATH,
+ g_param_spec_string (
+ "path",
+ "Path",
+ "File path to the local store",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+}
+
+static void
+camel_local_settings_init (CamelLocalSettings *settings)
+{
+ settings->priv = CAMEL_LOCAL_SETTINGS_GET_PRIVATE (settings);
+}
+
+/**
+ * camel_local_settings_get_path:
+ * @settings: a #CamelLocalSettings
+ *
+ * Returns the file path to the root of the local mail store.
+ *
+ * Returns: the file path to the local store
+ *
+ * Since: 3.4
+ **/
+const gchar *
+camel_local_settings_get_path (CamelLocalSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_LOCAL_SETTINGS (settings), NULL);
+
+ return settings->priv->path;
+}
+
+/**
+ * camel_local_settings_set_path:
+ * @settings: a #CamelLocalSettings
+ * @path: the file path to the local store
+ *
+ * Sets the file path to the root of the local mail store. Any
+ * trailing directory separator characters will be stripped off
+ * of the #CamelLocalSettings:path property.
+ *
+ * Since: 3.4
+ **/
+void
+camel_local_settings_set_path (CamelLocalSettings *settings,
+ const gchar *path)
+{
+ gsize length = 0;
+
+ g_return_if_fail (CAMEL_IS_LOCAL_SETTINGS (settings));
+
+ /* Exclude trailing directory separators. */
+ if (path != NULL) {
+ length = strlen (path);
+ while (length > 0) {
+ if (G_IS_DIR_SEPARATOR (path[length - 1]))
+ length--;
+ else
+ break;
+ }
+ }
+
+ g_free (settings->priv->path);
+ settings->priv->path = g_strndup (path, length);
+
+ g_object_notify (G_OBJECT (settings), "path");
+}
+
diff --git a/camel/camel-local-settings.h b/camel/camel-local-settings.h
new file mode 100644
index 0000000..31a7eb2
--- /dev/null
+++ b/camel/camel-local-settings.h
@@ -0,0 +1,78 @@
+/*
+ * camel-local-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/>
+ *
+ */
+
+#if !defined (__CAMEL_H_INSIDE__) && !defined (CAMEL_COMPILATION)
+#error "Only <camel/camel.h> can be included directly."
+#endif
+
+#ifndef CAMEL_LOCAL_SETTINGS_H
+#define CAMEL_LOCAL_SETTINGS_H
+
+#include <camel/camel-store-settings.h>
+
+/* Standard GObject macros */
+#define CAMEL_TYPE_LOCAL_SETTINGS \
+ (camel_local_settings_get_type ())
+#define CAMEL_LOCAL_SETTINGS(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), CAMEL_TYPE_LOCAL_SETTINGS, CamelLocalSettings))
+#define CAMEL_LOCAL_SETTINGS_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), CAMEL_TYPE_LOCAL_SETTINGS, CamelLocalSettingsClass))
+#define CAMEL_IS_LOCAL_SETTINGS(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), CAMEL_TYPE_LOCAL_SETTINGS))
+#define CAMEL_IS_LOCAL_SETTINGS_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), CAMEL_TYPE_LOCAL_SETTINGS))
+#define CAMEL_LOCAL_SETTINGS_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), CAMEL_TYPE_LOCAL_SETTINGS, CamelLocalSettingsClass))
+
+G_BEGIN_DECLS
+
+/**
+ * CamelLocalSettings:
+ *
+ * Contains only private data that should be read and manipulated using the
+ * functions below.
+ *
+ * Since: 3.4
+ **/
+typedef struct _CamelLocalSettings CamelLocalSettings;
+typedef struct _CamelLocalSettingsClass CamelLocalSettingsClass;
+typedef struct _CamelLocalSettingsPrivate CamelLocalSettingsPrivate;
+
+struct _CamelLocalSettings {
+ CamelStoreSettings parent;
+ CamelLocalSettingsPrivate *priv;
+};
+
+struct _CamelLocalSettingsClass {
+ CamelStoreSettingsClass parent_class;
+};
+
+GType camel_local_settings_get_type (void) G_GNUC_CONST;
+const gchar * camel_local_settings_get_path (CamelLocalSettings *settings);
+void camel_local_settings_set_path (CamelLocalSettings *settings,
+ const gchar *path);
+
+G_END_DECLS
+
+#endif /* CAMEL_LOCAL_SETTINGS_H */
+
diff --git a/camel/camel-network-service.c b/camel/camel-network-service.c
index 9a5f20b..687a387 100644
--- a/camel/camel-network-service.c
+++ b/camel/camel-network-service.c
@@ -40,33 +40,35 @@ network_service_connect_sync (CamelNetworkService *service,
GError **error)
{
CamelNetworkSecurityMethod method;
+ CamelNetworkSettings *network_settings;
CamelSettings *settings;
CamelSession *session;
CamelStream *stream;
- CamelURL *url;
const gchar *service_name;
+ const gchar *host;
guint16 default_port;
+ guint16 port;
gchar *socks_host;
gint socks_port;
gint status;
- url = camel_service_get_camel_url (CAMEL_SERVICE (service));
session = camel_service_get_session (CAMEL_SERVICE (service));
settings = camel_service_get_settings (CAMEL_SERVICE (service));
+ g_return_val_if_fail (CAMEL_IS_NETWORK_SETTINGS (settings), NULL);
- if (CAMEL_IS_NETWORK_SETTINGS (settings))
- g_object_get (settings, "security-method", &method, NULL);
- else
- method = CAMEL_NETWORK_SECURITY_METHOD_NONE;
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ method = camel_network_settings_get_security_method (network_settings);
+ host = camel_network_settings_get_host (network_settings);
+ port = camel_network_settings_get_port (network_settings);
service_name = camel_network_service_get_service_name (service, method);
default_port = camel_network_service_get_default_port (service, method);
/* If the URL explicitly gives a port number, make
* it override the service name and default port. */
- if (url->port > 0) {
+ if (port > 0) {
service_name = g_alloca (16);
- sprintf ((gchar *) service_name, "%d", url->port);
+ sprintf ((gchar *) service_name, "%u", port);
default_port = 0;
}
@@ -77,13 +79,13 @@ network_service_connect_sync (CamelNetworkService *service,
case CAMEL_NETWORK_SECURITY_METHOD_STARTTLS_ON_STANDARD_PORT:
stream = camel_tcp_stream_ssl_new_raw (
- session, url->host,
+ session, host,
CAMEL_TCP_STREAM_SSL_ENABLE_TLS);
break;
case CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT:
stream = camel_tcp_stream_ssl_new (
- session, url->host,
+ session, host,
CAMEL_TCP_STREAM_SSL_ENABLE_SSL2 |
CAMEL_TCP_STREAM_SSL_ENABLE_SSL3);
break;
@@ -92,7 +94,7 @@ network_service_connect_sync (CamelNetworkService *service,
g_return_val_if_reached (NULL);
}
- camel_session_get_socks_proxy (session, url->host, &socks_host, &socks_port);
+ camel_session_get_socks_proxy (session, host, &socks_host, &socks_port);
if (socks_host != NULL) {
camel_tcp_stream_set_socks_proxy (
@@ -102,12 +104,12 @@ network_service_connect_sync (CamelNetworkService *service,
}
status = camel_tcp_stream_connect (
- CAMEL_TCP_STREAM (stream), url->host,
+ CAMEL_TCP_STREAM (stream), host,
service_name, default_port, cancellable, error);
if (status == -1) {
g_prefix_error (
- error, _("Could not connect to %s: "), url->host);
+ error, _("Could not connect to %s: "), host);
g_object_unref (stream);
stream = NULL;
}
diff --git a/camel/camel-network-settings.c b/camel/camel-network-settings.c
index 84caef0..b62a099 100644
--- a/camel/camel-network-settings.c
+++ b/camel/camel-network-settings.c
@@ -21,7 +21,11 @@
#include <camel/camel-enumtypes.h>
#include <camel/camel-settings.h>
+#define AUTH_MECHANISM_KEY "CamelNetworkSettings:auth-mechanism"
+#define HOST_KEY "CamelNetworkSettings:host"
+#define PORT_KEY "CamelNetworkSettings:port"
#define SECURITY_METHOD_KEY "CamelNetworkSettings:security-method"
+#define USER_KEY "CamelNetworkSettings:user"
G_DEFINE_INTERFACE (
CamelNetworkSettings,
@@ -33,6 +37,39 @@ camel_network_settings_default_init (CamelNetworkSettingsInterface *interface)
{
g_object_interface_install_property (
interface,
+ g_param_spec_string (
+ "auth-mechanism",
+ "Auth Mechanism",
+ "Authentication mechanism name",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_interface_install_property (
+ interface,
+ g_param_spec_string (
+ "host",
+ "Host",
+ "Host name for the network service",
+ "localhost",
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_interface_install_property (
+ interface,
+ g_param_spec_uint (
+ "port",
+ "Port",
+ "Port number for the network service",
+ 0, G_MAXUINT16, 0,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_interface_install_property (
+ interface,
g_param_spec_enum (
"security-method",
"Security Method",
@@ -42,6 +79,163 @@ camel_network_settings_default_init (CamelNetworkSettingsInterface *interface)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
+
+ g_object_interface_install_property (
+ interface,
+ g_param_spec_string (
+ "user",
+ "User",
+ "User name for the network account",
+ g_get_user_name (),
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+}
+
+/**
+ * camel_network_settings_get_auth_mechanism:
+ * @settings: a #CamelNetworkSettings
+ *
+ * Returns the mechanism name used to authenticate to a network service.
+ * Often this refers to a SASL mechanism such as "LOGIN" or "GSSAPI".
+ *
+ * Returns: the authentication mechanism name
+ *
+ * Since: 3.4
+ **/
+const gchar *
+camel_network_settings_get_auth_mechanism (CamelNetworkSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_NETWORK_SETTINGS (settings), NULL);
+
+ return g_object_get_data (G_OBJECT (settings), AUTH_MECHANISM_KEY);
+}
+
+/**
+ * camel_network_settings_set_auth_mechanism:
+ * @settings: a #CamelNetworkSettings
+ * @auth_mechanism: an authentication mechanism name, or %NULL
+ *
+ * Sets the mechanism name used to authenticate to a network service.
+ * Often this refers to a SASL mechanism such as "LOGIN" or "GSSAPI".
+ * The #CamelNetworkSettings:auth-mechanism property is automatically
+ * stripped of leading and trailing whitespace.
+ *
+ * Since: 3.4
+ **/
+void
+camel_network_settings_set_auth_mechanism (CamelNetworkSettings *settings,
+ const gchar *auth_mechanism)
+{
+ gchar *stripped_auth_mechanism = NULL;
+
+ g_return_if_fail (CAMEL_IS_NETWORK_SETTINGS (settings));
+
+ /* Strip leading and trailing whitespace. */
+ if (auth_mechanism != NULL)
+ stripped_auth_mechanism =
+ g_strstrip (g_strdup (auth_mechanism));
+
+ g_object_set_data_full (
+ G_OBJECT (settings),
+ AUTH_MECHANISM_KEY,
+ stripped_auth_mechanism,
+ (GDestroyNotify) g_free);
+
+ g_object_notify (G_OBJECT (settings), "auth-mechanism");
+}
+
+/**
+ * camel_network_settings_get_host:
+ * @settings: a #CamelNetworkSettings
+ *
+ * Returns the host name used to authenticate to a network service.
+ *
+ * Returns: the host name of a network service
+ *
+ * Since: 3.4
+ **/
+const gchar *
+camel_network_settings_get_host (CamelNetworkSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_NETWORK_SETTINGS (settings), NULL);
+
+ return g_object_get_data (G_OBJECT (settings), HOST_KEY);
+}
+
+/**
+ * camel_network_settings_set_host:
+ * @settings: a #CamelNetworkSettings
+ * @host: a host name, or %NULL
+ *
+ * Sets the host name used to authenticate to a network service. The
+ * #CamelNetworkSettings:host property is automatically stripped of
+ * leading and trailing whitespace.
+ *
+ * Since: 3.4
+ **/
+void
+camel_network_settings_set_host (CamelNetworkSettings *settings,
+ const gchar *host)
+{
+ gchar *stripped_host = NULL;
+
+ g_return_if_fail (CAMEL_IS_NETWORK_SETTINGS (settings));
+
+ /* Strip leading and trailing whitespace. */
+ if (host != NULL)
+ stripped_host = g_strstrip (g_strdup (host));
+
+ g_object_set_data_full (
+ G_OBJECT (settings),
+ HOST_KEY, stripped_host,
+ (GDestroyNotify) g_free);
+
+ g_object_notify (G_OBJECT (settings), "host");
+}
+
+/**
+ * camel_network_settings_get_port:
+ * @settings: a #CamelNetworkSettings
+ *
+ * Returns the port number used to authenticate to a network service.
+ *
+ * Returns: the port number of a network service
+ *
+ * Since: 3.4
+ **/
+guint16
+camel_network_settings_get_port (CamelNetworkSettings *settings)
+{
+ gpointer data;
+
+ g_return_val_if_fail (CAMEL_IS_NETWORK_SETTINGS (settings), 0);
+
+ data = g_object_get_data (G_OBJECT (settings), PORT_KEY);
+
+ return (guint16) GPOINTER_TO_UINT (data);
+}
+
+/**
+ * camel_network_settings_set_port:
+ * @settings: a #CamelNetworkSettings
+ * @port: a port number
+ *
+ * Sets the port number used to authenticate to a network service.
+ *
+ * Since: 3.4
+ **/
+void
+camel_network_settings_set_port (CamelNetworkSettings *settings,
+ guint16 port)
+{
+ g_return_if_fail (CAMEL_IS_NETWORK_SETTINGS (settings));
+
+ g_object_set_data (
+ G_OBJECT (settings), PORT_KEY,
+ GUINT_TO_POINTER ((guint) port));
+
+ g_object_notify (G_OBJECT (settings), "port");
}
/**
@@ -93,3 +287,53 @@ camel_network_settings_set_security_method (CamelNetworkSettings *settings,
g_object_notify (G_OBJECT (settings), "security-method");
}
+
+/**
+ * camel_network_settings_get_user:
+ * @settings: a #CamelNetworkSettings
+ *
+ * Returns the user name used to authenticate to a network service.
+ *
+ * Returns: the user name of a network service
+ *
+ * Since: 3.4
+ **/
+const gchar *
+camel_network_settings_get_user (CamelNetworkSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_NETWORK_SETTINGS (settings), NULL);
+
+ return g_object_get_data (G_OBJECT (settings), USER_KEY);
+}
+
+/**
+ * camel_network_settings_set_user:
+ * @settings: a #CamelNetworkSettings
+ * @user: a user name, or %NULL
+ *
+ * Sets the user name used to authenticate to a network service. The
+ * #CamelNetworkSettings:user property is automatically stripped of
+ * leading and trailing whitespace.
+ *
+ * Since: 3.4
+ **/
+void
+camel_network_settings_set_user (CamelNetworkSettings *settings,
+ const gchar *user)
+{
+ gchar *stripped_user = NULL;
+
+ g_return_if_fail (CAMEL_IS_NETWORK_SETTINGS (settings));
+
+ /* Strip leading and trailing whitespace. */
+ if (user != NULL)
+ stripped_user = g_strstrip (g_strdup (user));
+
+ g_object_set_data_full (
+ G_OBJECT (settings),
+ USER_KEY, stripped_user,
+ (GDestroyNotify) g_free);
+
+ g_object_notify (G_OBJECT (settings), "user");
+}
+
diff --git a/camel/camel-network-settings.h b/camel/camel-network-settings.h
index 55e7bf6..1049e79 100644
--- a/camel/camel-network-settings.h
+++ b/camel/camel-network-settings.h
@@ -61,12 +61,32 @@ struct _CamelNetworkSettingsInterface {
GType camel_network_settings_get_type
(void) G_GNUC_CONST;
+const gchar * camel_network_settings_get_auth_mechanism
+ (CamelNetworkSettings *settings);
+void camel_network_settings_set_auth_mechanism
+ (CamelNetworkSettings *settings,
+ const gchar *auth_mechanism);
+const gchar * camel_network_settings_get_host
+ (CamelNetworkSettings *settings);
+void camel_network_settings_set_host
+ (CamelNetworkSettings *settings,
+ const gchar *host);
+guint16 camel_network_settings_get_port
+ (CamelNetworkSettings *settings);
+void camel_network_settings_set_port
+ (CamelNetworkSettings *settings,
+ guint16 port);
CamelNetworkSecurityMethod
camel_network_settings_get_security_method
(CamelNetworkSettings *settings);
void camel_network_settings_set_security_method
(CamelNetworkSettings *settings,
CamelNetworkSecurityMethod method);
+const gchar * camel_network_settings_get_user
+ (CamelNetworkSettings *settings);
+void camel_network_settings_set_user
+ (CamelNetworkSettings *settings,
+ const gchar *user);
G_END_DECLS
diff --git a/camel/camel-provider.c b/camel/camel-provider.c
index 751cf02..d687418 100644
--- a/camel/camel-provider.c
+++ b/camel/camel-provider.c
@@ -348,40 +348,35 @@ camel_provider_list (gboolean load)
/**
* camel_provider_get:
- * @url_string: the URL for the service whose provider you want
+ * @protocol: a #CamelProvider protocol name
* @error: return location for a #GError, or %NULL
*
- * This returns the CamelProvider that would be used to handle
- * @url_string, loading it in from disk if necessary.
+ * Returns the registered #CamelProvider for @protocol, loading it
+ * from disk if necessary. If no #CamelProvider can be found for
+ * @protocol, or the provider module fails to load, the function
+ * sets @error and returns %NULL.
*
- * Returns: the provider, or %NULL, in which case @error will be set.
+ * Returns: a #CamelProvider for %protocol, or %NULL
**/
CamelProvider *
-camel_provider_get (const gchar *url_string,
+camel_provider_get (const gchar *protocol,
GError **error)
{
CamelProvider *provider = NULL;
- gchar *protocol;
- gsize len;
- g_return_val_if_fail (url_string != NULL, NULL);
+ g_return_val_if_fail (protocol != NULL, NULL);
g_return_val_if_fail (provider_table != NULL, NULL);
- len = strcspn(url_string, ":");
- protocol = g_alloca (len + 1);
- memcpy (protocol, url_string, len);
- protocol[len] = 0;
-
LOCK ();
provider = g_hash_table_lookup (provider_table, protocol);
- if (!provider) {
- CamelProviderModule *m;
+ if (provider == NULL) {
+ CamelProviderModule *module;
- m = g_hash_table_lookup (module_table, protocol);
- if (m && !m->loaded) {
- m->loaded = 1;
- if (!camel_provider_load (m->path, error))
+ module = g_hash_table_lookup (module_table, protocol);
+ if (module != NULL && !module->loaded) {
+ module->loaded = 1;
+ if (!camel_provider_load (module->path, error))
goto fail;
}
provider = g_hash_table_lookup (provider_table, protocol);
diff --git a/camel/camel-provider.h b/camel/camel-provider.h
index 6fb4305..9b8a2e0 100644
--- a/camel/camel-provider.h
+++ b/camel/camel-provider.h
@@ -128,7 +128,7 @@ typedef struct {
typedef gint (*CamelProviderAutoDetectFunc) (CamelURL *url, GHashTable **auto_detected, GError **error);
typedef struct {
- /* Provider name used in CamelURLs. */
+ /* Provider protocol name (e.g. "imap", "smtp"). */
const gchar *protocol;
/* Provider name as used by people. (May be the same as protocol) */
diff --git a/camel/camel-sasl-cram-md5.c b/camel/camel-sasl-cram-md5.c
index ee3c106..0b171e1 100644
--- a/camel/camel-sasl-cram-md5.c
+++ b/camel/camel-sasl-cram-md5.c
@@ -30,6 +30,7 @@
#include <glib/gi18n-lib.h>
#include "camel-mime-utils.h"
+#include "camel-network-settings.h"
#include "camel-sasl-cram-md5.h"
#include "camel-service.h"
@@ -59,12 +60,14 @@ sasl_cram_md5_challenge_sync (CamelSasl *sasl,
GCancellable *cancellable,
GError **error)
{
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
CamelService *service;
GChecksum *checksum;
- CamelURL *url;
guint8 *digest;
gsize length;
const gchar *hex;
+ const gchar *user;
const gchar *password;
GByteArray *ret = NULL;
guchar ipad[64];
@@ -77,8 +80,12 @@ sasl_cram_md5_challenge_sync (CamelSasl *sasl,
service = camel_sasl_get_service (sasl);
- url = camel_service_get_camel_url (service);
- g_return_val_if_fail (url->user != NULL, NULL);
+ settings = camel_service_get_settings (service);
+ g_return_val_if_fail (CAMEL_IS_NETWORK_SETTINGS (settings), NULL);
+
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ user = camel_network_settings_get_user (network_settings);
+ g_return_val_if_fail (user != NULL, NULL);
password = camel_service_get_password (service);
g_return_val_if_fail (password != NULL, NULL);
@@ -122,7 +129,7 @@ sasl_cram_md5_challenge_sync (CamelSasl *sasl,
hex = g_checksum_get_string (checksum);
ret = g_byte_array_new ();
- g_byte_array_append (ret, (guint8 *) url->user, strlen (url->user));
+ g_byte_array_append (ret, (guint8 *) user, strlen (user));
g_byte_array_append (ret, (guint8 *) " ", 1);
g_byte_array_append (ret, (guint8 *) hex, strlen (hex));
diff --git a/camel/camel-sasl-digest-md5.c b/camel/camel-sasl-digest-md5.c
index dd0cdce..3f01046 100644
--- a/camel/camel-sasl-digest-md5.c
+++ b/camel/camel-sasl-digest-md5.c
@@ -35,6 +35,7 @@
#include "camel-iconv.h"
#include "camel-mime-utils.h"
#include "camel-net-utils.h"
+#include "camel-network-settings.h"
#ifdef G_OS_WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
@@ -800,8 +801,9 @@ sasl_digest_md5_challenge_sync (CamelSasl *sasl,
{
CamelSaslDigestMd5 *sasl_digest = CAMEL_SASL_DIGEST_MD5 (sasl);
struct _CamelSaslDigestMd5Private *priv = sasl_digest->priv;
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
CamelService *service;
- CamelURL *url;
struct _param *rspauth;
GByteArray *ret = NULL;
gboolean abort = FALSE;
@@ -811,6 +813,8 @@ sasl_digest_md5_challenge_sync (CamelSasl *sasl,
struct addrinfo *ai, hints;
const gchar *service_name;
const gchar *password;
+ const gchar *host;
+ const gchar *user;
/* Need to wait for the server */
if (!token)
@@ -819,8 +823,16 @@ sasl_digest_md5_challenge_sync (CamelSasl *sasl,
service = camel_sasl_get_service (sasl);
service_name = camel_sasl_get_service_name (sasl);
- url = camel_service_get_camel_url (service);
- g_return_val_if_fail (url->user != NULL, NULL);
+ settings = camel_service_get_settings (service);
+ g_return_val_if_fail (CAMEL_IS_NETWORK_SETTINGS (settings), NULL);
+
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
+ user = camel_network_settings_get_user (network_settings);
+ g_return_val_if_fail (user != NULL, NULL);
+
+ if (host == NULL)
+ host = "localhost";
password = camel_service_get_password (service);
g_return_val_if_fail (password != NULL, NULL);
@@ -858,8 +870,7 @@ sasl_digest_md5_challenge_sync (CamelSasl *sasl,
memset (&hints, 0, sizeof (hints));
hints.ai_flags = AI_CANONNAME;
ai = camel_getaddrinfo (
- url->host ? url->host : "localhost",
- NULL, &hints, cancellable, NULL);
+ host, NULL, &hints, cancellable, NULL);
if (ai && ai->ai_canonname)
ptr = ai->ai_canonname;
else
@@ -867,7 +878,7 @@ sasl_digest_md5_challenge_sync (CamelSasl *sasl,
priv->response = generate_response (
priv->challenge, ptr, service_name,
- url->user, password);
+ user, password);
if (ai)
camel_freeaddrinfo (ai);
ret = digest_response (priv->response);
diff --git a/camel/camel-sasl-gssapi.c b/camel/camel-sasl-gssapi.c
index 6783656..72d6665 100644
--- a/camel/camel-sasl-gssapi.c
+++ b/camel/camel-sasl-gssapi.c
@@ -40,6 +40,7 @@
#include <glib/gi18n-lib.h>
#include "camel-net-utils.h"
+#include "camel-network-settings.h"
#include "camel-sasl-gssapi.h"
#include "camel-session.h"
@@ -196,7 +197,7 @@ sasl_gssapi_finalize (GObject *object)
/* DBUS Specific code */
static gboolean
-send_dbus_message (gchar *name)
+send_dbus_message (const gchar *name)
{
gint success = FALSE;
GError *error = NULL;
@@ -266,8 +267,9 @@ sasl_gssapi_challenge_sync (CamelSasl *sasl,
GError **error)
{
CamelSaslGssapiPrivate *priv;
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
CamelService *service;
- CamelURL *url;
OM_uint32 major, minor, flags, time;
gss_buffer_desc inbuf, outbuf;
GByteArray *challenge = NULL;
@@ -278,21 +280,31 @@ sasl_gssapi_challenge_sync (CamelSasl *sasl,
gchar *str;
struct addrinfo *ai, hints;
const gchar *service_name;
+ const gchar *host;
+ const gchar *user;
priv = CAMEL_SASL_GSSAPI (sasl)->priv;
service = camel_sasl_get_service (sasl);
service_name = camel_sasl_get_service_name (sasl);
- url = camel_service_get_camel_url (service);
+ settings = camel_service_get_settings (service);
+ g_return_val_if_fail (CAMEL_IS_NETWORK_SETTINGS (settings), NULL);
+
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
+ user = camel_network_settings_get_user (network_settings);
+ g_return_val_if_fail (user != NULL, NULL);
+
+ if (host == NULL)
+ host = "localhost";
switch (priv->state) {
case GSSAPI_STATE_INIT:
memset (&hints, 0, sizeof (hints));
hints.ai_flags = AI_CANONNAME;
ai = camel_getaddrinfo (
- url->host ? url->host : "localhost",
- NULL, &hints, cancellable, error);
+ host, NULL, &hints, cancellable, error);
if (ai == NULL)
return NULL;
@@ -344,7 +356,7 @@ sasl_gssapi_challenge_sync (CamelSasl *sasl,
if (major == (OM_uint32) GSS_S_FAILURE &&
(minor == (OM_uint32) KRB5KRB_AP_ERR_TKT_EXPIRED ||
minor == (OM_uint32) KRB5KDC_ERR_NEVER_VALID) &&
- send_dbus_message (url->user))
+ send_dbus_message (user))
goto challenge;
gssapi_set_exception (major, minor, error);
@@ -398,11 +410,11 @@ sasl_gssapi_challenge_sync (CamelSasl *sasl,
return NULL;
}
- inbuf.length = 4 + strlen (url->user);
+ inbuf.length = 4 + strlen (user);
inbuf.value = str = g_malloc (inbuf.length);
memcpy (inbuf.value, outbuf.value, 4);
str[0] = DESIRED_SECURITY_LAYER;
- memcpy (str + 4, url->user, inbuf.length - 4);
+ memcpy (str + 4, user, inbuf.length - 4);
#ifndef HAVE_HEIMDAL_KRB5
gss_release_buffer (&minor, &outbuf);
diff --git a/camel/camel-sasl-login.c b/camel/camel-sasl-login.c
index d00ef07..dc3889a 100644
--- a/camel/camel-sasl-login.c
+++ b/camel/camel-sasl-login.c
@@ -28,6 +28,7 @@
#include <glib/gi18n-lib.h>
+#include "camel-network-settings.h"
#include "camel-sasl-login.h"
#include "camel-service.h"
@@ -59,17 +60,23 @@ sasl_login_challenge_sync (CamelSasl *sasl,
GError **error)
{
CamelSaslLoginPrivate *priv;
- GByteArray *buf = NULL;
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
CamelService *service;
- CamelURL *url;
+ GByteArray *buf = NULL;
const gchar *password;
+ const gchar *user;
priv = CAMEL_SASL_LOGIN (sasl)->priv;
service = camel_sasl_get_service (sasl);
- url = camel_service_get_camel_url (service);
- g_return_val_if_fail (url->user != NULL, NULL);
+ settings = camel_service_get_settings (service);
+ g_return_val_if_fail (CAMEL_IS_NETWORK_SETTINGS (settings), NULL);
+
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ user = camel_network_settings_get_user (network_settings);
+ g_return_val_if_fail (user != NULL, NULL);
password = camel_service_get_password (service);
g_return_val_if_fail (password != NULL, NULL);
@@ -81,7 +88,7 @@ sasl_login_challenge_sync (CamelSasl *sasl,
switch (priv->state) {
case LOGIN_USER:
buf = g_byte_array_new ();
- g_byte_array_append (buf, (guint8 *) url->user, strlen (url->user));
+ g_byte_array_append (buf, (guint8 *) user, strlen (user));
break;
case LOGIN_PASSWD:
buf = g_byte_array_new ();
diff --git a/camel/camel-sasl-ntlm.c b/camel/camel-sasl-ntlm.c
index 55718cd..092ebde 100644
--- a/camel/camel-sasl-ntlm.c
+++ b/camel/camel-sasl-ntlm.c
@@ -27,6 +27,7 @@
#include <glib/gi18n-lib.h>
+#include "camel-network-settings.h"
#include "camel-sasl-ntlm.h"
#include "camel-stream-process.h"
@@ -685,18 +686,24 @@ sasl_ntlm_challenge_sync (CamelSasl *sasl,
CamelSaslNTLM *ntlm = CAMEL_SASL_NTLM (sasl);
CamelSaslNTLMPrivate *priv = ntlm->priv;
#endif
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
CamelService *service;
- CamelURL *url;
GByteArray *ret;
- gchar *user;
guchar nonce[8], hash[21], lm_resp[24], nt_resp[24];
GString *domain = NULL;
const gchar *password;
+ const gchar *user;
+ const gchar *cp;
service = camel_sasl_get_service (sasl);
- url = camel_service_get_camel_url (service);
- g_return_val_if_fail (url->user != NULL, NULL);
+ settings = camel_service_get_settings (service);
+ g_return_val_if_fail (CAMEL_IS_NETWORK_SETTINGS (settings), NULL);
+
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ user = camel_network_settings_get_user (network_settings);
+ g_return_val_if_fail (user != NULL, NULL);
password = camel_service_get_password (service);
/* Assert a non-NULL password below, not here. */
@@ -799,12 +806,11 @@ sasl_ntlm_challenge_sync (CamelSasl *sasl,
}
/* If a domain is supplied as part of the username, use it */
- user = strchr (url->user, '\\');
- if (user) {
- domain = g_string_new_len (url->user, user - url->user);
- user++;
- } else
- user = url->user;
+ cp = strchr (user, '\\');
+ if (cp != NULL) {
+ domain = g_string_new_len (user, cp - user);
+ user = cp + 1;
+ }
/* Otherwise, fall back to the domain of the server, if possible */
if (domain == NULL)
@@ -857,11 +863,13 @@ sasl_ntlm_try_empty_password_sync (CamelSasl *sasl,
{
#ifndef G_OS_WIN32
CamelStream *stream = camel_stream_process_new ();
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
CamelService *service;
- CamelURL *url;
CamelSaslNTLM *ntlm = CAMEL_SASL_NTLM (sasl);
CamelSaslNTLMPrivate *priv = ntlm->priv;
- gchar *user;
+ const gchar *user;
+ const gchar *cp;
gchar buf[1024];
gsize s;
gchar *command;
@@ -871,22 +879,26 @@ sasl_ntlm_try_empty_password_sync (CamelSasl *sasl,
return FALSE;
service = camel_sasl_get_service (sasl);
- url = camel_service_get_camel_url (service);
- g_return_val_if_fail (url->user != NULL, FALSE);
- user = strchr (url->user, '\\');
- if (user) {
+ settings = camel_service_get_settings (service);
+ g_return_val_if_fail (CAMEL_IS_NETWORK_SETTINGS (settings), FALSE);
+
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ user = camel_network_settings_get_user (network_settings);
+ g_return_val_if_fail (user != NULL, FALSE);
+
+ cp = strchr (user, '\\');
+ if (cp != NULL) {
command = g_strdup_printf (
"%s --helper-protocol ntlmssp-client-1 "
"--use-cached-creds --username '%s' "
"--domain '%.*s'", NTLM_AUTH_HELPER,
- user + 1, (gint)(user - url->user),
- url->user);
+ cp + 1, (gint)(cp - user), user);
} else {
command = g_strdup_printf (
"%s --helper-protocol ntlmssp-client-1 "
"--use-cached-creds --username '%s'",
- NTLM_AUTH_HELPER, url->user);
+ NTLM_AUTH_HELPER, user);
}
ret = camel_stream_process_connect (
CAMEL_STREAM_PROCESS (stream), command, NULL, error);
diff --git a/camel/camel-sasl-plain.c b/camel/camel-sasl-plain.c
index 1731217..d80682c 100644
--- a/camel/camel-sasl-plain.c
+++ b/camel/camel-sasl-plain.c
@@ -28,6 +28,7 @@
#include <glib/gi18n-lib.h>
+#include "camel-network-settings.h"
#include "camel-sasl-plain.h"
#include "camel-service.h"
@@ -53,15 +54,21 @@ sasl_plain_challenge_sync (CamelSasl *sasl,
GCancellable *cancellable,
GError **error)
{
- GByteArray *buf = NULL;
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
CamelService *service;
- CamelURL *url;
+ GByteArray *buf = NULL;
const gchar *password;
+ const gchar *user;
service = camel_sasl_get_service (sasl);
- url = camel_service_get_camel_url (service);
- g_return_val_if_fail (url->user != NULL, NULL);
+ settings = camel_service_get_settings (service);
+ g_return_val_if_fail (CAMEL_IS_NETWORK_SETTINGS (settings), NULL);
+
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ user = camel_network_settings_get_user (network_settings);
+ g_return_val_if_fail (user != NULL, NULL);
password = camel_service_get_password (service);
g_return_val_if_fail (password != NULL, NULL);
@@ -69,7 +76,7 @@ sasl_plain_challenge_sync (CamelSasl *sasl,
/* FIXME: make sure these are "UTF8-SAFE" */
buf = g_byte_array_new ();
g_byte_array_append (buf, (guint8 *) "", 1);
- g_byte_array_append (buf, (guint8 *) url->user, strlen (url->user));
+ g_byte_array_append (buf, (guint8 *) user, strlen (user));
g_byte_array_append (buf, (guint8 *) "", 1);
g_byte_array_append (buf, (guint8 *) password, strlen (password));
diff --git a/camel/camel-service.c b/camel/camel-service.c
index fe60401..d05ab53 100644
--- a/camel/camel-service.c
+++ b/camel/camel-service.c
@@ -36,6 +36,8 @@
#include <glib/gi18n-lib.h>
#include "camel-debug.h"
+#include "camel-local-settings.h"
+#include "camel-network-settings.h"
#include "camel-operation.h"
#include "camel-service.h"
#include "camel-session.h"
@@ -54,7 +56,6 @@ struct _CamelServicePrivate {
CamelSettings *settings;
CamelProvider *provider;
- CamelURL *url;
gchar *display_name;
gchar *user_data_dir;
@@ -82,8 +83,7 @@ enum {
PROP_PROVIDER,
PROP_SESSION,
PROP_SETTINGS,
- PROP_UID,
- PROP_URL
+ PROP_UID
};
/* Forward Declarations */
@@ -120,7 +120,7 @@ service_find_old_data_dir (CamelService *service)
provider = camel_service_get_provider (service);
session = camel_service_get_session (service);
- url = camel_service_get_camel_url (service);
+ url = camel_service_new_camel_url (service);
allows_host = CAMEL_PROVIDER_ALLOWS (provider, CAMEL_URL_PART_HOST);
allows_user = CAMEL_PROVIDER_ALLOWS (provider, CAMEL_URL_PART_USER);
@@ -183,6 +183,8 @@ service_find_old_data_dir (CamelService *service)
old_data_dir = NULL;
}
+ camel_url_free (url);
+
return old_data_dir;
}
@@ -220,16 +222,6 @@ service_set_uid (CamelService *service,
}
static void
-service_set_url (CamelService *service,
- CamelURL *url)
-{
- g_return_if_fail (url != NULL);
- g_return_if_fail (service->priv->url == NULL);
-
- service->priv->url = camel_url_copy (url);
-}
-
-static void
service_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -271,12 +263,6 @@ service_set_property (GObject *object,
CAMEL_SERVICE (object),
g_value_get_string (value));
return;
-
- case PROP_URL:
- service_set_url (
- CAMEL_SERVICE (object),
- g_value_get_boxed (value));
- return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -324,12 +310,6 @@ service_get_property (GObject *object,
value, camel_service_get_uid (
CAMEL_SERVICE (object)));
return;
-
- case PROP_URL:
- g_value_set_boxed (
- value, camel_service_get_url (
- CAMEL_SERVICE (object)));
- return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -368,9 +348,6 @@ service_finalize (GObject *object)
CAMEL_SERVICE_GET_CLASS (object)->disconnect_sync (
CAMEL_SERVICE (object), TRUE, NULL, NULL);
- if (priv->url != NULL)
- camel_url_free (priv->url);
-
g_free (priv->display_name);
g_free (priv->user_data_dir);
g_free (priv->user_cache_dir);
@@ -589,69 +566,10 @@ service_initable_init (GInitable *initable,
GCancellable *cancellable,
GError **error)
{
- CamelProvider *provider;
- CamelService *service;
- CamelURL *url;
- gboolean success = FALSE;
- const gchar *new_data_dir;
- gchar *old_data_dir;
- gchar *url_string;
-
- service = CAMEL_SERVICE (initable);
- url = camel_service_get_camel_url (service);
- provider = camel_service_get_provider (service);
-
- url_string = camel_url_to_string (url, 0);
-
- if (CAMEL_PROVIDER_NEEDS (provider, CAMEL_URL_PART_USER)) {
- if (url->user == NULL || *url->user == '\0') {
- g_set_error (
- error, CAMEL_SERVICE_ERROR,
- CAMEL_SERVICE_ERROR_URL_INVALID,
- _("URL '%s' needs a user component"),
- url_string);
- goto exit;
- }
- }
-
- if (CAMEL_PROVIDER_NEEDS (provider, CAMEL_URL_PART_HOST)) {
- if (url->host == NULL || *url->host == '\0') {
- g_set_error (
- error, CAMEL_SERVICE_ERROR,
- CAMEL_SERVICE_ERROR_URL_INVALID,
- _("URL '%s' needs a host component"),
- url_string);
- goto exit;
- }
- }
-
- if (CAMEL_PROVIDER_NEEDS (provider, CAMEL_URL_PART_PATH)) {
- if (url->path == NULL || *url->path == '\0') {
- g_set_error (
- error, CAMEL_SERVICE_ERROR,
- CAMEL_SERVICE_ERROR_URL_INVALID,
- _("URL '%s' needs a path component"),
- url_string);
- goto exit;
- }
- }
-
- new_data_dir = camel_service_get_user_data_dir (service);
- old_data_dir = service_find_old_data_dir (service);
+ /* Nothing to do here, but we may need add something in the future.
+ * For now this is a placeholder so subclasses can safely chain up. */
- /* If the old data directory name exists, try renaming
- * it to the new data directory. Failure is non-fatal. */
- if (old_data_dir != NULL) {
- g_rename (old_data_dir, new_data_dir);
- g_free (old_data_dir);
- }
-
- success = TRUE;
-
-exit:
- g_free (url_string);
-
- return success;
+ return TRUE;
}
static void
@@ -750,18 +668,6 @@ camel_service_class_init (CamelServiceClass *class)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
- PROP_URL,
- g_param_spec_boxed (
- "url",
- "URL",
- "The CamelURL for the service",
- CAMEL_TYPE_URL,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
}
static void
@@ -795,27 +701,89 @@ camel_service_error_quark (void)
}
/**
- * camel_service_cancel_connect:
+ * camel_service_migrate_files:
* @service: a #CamelService
*
- * If @service is currently attempting to connect to or disconnect
- * from a server, this causes it to stop and fail. Otherwise it is a
- * no-op.
+ * Performs any necessary file migrations for @service. This should be
+ * called after installing or configuring the @service's #CamelSettings,
+ * since it requires building a URL string for @service.
+ *
+ * Since: 3.4
**/
void
-camel_service_cancel_connect (CamelService *service)
+camel_service_migrate_files (CamelService *service)
{
- CamelServiceClass *class;
+ const gchar *new_data_dir;
+ gchar *old_data_dir;
g_return_if_fail (CAMEL_IS_SERVICE (service));
- class = CAMEL_SERVICE_GET_CLASS (service);
- g_return_if_fail (class->cancel_connect != NULL);
+ new_data_dir = camel_service_get_user_data_dir (service);
+ old_data_dir = service_find_old_data_dir (service);
- camel_service_lock (service, CAMEL_SERVICE_CONNECT_OP_LOCK);
- if (service->priv->connect_op)
- class->cancel_connect (service);
- camel_service_unlock (service, CAMEL_SERVICE_CONNECT_OP_LOCK);
+ /* If the old data directory name exists, try renaming
+ * it to the new data directory. Failure is non-fatal. */
+ if (old_data_dir != NULL) {
+ g_rename (old_data_dir, new_data_dir);
+ g_free (old_data_dir);
+ }
+}
+
+/**
+ * camel_service_new_camel_url:
+ * @service: a #CamelService
+ *
+ * Returns a new #CamelURL representing @service.
+ * Free the returned #CamelURL with camel_url_free().
+ *
+ * Returns: a new #CamelURL
+ *
+ * Since: 3.2
+ **/
+CamelURL *
+camel_service_new_camel_url (CamelService *service)
+{
+ CamelURL *url;
+ CamelProvider *provider;
+ CamelSettings *settings;
+ const gchar *host = NULL;
+ const gchar *user = NULL;
+ const gchar *path = NULL;
+ guint16 port = 0;
+
+ g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL);
+
+ provider = camel_service_get_provider (service);
+ settings = camel_service_get_settings (service);
+
+ g_return_val_if_fail (provider != NULL, NULL);
+
+ /* Allocate as camel_url_new_with_base() does. */
+ url = g_new0 (CamelURL, 1);
+
+ if (CAMEL_IS_NETWORK_SETTINGS (settings)) {
+ CamelNetworkSettings *network_settings;
+
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
+ port = camel_network_settings_get_port (network_settings);
+ user = camel_network_settings_get_user (network_settings);
+ }
+
+ if (CAMEL_IS_LOCAL_SETTINGS (settings)) {
+ CamelLocalSettings *local_settings;
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
+ }
+
+ camel_url_set_protocol (url, provider->protocol);
+ camel_url_set_host (url, host);
+ camel_url_set_port (url, port);
+ camel_url_set_user (url, user);
+ camel_url_set_path (url, path);
+
+ return url;
}
/**
@@ -973,7 +941,6 @@ camel_service_get_name (CamelService *service,
CamelServiceClass *class;
g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL);
- g_return_val_if_fail (service->priv->url, NULL);
class = CAMEL_SERVICE_GET_CLASS (service);
g_return_val_if_fail (class->get_name != NULL, NULL);
@@ -1070,7 +1037,6 @@ camel_service_set_settings (CamelService *service,
class->settings_type,
CAMEL_TYPE_SETTINGS));
settings = g_object_new (class->settings_type, NULL);
- camel_settings_load_from_url (settings, camel_service_get_camel_url (service));
}
if (service->priv->settings != NULL)
@@ -1100,42 +1066,27 @@ camel_service_get_uid (CamelService *service)
}
/**
- * camel_service_get_camel_url:
- * @service: a #CamelService
- *
- * Returns the #CamelURL representing @service.
- *
- * Returns: the #CamelURL representing @service
- *
- * Since: 3.2
- **/
-CamelURL *
-camel_service_get_camel_url (CamelService *service)
-{
- g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL);
-
- return service->priv->url;
-}
-
-/**
- * camel_service_get_url:
+ * camel_service_cancel_connect:
* @service: a #CamelService
*
- * Gets the URL representing @service. The returned URL must be
- * freed when it is no longer needed.
- *
- * Returns: the URL representing @service
+ * If @service is currently attempting to connect to or disconnect
+ * from a server, this causes it to stop and fail. Otherwise it is a
+ * no-op.
**/
-gchar *
-camel_service_get_url (CamelService *service)
+void
+camel_service_cancel_connect (CamelService *service)
{
- CamelURL *url;
+ CamelServiceClass *class;
- g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL);
+ g_return_if_fail (CAMEL_IS_SERVICE (service));
- url = camel_service_get_camel_url (service);
+ class = CAMEL_SERVICE_GET_CLASS (service);
+ g_return_if_fail (class->cancel_connect != NULL);
- return camel_url_to_string (url, 0);
+ camel_service_lock (service, CAMEL_SERVICE_CONNECT_OP_LOCK);
+ if (service->priv->connect_op)
+ class->cancel_connect (service);
+ camel_service_unlock (service, CAMEL_SERVICE_CONNECT_OP_LOCK);
}
/**
@@ -1158,7 +1109,6 @@ camel_service_connect_sync (CamelService *service,
g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE);
g_return_val_if_fail (service->priv->session != NULL, FALSE);
- g_return_val_if_fail (service->priv->url != NULL, FALSE);
class = CAMEL_SERVICE_GET_CLASS (service);
g_return_val_if_fail (class->connect_sync != NULL, FALSE);
diff --git a/camel/camel-service.h b/camel/camel-service.h
index 7020471..3947e27 100644
--- a/camel/camel-service.h
+++ b/camel/camel-service.h
@@ -160,6 +160,8 @@ typedef struct {
GType camel_service_get_type (void);
GQuark camel_service_error_quark (void) G_GNUC_CONST;
+void camel_service_migrate_files (CamelService *service);
+CamelURL * camel_service_new_camel_url (CamelService *service);
const gchar * camel_service_get_display_name (CamelService *service);
void camel_service_set_display_name (CamelService *service,
const gchar *display_name);
@@ -178,8 +180,6 @@ CamelSettings * camel_service_get_settings (CamelService *service);
void camel_service_set_settings (CamelService *service,
CamelSettings *settings);
const gchar * camel_service_get_uid (CamelService *service);
-CamelURL * camel_service_get_camel_url (CamelService *service);
-gchar * camel_service_get_url (CamelService *service);
void camel_service_cancel_connect (CamelService *service);
gboolean camel_service_connect_sync (CamelService *service,
GError **error);
diff --git a/camel/camel-session.c b/camel/camel-session.c
index 983ae39..75d35f9 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -360,11 +360,10 @@ session_finalize (GObject *object)
static CamelService *
session_add_service (CamelSession *session,
const gchar *uid,
- const gchar *url_string,
+ const gchar *protocol,
CamelProviderType type,
GError **error)
{
- CamelURL *url;
CamelService *service;
CamelProvider *provider;
GType service_type = G_TYPE_INVALID;
@@ -373,12 +372,8 @@ session_add_service (CamelSession *session,
if (CAMEL_IS_SERVICE (service))
return service;
- url = camel_url_new (url_string, error);
- if (url == NULL)
- return NULL;
-
/* Try to find a suitable CamelService subclass. */
- provider = camel_provider_get (url->protocol, error);
+ provider = camel_provider_get (protocol, error);
if (provider != NULL)
service_type = provider->object_types[type];
@@ -387,8 +382,7 @@ session_add_service (CamelSession *session,
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_URL_INVALID,
_("No provider available for protocol '%s'"),
- url->protocol);
- camel_url_free (url);
+ protocol);
return NULL;
}
@@ -397,20 +391,14 @@ session_add_service (CamelSession *session,
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_INVALID,
_("Invalid GType registered for protocol '%s'"),
- url->protocol);
- camel_url_free (url);
+ protocol);
return NULL;
}
- /* If the provider does not use paths but the URL contains one,
- * ignore it. */
- if (!CAMEL_PROVIDER_ALLOWS (provider, CAMEL_URL_PART_PATH))
- camel_url_set_path (url, NULL);
-
service = g_initable_new (
service_type, NULL, error,
"provider", provider, "session",
- session, "uid", uid, "url", url, NULL);
+ session, "uid", uid, NULL);
/* The hash table takes ownership of the new CamelService. */
if (service != NULL) {
@@ -423,8 +411,6 @@ session_add_service (CamelSession *session,
camel_session_unlock (session, CAMEL_SESSION_SESSION_LOCK);
}
- camel_url_free (url);
-
return service;
}
@@ -772,23 +758,22 @@ camel_session_get_user_cache_dir (CamelSession *session)
* camel_session_add_service:
* @session: a #CamelSession
* @uid: a unique identifier string
- * @uri_string: a URI string describing the service
- * @type: the provider type (#CAMEL_PROVIDER_STORE or
- * #CAMEL_PROVIDER_TRANSPORT) to get, since some URLs may be able to
- * specify either type
+ * @protocol: the service protocol
+ * @type: the service type
* @error: return location for a #GError, or %NULL
*
* Instantiates a new #CamelService for @session. The @uid identifies the
- * service for future lookup. The @uri_string describes which provider to
- * use, authentication details, provider-specific options, etc. The @type
+ * service for future lookup. The @protocol indicates which #CamelProvider
+ * holds the #GType of the #CamelService subclass to instantiate. The @type
* explicitly designates the service as a #CamelStore or #CamelTransport.
*
* If the given @uid has already been added, the existing #CamelService
* with that @uid is returned regardless of whether it agrees with the
- * given @uri_string and @type.
+ * given @protocol and @type.
*
- * If the @uri_string is invalid or no #CamelProvider is available to
- * handle the @uri_string, the function sets @error and returns %NULL.
+ * If no #CamelProvider is available to handle the given @protocol, or
+ * if the #CamelProvider does not specify a valid #GType for @type, the
+ * function sets @error and returns %NULL.
*
* Returns: a #CamelService instance, or %NULL
*
@@ -797,7 +782,7 @@ camel_session_get_user_cache_dir (CamelSession *session)
CamelService *
camel_session_add_service (CamelSession *session,
const gchar *uid,
- const gchar *uri_string,
+ const gchar *protocol,
CamelProviderType type,
GError **error)
{
@@ -806,12 +791,12 @@ camel_session_add_service (CamelSession *session,
g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
g_return_val_if_fail (uid != NULL, NULL);
- g_return_val_if_fail (uri_string != NULL, NULL);
+ g_return_val_if_fail (protocol != NULL, NULL);
class = CAMEL_SESSION_GET_CLASS (session);
g_return_val_if_fail (class->add_service != NULL, NULL);
- service = class->add_service (session, uid, uri_string, type, error);
+ service = class->add_service (session, uid, protocol, type, error);
CAMEL_CHECK_GERROR (session, add_service, service != NULL, error);
return service;
@@ -911,10 +896,13 @@ camel_session_get_service_by_url (CamelSession *session,
CamelProvider *provider;
CamelService *service;
CamelURL *service_url;
+ gboolean url_equal;
service = CAMEL_SERVICE (iter->data);
provider = camel_service_get_provider (service);
- service_url = camel_service_get_camel_url (service);
+
+ if (provider == NULL)
+ continue;
if (provider == NULL)
continue;
@@ -922,7 +910,11 @@ camel_session_get_service_by_url (CamelSession *session,
if (provider->url_equal == NULL)
continue;
- if (!provider->url_equal (url, service_url))
+ service_url = camel_service_new_camel_url (service);
+ url_equal = provider->url_equal (url, service_url);
+ camel_url_free (service_url);
+
+ if (!url_equal)
continue;
switch (type) {
diff --git a/camel/camel-session.h b/camel/camel-session.h
index d53ce44..23e955f 100644
--- a/camel/camel-session.h
+++ b/camel/camel-session.h
@@ -107,7 +107,7 @@ struct _CamelSessionClass {
CamelService * (*add_service) (CamelSession *session,
const gchar *uid,
- const gchar *url_string,
+ const gchar *protocol,
CamelProviderType type,
GError **error);
gchar * (*get_password) (CamelSession *session,
diff --git a/camel/camel-settings.c b/camel/camel-settings.c
index e33b75a..51d7dc4 100644
--- a/camel/camel-settings.c
+++ b/camel/camel-settings.c
@@ -20,6 +20,10 @@
#include <stdlib.h>
+/* Needed for CamelSettings <--> CamelURL conversions. */
+#include "camel-local-settings.h"
+#include "camel-network-settings.h"
+
G_DEFINE_TYPE (CamelSettings, camel_settings, G_TYPE_OBJECT)
static GParamSpec **
@@ -250,6 +254,26 @@ camel_settings_load_from_url (CamelSettings *settings,
g_object_freeze_notify (G_OBJECT (settings));
+ /* Some CamelNetworkSettings properties are read directly
+ * from the CamelURL struct instead of from parameters. */
+
+ if (CAMEL_IS_NETWORK_SETTINGS (settings))
+ g_object_set (
+ settings,
+ "host", url->host,
+ "port", url->port,
+ "user", url->user,
+ NULL);
+
+ /* Some CamelLocalSettings properties are read directly
+ * from the CamelURL struct instead of from parameters. */
+
+ if (CAMEL_IS_LOCAL_SETTINGS (settings))
+ g_object_set (
+ settings,
+ "path", url->path,
+ NULL);
+
for (ii = 0; ii < n_properties; ii++) {
GParamSpec *pspec = properties[ii];
const gchar *string;
@@ -417,6 +441,40 @@ camel_settings_save_to_url (CamelSettings *settings,
G_OBJECT (settings),
pspec->name, &pvalue);
+ /* Some CamelNetworkSettings properties are put directly
+ * in the CamelURL struct instead of in parameters. */
+
+ if (g_strcmp0 (pspec->name, "host") == 0) {
+ const gchar *host = g_value_get_string (&pvalue);
+ camel_url_set_host (url, host);
+ g_value_unset (&pvalue);
+ continue;
+ }
+
+ if (g_strcmp0 (pspec->name, "port") == 0) {
+ guint port = g_value_get_uint (&pvalue);
+ camel_url_set_port (url, port);
+ g_value_unset (&pvalue);
+ continue;
+ }
+
+ if (g_strcmp0 (pspec->name, "user") == 0) {
+ const gchar *user = g_value_get_string (&pvalue);
+ camel_url_set_user (url, user);
+ g_value_unset (&pvalue);
+ continue;
+ }
+
+ /* Some CamelLocalSettings properties are put directly
+ * in the CamelURL struct instead of in parameters. */
+
+ if (g_strcmp0 (pspec->name, "path") == 0) {
+ const gchar *path = g_value_get_string (&pvalue);
+ camel_url_set_path (url, path);
+ g_value_unset (&pvalue);
+ continue;
+ }
+
/* If the property value matches the default value,
* remove the corresponding URL parameter so we keep
* the URL string to a minimum. */
diff --git a/camel/camel-vee-folder.c b/camel/camel-vee-folder.c
index 93c95f9..caf650c 100644
--- a/camel/camel-vee-folder.c
+++ b/camel/camel-vee-folder.c
@@ -1426,8 +1426,6 @@ vee_folder_synchronize_sync (CamelFolder *folder,
}
camel_vee_folder_unlock (vf, CAMEL_VEE_FOLDER_SUBFOLDER_LOCK);
- camel_object_state_write (CAMEL_OBJECT (vf));
-
return TRUE;
}
@@ -2079,7 +2077,6 @@ camel_vee_folder_new (CamelStore *parent_store,
guint32 flags)
{
CamelVeeFolder *vf;
- gchar *tmp;
g_return_val_if_fail (CAMEL_IS_STORE (parent_store), NULL);
g_return_val_if_fail (full != NULL, NULL);
@@ -2103,18 +2100,6 @@ camel_vee_folder_new (CamelStore *parent_store,
d (printf ("returning folder %s %p, count = %d\n", full, vf, camel_folder_get_message_count ((CamelFolder *)vf)));
- if (vf) {
- CamelObject *object = CAMEL_OBJECT (vf);
- CamelURL *url;
-
- url = camel_service_get_camel_url (CAMEL_SERVICE (parent_store));
- tmp = g_strdup_printf ("%s/%s.cmeta", url->path, full);
- camel_object_set_state_filename (object, tmp);
- g_free (tmp);
- if (camel_object_state_read (object) == -1) {
- /* setup defaults: we have none currently */
- }
- }
return (CamelFolder *) vf;
}
@@ -2358,7 +2343,7 @@ camel_vee_folder_hash_folder (CamelFolder *folder,
gsize length;
gint state = 0, save = 0;
const gchar *full_name;
- gchar *tmp;
+ const gchar *uid;
gint i;
length = g_checksum_type_get_length (G_CHECKSUM_MD5);
@@ -2366,9 +2351,8 @@ camel_vee_folder_hash_folder (CamelFolder *folder,
checksum = g_checksum_new (G_CHECKSUM_MD5);
parent_store = camel_folder_get_parent_store (folder);
- tmp = camel_service_get_url (CAMEL_SERVICE (parent_store));
- g_checksum_update (checksum, (guchar *) tmp, -1);
- g_free (tmp);
+ uid = camel_service_get_uid (CAMEL_SERVICE (parent_store));
+ g_checksum_update (checksum, (guchar *) uid, -1);
full_name = camel_folder_get_full_name (folder);
g_checksum_update (checksum, (guchar *) full_name, -1);
diff --git a/camel/camel.h b/camel/camel.h
index ab674c7..c110694 100644
--- a/camel/camel.h
+++ b/camel/camel.h
@@ -55,6 +55,7 @@
#include <camel/camel-internet-address.h>
#include <camel/camel-junk-filter.h>
#include <camel/camel-list-utils.h>
+#include <camel/camel-local-settings.h>
#include <camel/camel-lock.h>
#include <camel/camel-lock-client.h>
#include <camel/camel-lock-helper.h>
diff --git a/camel/providers/imap/camel-imap-command.c b/camel/providers/imap/camel-imap-command.c
index fe16972..03d1506 100644
--- a/camel/providers/imap/camel-imap-command.c
+++ b/camel/providers/imap/camel-imap-command.c
@@ -337,11 +337,25 @@ camel_imap_command_response (CamelImapStore *store,
GCancellable *cancellable,
GError **error)
{
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
+ CamelService *service;
+ CamelSession *session;
CamelImapResponseType type;
+ const gchar *host;
+ const gchar *user;
gchar *respbuf;
+ service = CAMEL_SERVICE (store);
+ session = camel_service_get_session (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 (camel_imap_store_readline (store, &respbuf, cancellable, error) < 0) {
- camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+ camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
return CAMEL_IMAP_RESPONSE_ERROR;
}
@@ -357,8 +371,7 @@ camel_imap_command_response (CamelImapStore *store,
err = g_strerror (104);
/* Connection was lost, no more data to fetch */
- camel_service_disconnect_sync (
- CAMEL_SERVICE (store), FALSE, NULL);
+ camel_service_disconnect_sync (service, FALSE, NULL);
g_set_error (
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_UNAVAILABLE,
@@ -379,21 +392,14 @@ camel_imap_command_response (CamelImapStore *store,
else if (!g_ascii_strncasecmp (respbuf, "* OK [ALERT]", 12)
|| !g_ascii_strncasecmp (respbuf, "* NO [ALERT]", 12)
|| !g_ascii_strncasecmp (respbuf, "* BAD [ALERT]", 13)) {
- CamelService *service;
- CamelSession *session;
- CamelURL *url;
gchar *msg;
/* for imap ALERT codes, account user host */
/* we might get a ']' from a BAD response since we +12,
* but who cares? */
- service = CAMEL_SERVICE (store);
- url = camel_service_get_camel_url (service);
- session = camel_service_get_session (service);
-
msg = g_strdup_printf (
_("Alert from IMAP server %s %s:\n%s"),
- url->user, url->host, respbuf + 12);
+ user, host, respbuf + 12);
camel_session_alert_user (
session, CAMEL_SESSION_ALERT_WARNING,
msg, FALSE);
@@ -412,7 +418,7 @@ camel_imap_command_response (CamelImapStore *store,
if (type == CAMEL_IMAP_RESPONSE_ERROR ||
type == CAMEL_IMAP_RESPONSE_TAGGED)
- camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+ camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
return type;
}
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index 97b05f1..ac48311 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -245,19 +245,29 @@ imap_folder_finalize (GObject *object)
static void
imap_folder_constructed (GObject *object)
{
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
+ CamelService *service;
CamelFolder *folder;
CamelStore *parent_store;
- CamelURL *url;
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);
}
@@ -1503,20 +1513,23 @@ host_ends_with (const gchar *host,
static gboolean
is_google_account (CamelStore *store)
{
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
CamelService *service;
- CamelURL *url;
+ const gchar *host;
g_return_val_if_fail (store != NULL, FALSE);
g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE);
service = CAMEL_SERVICE (store);
- g_return_val_if_fail (service != NULL, FALSE);
+ settings = camel_service_get_settings (service);
- url = camel_service_get_camel_url (service);
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
- return url != NULL && url->host != NULL && (
- host_ends_with (url->host, "gmail.com") ||
- host_ends_with (url->host, "googlemail.com"));
+ return host != NULL && (
+ host_ends_with (host, "gmail.com") ||
+ host_ends_with (host, "googlemail.com"));
}
static void
diff --git a/camel/providers/imap/camel-imap-settings.c b/camel/providers/imap/camel-imap-settings.c
index f5713b7..4cfcc59 100644
--- a/camel/providers/imap/camel-imap-settings.c
+++ b/camel/providers/imap/camel-imap-settings.c
@@ -44,17 +44,21 @@ struct _CamelImapSettingsPrivate {
enum {
PROP_0,
+ PROP_AUTH_MECHANISM,
PROP_CHECK_ALL,
PROP_CHECK_SUBSCRIBED,
PROP_FETCH_HEADERS,
PROP_FETCH_HEADERS_EXTRA,
PROP_FILTER_JUNK,
PROP_FILTER_JUNK_INBOX,
+ PROP_HOST,
PROP_NAMESPACE,
+ PROP_PORT,
PROP_REAL_JUNK_PATH,
PROP_REAL_TRASH_PATH,
PROP_SECURITY_METHOD,
PROP_SHELL_COMMAND,
+ PROP_USER,
PROP_USE_NAMESPACE,
PROP_USE_REAL_JUNK_PATH,
PROP_USE_REAL_TRASH_PATH,
@@ -76,6 +80,12 @@ imap_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_imap_settings_set_check_all (
CAMEL_IMAP_SETTINGS (object),
@@ -112,12 +122,24 @@ imap_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_NAMESPACE:
camel_imap_settings_set_namespace (
CAMEL_IMAP_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_REAL_JUNK_PATH:
camel_imap_settings_set_real_junk_path (
CAMEL_IMAP_SETTINGS (object),
@@ -142,6 +164,12 @@ imap_settings_set_property (GObject *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;
+
case PROP_USE_NAMESPACE:
camel_imap_settings_set_use_namespace (
CAMEL_IMAP_SETTINGS (object),
@@ -183,6 +211,13 @@ imap_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,
@@ -225,6 +260,13 @@ imap_settings_get_property (GObject *object,
CAMEL_IMAP_SETTINGS (object)));
return;
+ case PROP_HOST:
+ g_value_set_string (
+ value,
+ camel_network_settings_get_host (
+ CAMEL_NETWORK_SETTINGS (object)));
+ return;
+
case PROP_NAMESPACE:
g_value_set_string (
value,
@@ -232,6 +274,13 @@ imap_settings_get_property (GObject *object,
CAMEL_IMAP_SETTINGS (object)));
return;
+ case PROP_PORT:
+ g_value_set_uint (
+ value,
+ camel_network_settings_get_port (
+ CAMEL_NETWORK_SETTINGS (object)));
+ return;
+
case PROP_REAL_JUNK_PATH:
g_value_set_string (
value,
@@ -260,6 +309,13 @@ imap_settings_get_property (GObject *object,
CAMEL_IMAP_SETTINGS (object)));
return;
+ case PROP_USER:
+ g_value_set_string (
+ value,
+ camel_network_settings_get_user (
+ CAMEL_NETWORK_SETTINGS (object)));
+ return;
+
case PROP_USE_NAMESPACE:
g_value_set_boolean (
value,
@@ -328,6 +384,12 @@ camel_imap_settings_class_init (CamelImapSettingsClass *class)
object_class->get_property = imap_settings_get_property;
object_class->finalize = imap_settings_finalize;
+ /* Inherited from CamelNetworkSettings. */
+ g_object_class_override_property (
+ object_class,
+ PROP_AUTH_MECHANISM,
+ "auth-mechanism");
+
g_object_class_install_property (
object_class,
PROP_CHECK_ALL,
@@ -401,6 +463,12 @@ camel_imap_settings_class_init (CamelImapSettingsClass *class)
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
+ /* Inherited from CamelNetworkSettings. */
+ g_object_class_override_property (
+ object_class,
+ PROP_HOST,
+ "host");
+
g_object_class_install_property (
object_class,
PROP_NAMESPACE,
@@ -413,6 +481,12 @@ camel_imap_settings_class_init (CamelImapSettingsClass *class)
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
+ /* Inherited from CamelNetworkSettings. */
+ g_object_class_override_property (
+ object_class,
+ PROP_PORT,
+ "port");
+
g_object_class_install_property (
object_class,
PROP_REAL_JUNK_PATH,
@@ -455,6 +529,12 @@ camel_imap_settings_class_init (CamelImapSettingsClass *class)
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
+ /* Inherited from CamelNetworkSettings. */
+ g_object_class_override_property (
+ object_class,
+ PROP_USER,
+ "user");
+
g_object_class_install_property (
object_class,
PROP_USE_NAMESPACE,
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index 9d72621..8664d3a 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -135,6 +135,44 @@ G_DEFINE_TYPE_WITH_CODE (
camel_subscribable_init))
static void
+imap_store_update_store_flags (CamelStore *store)
+{
+ CamelService *service;
+ CamelSettings *settings;
+ CamelImapSettings *imap_settings;
+ const gchar *real_path;
+ gboolean use_real_path;
+
+ /* XXX This only responds to the service's entire settings object
+ * being replaced, not when individual settings change. When
+ * individual settings change, a restart is required for them
+ * to take effect. */
+
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
+ imap_settings = CAMEL_IMAP_SETTINGS (settings);
+
+ real_path = camel_imap_settings_get_real_junk_path (imap_settings);
+ use_real_path = camel_imap_settings_get_use_real_junk_path (imap_settings);
+
+ if (use_real_path && real_path != NULL) {
+ store->flags &= ~CAMEL_STORE_VJUNK;
+ store->flags |= CAMEL_STORE_REAL_JUNK_FOLDER;
+ } else {
+ store->flags &= CAMEL_STORE_REAL_JUNK_FOLDER;
+ store->flags |= CAMEL_STORE_VJUNK;
+ }
+
+ real_path = camel_imap_settings_get_real_trash_path (imap_settings);
+ use_real_path = camel_imap_settings_get_use_real_trash_path (imap_settings);
+
+ if (use_real_path && real_path != NULL)
+ store->flags &= ~CAMEL_STORE_VTRASH;
+ else
+ store->flags |= CAMEL_STORE_VTRASH;
+}
+
+static void
parse_capability (CamelImapStore *store,
gchar *capa)
{
@@ -240,14 +278,15 @@ connect_to_server (CamelService *service,
GError **error)
{
CamelImapStore *store = (CamelImapStore *) service;
+ CamelNetworkSettings *network_settings;
CamelSettings *settings;
- CamelURL *url;
CamelImapResponse *response;
CamelStream *tcp_stream;
CamelSockOptData sockopt;
CamelNetworkSecurityMethod method;
gboolean force_imap4 = FALSE;
gboolean clean_quit = TRUE;
+ const gchar *host;
gchar *buf;
tcp_stream = camel_network_service_connect_sync (
@@ -256,10 +295,11 @@ connect_to_server (CamelService *service,
if (tcp_stream == NULL)
return FALSE;
- url = camel_service_get_camel_url (service);
settings = camel_service_get_settings (service);
- g_object_get (settings, "security-method", &method, NULL);
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
+ method = camel_network_settings_get_security_method (network_settings);
store->ostream = tcp_stream;
store->istream = camel_stream_buffer_new (tcp_stream, CAMEL_STREAM_BUFFER_READ);
@@ -359,7 +399,7 @@ connect_to_server (CamelService *service,
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to connect to IMAP server %s in secure mode: %s"),
- url->host, _("STARTTLS not supported"));
+ host, _("STARTTLS not supported"));
goto exception;
}
@@ -379,7 +419,7 @@ connect_to_server (CamelService *service,
g_prefix_error (
error,
_("Failed to connect to IMAP server %s in secure mode: "),
- url->host);
+ host);
goto exception;
}
@@ -406,7 +446,7 @@ connect_to_server (CamelService *service,
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to connect to IMAP server %s in secure mode: %s"),
- url->host, _("Unknown error"));
+ host, _("Unknown error"));
goto exception;
}
@@ -447,33 +487,50 @@ connect_to_server_process (CamelService *service,
GError **error)
{
CamelImapStore *store = (CamelImapStore *) service;
+ CamelNetworkSettings *network_settings;
+ CamelProvider *provider;
+ CamelSettings *settings;
CamelStream *cmd_stream;
- CamelURL *url;
+ CamelURL url;
gint ret, i = 0;
gchar *buf;
gchar *cmd_copy;
gchar *full_cmd;
gchar *child_env[7];
const gchar *password;
+ const gchar *host;
+ const gchar *user;
+ guint16 port;
+
+ memset (&url, 0, sizeof (CamelURL));
- url = camel_service_get_camel_url (service);
password = camel_service_get_password (service);
+ provider = camel_service_get_provider (service);
+ settings = camel_service_get_settings (service);
+
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
+ port = camel_network_settings_get_port (network_settings);
+ user = camel_network_settings_get_user (network_settings);
+
+ camel_url_set_protocol (&url, provider->protocol);
+ camel_url_set_host (&url, host);
+ camel_url_set_port (&url, port);
+ camel_url_set_user (&url, user);
/* Put full details in the environment, in case the connection
* program needs them */
- buf = camel_url_to_string (url, 0);
+ buf = camel_url_to_string (&url, 0);
child_env[i++] = g_strdup_printf("URL=%s", buf);
g_free (buf);
- child_env[i++] = g_strdup_printf("URLHOST=%s", url->host);
- if (url->port)
- child_env[i++] = g_strdup_printf("URLPORT=%d", url->port);
- if (url->user)
- child_env[i++] = g_strdup_printf("URLUSER=%s", url->user);
+ child_env[i++] = g_strdup_printf("URLHOST=%s", host);
+ if (port)
+ child_env[i++] = g_strdup_printf("URLPORT=%d", port);
+ if (user)
+ child_env[i++] = g_strdup_printf("URLUSER=%s", user);
if (password)
child_env[i++] = g_strdup_printf("URLPASSWD=%s", password);
- if (url->path)
- child_env[i++] = g_strdup_printf("URLPATH=%s", url->path);
child_env[i] = NULL;
/* Now do %h, %u, etc. substitution in cmd */
@@ -484,7 +541,7 @@ connect_to_server_process (CamelService *service,
for (;;) {
gchar *pc;
gchar *tmp;
- gchar *var;
+ const gchar *var;
gint len;
pc = strchr (buf, '%');
@@ -502,10 +559,10 @@ connect_to_server_process (CamelService *service,
switch (pc[1]) {
case 'h':
- var = url->host;
+ var = host;
break;
case 'u':
- var = url->user;
+ var = user;
break;
}
if (!var) {
@@ -618,19 +675,23 @@ imap_auth_loop (CamelService *service,
GError **error)
{
CamelImapStore *store = CAMEL_IMAP_STORE (service);
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
CamelSession *session;
- CamelURL *url;
const gchar *mechanism;
+ const gchar *host;
session = camel_service_get_session (service);
+ settings = camel_service_get_settings (service);
- url = camel_service_get_camel_url (service);
- mechanism = url->authmech;
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
+ mechanism = camel_network_settings_get_auth_mechanism (network_settings);
if (store->preauthed) {
if (camel_verbose_debug)
fprintf(stderr, "Server %s has preauthenticated us.\n",
- url->host);
+ host);
return TRUE;
}
@@ -640,7 +701,7 @@ imap_auth_loop (CamelService *service,
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("IMAP server %s does not support %s "
- "authentication"), url->host, mechanism);
+ "authentication"), host, mechanism);
return FALSE;
}
}
@@ -690,17 +751,23 @@ static gchar *
imap_store_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 (
- _("IMAP server %s"), url->host);
+ _("IMAP server %s"), host);
else
return g_strdup_printf (
- _("IMAP service for %s on %s"),
- url->user, url->host);
+ _("IMAP service for %s on %s"), user, host);
}
static gboolean
@@ -977,13 +1044,18 @@ imap_store_authenticate_sync (CamelService *service,
/* If not using SASL, do a simple LOGIN here. */
if (mechanism == NULL) {
- CamelURL *url;
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
const gchar *password;
+ const gchar *user;
- url = camel_service_get_camel_url (service);
password = camel_service_get_password (service);
+ settings = camel_service_get_settings (service);
+
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ user = camel_network_settings_get_user (network_settings);
- if (url->user == NULL) {
+ if (user == NULL) {
g_set_error_literal (
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
@@ -1001,7 +1073,7 @@ imap_store_authenticate_sync (CamelService *service,
response = camel_imap_command (
store, NULL, cancellable, &local_error,
- "LOGIN %S %S", url->user, password);
+ "LOGIN %S %S", user, password);
if (response != NULL)
camel_imap_response_free (store, response);
@@ -1175,10 +1247,7 @@ imap_store_initable_init (GInitable *initable,
CamelImapStore *imap_store;
CamelStore *store;
CamelService *service;
- CamelSettings *settings;
const gchar *user_cache_dir;
- const gchar *real_path;
- gboolean use_real_path;
gchar *tmp_path;
imap_store = CAMEL_IMAP_STORE (initable);
@@ -1193,37 +1262,8 @@ imap_store_initable_init (GInitable *initable,
return FALSE;
service = CAMEL_SERVICE (initable);
- settings = camel_service_get_settings (service);
user_cache_dir = camel_service_get_user_cache_dir (service);
- /* XXX Using CamelStoreFlags like this is suboptimal because they're
- * only set once during initialization. Subsequent changes to the
- * CamelSettings are not propagated to the flags -- a restart
- * is required. Probably should define interfaces for this. */
-
- real_path = camel_imap_settings_get_real_junk_path (
- CAMEL_IMAP_SETTINGS (settings));
- use_real_path = camel_imap_settings_get_use_real_junk_path (
- CAMEL_IMAP_SETTINGS (settings));
-
- if (use_real_path && real_path != NULL) {
- CAMEL_STORE (service)->flags &= ~CAMEL_STORE_VJUNK;
- CAMEL_STORE (service)->flags |= CAMEL_STORE_REAL_JUNK_FOLDER;
- } else {
- CAMEL_STORE (service)->flags &= CAMEL_STORE_REAL_JUNK_FOLDER;
- CAMEL_STORE (service)->flags |= CAMEL_STORE_VJUNK;
- }
-
- real_path = camel_imap_settings_get_real_trash_path (
- CAMEL_IMAP_SETTINGS (settings));
- use_real_path = camel_imap_settings_get_use_real_trash_path (
- CAMEL_IMAP_SETTINGS (settings));
-
- if (use_real_path && real_path != NULL)
- CAMEL_STORE (service)->flags &= ~CAMEL_STORE_VTRASH;
- else
- CAMEL_STORE (service)->flags |= CAMEL_STORE_VTRASH;
-
/* setup/load the store summary */
tmp_path = g_build_filename (user_cache_dir, ".ev-store-summary", NULL);
imap_store->summary = camel_imap_store_summary_new ();
@@ -1232,6 +1272,9 @@ imap_store_initable_init (GInitable *initable,
if (camel_store_summary_load ((CamelStoreSummary *) imap_store->summary) == 0) {
CamelImapStoreSummary *is = imap_store->summary;
+ /* XXX This won't work anymore. The CamelSettings
+ * object for this store is not yet configured. */
+#if 0
if (is->namespace) {
const gchar *namespace;
@@ -1242,6 +1285,7 @@ imap_store_initable_init (GInitable *initable,
if (g_strcmp0 (namespace, is->namespace->full_name) != 0)
camel_store_summary_clear ((CamelStoreSummary *) is);
}
+#endif
imap_store->capabilities = is->capabilities;
imap_set_server_level (imap_store);
@@ -1477,6 +1521,10 @@ camel_imap_store_init (CamelImapStore *imap_store)
imap_store->tag_prefix = imap_tag_prefix++;
if (imap_tag_prefix > 'Z')
imap_tag_prefix = 'A';
+
+ g_signal_connect (
+ imap_store, "notify::settings",
+ G_CALLBACK (imap_store_update_store_flags), NULL);
}
static void
diff --git a/camel/providers/imapx/camel-imapx-conn-manager.c b/camel/providers/imapx/camel-imapx-conn-manager.c
index f1d2e79..d6ccd0b 100644
--- a/camel/providers/imapx/camel-imapx-conn-manager.c
+++ b/camel/providers/imapx/camel-imapx-conn-manager.c
@@ -354,12 +354,10 @@ imapx_create_new_connection (CamelIMAPXConnManager *con_man,
CamelIMAPXStore *imapx_store;
CamelStore *store = con_man->priv->store;
CamelService *service;
- CamelURL *url;
ConnectionInfo *cinfo = NULL;
gboolean success;
service = CAMEL_SERVICE (store);
- url = camel_service_get_camel_url (service);
imapx_store = CAMEL_IMAPX_STORE (store);
@@ -367,7 +365,7 @@ imapx_create_new_connection (CamelIMAPXConnManager *con_man,
camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
- conn = camel_imapx_server_new (store, url);
+ conn = camel_imapx_server_new (store);
/* XXX As part of the connect operation the CamelIMAPXServer will
* have to call camel_session_authenticate_sync(), but it has
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 567dad5..d1b9f8f 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -2839,34 +2839,52 @@ connect_to_server_process (CamelIMAPXServer *is,
const gchar *cmd,
GError **error)
{
+ CamelNetworkSettings *network_settings;
+ CamelProvider *provider;
+ CamelSettings *settings;
CamelStream *cmd_stream;
CamelService *service;
+ CamelURL url;
gint ret, i = 0;
gchar *buf;
gchar *cmd_copy;
gchar *full_cmd;
gchar *child_env[7];
const gchar *password;
+ const gchar *host;
+ const gchar *user;
+ guint16 port;
+
+ memset (&url, 0, sizeof (CamelURL));
service = CAMEL_SERVICE (is->store);
password = camel_service_get_password (service);
+ provider = camel_service_get_provider (service);
+ settings = camel_service_get_settings (service);
g_return_val_if_fail (password != NULL, FALSE);
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
+ port = camel_network_settings_get_port (network_settings);
+ user = camel_network_settings_get_user (network_settings);
+
/* Put full details in the environment, in case the connection
* program needs them */
- buf = camel_url_to_string (is->url, 0);
+ camel_url_set_protocol (&url, provider->protocol);
+ camel_url_set_host (&url, host);
+ camel_url_set_port (&url, port);
+ camel_url_set_user (&url, user);
+ buf = camel_url_to_string (&url, 0);
child_env[i++] = g_strdup_printf("URL=%s", buf);
g_free (buf);
- child_env[i++] = g_strdup_printf("URLHOST=%s", is->url->host);
- if (is->url->port)
- child_env[i++] = g_strdup_printf("URLPORT=%d", is->url->port);
- if (is->url->user)
- child_env[i++] = g_strdup_printf("URLUSER=%s", is->url->user);
+ child_env[i++] = g_strdup_printf("URLHOST=%s", host);
+ if (port)
+ child_env[i++] = g_strdup_printf("URLPORT=%u", port);
+ if (user)
+ child_env[i++] = g_strdup_printf("URLUSER=%s", user);
if (password)
child_env[i++] = g_strdup_printf("URLPASSWD=%s", password);
- if (is->url->path)
- child_env[i++] = g_strdup_printf("URLPATH=%s", is->url->path);
child_env[i] = NULL;
/* Now do %h, %u, etc. substitution in cmd */
@@ -2877,7 +2895,7 @@ connect_to_server_process (CamelIMAPXServer *is,
for (;;) {
gchar *pc;
gchar *tmp;
- gchar *var;
+ const gchar *var;
gint len;
pc = strchr (buf, '%');
@@ -2895,10 +2913,10 @@ connect_to_server_process (CamelIMAPXServer *is,
switch (pc[1]) {
case 'h':
- var = is->url->host;
+ var = host;
break;
case 'u':
- var = is->url->user;
+ var = user;
break;
}
if (!var) {
@@ -2945,6 +2963,7 @@ imapx_connect_to_server (CamelIMAPXServer *is,
GCancellable *cancellable,
GError **error)
{
+ CamelNetworkSettings *network_settings;
CamelNetworkSecurityMethod method;
CamelStream * tcp_stream = NULL;
CamelSockOptData sockopt;
@@ -2954,6 +2973,7 @@ imapx_connect_to_server (CamelIMAPXServer *is,
guchar *token;
gint tok;
CamelIMAPXCommand *ic;
+ const gchar *host;
GError *local_error = NULL;
#ifndef G_OS_WIN32
@@ -2964,7 +2984,9 @@ imapx_connect_to_server (CamelIMAPXServer *is,
service = CAMEL_SERVICE (is->store);
settings = camel_service_get_settings (service);
- g_object_get (settings, "security-method", &method, NULL);
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
+ method = camel_network_settings_get_security_method (network_settings);
#ifndef G_OS_WIN32
use_shell_command = camel_imapx_settings_get_use_shell_command (
@@ -3058,7 +3080,7 @@ imapx_connect_to_server (CamelIMAPXServer *is,
&local_error, CAMEL_ERROR,
CAMEL_ERROR_GENERIC,
_("Failed to connect to IMAP server %s in secure mode: %s"),
- is->url->host, _("STARTTLS not supported"));
+ host, _("STARTTLS not supported"));
goto exit;
}
@@ -3097,7 +3119,7 @@ imapx_connect_to_server (CamelIMAPXServer *is,
g_prefix_error (
&local_error,
_("Failed to connect to IMAP server %s in secure mode: "),
- is->url->host);
+ host);
goto exit;
}
/* Get new capabilities if they weren't already given */
@@ -3142,18 +3164,25 @@ camel_imapx_server_authenticate (CamelIMAPXServer *is,
GCancellable *cancellable,
GError **error)
{
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
CamelAuthenticationResult result;
CamelIMAPXCommand *ic;
CamelService *service;
CamelSasl *sasl = NULL;
- CamelURL *url;
+ const gchar *host;
+ const gchar *user;
g_return_val_if_fail (
CAMEL_IS_IMAPX_SERVER (is),
CAMEL_AUTHENTICATION_REJECTED);
service = CAMEL_SERVICE (is->store);
- 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 (mechanism != NULL) {
if (!g_hash_table_lookup (is->cinfo->auth_types, mechanism)) {
@@ -3161,7 +3190,7 @@ camel_imapx_server_authenticate (CamelIMAPXServer *is,
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("IMAP server %s does not support %s "
- "authentication"), url->host, mechanism);
+ "authentication"), host, mechanism);
return CAMEL_AUTHENTICATION_ERROR;
}
@@ -3185,7 +3214,7 @@ camel_imapx_server_authenticate (CamelIMAPXServer *is,
password = camel_service_get_password (service);
- if (url->user == NULL) {
+ if (user == NULL) {
g_set_error_literal (
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
@@ -3203,7 +3232,7 @@ camel_imapx_server_authenticate (CamelIMAPXServer *is,
ic = camel_imapx_command_new (
is, "LOGIN", NULL, cancellable,
- "LOGIN %s %s", url->user, password);
+ "LOGIN %s %s", user, password);
}
imapx_command_run (is, ic);
@@ -3250,7 +3279,6 @@ imapx_reconnect (CamelIMAPXServer *is,
CamelService *service;
CamelSession *session;
CamelSettings *settings;
- CamelURL *url;
const gchar *mechanism;
gboolean use_idle;
gboolean use_qresync;
@@ -3259,8 +3287,8 @@ imapx_reconnect (CamelIMAPXServer *is,
session = camel_service_get_session (service);
settings = camel_service_get_settings (service);
- url = camel_service_get_camel_url (service);
- mechanism = url->authmech;
+ mechanism = camel_network_settings_get_auth_mechanism (
+ CAMEL_NETWORK_SETTINGS (settings));
use_idle = camel_imapx_settings_get_use_idle (
CAMEL_IMAPX_SETTINGS (settings));
@@ -5089,8 +5117,6 @@ imapx_server_finalize (GObject *object)
{
CamelIMAPXServer *is = CAMEL_IMAPX_SERVER (object);
- camel_url_free (is->url);
-
g_static_rec_mutex_free (&is->queue_lock);
g_static_rec_mutex_free (&is->ostream_lock);
g_mutex_free (is->fetch_mutex);
@@ -5184,8 +5210,7 @@ camel_imapx_server_init (CamelIMAPXServer *is)
}
CamelIMAPXServer *
-camel_imapx_server_new (CamelStore *store,
- CamelURL *url)
+camel_imapx_server_new (CamelStore *store)
{
CamelService *service;
CamelSession *session;
@@ -5197,7 +5222,6 @@ camel_imapx_server_new (CamelStore *store,
is = g_object_new (CAMEL_TYPE_IMAPX_SERVER, NULL);
is->session = g_object_ref (session);
is->store = store;
- is->url = camel_url_copy (url);
return is;
}
diff --git a/camel/providers/imapx/camel-imapx-server.h b/camel/providers/imapx/camel-imapx-server.h
index 9e10bb3..79e76ab 100644
--- a/camel/providers/imapx/camel-imapx-server.h
+++ b/camel/providers/imapx/camel-imapx-server.h
@@ -64,7 +64,6 @@ struct _CamelIMAPXServer {
CamelSession *session;
/* Info about the current connection */
- CamelURL *url;
CamelIMAPXStream *stream;
struct _capability_info *cinfo;
gboolean is_process_stream;
@@ -137,8 +136,7 @@ struct _CamelIMAPXServerClass {
GType camel_imapx_server_get_type (void);
CamelIMAPXServer *
- camel_imapx_server_new (CamelStore *store,
- CamelURL *url);
+ camel_imapx_server_new (CamelStore *store);
gboolean camel_imapx_server_connect (CamelIMAPXServer *is,
GCancellable *cancellable,
GError **error);
diff --git a/camel/providers/imapx/camel-imapx-settings.c b/camel/providers/imapx/camel-imapx-settings.c
index 07333f5..d880a0e 100644
--- a/camel/providers/imapx/camel-imapx-settings.c
+++ b/camel/providers/imapx/camel-imapx-settings.c
@@ -47,6 +47,7 @@ struct _CamelIMAPXSettingsPrivate {
enum {
PROP_0,
+ PROP_AUTH_MECHANISM,
PROP_BATCH_FETCH_COUNT,
PROP_CHECK_ALL,
PROP_CHECK_SUBSCRIBED,
@@ -54,9 +55,12 @@ enum {
PROP_FETCH_ORDER,
PROP_FILTER_JUNK,
PROP_FILTER_JUNK_INBOX,
+ PROP_HOST,
PROP_NAMESPACE,
+ PROP_PORT,
PROP_SECURITY_METHOD,
PROP_SHELL_COMMAND,
+ PROP_USER,
PROP_USE_IDLE,
PROP_USE_NAMESPACE,
PROP_USE_QRESYNC,
@@ -78,6 +82,12 @@ imapx_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_BATCH_FETCH_COUNT:
camel_imapx_settings_set_batch_fetch_count (
CAMEL_IMAPX_SETTINGS (object),
@@ -120,12 +130,24 @@ imapx_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_NAMESPACE:
camel_imapx_settings_set_namespace (
CAMEL_IMAPX_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),
@@ -138,6 +160,12 @@ imapx_settings_set_property (GObject *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;
+
case PROP_USE_IDLE:
camel_imapx_settings_set_use_idle (
CAMEL_IMAPX_SETTINGS (object),
@@ -179,6 +207,13 @@ imapx_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_BATCH_FETCH_COUNT:
g_value_set_uint (
value,
@@ -228,6 +263,13 @@ imapx_settings_get_property (GObject *object,
CAMEL_IMAPX_SETTINGS (object)));
return;
+ case PROP_HOST:
+ g_value_set_string (
+ value,
+ camel_network_settings_get_host (
+ CAMEL_NETWORK_SETTINGS (object)));
+ return;
+
case PROP_NAMESPACE:
g_value_set_string (
value,
@@ -235,6 +277,13 @@ imapx_settings_get_property (GObject *object,
CAMEL_IMAPX_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,
@@ -249,6 +298,13 @@ imapx_settings_get_property (GObject *object,
CAMEL_IMAPX_SETTINGS (object)));
return;
+ case PROP_USER:
+ g_value_set_string (
+ value,
+ camel_network_settings_get_user (
+ CAMEL_NETWORK_SETTINGS (object)));
+ return;
+
case PROP_USE_IDLE:
g_value_set_boolean (
value,
@@ -314,6 +370,12 @@ camel_imapx_settings_class_init (CamelIMAPXSettingsClass *class)
object_class->get_property = imapx_settings_get_property;
object_class->finalize = imapx_settings_finalize;
+ /* Inherited from CamelNetworkSettings. */
+ g_object_class_override_property (
+ object_class,
+ PROP_AUTH_MECHANISM,
+ "auth-mechanism");
+
g_object_class_install_property (
object_class,
PROP_BATCH_FETCH_COUNT,
@@ -403,6 +465,12 @@ camel_imapx_settings_class_init (CamelIMAPXSettingsClass *class)
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
+ /* Inherited from CamelNetworkSettings. */
+ g_object_class_override_property (
+ object_class,
+ PROP_HOST,
+ "host");
+
g_object_class_install_property (
object_class,
PROP_NAMESPACE,
@@ -418,6 +486,12 @@ camel_imapx_settings_class_init (CamelIMAPXSettingsClass *class)
/* 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");
@@ -433,6 +507,12 @@ camel_imapx_settings_class_init (CamelIMAPXSettingsClass *class)
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
+ /* Inherited from CamelNetworkSettings. */
+ g_object_class_override_property (
+ object_class,
+ PROP_USER,
+ "user");
+
g_object_class_install_property (
object_class,
PROP_USE_IDLE,
diff --git a/camel/providers/imapx/camel-imapx-store.c b/camel/providers/imapx/camel-imapx-store.c
index 862e6bb..b1342d2 100644
--- a/camel/providers/imapx/camel-imapx-store.c
+++ b/camel/providers/imapx/camel-imapx-store.c
@@ -138,17 +138,23 @@ static gchar *
imapx_get_name (CamelService *service,
gboolean brief)
{
- CamelURL *url;
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
+ const gchar *host;
+ const gchar *user;
+
+ settings = camel_service_get_settings (service);
- url = camel_service_get_camel_url (service);
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
+ user = camel_network_settings_get_user (network_settings);
if (brief)
return g_strdup_printf (
- _("IMAP server %s"), url->host);
+ _("IMAP server %s"), host);
else
return g_strdup_printf (
- _("IMAP service for %s on %s"),
- url->user, url->host);
+ _("IMAP service for %s on %s"), user, host);
}
CamelIMAPXServer *
@@ -258,7 +264,6 @@ imapx_query_auth_types_sync (CamelService *service,
{
CamelIMAPXStore *istore = CAMEL_IMAPX_STORE (service);
CamelServiceAuthType *authtype;
- CamelURL *url;
GList *sasl_types, *t, *next;
gboolean connected;
CamelIMAPXServer *server;
@@ -273,8 +278,7 @@ imapx_query_auth_types_sync (CamelService *service,
camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
- url = camel_service_get_camel_url (service);
- server = camel_imapx_server_new ((CamelStore *) istore, url);
+ server = camel_imapx_server_new (CAMEL_STORE (istore));
connected = server->stream != NULL;
if (!connected)
diff --git a/camel/providers/local/camel-local-folder.c b/camel/providers/local/camel-local-folder.c
index 5b68f1e..b6601bb 100644
--- a/camel/providers/local/camel-local-folder.c
+++ b/camel/providers/local/camel-local-folder.c
@@ -151,10 +151,14 @@ local_folder_finalize (GObject *object)
static void
local_folder_constructed (GObject *object)
{
+ CamelLocalSettings *local_settings;
+ CamelProvider *provider;
+ CamelSettings *settings;
+ CamelService *service;
CamelFolder *folder;
CamelStore *parent_store;
- CamelURL *url;
const gchar *full_name;
+ const gchar *root_path;
const gchar *tmp;
gchar *description;
gchar *path;
@@ -163,11 +167,17 @@ local_folder_constructed (GObject *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));
- if (url->path == NULL)
+ service = CAMEL_SERVICE (parent_store);
+ provider = camel_service_get_provider (service);
+ settings = camel_service_get_settings (service);
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ root_path = camel_local_settings_get_path (local_settings);
+
+ if (root_path == NULL)
return;
- path = g_strdup_printf ("%s/%s", url->path, full_name);
+ path = g_strdup_printf ("%s/%s", root_path, full_name);
if ((tmp = getenv ("HOME")) && strncmp (tmp, path, strlen (tmp)) == 0)
/* Translators: This is used for a folder description,
@@ -177,7 +187,7 @@ local_folder_constructed (GObject *object)
description = g_strdup_printf (
_("~%s (%s)"),
path + strlen (tmp),
- url->protocol);
+ provider->protocol);
else if ((tmp = "/var/spool/mail") && strncmp (tmp, path, strlen (tmp)) == 0)
/* Translators: This is used for a folder description, for
* folders being under /var/spool/mail. The first %s is
@@ -187,7 +197,7 @@ local_folder_constructed (GObject *object)
description = g_strdup_printf (
_("mailbox: %s (%s)"),
path + strlen (tmp),
- url->protocol);
+ provider->protocol);
else if ((tmp = "/var/mail") && strncmp (tmp, path, strlen (tmp)) == 0)
/* Translators: This is used for a folder description, for
* folders being under /var/mail. The first %s is replaced
@@ -196,7 +206,7 @@ local_folder_constructed (GObject *object)
description = g_strdup_printf (
_("mailbox: %s (%s)"),
path + strlen (tmp),
- url->protocol);
+ provider->protocol);
else
/* Translators: This is used for a folder description.
* The first %s is replaced with a folder's full path,
@@ -204,7 +214,7 @@ local_folder_constructed (GObject *object)
* mbox/maldir/... */
description = g_strdup_printf (
_("%s (%s)"), path,
- url->protocol);
+ provider->protocol);
camel_folder_set_description (folder, description);
@@ -505,8 +515,10 @@ camel_local_folder_construct (CamelLocalFolder *lf,
GError **error)
{
CamelFolder *folder;
- const gchar *root_dir_path;
- gchar *tmp, *statepath;
+ CamelLocalSettings *local_settings;
+ CamelSettings *settings;
+ CamelService *service;
+ gchar *statepath;
#ifndef G_OS_WIN32
#ifdef __GLIBC__
gchar *folder_path;
@@ -515,28 +527,27 @@ camel_local_folder_construct (CamelLocalFolder *lf,
#endif
struct stat st;
#endif
- gint forceindex, len;
+ gint forceindex;
CamelLocalStore *ls;
CamelStore *parent_store;
const gchar *full_name;
+ const gchar *path;
gboolean need_summary_check;
folder = CAMEL_FOLDER (lf);
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
+ service = CAMEL_SERVICE (parent_store);
+ settings = camel_service_get_settings (service);
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
+
ls = CAMEL_LOCAL_STORE (parent_store);
need_summary_check = camel_local_store_get_need_summary_check (ls);
- root_dir_path = camel_local_store_get_toplevel_dir (ls);
- /* strip the trailing '/' which is always present */
- len = strlen (root_dir_path);
- tmp = g_alloca (len + 1);
- strcpy (tmp, root_dir_path);
- if (len > 1 && G_IS_DIR_SEPARATOR (tmp[len - 1]))
- tmp[len - 1] = 0;
-
- lf->base_path = g_strdup (root_dir_path);
+ lf->base_path = g_strdup (path);
lf->folder_path = camel_local_store_get_full_path (ls, full_name);
lf->summary_path = camel_local_store_get_meta_path(ls, full_name, ".ev-summary");
diff --git a/camel/providers/local/camel-local-store.c b/camel/providers/local/camel-local-store.c
index 1b7bc9a..2bcb3f2 100644
--- a/camel/providers/local/camel-local-store.c
+++ b/camel/providers/local/camel-local-store.c
@@ -63,11 +63,19 @@ xrename (const gchar *oldp,
GError **error)
{
struct stat st;
- gchar *old = g_strconcat (prefix, oldp, suffix, NULL);
- gchar *new = g_strconcat (prefix, newp, suffix, NULL);
+ gchar *old, *new;
+ gchar *basename;
gint ret = -1;
gint err = 0;
+ basename = g_strconcat (oldp, suffix, NULL);
+ old = g_build_filename (prefix, basename, NULL);
+ g_free (basename);
+
+ basename = g_strconcat (newp, suffix, NULL);
+ new = g_build_filename (prefix, basename, NULL);
+ g_free (basename);
+
d(printf("renaming %s%s to %s%s\n", oldp, suffix, newp, suffix));
if (g_stat (old, &st) == -1) {
@@ -134,24 +142,11 @@ local_store_get_property (GObject *object,
}
static void
-local_store_finalize (GObject *object)
-{
- CamelLocalStore *local_store = CAMEL_LOCAL_STORE (object);
-
- g_free (local_store->toplevel_dir);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (camel_local_store_parent_class)->finalize (object);
-}
-
-static void
local_store_constructed (GObject *object)
{
CamelLocalStore *local_store;
CamelService *service;
- CamelURL *url;
const gchar *uid;
- gint len;
local_store = CAMEL_LOCAL_STORE (object);
@@ -160,13 +155,6 @@ local_store_constructed (GObject *object)
service = CAMEL_SERVICE (object);
uid = camel_service_get_uid (service);
- url = camel_service_get_camel_url (service);
-
- len = strlen (url->path);
- if (!G_IS_DIR_SEPARATOR (url->path[len - 1]))
- local_store->toplevel_dir = g_strdup_printf ("%s/", url->path);
- else
- local_store->toplevel_dir = g_strdup (url->path);
/* XXX This is Evolution-specific policy. */
local_store->is_main_store = (g_strcmp0 (uid, "local") == 0);
@@ -176,12 +164,19 @@ static gchar *
local_store_get_name (CamelService *service,
gboolean brief)
{
- gchar *dir = ((CamelLocalStore *) service)->toplevel_dir;
+ CamelLocalSettings *local_settings;
+ CamelSettings *settings;
+ const gchar *path;
+
+ settings = camel_service_get_settings (service);
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
if (brief)
- return g_strdup (dir);
+ return g_strdup (path);
else
- return g_strdup_printf (_("Local mail file %s"), dir);
+ return g_strdup_printf (_("Local mail file %s"), path);
}
static gboolean
@@ -200,13 +195,17 @@ local_store_get_folder_sync (CamelStore *store,
GCancellable *cancellable,
GError **error)
{
- gint len = strlen (((CamelLocalStore *) store)->toplevel_dir);
- gchar *path = g_alloca (len + 1);
+ CamelLocalSettings *local_settings;
+ CamelSettings *settings;
+ CamelService *service;
+ const gchar *path;
struct stat st;
- strcpy (path, ((CamelLocalStore *) store)->toplevel_dir);
- if (G_IS_DIR_SEPARATOR (path[len - 1]))
- path[len - 1] = '\0';
+ service = CAMEL_SERVICE (store);
+ settings= camel_service_get_settings (service);
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
if (!g_path_is_absolute (path)) {
g_set_error (
@@ -342,12 +341,21 @@ local_store_create_folder_sync (CamelStore *store,
GCancellable *cancellable,
GError **error)
{
- gchar *path = ((CamelLocalStore *) store)->toplevel_dir;
- gchar *name;
+ CamelLocalSettings *local_settings;
+ CamelSettings *settings;
+ CamelService *service;
CamelFolder *folder;
CamelFolderInfo *info = NULL;
+ const gchar *path;
+ gchar *name;
struct stat st;
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
+
/* This is a pretty hacky version of create folder, but should basically work */
if (!g_path_is_absolute (path)) {
@@ -400,13 +408,23 @@ local_store_delete_folder_sync (CamelStore *store,
GCancellable *cancellable,
GError **error)
{
+ CamelLocalSettings *local_settings;
+ CamelSettings *settings;
+ CamelService *service;
CamelFolderInfo *fi;
CamelFolder *lf;
+ const gchar *path;
gchar *name;
gchar *str;
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
+
/* remove metadata only */
- name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name);
+ name = g_build_filename (path, folder_name, NULL);
str = g_strdup_printf("%s.ibex", name);
if (camel_text_index_remove (str) == -1 && errno != ENOENT && errno != ENOTDIR) {
g_set_error (
@@ -469,10 +487,30 @@ local_store_rename_folder_sync (CamelStore *store,
GCancellable *cancellable,
GError **error)
{
- gchar *path = CAMEL_LOCAL_STORE (store)->toplevel_dir;
- CamelLocalFolder *folder = NULL;
- gchar *newibex = g_strdup_printf("%s%s.ibex", path, new);
- gchar *oldibex = g_strdup_printf("%s%s.ibex", path, old);
+ CamelLocalFolder *folder;
+ CamelLocalSettings *local_settings;
+ CamelSettings *settings;
+ CamelService *service;
+ const gchar *path;
+ gchar *old_basename;
+ gchar *new_basename;
+ gchar *newibex;
+ gchar *oldibex;
+
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
+
+ old_basename = g_strdup_printf ("%s.ibex", old);
+ new_basename = g_strdup_printf ("%s.ibex", new);
+
+ oldibex = g_build_filename (path, old_basename, NULL);
+ newibex = g_build_filename (path, new_basename, NULL);
+
+ g_free (old_basename);
+ g_free (new_basename);
/* try to rollback failures, has obvious races */
@@ -542,7 +580,18 @@ static gchar *
local_store_get_full_path (CamelLocalStore *ls,
const gchar *full_name)
{
- return g_strdup_printf ("%s%s", ls->toplevel_dir, full_name);
+ CamelLocalSettings *local_settings;
+ CamelSettings *settings;
+ CamelService *service;
+ const gchar *path;
+
+ service = CAMEL_SERVICE (ls);
+ settings = camel_service_get_settings (service);
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
+
+ return g_build_filename (path, full_name, NULL);
}
static gchar *
@@ -550,7 +599,24 @@ local_store_get_meta_path (CamelLocalStore *ls,
const gchar *full_name,
const gchar *ext)
{
- return g_strdup_printf ("%s%s%s", ls->toplevel_dir, full_name, ext);
+ CamelLocalSettings *local_settings;
+ CamelSettings *settings;
+ CamelService *service;
+ const gchar *path;
+ gchar *basename;
+ gchar *filename;
+
+ service = CAMEL_SERVICE (ls);
+ settings = camel_service_get_settings (service);
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
+
+ basename = g_strconcat (full_name, ext, NULL);
+ filename = g_build_filename (path, basename, NULL);
+ g_free (basename);
+
+ return filename;
}
static void
@@ -565,10 +631,10 @@ camel_local_store_class_init (CamelLocalStoreClass *class)
object_class = G_OBJECT_CLASS (class);
object_class->set_property = local_store_set_property;
object_class->get_property = local_store_get_property;
- object_class->finalize = local_store_finalize;
object_class->constructed = local_store_constructed;
service_class = CAMEL_SERVICE_CLASS (class);
+ service_class->settings_type = CAMEL_TYPE_LOCAL_SETTINGS;
service_class->get_name = local_store_get_name;
store_class = CAMEL_STORE_CLASS (class);
@@ -605,12 +671,6 @@ camel_local_store_init (CamelLocalStore *local_store)
local_store->priv = CAMEL_LOCAL_STORE_GET_PRIVATE (local_store);
}
-const gchar *
-camel_local_store_get_toplevel_dir (CamelLocalStore *store)
-{
- return store->toplevel_dir;
-}
-
/* Returns whether is this store used as 'On This Computer' main store */
gboolean
camel_local_store_is_main_store (CamelLocalStore *store)
diff --git a/camel/providers/local/camel-local-store.h b/camel/providers/local/camel-local-store.h
index 000706d..f83e460 100644
--- a/camel/providers/local/camel-local-store.h
+++ b/camel/providers/local/camel-local-store.h
@@ -54,7 +54,6 @@ struct _CamelLocalStore {
CamelStore parent;
CamelLocalStorePrivate *priv;
- gchar *toplevel_dir;
gboolean is_main_store;
};
@@ -69,8 +68,6 @@ struct _CamelLocalStoreClass {
};
GType camel_local_store_get_type (void);
-const gchar * camel_local_store_get_toplevel_dir
- (CamelLocalStore *store);
gboolean camel_local_store_is_main_store (CamelLocalStore *store);
gchar * camel_local_store_get_full_path (CamelLocalStore *store,
const gchar *full_name);
diff --git a/camel/providers/local/camel-maildir-store.c b/camel/providers/local/camel-maildir-store.c
index 4bd0cba..47540b8 100644
--- a/camel/providers/local/camel-maildir-store.c
+++ b/camel/providers/local/camel-maildir-store.c
@@ -72,19 +72,28 @@ md_canon_name (const gchar *a)
static CamelFolderInfo *
maildir_store_create_folder_sync (CamelStore *store,
- const gchar *parent_name,
- const gchar *folder_name,
- GCancellable *cancellable,
- GError **error)
+ const gchar *parent_name,
+ const gchar *folder_name,
+ GCancellable *cancellable,
+ GError **error)
{
- gchar *path = ((CamelLocalStore *) store)->toplevel_dir;
- gchar *name;
+ CamelLocalSettings *local_settings;
+ CamelSettings *settings;
+ CamelService *service;
CamelFolder *folder;
CamelFolderInfo *info = NULL;
+ const gchar *path;
+ gchar *name;
struct stat st;
/* This is a pretty hacky version of create folder, but should basically work */
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
+
if (!g_path_is_absolute (path)) {
g_set_error (
error, CAMEL_STORE_ERROR,
@@ -154,15 +163,24 @@ maildir_store_get_folder_sync (CamelStore *store,
GError **error)
{
CamelStoreClass *store_class;
+ CamelLocalSettings *local_settings;
+ CamelSettings *settings;
+ CamelService *service;
+ const gchar *path;
gchar *name, *tmp, *cur, *new, *dir_name;
struct stat st;
CamelFolder *folder = NULL;
- folder_name = md_canon_name (folder_name);
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
- /* Chain up to parent's get_folder() method. */
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
+
+ folder_name = md_canon_name (folder_name);
dir_name = maildir_full_name_to_dir_name (folder_name);
+ /* Chain up to parent's get_folder() method. */
store_class = CAMEL_STORE_CLASS (camel_maildir_store_parent_class);
if (!store_class->get_folder_sync (store, dir_name, flags, cancellable, error)) {
g_free (dir_name);
@@ -170,7 +188,7 @@ maildir_store_get_folder_sync (CamelStore *store,
}
/* maildir++ directory names start with a '.' */
- name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, dir_name);
+ name = g_build_filename (path, dir_name, NULL);
g_free (dir_name);
tmp = g_strdup_printf("%s/tmp", name);
@@ -257,14 +275,24 @@ fail:
static gboolean
maildir_store_delete_folder_sync (CamelStore *store,
- const gchar *folder_name,
- GCancellable *cancellable,
- GError **error)
+ const gchar *folder_name,
+ GCancellable *cancellable,
+ GError **error)
{
+ CamelLocalSettings *local_settings;
+ CamelSettings *settings;
+ CamelService *service;
+ const gchar *path;
gchar *name, *tmp, *cur, *new, *dir_name;
struct stat st;
gboolean success = TRUE;
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
+
if (g_ascii_strcasecmp (folder_name, "Inbox") == 0) {
g_set_error (
error, CAMEL_STORE_ERROR,
@@ -276,7 +304,7 @@ maildir_store_delete_folder_sync (CamelStore *store,
/* maildir++ directory names start with a '.' */
dir_name = maildir_full_name_to_dir_name (folder_name);
- name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, dir_name);
+ name = g_build_filename (path, dir_name, NULL);
g_free (dir_name);
tmp = g_strdup_printf("%s/tmp", name);
@@ -366,21 +394,28 @@ fill_fi (CamelStore *store,
fi->total = camel_folder_get_message_count (folder);
g_object_unref (folder);
} else {
+ CamelLocalSettings *local_settings;
+ CamelSettings *settings;
+ CamelService *service;
gchar *path, *folderpath, *dir_name;
CamelFolderSummary *s;
const gchar *root;
- /* This should be fast enough not to have to test for INFO_FAST */
- root = camel_local_store_get_toplevel_dir ((CamelLocalStore *) store);
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ root = camel_local_settings_get_path (local_settings);
+ /* This should be fast enough not to have to test for INFO_FAST */
dir_name = maildir_full_name_to_dir_name (fi->full_name);
if (!strcmp (dir_name, ".")) {
- path = g_strdup_printf("%s/.ev-summary", root);
+ path = g_build_filename (root, ".ev-summary", NULL);
folderpath = g_strdup (root);
} else {
- path = g_strdup_printf("%s/%s.ev-summary", root, dir_name);
- folderpath = g_strdup_printf("%s%s", root, dir_name);
+ path = g_build_filename (root, dir_name, ".ev-summary", NULL);
+ folderpath = g_build_filename (root, dir_name, NULL);
}
s = (CamelFolderSummary *) camel_maildir_summary_new (NULL, path, folderpath, NULL);
@@ -403,15 +438,25 @@ fill_fi (CamelStore *store,
static CamelFolderInfo *
scan_fi (CamelStore *store,
guint32 flags,
- CamelURL *url,
const gchar *full,
const gchar *name,
GCancellable *cancellable)
{
+ CamelLocalSettings *local_settings;
+ CamelSettings *settings;
+ CamelService *service;
CamelFolderInfo *fi;
gchar *tmp, *cur, *new, *dir_name;
+ const gchar *path;
struct stat st;
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
+ g_return_val_if_fail (path != NULL, NULL);
+
fi = camel_folder_info_new ();
fi->full_name = g_strdup (full);
fi->display_name = g_strdup (name);
@@ -426,9 +471,9 @@ scan_fi (CamelStore *store,
dir_name = maildir_full_name_to_dir_name (fi->full_name);
d(printf("Adding maildir info: '%s' '%s' '%s'\n", fi->name, dir_name, fi->uri));
- tmp = g_build_filename (url->path, dir_name, "tmp", NULL);
- cur = g_build_filename (url->path, dir_name, "cur", NULL);
- new = g_build_filename (url->path, dir_name, "new", NULL);
+ tmp = g_build_filename (path, dir_name, "tmp", NULL);
+ cur = g_build_filename (path, dir_name, "cur", NULL);
+ new = g_build_filename (path, dir_name, "new", NULL);
if (!(g_stat (tmp, &st) == 0 && S_ISDIR (st.st_mode)
&& g_stat (cur, &st) == 0 && S_ISDIR (st.st_mode)
@@ -483,32 +528,37 @@ static gint
scan_dirs (CamelStore *store,
guint32 flags,
CamelFolderInfo **topfi,
- CamelURL *url,
GCancellable *cancellable,
GError **error)
{
- CamelURL *service_url;
- const gchar *root;
+ CamelLocalSettings *local_settings;
+ CamelSettings *settings;
+ CamelService *service;
+ const gchar *path;
GPtrArray *folders;
gint res = -1;
DIR *dir;
struct dirent *d;
gchar *meta_path = NULL;
- service_url = camel_service_get_camel_url (CAMEL_SERVICE (store));
- root = service_url->path;
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
+ g_return_val_if_fail (path != NULL, -1);
folders = g_ptr_array_new ();
if (!g_ascii_strcasecmp ((*topfi)->full_name, "Inbox"))
g_ptr_array_add (folders, (*topfi));
- dir = opendir (root);
+ dir = opendir (path);
if (dir == NULL) {
g_set_error (
- error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Could not scan folder '%s': %s"),
- root, g_strerror (errno));
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ _("Could not scan folder '%s': %s"),
+ path, g_strerror (errno));
goto fail;
}
@@ -534,7 +584,7 @@ scan_dirs (CamelStore *store,
continue;
- filename = g_build_filename (root, d->d_name, NULL);
+ filename = g_build_filename (path, d->d_name, NULL);
if (!(g_stat (filename, &st) == 0 && S_ISDIR (st.st_mode))) {
g_free (filename);
continue;
@@ -554,7 +604,7 @@ scan_dirs (CamelStore *store,
continue;
}
- fi = scan_fi (store, flags, url, full_name, short_name, cancellable);
+ fi = scan_fi (store, flags, full_name, short_name, cancellable);
g_free (full_name);
fi->flags &= ~CAMEL_FOLDER_NOCHILDREN;
@@ -606,44 +656,33 @@ maildir_store_get_folder_info_sync (CamelStore *store,
GError **error)
{
CamelFolderInfo *fi = NULL;
- CamelURL *service_url;
- CamelURL *url;
-
- service_url = camel_service_get_camel_url (CAMEL_SERVICE (store));
-
- url = camel_url_new ("maildir:", NULL);
- camel_url_set_path (url, service_url->path);
if (top == NULL || top[0] == 0) {
/* create a dummy "." parent inbox, use to scan, then put back at the top level */
- fi = scan_fi(store, flags, url, "Inbox", _("Inbox"), cancellable);
- if (scan_dirs (store, flags, &fi, url, cancellable, error) == -1)
+ fi = scan_fi(store, flags, "Inbox", _("Inbox"), cancellable);
+ if (scan_dirs (store, flags, &fi, cancellable, error) == -1)
goto fail;
fi->flags |= CAMEL_FOLDER_SYSTEM | CAMEL_FOLDER_TYPE_INBOX;
} else if (!strcmp(top, ".")) {
- fi = scan_fi(store, flags, url, "Inbox", _("Inbox"), cancellable);
+ fi = scan_fi(store, flags, "Inbox", _("Inbox"), cancellable);
fi->flags |= CAMEL_FOLDER_SYSTEM | CAMEL_FOLDER_TYPE_INBOX;
} else {
const gchar *name = strrchr (top, '/');
- fi = scan_fi (store, flags, url, top, name ? name + 1 : top, cancellable);
+ fi = scan_fi (store, flags, top, name ? name + 1 : top, cancellable);
if (g_strcmp0 (fi->full_name, CAMEL_VTRASH_NAME) != 0 &&
g_strcmp0 (fi->full_name, CAMEL_VJUNK_NAME) != 0 &&
- scan_dirs (store, flags, &fi, url, cancellable, error) == -1)
+ scan_dirs (store, flags, &fi, cancellable, error) == -1)
goto fail;
}
- camel_url_free (url);
-
return fi;
fail:
if (fi)
camel_store_free_folder_info_full (store, fi);
- camel_url_free (url);
-
return NULL;
}
@@ -785,13 +824,24 @@ static gchar *
maildir_get_full_path (CamelLocalStore *ls,
const gchar *full_name)
{
- gchar *dir_name, *path;
+ CamelLocalSettings *local_settings;
+ CamelSettings *settings;
+ CamelService *service;
+ const gchar *path;
+ gchar *filename;
+ gchar *dir_name;
+
+ service = CAMEL_SERVICE (ls);
+ settings = camel_service_get_settings (service);
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
dir_name = maildir_full_name_to_dir_name (full_name);
- path = g_strdup_printf("%s%s", ls->toplevel_dir, dir_name);
+ filename = g_build_filename (path, dir_name, NULL);
g_free (dir_name);
- return path;
+ return filename;
}
static gchar *
@@ -799,13 +849,27 @@ maildir_get_meta_path (CamelLocalStore *ls,
const gchar *full_name,
const gchar *ext)
{
- gchar *dir_name, *path;
+ CamelLocalSettings *local_settings;
+ CamelSettings *settings;
+ CamelService *service;
+ const gchar *path;
+ gchar *filename;
+ gchar *dir_name;
+ gchar *tmp;
+
+ service = CAMEL_SERVICE (ls);
+ settings = camel_service_get_settings (service);
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
dir_name = maildir_full_name_to_dir_name (full_name);
- path = g_strdup_printf("%s%s%s", ls->toplevel_dir, dir_name, ext);
+ tmp = g_build_filename (path, dir_name, NULL);
+ filename = g_strconcat (tmp, ext, NULL);
+ g_free (tmp);
g_free (dir_name);
- return path;
+ return filename;
}
/* Migration from old to maildir++ hierarchy */
@@ -844,17 +908,22 @@ scan_old_dir_info (CamelStore *store,
CamelFolderInfo *topfi,
GError **error)
{
+ CamelLocalSettings *local_settings;
+ CamelSettings *settings;
+ CamelService *service;
CamelDList queue = CAMEL_DLIST_INITIALISER (queue);
- CamelURL *url;
struct _scan_node *sn;
- const gchar *root;
+ const gchar *path;
gchar *tmp;
GHashTable *visited;
struct stat st;
gint res = -1;
- url = camel_service_get_camel_url (CAMEL_SERVICE (store));
- root = url->path;
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
visited = g_hash_table_new (scan_hash, scan_equal);
@@ -874,9 +943,9 @@ scan_old_dir_info (CamelStore *store,
last = (CamelFolderInfo *) &sn->fi->child;
if (!strcmp(sn->fi->full_name, "."))
- name = g_strdup (root);
+ name = g_strdup (path);
else
- name = g_build_filename (root, sn->fi->full_name, NULL);
+ name = g_build_filename (path, sn->fi->full_name, NULL);
dir = opendir (name);
if (dir == NULL) {
@@ -885,7 +954,7 @@ scan_old_dir_info (CamelStore *store,
error, G_IO_ERROR,
g_io_error_from_errno (errno),
_("Could not scan folder '%s': %s"),
- root, g_strerror (errno));
+ path, g_strerror (errno));
goto fail;
}
diff --git a/camel/providers/local/camel-mbox-store.c b/camel/providers/local/camel-mbox-store.c
index 9a39c30..e8621f1 100644
--- a/camel/providers/local/camel-mbox-store.c
+++ b/camel/providers/local/camel-mbox-store.c
@@ -525,22 +525,30 @@ mbox_store_create_folder_sync (CamelStore *store,
{
/* FIXME: this is almost an exact copy of CamelLocalStore::create_folder() except that we use
* different path schemes... need to find a way to share parent's code? */
+ CamelLocalSettings *local_settings;
CamelLocalStore *local_store;
CamelFolderInfo *info = NULL;
- const gchar *toplevel_dir;
+ CamelSettings *settings;
+ CamelService *service;
+ const gchar *root_path;
gchar *path, *name, *dir;
CamelFolder *folder;
struct stat st;
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ root_path = camel_local_settings_get_path (local_settings);
+
local_store = CAMEL_LOCAL_STORE (store);
- toplevel_dir = local_store->toplevel_dir;
- if (!g_path_is_absolute (toplevel_dir)) {
+ if (!g_path_is_absolute (root_path)) {
g_set_error (
error, CAMEL_STORE_ERROR,
CAMEL_STORE_ERROR_NO_FOLDER,
_("Store root %s is not an absolute path"),
- toplevel_dir);
+ root_path);
return NULL;
}
@@ -895,18 +903,29 @@ static gchar *
mbox_store_get_full_path (CamelLocalStore *ls,
const gchar *full_name)
{
+ CamelLocalSettings *local_settings;
+ CamelSettings *settings;
+ CamelService *service;
const gchar *inptr = full_name;
+ const gchar *root_path;
gint subdirs = 0;
gchar *path, *p;
+ service = CAMEL_SERVICE (ls);
+ settings = camel_service_get_settings (service);
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ root_path = camel_local_settings_get_path (local_settings);
+ g_return_val_if_fail (root_path != NULL, NULL);
+
while (*inptr != '\0') {
if (G_IS_DIR_SEPARATOR (*inptr))
subdirs++;
inptr++;
}
- path = g_malloc (strlen (ls->toplevel_dir) + (inptr - full_name) + (4 * subdirs) + 1);
- p = g_stpcpy (path, ls->toplevel_dir);
+ path = g_malloc (strlen (root_path) + (inptr - full_name) + (4 * subdirs) + 1);
+ p = g_stpcpy (path, root_path);
inptr = full_name;
while (*inptr != '\0') {
diff --git a/camel/providers/local/camel-mh-settings.c b/camel/providers/local/camel-mh-settings.c
index a37073a..fc5c936 100644
--- a/camel/providers/local/camel-mh-settings.c
+++ b/camel/providers/local/camel-mh-settings.c
@@ -34,7 +34,7 @@ enum {
G_DEFINE_TYPE (
CamelMhSettings,
camel_mh_settings,
- CAMEL_TYPE_STORE_SETTINGS)
+ CAMEL_TYPE_LOCAL_SETTINGS)
static void
mh_settings_set_property (GObject *object,
diff --git a/camel/providers/local/camel-mh-settings.h b/camel/providers/local/camel-mh-settings.h
index cad65cd..08a9f0c 100644
--- a/camel/providers/local/camel-mh-settings.h
+++ b/camel/providers/local/camel-mh-settings.h
@@ -47,12 +47,12 @@ typedef struct _CamelMhSettingsClass CamelMhSettingsClass;
typedef struct _CamelMhSettingsPrivate CamelMhSettingsPrivate;
struct _CamelMhSettings {
- CamelStoreSettings parent;
+ CamelLocalSettings parent;
CamelMhSettingsPrivate *priv;
};
struct _CamelMhSettingsClass {
- CamelStoreSettingsClass parent_class;
+ CamelLocalSettingsClass parent_class;
};
GType camel_mh_settings_get_type (void) G_GNUC_CONST;
diff --git a/camel/providers/local/camel-mh-store.c b/camel/providers/local/camel-mh-store.c
index 2c7d221..c5f2cf5 100644
--- a/camel/providers/local/camel-mh-store.c
+++ b/camel/providers/local/camel-mh-store.c
@@ -64,7 +64,7 @@ folders_update (const gchar *root,
folder_newline = g_strdup_printf ("%s\n", folder);
tmpnew = g_alloca (strlen (root) + 16);
- sprintf (tmpnew, "%s.folders~", root);
+ sprintf (tmpnew, "%s" G_DIR_SEPARATOR_S ".folders~", root);
out = camel_stream_fs_new_with_name (
tmpnew, O_WRONLY | O_CREAT | O_TRUNC, 0666, NULL);
@@ -72,7 +72,7 @@ folders_update (const gchar *root,
goto fail;
tmp = g_alloca (strlen (root) + 16);
- sprintf (tmp, "%s.folders", root);
+ sprintf (tmp, "%s" G_DIR_SEPARATOR_S ".folders", root);
stream = camel_stream_fs_new_with_name (tmp, O_RDONLY, 0, NULL);
if (stream) {
in = camel_stream_buffer_new (stream, CAMEL_STREAM_BUFFER_READ);
@@ -201,9 +201,20 @@ fill_fi (CamelStore *store,
g_object_unref (folder);
} else {
- gchar *path, *folderpath;
+ CamelLocalSettings *local_settings;
+ CamelSettings *settings;
+ CamelService *service;
+ gchar *filename;
+ gchar *folderpath;
CamelFolderSummary *s;
- const gchar *root;
+ const gchar *path;
+ gchar *basename;
+
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
/* This should be fast enough not to have to test for INFO_FAST */
@@ -211,12 +222,13 @@ fill_fi (CamelStore *store,
* scan of all messages for their status flags. But its probably not worth
* it as we need to read the top of every file, i.e. very very slow */
- root = camel_local_store_get_toplevel_dir (local_store);
- path = g_strdup_printf (
- "%s/%s.ev-summary", root, fi->full_name);
- folderpath = g_strdup_printf ("%s/%s", root, fi->full_name);
+ basename = g_strdup_printf ("%s.ev-summary", fi->full_name);
+ filename = g_build_filename (path, basename, NULL);
+ g_free (basename);
+
+ folderpath = g_strdup_printf ("%s/%s", path, fi->full_name);
s = (CamelFolderSummary *) camel_mh_summary_new (
- NULL, path, folderpath, NULL);
+ NULL, filename, folderpath, NULL);
if (camel_folder_summary_header_load_from_db (
s, store, fi->full_name, NULL)) {
fi->unread = camel_folder_summary_get_unread_count (s);
@@ -224,7 +236,7 @@ fill_fi (CamelStore *store,
}
g_object_unref (s);
g_free (folderpath);
- g_free (path);
+ g_free (filename);
}
if (camel_local_store_is_main_store (local_store) && fi->full_name
@@ -474,18 +486,20 @@ mh_store_get_folder_sync (CamelStore *store,
GError **error)
{
CamelStoreClass *store_class;
- CamelLocalStore *local_store;
- CamelService *service;
+ CamelLocalSettings *local_settings;
CamelSettings *settings;
+ CamelService *service;
gboolean use_dot_folders;
+ const gchar *path;
gchar *name;
struct stat st;
- local_store = CAMEL_LOCAL_STORE (store);
-
service = CAMEL_SERVICE (store);
settings = camel_service_get_settings (service);
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
+
use_dot_folders = camel_mh_settings_get_use_dot_folders (
CAMEL_MH_SETTINGS (settings));
@@ -495,7 +509,7 @@ mh_store_get_folder_sync (CamelStore *store,
store, folder_name, flags, cancellable, error) == NULL)
return NULL;
- name = g_strconcat (local_store->toplevel_dir, folder_name, NULL);
+ name = g_build_filename (path, folder_name, NULL);
if (g_stat (name, &st) == -1) {
if (errno != ENOENT) {
@@ -532,8 +546,8 @@ mh_store_get_folder_sync (CamelStore *store,
/* FIXME: throw exception on error */
if (use_dot_folders)
folders_update (
- local_store->toplevel_dir,
- UPDATE_ADD, folder_name, NULL, cancellable);
+ path, UPDATE_ADD, folder_name,
+ NULL, cancellable);
} else if (!S_ISDIR (st.st_mode)) {
g_set_error (
@@ -566,23 +580,26 @@ mh_store_get_folder_info_sync (CamelStore *store,
GCancellable *cancellable,
GError **error)
{
+ CamelLocalSettings *local_settings;
CamelService *service;
CamelSettings *settings;
CamelFolderInfo *fi = NULL;
- CamelURL *url;
gboolean use_dot_folders;
+ const gchar *path;
service = CAMEL_SERVICE (store);
- url = camel_service_get_camel_url (service);
settings = camel_service_get_settings (service);
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
+
use_dot_folders = camel_mh_settings_get_use_dot_folders (
CAMEL_MH_SETTINGS (settings));
/* use .folders if we are supposed to */
if (use_dot_folders) {
folders_scan (
- store, url->path, top, &fi, flags, cancellable);
+ store, path, top, &fi, flags, cancellable);
} else {
GHashTable *visited;
@@ -592,8 +609,8 @@ mh_store_get_folder_info_sync (CamelStore *store,
top = "";
recursive_scan (
- store, &fi, NULL, visited, url->path,
- top, flags, cancellable);
+ store, &fi, NULL, visited,
+ path, top, flags, cancellable);
/* If we actually scanned from root,
* we have a "" root node we dont want. */
@@ -629,22 +646,24 @@ mh_store_delete_folder_sync (CamelStore *store,
GError **error)
{
CamelStoreClass *store_class;
- CamelLocalStore *local_store;
- CamelService *service;
+ CamelLocalSettings *local_settings;
CamelSettings *settings;
+ CamelService *service;
gboolean use_dot_folders;
+ const gchar *path;
gchar *name;
- local_store = CAMEL_LOCAL_STORE (store);
-
service = CAMEL_SERVICE (store);
settings = camel_service_get_settings (service);
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
+
use_dot_folders = camel_mh_settings_get_use_dot_folders (
CAMEL_MH_SETTINGS (settings));
/* remove folder directory - will fail if not empty */
- name = g_strconcat (local_store->toplevel_dir, folder_name, NULL);
+ name = g_build_filename (path, folder_name, NULL);
if (rmdir (name) == -1) {
g_set_error (
error, G_IO_ERROR,
@@ -659,8 +678,8 @@ mh_store_delete_folder_sync (CamelStore *store,
/* remove from .folders if we are supposed to */
if (use_dot_folders)
folders_update (
- local_store->toplevel_dir,
- UPDATE_REMOVE, folder_name, NULL, cancellable);
+ path, UPDATE_REMOVE, folder_name,
+ NULL, cancellable);
/* Chain up to parent's delete_folder() method. */
store_class = CAMEL_STORE_CLASS (camel_mh_store_parent_class);
@@ -676,16 +695,18 @@ mh_store_rename_folder_sync (CamelStore *store,
GError **error)
{
CamelStoreClass *store_class;
- CamelLocalStore *local_store;
- CamelService *service;
+ CamelLocalSettings *local_settings;
CamelSettings *settings;
+ CamelService *service;
gboolean use_dot_folders;
-
- local_store = CAMEL_LOCAL_STORE (store);
+ const gchar *path;
service = CAMEL_SERVICE (store);
settings = camel_service_get_settings (service);
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
+
use_dot_folders = camel_mh_settings_get_use_dot_folders (
CAMEL_MH_SETTINGS (settings));
@@ -698,8 +719,7 @@ mh_store_rename_folder_sync (CamelStore *store,
if (use_dot_folders) {
/* yeah this is messy, but so is mh! */
folders_update (
- local_store->toplevel_dir,
- UPDATE_RENAME, old, new, cancellable);
+ path, UPDATE_RENAME, old, new, cancellable);
}
return TRUE;
diff --git a/camel/providers/local/camel-spool-settings.c b/camel/providers/local/camel-spool-settings.c
index 38218f4..0fb60c1 100644
--- a/camel/providers/local/camel-spool-settings.c
+++ b/camel/providers/local/camel-spool-settings.c
@@ -34,7 +34,7 @@ enum {
G_DEFINE_TYPE (
CamelSpoolSettings,
camel_spool_settings,
- CAMEL_TYPE_STORE_SETTINGS)
+ CAMEL_TYPE_LOCAL_SETTINGS)
static void
spool_settings_set_property (GObject *object,
diff --git a/camel/providers/local/camel-spool-settings.h b/camel/providers/local/camel-spool-settings.h
index f733f93..39143b4 100644
--- a/camel/providers/local/camel-spool-settings.h
+++ b/camel/providers/local/camel-spool-settings.h
@@ -47,12 +47,12 @@ typedef struct _CamelSpoolSettingsClass CamelSpoolSettingsClass;
typedef struct _CamelSpoolSettingsPrivate CamelSpoolSettingsPrivate;
struct _CamelSpoolSettings {
- CamelStoreSettings parent;
+ CamelLocalSettings parent;
CamelSpoolSettingsPrivate *priv;
};
struct _CamelSpoolSettingsClass {
- CamelStoreSettingsClass parent_class;
+ CamelLocalSettingsClass parent_class;
};
GType camel_spool_settings_get_type (void) G_GNUC_CONST;
diff --git a/camel/providers/local/camel-spool-store.c b/camel/providers/local/camel-spool-store.c
index e714b05..d016059 100644
--- a/camel/providers/local/camel-spool-store.c
+++ b/camel/providers/local/camel-spool-store.c
@@ -46,26 +46,69 @@
#define d(x)
typedef enum _camel_spool_store_t {
+ CAMEL_SPOOL_STORE_INVALID,
CAMEL_SPOOL_STORE_MBOX, /* a single mbox */
CAMEL_SPOOL_STORE_ELM /* elm/pine/etc tree of mbox files in folders */
} camel_spool_store_t;
struct _CamelSpoolStorePrivate {
- camel_spool_store_t type;
+ gint placeholder; /* for future expansion */
};
-static GInitableIface *parent_initable_interface;
-
-/* Forward Declarations */
-static void camel_spool_store_initable_init (GInitableIface *interface);
-
-G_DEFINE_TYPE_WITH_CODE (
+G_DEFINE_TYPE (
CamelSpoolStore,
camel_spool_store,
- CAMEL_TYPE_MBOX_STORE,
- G_IMPLEMENT_INTERFACE (
- G_TYPE_INITABLE,
- camel_spool_store_initable_init))
+ CAMEL_TYPE_MBOX_STORE)
+
+static camel_spool_store_t
+spool_store_get_type (CamelSpoolStore *spool_store,
+ GError **error)
+{
+ CamelLocalSettings *local_settings;
+ CamelSettings *settings;
+ CamelService *service;
+ const gchar *path;
+ struct stat st;
+
+ service = CAMEL_SERVICE (spool_store);
+ settings = camel_service_get_settings (service);
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
+
+ /* Check the path for validity while we have the opportunity. */
+
+ if (path == NULL || *path != '/') {
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
+ _("Store root %s is not an absolute path"),
+ (path != NULL) ? path : "(null)");
+ return CAMEL_SPOOL_STORE_INVALID;
+ }
+
+ if (g_stat (path, &st) == -1) {
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ _("Spool '%s' cannot be opened: %s"),
+ path, g_strerror (errno));
+ return CAMEL_SPOOL_STORE_INVALID;
+ }
+
+ if (S_ISREG (st.st_mode))
+ return CAMEL_SPOOL_STORE_MBOX;
+
+ if (S_ISDIR (st.st_mode))
+ return CAMEL_SPOOL_STORE_ELM;
+
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
+ _("Spool '%s' is not a regular file or directory"), path);
+
+ return CAMEL_SPOOL_STORE_INVALID;
+}
/* partially copied from mbox */
static void
@@ -128,7 +171,7 @@ struct _inode {
static gint
scan_dir (CamelStore *store,
GHashTable *visited,
- gchar *root,
+ const gchar *root,
const gchar *path,
guint32 flags,
CamelFolderInfo *parent,
@@ -152,7 +195,7 @@ scan_dir (CamelStore *store,
name = alloca (strlen (root) + strlen (path) + 2);
sprintf(name, "%s/%s", root, path);
} else
- name = root;
+ name = (gchar *) root; /* XXX casting away const */
if (g_stat (name, &st) == -1) {
g_set_error (
@@ -290,15 +333,22 @@ get_folder_info_elm (CamelStore *store,
GCancellable *cancellable,
GError **error)
{
+ CamelLocalSettings *local_settings;
+ CamelSettings *settings;
+ CamelService *service;
CamelFolderInfo *fi = NULL;
GHashTable *visited;
- CamelURL *url;
+ const gchar *path;
visited = g_hash_table_new (inode_hash, inode_equal);
- url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
- if (scan_dir (store, visited, url->path, top, flags, NULL, &fi, cancellable, error) == -1 && fi != NULL) {
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
+
+ if (scan_dir (store, visited, path, top, flags, NULL, &fi, cancellable, error) == -1 && fi != NULL) {
camel_store_free_folder_info_full (store, fi);
fi = NULL;
}
@@ -336,21 +386,36 @@ static gchar *
spool_store_get_name (CamelService *service,
gboolean brief)
{
+ CamelLocalSettings *local_settings;
CamelSpoolStore *spool_store;
- CamelURL *url;
+ CamelSettings *settings;
+ const gchar *path;
+ gchar *name;
spool_store = CAMEL_SPOOL_STORE (service);
+ settings = camel_service_get_settings (service);
- url = camel_service_get_camel_url (service);
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
if (brief)
- return g_strdup (url->path);
- else if (spool_store->priv->type == CAMEL_SPOOL_STORE_MBOX)
- return g_strdup_printf (
- _("Spool mail file %s"), url->path);
- else
- return g_strdup_printf (
- _("Spool folder tree %s"), url->path);
+ return g_strdup (path);
+
+ switch (spool_store_get_type (spool_store, NULL)) {
+ case CAMEL_SPOOL_STORE_MBOX:
+ name = g_strdup_printf (
+ _("Spool mail file %s"), path);
+ break;
+ case CAMEL_SPOOL_STORE_ELM:
+ name = g_strdup_printf (
+ _("Spool folder tree %s"), path);
+ break;
+ default:
+ name = g_strdup (_("Invalid spool"));
+ break;
+ }
+
+ return name;
}
static void
@@ -371,35 +436,44 @@ spool_store_get_folder_sync (CamelStore *store,
GCancellable *cancellable,
GError **error)
{
- CamelLocalStore *local_store;
+ CamelLocalSettings *local_settings;
CamelSpoolStore *spool_store;
+ CamelSettings *settings;
+ CamelService *service;
CamelFolder *folder = NULL;
- CamelURL *url;
+ camel_spool_store_t type;
struct stat st;
+ const gchar *path;
gchar *name;
d(printf("opening folder %s on path %s\n", folder_name, path));
- local_store = CAMEL_LOCAL_STORE (store);
spool_store = CAMEL_SPOOL_STORE (store);
+ type = spool_store_get_type (spool_store, error);
+
+ if (type == CAMEL_SPOOL_STORE_INVALID)
+ return NULL;
+
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
- url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
/* we only support an 'INBOX' in mbox mode */
- if (spool_store->priv->type == CAMEL_SPOOL_STORE_MBOX) {
+ if (type == CAMEL_SPOOL_STORE_MBOX) {
if (strcmp(folder_name, "INBOX") != 0) {
g_set_error (
error, CAMEL_STORE_ERROR,
CAMEL_STORE_ERROR_NO_FOLDER,
_("Folder '%s/%s' does not exist."),
- url->path, folder_name);
+ path, folder_name);
} else {
folder = camel_spool_folder_new (
store, folder_name, flags, cancellable, error);
}
} else {
- name = g_strconcat (
- local_store->toplevel_dir, folder_name, NULL);
+ name = g_build_filename (path, folder_name, NULL);
if (g_stat (name, &st) == -1) {
if (errno != ENOENT) {
g_set_error (
@@ -449,15 +523,26 @@ spool_store_get_folder_info_sync (CamelStore *store,
GError **error)
{
CamelSpoolStore *spool_store;
+ CamelFolderInfo *folder_info = NULL;
spool_store = CAMEL_SPOOL_STORE (store);
- if (spool_store->priv->type == CAMEL_SPOOL_STORE_MBOX)
- return get_folder_info_mbox (
- store, top, flags, cancellable, error);
- else
- return get_folder_info_elm (
- store, top, flags, cancellable, error);
+ switch (spool_store_get_type (spool_store, error)) {
+ case CAMEL_SPOOL_STORE_MBOX:
+ folder_info = get_folder_info_mbox (
+ store, top, flags, cancellable, error);
+ break;
+
+ case CAMEL_SPOOL_STORE_ELM:
+ folder_info = get_folder_info_elm (
+ store, top, flags, cancellable, error);
+ break;
+
+ default:
+ break;
+ }
+
+ return folder_info;
}
static CamelFolder *
@@ -470,15 +555,23 @@ spool_store_get_inbox_folder_sync (CamelStore *store,
spool_store = CAMEL_SPOOL_STORE (store);
- if (spool_store->priv->type == CAMEL_SPOOL_STORE_MBOX)
- folder = spool_store_get_folder_sync (
- store, "INBOX", CAMEL_STORE_FOLDER_CREATE,
- cancellable, error);
- else
- g_set_error (
- error, CAMEL_STORE_ERROR,
- CAMEL_STORE_ERROR_NO_FOLDER,
- _("Store does not support an INBOX"));
+ switch (spool_store_get_type (spool_store, error)) {
+ case CAMEL_SPOOL_STORE_MBOX:
+ folder = spool_store_get_folder_sync (
+ store, "INBOX", CAMEL_STORE_FOLDER_CREATE,
+ cancellable, error);
+ break;
+
+ case CAMEL_SPOOL_STORE_ELM:
+ g_set_error (
+ error, CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
+ _("Store does not support an INBOX"));
+ break;
+
+ default:
+ break;
+ }
return folder;
}
@@ -516,19 +609,36 @@ static gchar *
spool_store_get_full_path (CamelLocalStore *local_store,
const gchar *full_name)
{
+ CamelLocalSettings *local_settings;
CamelSpoolStore *spool_store;
+ CamelSettings *settings;
+ CamelService *service;
+ const gchar *path;
+ gchar *full_path;
+
+ service = CAMEL_SERVICE (local_store);
+ settings = camel_service_get_settings (service);
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ path = camel_local_settings_get_path (local_settings);
spool_store = CAMEL_SPOOL_STORE (local_store);
- if (spool_store->priv->type == CAMEL_SPOOL_STORE_MBOX)
- /* A trailing / is always present on
- * toplevel_dir from CamelLocalStore. */
- return g_strndup (
- local_store->toplevel_dir,
- strlen (local_store->toplevel_dir) - 1);
- else
- return g_strdup_printf (
- "%s/%s", local_store->toplevel_dir, full_name);
+ switch (spool_store_get_type (spool_store, NULL)) {
+ case CAMEL_SPOOL_STORE_MBOX:
+ full_path = g_strdup (path);
+ break;
+
+ case CAMEL_SPOOL_STORE_ELM:
+ full_path = g_build_filename (path, full_name, NULL);
+ break;
+
+ default:
+ full_path = NULL;
+ break;
+ }
+
+ return full_path;
}
static gchar *
@@ -550,60 +660,6 @@ spool_store_get_meta_path (CamelLocalStore *ls,
return path;
}
-static gboolean
-spool_store_initable_init (GInitable *initable,
- GCancellable *cancellable,
- GError **error)
-{
- CamelSpoolStore *spool_store;
- CamelService *service;
- CamelURL *url;
- struct stat st;
-
- /* Chain up to parent interface's init() method. */
- if (!parent_initable_interface->init (initable, cancellable, error))
- return FALSE;
-
- service = CAMEL_SERVICE (initable);
- url = camel_service_get_camel_url (service);
-
- if (url->path[0] != '/') {
- g_set_error (
- error, CAMEL_STORE_ERROR,
- CAMEL_STORE_ERROR_NO_FOLDER,
- _("Store root %s is not an absolute path"),
- url->path);
- return FALSE;
- }
-
- if (g_stat (url->path, &st) == -1) {
- g_set_error (
- error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Spool '%s' cannot be opened: %s"),
- url->path, g_strerror (errno));
- return FALSE;
- }
-
- spool_store = CAMEL_SPOOL_STORE (initable);
-
- if (S_ISREG (st.st_mode))
- spool_store->priv->type = CAMEL_SPOOL_STORE_MBOX;
- else if (S_ISDIR (st.st_mode))
- /* we could check here for slight variations */
- spool_store->priv->type = CAMEL_SPOOL_STORE_ELM;
- else {
- g_set_error (
- error, CAMEL_STORE_ERROR,
- CAMEL_STORE_ERROR_NO_FOLDER,
- _("Spool '%s' is not a regular file or directory"),
- url->path);
- return FALSE;
- }
-
- return TRUE;
-}
-
static void
camel_spool_store_class_init (CamelSpoolStoreClass *class)
{
@@ -631,14 +687,6 @@ camel_spool_store_class_init (CamelSpoolStoreClass *class)
}
static void
-camel_spool_store_initable_init (GInitableIface *interface)
-{
- parent_initable_interface = g_type_interface_peek_parent (interface);
-
- interface->init = spool_store_initable_init;
-}
-
-static void
camel_spool_store_init (CamelSpoolStore *spool_store)
{
spool_store->priv = CAMEL_SPOOL_STORE_GET_PRIVATE (spool_store);
diff --git a/camel/providers/nntp/camel-nntp-settings.c b/camel/providers/nntp/camel-nntp-settings.c
index 2ce87ac..1cade9b 100644
--- a/camel/providers/nntp/camel-nntp-settings.c
+++ b/camel/providers/nntp/camel-nntp-settings.c
@@ -29,9 +29,13 @@ struct _CamelNNTPSettingsPrivate {
enum {
PROP_0,
+ PROP_AUTH_MECHANISM,
PROP_FOLDER_HIERARCHY_RELATIVE,
+ PROP_HOST,
+ PROP_PORT,
PROP_SECURITY_METHOD,
- PROP_SHORT_FOLDER_NAMES
+ PROP_SHORT_FOLDER_NAMES,
+ PROP_USER
};
G_DEFINE_TYPE_WITH_CODE (
@@ -48,12 +52,30 @@ nntp_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_FOLDER_HIERARCHY_RELATIVE:
camel_nntp_settings_set_folder_hierarchy_relative (
CAMEL_NNTP_SETTINGS (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),
@@ -65,6 +87,12 @@ nntp_settings_set_property (GObject *object,
CAMEL_NNTP_SETTINGS (object),
g_value_get_boolean (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);
@@ -77,6 +105,13 @@ nntp_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_FOLDER_HIERARCHY_RELATIVE:
g_value_set_boolean (
value,
@@ -84,6 +119,20 @@ nntp_settings_get_property (GObject *object,
CAMEL_NNTP_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,
@@ -97,6 +146,13 @@ nntp_settings_get_property (GObject *object,
camel_nntp_settings_get_short_folder_names (
CAMEL_NNTP_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);
@@ -113,6 +169,12 @@ camel_nntp_settings_class_init (CamelNNTPSettingsClass *class)
object_class->set_property = nntp_settings_set_property;
object_class->get_property = nntp_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_FOLDER_HIERARCHY_RELATIVE,
@@ -128,6 +190,18 @@ camel_nntp_settings_class_init (CamelNNTPSettingsClass *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");
@@ -142,6 +216,12 @@ camel_nntp_settings_class_init (CamelNNTPSettingsClass *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/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c
index 48b0eb9..1bd0280 100644
--- a/camel/providers/nntp/camel-nntp-store.c
+++ b/camel/providers/nntp/camel-nntp-store.c
@@ -248,19 +248,26 @@ connect_to_server (CamelService *service,
{
CamelNNTPStore *store = (CamelNNTPStore *) service;
CamelDiscoStore *disco_store = (CamelDiscoStore *) service;
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
CamelSession *session;
- CamelURL *url;
CamelStream *tcp_stream;
const gchar *user_cache_dir;
+ const gchar *host;
+ const gchar *user;
gboolean retval = FALSE;
guchar *buf;
guint len;
gchar *path;
- url = camel_service_get_camel_url (service);
session = camel_service_get_session (service);
+ settings = camel_service_get_settings (service);
user_cache_dir = camel_service_get_user_cache_dir (service);
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
+ user = camel_network_settings_get_user (network_settings);
+
camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
tcp_stream = camel_network_service_connect_sync (
@@ -275,8 +282,7 @@ connect_to_server (CamelService *service,
/* Read the greeting, if any. */
if (camel_nntp_stream_line (store->stream, &buf, &len, cancellable, error) == -1) {
g_prefix_error (
- error, _("Could not read greeting from %s: "),
- url->host);
+ error, _("Could not read greeting from %s: "), host);
g_object_unref (store->stream);
store->stream = NULL;
@@ -289,7 +295,7 @@ connect_to_server (CamelService *service,
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("NNTP server %s returned error code %d: %s"),
- url->host, len, buf);
+ host, len, buf);
g_object_unref (store->stream);
store->stream = NULL;
@@ -298,7 +304,7 @@ connect_to_server (CamelService *service,
}
/* if we have username, try it here */
- if (url->user != NULL && *url->user != '\0') {
+ if (user != NULL && *user != '\0') {
/* XXX No SASL support. */
if (!camel_session_authenticate_sync (
@@ -443,14 +449,19 @@ static gchar *
nntp_store_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 ("%s", url->host);
+ return g_strdup_printf ("%s", host);
else
- return g_strdup_printf (_("USENET News via %s"), url->host);
+ return g_strdup_printf (_("USENET News via %s"), host);
}
@@ -462,19 +473,24 @@ nntp_store_authenticate_sync (CamelService *service,
GCancellable *cancellable,
GError **error)
{
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
CamelNNTPStore *store;
CamelAuthenticationResult result;
- CamelURL *url;
const gchar *password;
+ const gchar *user;
gchar *line = NULL;
gint status;
store = CAMEL_NNTP_STORE (service);
- url = camel_service_get_camel_url (service);
password = camel_service_get_password (service);
+ settings = camel_service_get_settings (service);
+
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ user = camel_network_settings_get_user (network_settings);
- if (url->user == NULL) {
+ if (user == NULL) {
g_set_error_literal (
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
@@ -493,7 +509,7 @@ nntp_store_authenticate_sync (CamelService *service,
/* XXX Currently only authinfo user/pass is supported. */
status = camel_nntp_raw_command (
store, cancellable, error, &line,
- "authinfo user %s", url->user);
+ "authinfo user %s", user);
if (status == NNTP_AUTH_CONTINUE)
status = camel_nntp_raw_command (
store, cancellable, error, &line,
diff --git a/camel/providers/nntp/camel-nntp-summary.c b/camel/providers/nntp/camel-nntp-summary.c
index f8c02e3..d1d4e9f 100644
--- a/camel/providers/nntp/camel-nntp-summary.c
+++ b/camel/providers/nntp/camel-nntp-summary.c
@@ -219,10 +219,13 @@ add_range_xover (CamelNNTPSummary *cns,
GCancellable *cancellable,
GError **error)
{
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
+ CamelService *service;
CamelFolderSummary *s;
CamelMessageInfoBase *mi;
- CamelURL *url;
struct _camel_header_raw *headers = NULL;
+ const gchar *host;
gchar *line, *tab;
guint len;
gint ret;
@@ -231,10 +234,14 @@ add_range_xover (CamelNNTPSummary *cns,
s = (CamelFolderSummary *) cns;
- url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
+
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
camel_operation_push_message (
- cancellable, _("%s: Scanning new messages"), url->host);
+ cancellable, _("%s: Scanning new messages"), host);
if ((store->capabilities & NNTP_CAPABILITY_OVER) != 0)
ret = camel_nntp_raw_command_auth (store, cancellable, error, &line, "over %r", low, high);
@@ -332,22 +339,29 @@ add_range_head (CamelNNTPSummary *cns,
GCancellable *cancellable,
GError **error)
{
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
+ CamelService *service;
CamelFolderSummary *s;
- CamelURL *url;
gint ret = -1;
gchar *line, *msgid;
guint i, n, count, total;
CamelMessageInfo *mi;
CamelMimeParser *mp;
+ const gchar *host;
s = (CamelFolderSummary *) cns;
mp = camel_mime_parser_new ();
- url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
+
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
camel_operation_push_message (
- cancellable, _("%s: Scanning new messages"), url->host);
+ cancellable, _("%s: Scanning new messages"), host);
count = 0;
total = high - low + 1;
diff --git a/camel/providers/pop3/camel-pop3-settings.c b/camel/providers/pop3/camel-pop3-settings.c
index 6186384..85be9fa 100644
--- a/camel/providers/pop3/camel-pop3-settings.c
+++ b/camel/providers/pop3/camel-pop3-settings.c
@@ -31,11 +31,15 @@ struct _CamelPOP3SettingsPrivate {
enum {
PROP_0,
+ PROP_AUTH_MECHANISM,
PROP_DELETE_AFTER_DAYS,
PROP_DELETE_EXPUNGED,
PROP_DISABLE_EXTENSIONS,
+ PROP_HOST,
PROP_KEEP_ON_SERVER,
- PROP_SECURITY_METHOD
+ PROP_PORT,
+ PROP_SECURITY_METHOD,
+ PROP_USER
};
G_DEFINE_TYPE_WITH_CODE (
@@ -52,6 +56,12 @@ pop3_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_DELETE_AFTER_DAYS:
camel_pop3_settings_set_delete_after_days (
CAMEL_POP3_SETTINGS (object),
@@ -70,17 +80,35 @@ pop3_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_KEEP_ON_SERVER:
camel_pop3_settings_set_keep_on_server (
CAMEL_POP3_SETTINGS (object),
g_value_get_boolean (value));
return;
+ case PROP_PORT:
+ camel_network_settings_set_port (
+ CAMEL_NETWORK_SETTINGS (object),
+ g_value_get_uint (value));
+ return;
+
case PROP_SECURITY_METHOD:
camel_network_settings_set_security_method (
CAMEL_NETWORK_SETTINGS (object),
g_value_get_enum (value));
return;
+
+ case PROP_USER:
+ camel_network_settings_set_user (
+ CAMEL_NETWORK_SETTINGS (object),
+ g_value_get_string (value));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -93,6 +121,13 @@ pop3_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_DELETE_AFTER_DAYS:
g_value_set_int (
value,
@@ -114,6 +149,13 @@ pop3_settings_get_property (GObject *object,
CAMEL_POP3_SETTINGS (object)));
return;
+ case PROP_HOST:
+ g_value_set_string (
+ value,
+ camel_network_settings_get_host (
+ CAMEL_NETWORK_SETTINGS (object)));
+ return;
+
case PROP_KEEP_ON_SERVER:
g_value_set_boolean (
value,
@@ -121,12 +163,26 @@ pop3_settings_get_property (GObject *object,
CAMEL_POP3_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,
camel_network_settings_get_security_method (
CAMEL_NETWORK_SETTINGS (object)));
return;
+
+ case PROP_USER:
+ g_value_set_string (
+ value,
+ camel_network_settings_get_user (
+ CAMEL_NETWORK_SETTINGS (object)));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -143,6 +199,12 @@ camel_pop3_settings_class_init (CamelPOP3SettingsClass *class)
object_class->set_property = pop3_settings_set_property;
object_class->get_property = pop3_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_DELETE_AFTER_DAYS,
@@ -181,6 +243,12 @@ camel_pop3_settings_class_init (CamelPOP3SettingsClass *class)
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
+ /* Inherited from CamelNetworkSettings. */
+ g_object_class_override_property (
+ object_class,
+ PROP_HOST,
+ "host");
+
g_object_class_install_property (
object_class,
PROP_KEEP_ON_SERVER,
@@ -196,8 +264,20 @@ camel_pop3_settings_class_init (CamelPOP3SettingsClass *class)
/* 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");
+
+ /* Inherited from CamelNetworkSettings. */
+ g_object_class_override_property (
+ object_class,
+ PROP_USER,
+ "user");
}
static void
diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c
index de07cd0..adcba5c 100644
--- a/camel/providers/pop3/camel-pop3-store.c
+++ b/camel/providers/pop3/camel-pop3-store.c
@@ -92,19 +92,22 @@ connect_to_server (CamelService *service,
GError **error)
{
CamelPOP3Store *store = CAMEL_POP3_STORE (service);
+ CamelNetworkSettings *network_settings;
CamelNetworkSecurityMethod method;
CamelSettings *settings;
- CamelURL *url;
CamelStream *tcp_stream;
CamelPOP3Command *pc;
gboolean disable_extensions;
+ const gchar *host;
guint32 flags = 0;
gint clean_quit = TRUE;
gint ret;
- 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);
+
tcp_stream = camel_network_service_connect_sync (
CAMEL_NETWORK_SERVICE (service), cancellable, error);
@@ -128,7 +131,7 @@ connect_to_server (CamelService *service,
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to read a valid greeting from POP server %s"),
- url->host);
+ host);
g_object_unref (tcp_stream);
return FALSE;
}
@@ -147,7 +150,7 @@ connect_to_server (CamelService *service,
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to connect to POP server %s in secure mode: %s"),
- url->host, _("STLS not supported by server"));
+ host, _("STLS not supported by server"));
goto stls_exception;
}
@@ -166,7 +169,7 @@ connect_to_server (CamelService *service,
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
/* Translators: Last %s is an optional explanation beginning with ": " separator */
_("Failed to connect to POP server %s in secure mode%s"),
- url->host, (tmp != NULL) ? tmp : "");
+ host, (tmp != NULL) ? tmp : "");
g_free (tmp);
goto stls_exception;
}
@@ -179,7 +182,7 @@ connect_to_server (CamelService *service,
g_prefix_error (
error,
_("Failed to connect to POP server %s in secure mode: "),
- url->host);
+ host);
goto stls_exception;
}
@@ -214,17 +217,22 @@ try_sasl (CamelPOP3Store *store,
GError **error)
{
CamelPOP3Stream *stream = store->engine->stream;
+ CamelNetworkSettings *network_settings;
CamelAuthenticationResult result;
+ CamelSettings *settings;
CamelService *service;
- CamelURL *url;
guchar *line, *resp;
+ const gchar *host;
CamelSasl *sasl;
gchar *string;
guint len;
gint ret;
service = CAMEL_SERVICE (store);
- 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);
sasl = camel_sasl_new ("pop", mechanism, service);
if (sasl == NULL) {
@@ -270,8 +278,7 @@ try_sasl (CamelPOP3Store *store,
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("Cannot login to POP server %s: "
- "SASL Protocol error"),
- url->host);
+ "SASL Protocol error"), host);
result = CAMEL_AUTHENTICATION_ERROR;
goto done;
}
@@ -292,8 +299,7 @@ try_sasl (CamelPOP3Store *store,
ioerror:
g_prefix_error (
- error, _("Failed to authenticate on POP server %s: "),
- url->host);
+ error, _("Failed to authenticate on POP server %s: "), host);
result = CAMEL_AUTHENTICATION_ERROR;
done:
@@ -325,17 +331,23 @@ static gchar *
pop3_store_get_name (CamelService *service,
gboolean brief)
{
- CamelURL *url;
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
+ const gchar *host;
+ const gchar *user;
+
+ settings = camel_service_get_settings (service);
- url = camel_service_get_camel_url (service);
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
+ user = camel_network_settings_get_user (network_settings);
if (brief)
return g_strdup_printf (
- _("POP3 server %s"), url->host);
+ _("POP3 server %s"), host);
else
return g_strdup_printf (
- _("POP3 server for %s on %s"),
- url->user, url->host);
+ _("POP3 server for %s on %s"), user, host);
}
static gboolean
@@ -344,17 +356,18 @@ pop3_store_connect_sync (CamelService *service,
GError **error)
{
CamelPOP3Store *store = (CamelPOP3Store *) service;
+ CamelSettings *settings;
CamelSession *session;
- CamelURL *url;
const gchar *mechanism;
const gchar *user_data_dir;
gboolean success;
session = camel_service_get_session (service);
+ settings = camel_service_get_settings (service);
user_data_dir = camel_service_get_user_data_dir (service);
- url = camel_service_get_camel_url (service);
- mechanism = url->authmech;
+ mechanism = camel_network_settings_get_auth_mechanism (
+ CAMEL_NETWORK_SETTINGS (settings));
if (store->cache == NULL) {
store->cache = camel_data_cache_new (user_data_dir, error);
@@ -422,15 +435,22 @@ pop3_store_authenticate_sync (CamelService *service,
GError **error)
{
CamelPOP3Store *store = CAMEL_POP3_STORE (service);
+ CamelNetworkSettings *network_settings;
CamelAuthenticationResult result;
+ CamelSettings *settings;
CamelPOP3Command *pcu = NULL;
CamelPOP3Command *pcp = NULL;
- CamelURL *url;
const gchar *password;
+ const gchar *host;
+ const gchar *user;
gint status;
- url = camel_service_get_camel_url (service);
password = camel_service_get_password (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 (mechanism == NULL) {
if (password == NULL) {
@@ -444,7 +464,7 @@ pop3_store_authenticate_sync (CamelService *service,
/* pop engine will take care of pipelining ability */
pcu = camel_pop3_engine_command_new (
store->engine, 0, NULL, NULL, cancellable, error,
- "USER %s\r\n", url->user);
+ "USER %s\r\n", user);
pcp = camel_pop3_engine_command_new (
store->engine, 0, NULL, NULL, cancellable, error,
"PASS %s\r\n", password);
@@ -472,7 +492,7 @@ pop3_store_authenticate_sync (CamelService *service,
_("Unable to connect to POP server %s: "
"Invalid APOP ID received. Impersonation "
"attack suspected. Please contact your admin."),
- url->host);
+ host);
return CAMEL_AUTHENTICATION_ERROR;
}
@@ -487,7 +507,7 @@ pop3_store_authenticate_sync (CamelService *service,
G_CHECKSUM_MD5, secret, -1);
pcp = camel_pop3_engine_command_new (
store->engine, 0, NULL, NULL, cancellable, error,
- "APOP %s %s\r\n", url->user, md5asc);
+ "APOP %s %s\r\n", user, md5asc);
g_free (md5asc);
} else {
@@ -518,7 +538,7 @@ pop3_store_authenticate_sync (CamelService *service,
g_prefix_error (
error,
_("Unable to connect to POP server %s.\n"
- "Error sending password: "), url->host);
+ "Error sending password: "), host);
result = CAMEL_AUTHENTICATION_ERROR;
} else if (pcu && pcu->state != CAMEL_POP3_COMMAND_OK) {
@@ -534,7 +554,7 @@ pop3_store_authenticate_sync (CamelService *service,
* beginning with ": " separator. */
_("Unable to connect to POP server %s.\n"
"Error sending username%s"),
- url->host, (tmp != NULL) ? tmp : "");
+ host, (tmp != NULL) ? tmp : "");
g_free (tmp);
result = CAMEL_AUTHENTICATION_ERROR;
@@ -558,8 +578,10 @@ pop3_store_query_auth_types_sync (CamelService *service,
{
CamelServiceClass *service_class;
CamelPOP3Store *store = CAMEL_POP3_STORE (service);
- CamelURL *url;
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
GList *types = NULL;
+ const gchar *host;
GError *local_error = NULL;
/* Chain up to parent's query_auth_types() method. */
@@ -572,7 +594,10 @@ pop3_store_query_auth_types_sync (CamelService *service,
return NULL;
}
- 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 (connect_to_server (service, cancellable, NULL)) {
types = g_list_concat (types, g_list_copy (store->engine->auth));
@@ -581,8 +606,7 @@ pop3_store_query_auth_types_sync (CamelService *service,
g_set_error (
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_UNAVAILABLE,
- _("Could not connect to POP server %s"),
- url->host);
+ _("Could not connect to POP server %s"), host);
}
return types;
diff --git a/camel/providers/smtp/camel-smtp-settings.c b/camel/providers/smtp/camel-smtp-settings.c
index 4a267f3..f1ba57f 100644
--- a/camel/providers/smtp/camel-smtp-settings.c
+++ b/camel/providers/smtp/camel-smtp-settings.c
@@ -24,7 +24,11 @@
enum {
PROP_0,
- PROP_SECURITY_METHOD
+ PROP_AUTH_MECHANISM,
+ PROP_HOST,
+ PROP_PORT,
+ PROP_SECURITY_METHOD,
+ PROP_USER
};
G_DEFINE_TYPE_WITH_CODE (
@@ -41,11 +45,35 @@ smtp_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_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),
g_value_get_enum (value));
return;
+
+ case PROP_USER:
+ camel_network_settings_set_user (
+ CAMEL_NETWORK_SETTINGS (object),
+ g_value_get_string (value));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -58,12 +86,40 @@ smtp_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_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,
camel_network_settings_get_security_method (
CAMEL_NETWORK_SETTINGS (object)));
return;
+
+ case PROP_USER:
+ g_value_set_string (
+ value,
+ camel_network_settings_get_user (
+ CAMEL_NETWORK_SETTINGS (object)));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -81,8 +137,32 @@ camel_smtp_settings_class_init (CamelSmtpSettingsClass *class)
/* Inherited from CamelNetworkSettings. */
g_object_class_override_property (
object_class,
+ PROP_AUTH_MECHANISM,
+ "auth-mechanism");
+
+ /* 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");
+
+ /* Inherited from CamelNetworkSettings. */
+ g_object_class_override_property (
+ object_class,
+ PROP_USER,
+ "user");
}
static void
diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c
index ef7c0fa..41d41a6 100644
--- a/camel/providers/smtp/camel-smtp-transport.c
+++ b/camel/providers/smtp/camel-smtp-transport.c
@@ -101,10 +101,11 @@ connect_to_server (CamelService *service,
GError **error)
{
CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service);
+ CamelNetworkSettings *network_settings;
CamelNetworkSecurityMethod method;
CamelSettings *settings;
- CamelURL *url;
CamelStream *tcp_stream;
+ const gchar *host;
gchar *respbuf = NULL;
if (!CAMEL_SERVICE_CLASS (camel_smtp_transport_parent_class)->
@@ -115,10 +116,11 @@ connect_to_server (CamelService *service,
transport->flags = 0;
transport->authtypes = NULL;
- url = camel_service_get_camel_url (service);
settings = camel_service_get_settings (service);
- g_object_get (settings, "security-method", &method, NULL);
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
+ method = camel_network_settings_get_security_method (network_settings);
tcp_stream = camel_network_service_connect_sync (
CAMEL_NETWORK_SERVICE (service), cancellable, error);
@@ -184,7 +186,7 @@ connect_to_server (CamelService *service,
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to connect to SMTP server %s in secure mode: %s"),
- url->host, _("STARTTLS not supported"));
+ host, _("STARTTLS not supported"));
goto exception_cleanup;
}
@@ -223,7 +225,7 @@ connect_to_server (CamelService *service,
g_prefix_error (
error,
_("Failed to connect to SMTP server %s in secure mode: "),
- url->host);
+ host);
goto exception_cleanup;
}
@@ -262,18 +264,21 @@ static gchar *
smtp_transport_get_name (CamelService *service,
gboolean brief)
{
- CamelURL *url;
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
+ const gchar *host;
+
+ settings = camel_service_get_settings (service);
- url = camel_service_get_camel_url (service);
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
if (brief)
return g_strdup_printf (
- _("SMTP server %s"),
- url->host);
+ _("SMTP server %s"), host);
else
return g_strdup_printf (
- _("SMTP mail delivery via %s"),
- url->host);
+ _("SMTP mail delivery via %s"), host);
}
static gboolean
@@ -282,13 +287,18 @@ smtp_transport_connect_sync (CamelService *service,
GError **error)
{
CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service);
- CamelURL *url;
+ CamelNetworkSettings *network_settings;
+ CamelSettings *settings;
+ const gchar *host;
const gchar *mechanism;
gboolean auth_required;
gboolean success = TRUE;
- url = camel_service_get_camel_url (service);
- mechanism = url->authmech;
+ settings = camel_service_get_settings (service);
+
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
+ mechanism = camel_network_settings_get_auth_mechanism (network_settings);
/* We (probably) need to check popb4smtp before we connect ... */
if (g_strcmp0 (mechanism, "POPB4SMTP") == 0) {
@@ -333,7 +343,7 @@ smtp_transport_connect_sync (CamelService *service,
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("SMTP server %s does not support %s "
- "authentication"), url->host, mechanism);
+ "authentication"), host, mechanism);
success = FALSE;
}
diff --git a/configure.ac b/configure.ac
index 0bbe4f2..c8a8680 100644
--- a/configure.ac
+++ b/configure.ac
@@ -101,7 +101,7 @@ LIBEBOOK_CURRENT=15
LIBEBOOK_REVISION=1
LIBEBOOK_AGE=3
-LIBCAMEL_CURRENT=30
+LIBCAMEL_CURRENT=31
LIBCAMEL_REVISION=0
LIBCAMEL_AGE=0
diff --git a/docs/reference/calendar/libedata-cal/tmpl/e-cal-backend-sync.sgml b/docs/reference/calendar/libedata-cal/tmpl/e-cal-backend-sync.sgml
index da68e6b..17290be 100644
--- a/docs/reference/calendar/libedata-cal/tmpl/e-cal-backend-sync.sgml
+++ b/docs/reference/calendar/libedata-cal/tmpl/e-cal-backend-sync.sgml
@@ -149,7 +149,7 @@ Base class for synchronous backends.
@cancellable:
@calobj:
@uid:
- new_object:
+ new_component:
@error:
@@ -163,8 +163,8 @@ Base class for synchronous backends.
@cancellable:
@calobj:
@mod:
- old_object:
- new_object:
+ old_component:
+ new_component:
@error:
@@ -179,8 +179,8 @@ Base class for synchronous backends.
@uid:
@rid:
@mod:
- old_object:
- new_object:
+ old_component:
+ new_component:
@error:
diff --git a/docs/reference/calendar/libedata-cal/tmpl/e-data-cal.sgml b/docs/reference/calendar/libedata-cal/tmpl/e-data-cal.sgml
index 61a61e0..e071465 100644
--- a/docs/reference/calendar/libedata-cal/tmpl/e-data-cal.sgml
+++ b/docs/reference/calendar/libedata-cal/tmpl/e-data-cal.sgml
@@ -208,7 +208,7 @@ Implementation of the calendar CORBA client interface.
@opid:
@error:
@uid:
- object:
+ component:
<!-- ##### FUNCTION e_data_cal_respond_modify_object ##### -->
@@ -219,8 +219,8 @@ Implementation of the calendar CORBA client interface.
@cal:
@opid:
@error:
- old_object:
- object:
+ old_component:
+ component:
<!-- ##### FUNCTION e_data_cal_respond_remove_object ##### -->
@@ -232,8 +232,8 @@ Implementation of the calendar CORBA client interface.
@opid:
@error:
@id:
- old_object:
- object:
+ old_component:
+ component:
<!-- ##### FUNCTION e_data_cal_respond_receive_objects ##### -->
diff --git a/docs/reference/camel/camel-docs.sgml b/docs/reference/camel/camel-docs.sgml
index 9fc32b7..2d9fb7e 100644
--- a/docs/reference/camel/camel-docs.sgml
+++ b/docs/reference/camel/camel-docs.sgml
@@ -99,6 +99,7 @@
<xi:include href="xml/camel-settings.xml"/>
<xi:include href="xml/camel-network-settings.xml"/>
<xi:include href="xml/camel-store-settings.xml"/>
+ <xi:include href="xml/camel-local-settings.xml"/>
<xi:include href="xml/camel-offline-settings.xml"/>
</chapter>
diff --git a/docs/reference/camel/camel-sections.txt b/docs/reference/camel/camel-sections.txt
index dfd2af6..ebb2f8d 100644
--- a/docs/reference/camel/camel-sections.txt
+++ b/docs/reference/camel/camel-sections.txt
@@ -865,6 +865,25 @@ camel_junk_filter_get_type
</SECTION>
<SECTION>
+<FILE>camel-local-settings</FILE>
+<TITLE>CamelLocalSettings</TITLE>
+CamelLocalSettings
+camel_local_settings_get_path
+camel_local_settings_set_path
+<SUBSECTION Standard>
+CAMEL_LOCAL_SETTINGS
+CAMEL_IS_LOCAL_SETTINGS
+CAMEL_TYPE_LOCAL_SETTINGS
+CAMEL_LOCAL_SETTINGS_CLASS
+CAMEL_IS_LOCAL_SETTINGS_CLASS
+CAMEL_LOCAL_SETTINGS_GET_CLASS
+CamelLocalSettingsClass
+<SUBSECTION Private>
+CamelLocalSettingsPrivate
+camel_local_settings_get_type
+</SECTION>
+
+<SECTION>
<FILE>camel-medium</FILE>
<TITLE>CamelMedium</TITLE>
CamelMedium
@@ -1499,9 +1518,17 @@ camel_network_service_get_type
<FILE>camel-network-settings</FILE>
<TITLE>CamelNetworkSettings</TITLE>
CamelNetworkSettings
+camel_network_settings_get_auth_mechanism
+camel_network_settings_set_auth_mechanism
+camel_network_settings_get_host
+camel_network_settings_set_host
+camel_network_settings_get_port
+camel_network_settings_set_port
CamelNetworkSecurityMethod
camel_network_settings_get_security_method
camel_network_settings_set_security_method
+camel_network_settings_get_user
+camel_network_settings_set_user
<SUBSECTION Standard>
CAMEL_NETWORK_SETTINGS
CAMEL_IS_NETWORK_SETTINGS
@@ -1955,6 +1982,8 @@ CAMEL_SERVICE_ERROR
CamelServiceError
CamelServiceConnectionStatus
CamelServiceAuthType
+camel_service_migrate_files
+camel_service_new_camel_url
camel_service_get_display_name
camel_service_set_display_name
camel_service_get_password
@@ -1967,8 +1996,6 @@ camel_service_get_session
camel_service_get_settings
camel_service_set_settings
camel_service_get_uid
-camel_service_get_camel_url
-camel_service_get_url
camel_service_cancel_connect
camel_service_connect_sync
camel_service_disconnect_sync
diff --git a/docs/reference/camel/tmpl/camel-local-settings.sgml b/docs/reference/camel/tmpl/camel-local-settings.sgml
new file mode 100644
index 0000000..84e002b
--- /dev/null
+++ b/docs/reference/camel/tmpl/camel-local-settings.sgml
@@ -0,0 +1,48 @@
+<!-- ##### SECTION Title ##### -->
+CamelLocalSettings
+
+<!-- ##### SECTION Short_Description ##### -->
+
+
+<!-- ##### SECTION Long_Description ##### -->
+<para>
+
+</para>
+
+<!-- ##### SECTION See_Also ##### -->
+<para>
+
+</para>
+
+<!-- ##### SECTION Stability_Level ##### -->
+
+
+<!-- ##### SECTION Image ##### -->
+
+
+<!-- ##### STRUCT CamelLocalSettings ##### -->
+<para>
+
+</para>
+
+ parent:
+ priv:
+
+<!-- ##### FUNCTION camel_local_settings_get_path ##### -->
+<para>
+
+</para>
+
+ settings:
+ Returns:
+
+
+<!-- ##### FUNCTION camel_local_settings_set_path ##### -->
+<para>
+
+</para>
+
+ settings:
+ path:
+
+
diff --git a/docs/reference/camel/tmpl/camel-network-settings.sgml b/docs/reference/camel/tmpl/camel-network-settings.sgml
index e49f882..8fe2af7 100644
--- a/docs/reference/camel/tmpl/camel-network-settings.sgml
+++ b/docs/reference/camel/tmpl/camel-network-settings.sgml
@@ -26,11 +26,85 @@ CamelNetworkSettings
</para>
+<!-- ##### ARG CamelNetworkSettings:auth-mechanism ##### -->
+<para>
+
+</para>
+
+<!-- ##### ARG CamelNetworkSettings:host ##### -->
+<para>
+
+</para>
+
+<!-- ##### ARG CamelNetworkSettings:port ##### -->
+<para>
+
+</para>
+
<!-- ##### ARG CamelNetworkSettings:security-method ##### -->
<para>
</para>
+<!-- ##### ARG CamelNetworkSettings:user ##### -->
+<para>
+
+</para>
+
+<!-- ##### FUNCTION camel_network_settings_get_auth_mechanism ##### -->
+<para>
+
+</para>
+
+ settings:
+ Returns:
+
+
+<!-- ##### FUNCTION camel_network_settings_set_auth_mechanism ##### -->
+<para>
+
+</para>
+
+ settings:
+ auth_mechanism:
+
+
+<!-- ##### FUNCTION camel_network_settings_get_host ##### -->
+<para>
+
+</para>
+
+ settings:
+ Returns:
+
+
+<!-- ##### FUNCTION camel_network_settings_set_host ##### -->
+<para>
+
+</para>
+
+ settings:
+ host:
+
+
+<!-- ##### FUNCTION camel_network_settings_get_port ##### -->
+<para>
+
+</para>
+
+ settings:
+ Returns:
+
+
+<!-- ##### FUNCTION camel_network_settings_set_port ##### -->
+<para>
+
+</para>
+
+ settings:
+ port:
+
+
<!-- ##### ENUM CamelNetworkSecurityMethod ##### -->
<para>
@@ -58,3 +132,21 @@ CamelNetworkSettings
@method:
+<!-- ##### FUNCTION camel_network_settings_get_user ##### -->
+<para>
+
+</para>
+
+ settings:
+ Returns:
+
+
+<!-- ##### FUNCTION camel_network_settings_set_user ##### -->
+<para>
+
+</para>
+
+ settings:
+ user:
+
+
diff --git a/docs/reference/camel/tmpl/camel-service.sgml b/docs/reference/camel/tmpl/camel-service.sgml
index 7a60a45..89f24de 100644
--- a/docs/reference/camel/tmpl/camel-service.sgml
+++ b/docs/reference/camel/tmpl/camel-service.sgml
@@ -56,11 +56,6 @@ CamelService
</para>
-<!-- ##### ARG CamelService:url ##### -->
-<para>
-
-</para>
-
<!-- ##### MACRO CAMEL_SERVICE_ERROR ##### -->
<para>
@@ -99,6 +94,23 @@ CamelService
@authproto:
@need_password:
+<!-- ##### FUNCTION camel_service_migrate_files ##### -->
+<para>
+
+</para>
+
+ service:
+
+
+<!-- ##### FUNCTION camel_service_new_camel_url ##### -->
+<para>
+
+</para>
+
+ service:
+ Returns:
+
+
<!-- ##### FUNCTION camel_service_get_display_name ##### -->
<para>
@@ -208,24 +220,6 @@ CamelService
@Returns:
-<!-- ##### FUNCTION camel_service_get_camel_url ##### -->
-<para>
-
-</para>
-
- service:
- Returns:
-
-
-<!-- ##### FUNCTION camel_service_get_url ##### -->
-<para>
-
-</para>
-
- service:
- Returns:
-
-
<!-- ##### FUNCTION camel_service_cancel_connect ##### -->
<para>
diff --git a/docs/reference/camel/tmpl/camel-unused.sgml b/docs/reference/camel/tmpl/camel-unused.sgml
index 5b8efef..a7099f6 100644
--- a/docs/reference/camel/tmpl/camel-unused.sgml
+++ b/docs/reference/camel/tmpl/camel-unused.sgml
@@ -4443,6 +4443,12 @@ streams
@parent:
+<!-- ##### ARG CamelService:url ##### -->
+<para>
+
+</para>
+
+
<!-- ##### ARG CamelSession:data-dir ##### -->
<para>
@@ -8869,6 +8875,14 @@ streams
@error:
@Returns:
+<!-- ##### FUNCTION camel_service_get_camel_url ##### -->
+<para>
+
+</para>
+
+ service:
+ Returns:
+
<!-- ##### FUNCTION camel_service_get_path ##### -->
<para>
@@ -8877,6 +8891,14 @@ streams
@service:
@Returns:
+<!-- ##### FUNCTION camel_service_get_url ##### -->
+<para>
+
+</para>
+
+ service:
+ Returns:
+
<!-- ##### FUNCTION camel_session_check_junk ##### -->
<para>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]