[evolution-data-server] Add CamelPOP3Settings.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Add CamelPOP3Settings.
- Date: Mon, 15 Aug 2011 15:56:42 +0000 (UTC)
commit e9e445b58f44831e8ffb7e70d1abd21bbe6db318
Author: Matthew Barnes <mbarnes redhat com>
Date: Thu Jul 21 11:29:17 2011 -0500
Add CamelPOP3Settings.
CamelPOP3Settings replaces the various URL parameters used in
CamelPOP3Store with equivalent GObject properties.
Adapt the pop3 provider to use CamelPOP3Settings.
camel/providers/pop3/Makefile.am | 2 +
camel/providers/pop3/camel-pop3-folder.c | 27 ++-
camel/providers/pop3/camel-pop3-provider.c | 18 +-
camel/providers/pop3/camel-pop3-settings.c | 382 ++++++++++++++++++++++++++++
camel/providers/pop3/camel-pop3-settings.h | 82 ++++++
camel/providers/pop3/camel-pop3-store.c | 151 +----------
camel/providers/pop3/camel-pop3-store.h | 14 -
7 files changed, 509 insertions(+), 167 deletions(-)
---
diff --git a/camel/providers/pop3/Makefile.am b/camel/providers/pop3/Makefile.am
index 356428b..5f6f386 100644
--- a/camel/providers/pop3/Makefile.am
+++ b/camel/providers/pop3/Makefile.am
@@ -12,12 +12,14 @@ libcamelpop3_la_SOURCES = \
camel-pop3-engine.c \
camel-pop3-folder.c \
camel-pop3-provider.c \
+ camel-pop3-settings.c \
camel-pop3-stream.c \
camel-pop3-store.c
noinst_HEADERS = \
camel-pop3-engine.h \
camel-pop3-folder.h \
+ camel-pop3-settings.h \
camel-pop3-stream.h \
camel-pop3-store.h
diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c
index f080748..13ed8c5 100644
--- a/camel/providers/pop3/camel-pop3-folder.c
+++ b/camel/providers/pop3/camel-pop3-folder.c
@@ -524,33 +524,44 @@ pop3_folder_synchronize_sync (CamelFolder *folder,
GCancellable *cancellable,
GError **error)
{
+ CamelService *service;
+ CamelSettings *settings;
CamelStore *parent_store;
CamelPOP3Folder *pop3_folder;
CamelPOP3Store *pop3_store;
- gint i;
CamelPOP3FolderInfo *fi;
+ gint delete_after_days;
+ gboolean delete_expunged;
+ gboolean keep_on_server;
+ gint i;
parent_store = camel_folder_get_parent_store (folder);
pop3_folder = CAMEL_POP3_FOLDER (folder);
pop3_store = CAMEL_POP3_STORE (parent_store);
- if (pop3_store->delete_after > 0 && !expunge) {
- d(printf("%s(%d): pop3_store->delete_after = [%d], expunge=[%d]\n",
- __FILE__, __LINE__, pop3_store->delete_after, expunge));
+ service = CAMEL_SERVICE (parent_store);
+ settings = camel_service_get_settings (service);
+
+ g_object_get (
+ settings,
+ "delete-after-days", &delete_after_days,
+ "delete-expunged", &delete_expunged,
+ "keep-on-server", &keep_on_server,
+ NULL);
+
+ if (delete_after_days > 0 && !expunge) {
camel_operation_push_message (
cancellable, _("Expunging old messages"));
camel_pop3_delete_old (
- folder, pop3_store->delete_after,
- cancellable, error);
+ folder, delete_after_days, cancellable, error);
camel_operation_pop_message (cancellable);
}
- if (!expunge || (pop3_store->keep_on_server && !pop3_store->delete_expunged)) {
+ if (!expunge || (keep_on_server && !delete_expunged))
return TRUE;
- }
camel_operation_push_message (
cancellable, _("Expunging deleted messages"));
diff --git a/camel/providers/pop3/camel-pop3-provider.c b/camel/providers/pop3/camel-pop3-provider.c
index 80e6f36..93d3f1a 100644
--- a/camel/providers/pop3/camel-pop3-provider.c
+++ b/camel/providers/pop3/camel-pop3-provider.c
@@ -36,25 +36,25 @@ static gint pop3_url_equal (gconstpointer a, gconstpointer b);
static CamelProviderConfEntry pop3_conf_entries[] = {
{ CAMEL_PROVIDER_CONF_SECTION_START, "storage", NULL,
- N_("Message storage") },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "keep_on_server", NULL,
+ N_("Message Storage") },
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "keep-on-server", NULL,
N_("_Leave messages on server"), "0" },
- { CAMEL_PROVIDER_CONF_CHECKSPIN, "delete_after", "keep_on_server",
+ { CAMEL_PROVIDER_CONF_CHECKSPIN, "delete-after-days", "keep-on-server",
/* Translators: '%s' is replaced with a widget, where user can select how many days can be message left on the server */
N_("_Delete after %s day(s)"), "0:1:7:365" },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "delete_expunged", "keep_on_server",
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "delete-expunged", "keep-on-server",
N_("Delete _expunged from local Inbox"), "0" },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "disable_extensions", NULL,
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "disable-extensions", NULL,
N_("Disable _support for all POP3 extensions"), "0" },
{ CAMEL_PROVIDER_CONF_SECTION_END },
{ CAMEL_PROVIDER_CONF_END }
};
CamelProviderPortEntry pop3_port_entries[] = {
- { 110, N_("Default POP3 port"), FALSE },
- { 995, N_("POP3 over SSL"), TRUE },
- { 0, NULL, 0 }
- };
+ { 110, N_("Default POP3 port"), FALSE },
+ { 995, N_("POP3 over SSL"), TRUE },
+ { 0, NULL, 0 }
+};
static CamelProvider pop3_provider = {
"pop",
diff --git a/camel/providers/pop3/camel-pop3-settings.c b/camel/providers/pop3/camel-pop3-settings.c
new file mode 100644
index 0000000..6186384
--- /dev/null
+++ b/camel/providers/pop3/camel-pop3-settings.c
@@ -0,0 +1,382 @@
+/*
+ * camel-pop3-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-pop3-settings.h"
+
+#define CAMEL_POP3_SETTINGS_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), CAMEL_TYPE_POP3_SETTINGS, CamelPOP3SettingsPrivate))
+
+struct _CamelPOP3SettingsPrivate {
+ gint delete_after_days;
+ gboolean delete_expunged;
+ gboolean disable_extensions;
+ gboolean keep_on_server;
+};
+
+enum {
+ PROP_0,
+ PROP_DELETE_AFTER_DAYS,
+ PROP_DELETE_EXPUNGED,
+ PROP_DISABLE_EXTENSIONS,
+ PROP_KEEP_ON_SERVER,
+ PROP_SECURITY_METHOD
+};
+
+G_DEFINE_TYPE_WITH_CODE (
+ CamelPOP3Settings,
+ camel_pop3_settings,
+ CAMEL_TYPE_STORE_SETTINGS,
+ G_IMPLEMENT_INTERFACE (
+ CAMEL_TYPE_NETWORK_SETTINGS, NULL))
+
+static void
+pop3_settings_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_DELETE_AFTER_DAYS:
+ camel_pop3_settings_set_delete_after_days (
+ CAMEL_POP3_SETTINGS (object),
+ g_value_get_int (value));
+ return;
+
+ case PROP_DELETE_EXPUNGED:
+ camel_pop3_settings_set_delete_expunged (
+ CAMEL_POP3_SETTINGS (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_DISABLE_EXTENSIONS:
+ camel_pop3_settings_set_disable_extensions (
+ CAMEL_POP3_SETTINGS (object),
+ g_value_get_boolean (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_SECURITY_METHOD:
+ camel_network_settings_set_security_method (
+ CAMEL_NETWORK_SETTINGS (object),
+ g_value_get_enum (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+pop3_settings_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_DELETE_AFTER_DAYS:
+ g_value_set_int (
+ value,
+ camel_pop3_settings_get_delete_after_days (
+ CAMEL_POP3_SETTINGS (object)));
+ return;
+
+ case PROP_DELETE_EXPUNGED:
+ g_value_set_boolean (
+ value,
+ camel_pop3_settings_get_delete_expunged (
+ CAMEL_POP3_SETTINGS (object)));
+ return;
+
+ case PROP_DISABLE_EXTENSIONS:
+ g_value_set_boolean (
+ value,
+ camel_pop3_settings_get_disable_extensions (
+ CAMEL_POP3_SETTINGS (object)));
+ return;
+
+ case PROP_KEEP_ON_SERVER:
+ g_value_set_boolean (
+ value,
+ camel_pop3_settings_get_keep_on_server (
+ CAMEL_POP3_SETTINGS (object)));
+ return;
+
+ case PROP_SECURITY_METHOD:
+ g_value_set_enum (
+ value,
+ camel_network_settings_get_security_method (
+ CAMEL_NETWORK_SETTINGS (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+camel_pop3_settings_class_init (CamelPOP3SettingsClass *class)
+{
+ GObjectClass *object_class;
+
+ g_type_class_add_private (class, sizeof (CamelPOP3SettingsPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = pop3_settings_set_property;
+ object_class->get_property = pop3_settings_get_property;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_DELETE_AFTER_DAYS,
+ g_param_spec_int (
+ "delete-after-days",
+ "Delete After Days",
+ "Delete messages left on server after N days",
+ 0,
+ 365,
+ 7,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_DELETE_EXPUNGED,
+ g_param_spec_boolean (
+ "delete-expunged",
+ "Delete Expunged",
+ "Delete expunged from local Inbox",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_DISABLE_EXTENSIONS,
+ g_param_spec_boolean (
+ "disable-extensions",
+ "Disable Extensions",
+ "Disable support for all POP3 extensions",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_KEEP_ON_SERVER,
+ g_param_spec_boolean (
+ "keep-on-server",
+ "Keep On Server",
+ "Leave messages on POP3 server",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ /* Inherited from CamelNetworkSettings. */
+ g_object_class_override_property (
+ object_class,
+ PROP_SECURITY_METHOD,
+ "security-method");
+}
+
+static void
+camel_pop3_settings_init (CamelPOP3Settings *settings)
+{
+ settings->priv = CAMEL_POP3_SETTINGS_GET_PRIVATE (settings);
+}
+
+/**
+ * camel_pop3_settings_get_delete_after_days:
+ * @settings: a #CamelPOP3Settings
+ *
+ * Returns the number of days to leave messages on the POP3 server before
+ * automatically deleting them. If the value is zero, messages will not
+ * be automatically deleted. The @settings's #CamelPOP3Settings:keep-on-server
+ * property must be %TRUE for this to have any effect.
+ *
+ * Returns: the number of days to leave messages on the server before
+ * automatically deleting them
+ *
+ * Since: 3.2
+ **/
+gint
+camel_pop3_settings_get_delete_after_days (CamelPOP3Settings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_POP3_SETTINGS (settings), 0);
+
+ return settings->priv->delete_after_days;
+}
+
+/**
+ * camel_pop3_settings_set_delete_after_days:
+ * @settings: a #CamelPOP3Settings
+ * @delete_after_days: the number of days to leave messages on the server
+ * before automatically deleting them
+ *
+ * Sets the number of days to leave messages on the POP3 server before
+ * automatically deleting them. If the value is zero, messages will not
+ * be automatically deleted. The @settings's #CamelPOP3Settings:keep-on-server
+ * property must be %TRUE for this to have any effect.
+ *
+ * Since: 3.2
+ **/
+void
+camel_pop3_settings_set_delete_after_days (CamelPOP3Settings *settings,
+ gint delete_after_days)
+{
+ g_return_if_fail (CAMEL_IS_POP3_SETTINGS (settings));
+
+ settings->priv->delete_after_days = delete_after_days;
+
+ g_object_notify (G_OBJECT (settings), "delete-after-days");
+}
+
+/**
+ * camel_pop3_settings_get_delete_expunged:
+ * @settings: a #CamelPOP3Settings
+ *
+ * Returns whether to delete corresponding messages left on the POP3 server
+ * when expunging the local #CamelSettings. The @settings's
+ * #CamelPOP3Settings:keep-on-server property must be %TRUE for this to have
+ * any effect.
+ *
+ * Returns: whether to delete corresponding messages on the server when
+ * expunging the local #CamelSettings
+ *
+ * Since: 3.2
+ **/
+gboolean
+camel_pop3_settings_get_delete_expunged (CamelPOP3Settings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_POP3_SETTINGS (settings), FALSE);
+
+ return settings->priv->delete_expunged;
+}
+
+/**
+ * camel_pop3_settings_set_delete_expunged:
+ * @settings: a #CamelPOP3Settings
+ * @delete_expunged: whether to delete corresponding messages on the
+ * server when expunging the local #CamelSettings
+ *
+ * Sets whether to delete corresponding messages left on the POP3 server
+ * when expunging the local #CamelSettings. The @settings's
+ * #CamelPOP3Settings:keep-on-server property must be %TRUE for this to have
+ * any effect.
+ *
+ * Since: 3.2
+ **/
+void
+camel_pop3_settings_set_delete_expunged (CamelPOP3Settings *settings,
+ gboolean delete_expunged)
+{
+ g_return_if_fail (CAMEL_IS_POP3_SETTINGS (settings));
+
+ settings->priv->delete_expunged = delete_expunged;
+
+ g_object_notify (G_OBJECT (settings), "delete-expunged");
+}
+
+/**
+ * camel_pop3_settings_get_disable_extensions:
+ * @settings: a #CamelPOP3Settings
+ *
+ * Returns whether to disable support for POP3 extensions. If %TRUE, the
+ * #CamelPOP3Engine will refrain from issuing a "CAPA" command to the server
+ * upon connection.
+ *
+ * Returns: whether to disable support for POP3 extensions
+ *
+ * Since: 3.2
+ **/
+gboolean
+camel_pop3_settings_get_disable_extensions (CamelPOP3Settings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_POP3_SETTINGS (settings), FALSE);
+
+ return settings->priv->disable_extensions;
+}
+
+/**
+ * camel_pop3_settings_set_disable_extensions:
+ * @settings: a #CamelPOP3Settings
+ * @disable_extensions: whether to disable support for POP3 extensions
+ *
+ * Sets whether to disable support for POP3 extensions. If %TRUE, the
+ * #CamelPOP3Engine will refrain from issuing a "CAPA" command to the server
+ * upon connection.
+ *
+ * Since: 3.2
+ **/
+void
+camel_pop3_settings_set_disable_extensions (CamelPOP3Settings *settings,
+ gboolean disable_extensions)
+{
+ g_return_if_fail (CAMEL_IS_POP3_SETTINGS (settings));
+
+ settings->priv->disable_extensions = disable_extensions;
+
+ g_object_notify (G_OBJECT (settings), "disable-extensions");
+}
+
+/**
+ * camel_pop3_settings_get_keep_on_server:
+ * @settings: a #CamelPOP3Settings
+ *
+ * Returns whether to leave messages on the remote POP3 server after
+ * downloading them to the local Inbox.
+ *
+ * Returns: whether to leave messages on the POP3 server
+ *
+ * Since: 3.2
+ **/
+gboolean
+camel_pop3_settings_get_keep_on_server (CamelPOP3Settings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_POP3_SETTINGS (settings), FALSE);
+
+ return settings->priv->keep_on_server;
+}
+
+/**
+ * camel_pop3_settings_set_keep_on_server:
+ * @settings: a #CamelPOP3Settings
+ * @keep_on_server: whether to leave messages on the POP3 server
+ *
+ * Sets whether to leave messages on the remote POP3 server after
+ * downloading them to the local Inbox.
+ *
+ * Since: 3.2
+ **/
+void
+camel_pop3_settings_set_keep_on_server (CamelPOP3Settings *settings,
+ gboolean keep_on_server)
+{
+ g_return_if_fail (CAMEL_IS_POP3_SETTINGS (settings));
+
+ settings->priv->keep_on_server = keep_on_server;
+
+ g_object_notify (G_OBJECT (settings), "keep-on-server");
+}
+
diff --git a/camel/providers/pop3/camel-pop3-settings.h b/camel/providers/pop3/camel-pop3-settings.h
new file mode 100644
index 0000000..29812bf
--- /dev/null
+++ b/camel/providers/pop3/camel-pop3-settings.h
@@ -0,0 +1,82 @@
+/*
+ * camel-pop3-settings.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef CAMEL_POP3_SETTINGS_H
+#define CAMEL_POP3_SETTINGS_H
+
+#include <camel/camel.h>
+
+/* Standard GObject macros */
+#define CAMEL_TYPE_POP3_SETTINGS \
+ (camel_pop3_settings_get_type ())
+#define CAMEL_POP3_SETTINGS(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), CAMEL_TYPE_POP3_SETTINGS, CamelPOP3Settings))
+#define CAMEL_POP3_SETTINGS_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), CAMEL_TYPE_POP3_SETTINGS, CamelPOP3SettingsClass))
+#define CAMEL_IS_POP3_SETTINGS(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), CAMEL_TYPE_POP3_SETTINGS))
+#define CAMEL_IS_POP3_SETTINGS_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), CAMEL_TYPE_POP3_SETTINGS))
+#define CAMEL_POP3_SETTINGS_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), CAMEL_TYPE_POP3_SETTINGS, CamelPOP3SettingsClass))
+
+G_BEGIN_DECLS
+
+typedef struct _CamelPOP3Settings CamelPOP3Settings;
+typedef struct _CamelPOP3SettingsClass CamelPOP3SettingsClass;
+typedef struct _CamelPOP3SettingsPrivate CamelPOP3SettingsPrivate;
+
+struct _CamelPOP3Settings {
+ CamelStoreSettings parent;
+ CamelPOP3SettingsPrivate *priv;
+};
+
+struct _CamelPOP3SettingsClass {
+ CamelStoreSettingsClass parent_class;
+};
+
+GType camel_pop3_settings_get_type (void) G_GNUC_CONST;
+gint camel_pop3_settings_get_delete_after_days
+ (CamelPOP3Settings *settings);
+void camel_pop3_settings_set_delete_after_days
+ (CamelPOP3Settings *settings,
+ gint delete_after_days);
+gboolean camel_pop3_settings_get_delete_expunged
+ (CamelPOP3Settings *settings);
+void camel_pop3_settings_set_delete_expunged
+ (CamelPOP3Settings *settings,
+ gboolean delete_expunged);
+gboolean camel_pop3_settings_get_disable_extensions
+ (CamelPOP3Settings *settings);
+void camel_pop3_settings_set_disable_extensions
+ (CamelPOP3Settings *settings,
+ gboolean disable_extensions);
+gboolean camel_pop3_settings_get_keep_on_server
+ (CamelPOP3Settings *settings);
+void camel_pop3_settings_set_keep_on_server
+ (CamelPOP3Settings *settings,
+ gboolean keep_on_server);
+
+G_END_DECLS
+
+#endif /* CAMEL_POP3_SETTINGS_H */
diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c
index 3a194e0..7859f53 100644
--- a/camel/providers/pop3/camel-pop3-store.c
+++ b/camel/providers/pop3/camel-pop3-store.c
@@ -37,6 +37,7 @@
#include <glib/gi18n-lib.h>
#include "camel-pop3-folder.h"
+#include "camel-pop3-settings.h"
#include "camel-pop3-store.h"
#ifdef G_OS_WIN32
@@ -44,10 +45,6 @@
#include <ws2tcpip.h>
#endif
-#define CAMEL_POP3_STORE_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), CAMEL_TYPE_POP3_STORE, CamelPOP3StorePrivate))
-
/* Specified in RFC 1939 */
#define POP3_PORT 110
#define POP3S_PORT 995
@@ -55,17 +52,6 @@
/* defines the length of the server error message we can display in the error dialog */
#define POP3_ERROR_SIZE_LIMIT 60
-struct _CamelPOP3StorePrivate {
- gint placeholder;
-};
-
-enum {
- PROP_0,
- PROP_DEFAULT_PORT,
- PROP_SECURITY_METHOD,
- PROP_SERVICE_NAME
-};
-
extern CamelServiceAuthType camel_pop3_password_authtype;
extern CamelServiceAuthType camel_pop3_apop_authtype;
@@ -106,17 +92,18 @@ connect_to_server (CamelService *service,
GError **error)
{
CamelPOP3Store *store = CAMEL_POP3_STORE (service);
- CamelNetworkService *network_service;
CamelNetworkSecurityMethod method;
+ CamelSettings *settings;
CamelURL *url;
CamelStream *tcp_stream;
CamelPOP3Command *pc;
+ gboolean disable_extensions;
guint32 flags = 0;
gint clean_quit = TRUE;
gint ret;
- const gchar *param;
url = camel_service_get_camel_url (service);
+ settings = camel_service_get_settings (service);
tcp_stream = camel_network_service_connect_sync (
CAMEL_NETWORK_SERVICE (service), cancellable, error);
@@ -124,9 +111,6 @@ connect_to_server (CamelService *service,
if (tcp_stream == NULL)
return FALSE;
- network_service = CAMEL_NETWORK_SERVICE (service);
- method = camel_network_service_get_security_method (network_service);
-
/* parent class connect initialization */
if (CAMEL_SERVICE_CLASS (camel_pop3_store_parent_class)->
connect_sync (service, cancellable, error) == FALSE) {
@@ -134,16 +118,11 @@ connect_to_server (CamelService *service,
return FALSE;
}
- if (camel_url_get_param (url, "disable_extensions"))
- flags |= CAMEL_POP3_ENGINE_DISABLE_EXTENSIONS;
-
- store->keep_on_server = camel_url_get_param (url, "keep_on_server") != NULL;
- store->delete_expunged = camel_url_get_param (url, "delete_expunged") != NULL;
+ disable_extensions = camel_pop3_settings_get_disable_extensions (
+ CAMEL_POP3_SETTINGS (settings));
- if ((param = camel_url_get_param (url, "delete_after")))
- store->delete_after = atoi (param);
- else
- store->delete_after = 0;
+ if (disable_extensions)
+ flags |= CAMEL_POP3_ENGINE_DISABLE_EXTENSIONS;
if (!(store->engine = camel_pop3_engine_new (tcp_stream, flags))) {
g_set_error (
@@ -154,6 +133,8 @@ connect_to_server (CamelService *service,
return FALSE;
}
+ g_object_get (settings, "security-method", &method, NULL);
+
if (method != CAMEL_NETWORK_SECURITY_METHOD_STARTTLS_ON_STANDARD_PORT) {
g_object_unref (tcp_stream);
return TRUE;
@@ -480,55 +461,6 @@ pop3_try_authenticate (CamelService *service,
}
static void
-pop3_store_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_SECURITY_METHOD:
- camel_network_service_set_security_method (
- CAMEL_NETWORK_SERVICE (object),
- g_value_get_enum (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-pop3_store_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_DEFAULT_PORT:
- g_value_set_uint (
- value,
- camel_network_service_get_default_port (
- CAMEL_NETWORK_SERVICE (object)));
- return;
-
- case PROP_SECURITY_METHOD:
- g_value_set_enum (
- value,
- camel_network_service_get_security_method (
- CAMEL_NETWORK_SERVICE (object)));
- return;
-
- case PROP_SERVICE_NAME:
- g_value_set_string (
- value,
- camel_network_service_get_service_name (
- CAMEL_NETWORK_SERVICE (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
pop3_store_finalize (GObject *object)
{
CamelPOP3Store *pop3_store = CAMEL_POP3_STORE (object);
@@ -547,32 +479,6 @@ pop3_store_finalize (GObject *object)
G_OBJECT_CLASS (camel_pop3_store_parent_class)->finalize (object);
}
-static void
-pop3_store_constructed (GObject *object)
-{
- CamelURL *url;
- const gchar *use_ssl;
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (camel_pop3_store_parent_class)->constructed (object);
-
- url = camel_service_get_camel_url (CAMEL_SERVICE (object));
- use_ssl = camel_url_get_param (url, "use_ssl");
-
- if (g_strcmp0 (use_ssl, "never") == 0)
- camel_network_service_set_security_method (
- CAMEL_NETWORK_SERVICE (object),
- CAMEL_NETWORK_SECURITY_METHOD_NONE);
- else if (g_strcmp0 (use_ssl, "always") == 0)
- camel_network_service_set_security_method (
- CAMEL_NETWORK_SERVICE (object),
- CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT);
- else if (g_strcmp0 (use_ssl, "when-possible") == 0)
- camel_network_service_set_security_method (
- CAMEL_NETWORK_SERVICE (object),
- CAMEL_NETWORK_SECURITY_METHOD_STARTTLS_ON_STANDARD_PORT);
-}
-
static gchar *
pop3_store_get_name (CamelService *service,
gboolean brief)
@@ -776,13 +682,11 @@ pop3_store_get_trash_folder_sync (CamelStore *store,
}
static const gchar *
-pop3_store_get_service_name (CamelNetworkService *service)
+pop3_store_get_service_name (CamelNetworkService *service,
+ CamelNetworkSecurityMethod method)
{
- CamelNetworkSecurityMethod method;
const gchar *service_name;
- method = camel_network_service_get_security_method (service);
-
switch (method) {
case CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT:
service_name = "pop3s";
@@ -797,13 +701,11 @@ pop3_store_get_service_name (CamelNetworkService *service)
}
static guint16
-pop3_store_get_default_port (CamelNetworkService *service)
+pop3_store_get_default_port (CamelNetworkService *service,
+ CamelNetworkSecurityMethod method)
{
- CamelNetworkSecurityMethod method;
guint16 default_port;
- method = camel_network_service_get_security_method (service);
-
switch (method) {
case CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT:
default_port = POP3S_PORT;
@@ -824,15 +726,11 @@ camel_pop3_store_class_init (CamelPOP3StoreClass *class)
CamelServiceClass *service_class;
CamelStoreClass *store_class;
- g_type_class_add_private (class, sizeof (CamelPOP3StorePrivate));
-
object_class = G_OBJECT_CLASS (class);
- object_class->set_property = pop3_store_set_property;
- object_class->get_property = pop3_store_get_property;
object_class->finalize = pop3_store_finalize;
- object_class->constructed = pop3_store_constructed;
service_class = CAMEL_SERVICE_CLASS (class);
+ service_class->settings_type = CAMEL_TYPE_POP3_SETTINGS;
service_class->get_name = pop3_store_get_name;
service_class->connect_sync = pop3_store_connect_sync;
service_class->disconnect_sync = pop3_store_disconnect_sync;
@@ -843,24 +741,6 @@ camel_pop3_store_class_init (CamelPOP3StoreClass *class)
store_class->get_folder_sync = pop3_store_get_folder_sync;
store_class->get_folder_info_sync = pop3_store_get_folder_info_sync;
store_class->get_trash_folder_sync = pop3_store_get_trash_folder_sync;
-
- /* Inherited from CamelNetworkService. */
- g_object_class_override_property (
- object_class,
- PROP_DEFAULT_PORT,
- "default-port");
-
- /* Inherited from CamelNetworkService. */
- g_object_class_override_property (
- object_class,
- PROP_SECURITY_METHOD,
- "security-method");
-
- /* Inherited from CamelNetworkService. */
- g_object_class_override_property (
- object_class,
- PROP_SERVICE_NAME,
- "service-name");
}
static void
@@ -873,7 +753,6 @@ camel_network_service_init (CamelNetworkServiceInterface *interface)
static void
camel_pop3_store_init (CamelPOP3Store *pop3_store)
{
- pop3_store->priv = CAMEL_POP3_STORE_GET_PRIVATE (pop3_store);
}
/**
diff --git a/camel/providers/pop3/camel-pop3-store.h b/camel/providers/pop3/camel-pop3-store.h
index 02bb7ff..d970780 100644
--- a/camel/providers/pop3/camel-pop3-store.h
+++ b/camel/providers/pop3/camel-pop3-store.h
@@ -60,12 +60,7 @@ struct _CamelPOP3Store {
CamelPOP3StorePrivate *priv;
CamelPOP3Engine *engine; /* pop processing engine */
-
CamelDataCache *cache;
-
- gboolean keep_on_server;
- guint delete_after;
- gboolean delete_expunged;
};
struct _CamelPOP3StoreClass {
@@ -75,15 +70,6 @@ struct _CamelPOP3StoreClass {
GType camel_pop3_store_get_type (void);
void camel_pop3_store_expunge (CamelPOP3Store *store,
GError **error);
-gint camel_pop3_command (CamelPOP3Store *store,
- gchar **ret,
- GError **error,
- gchar *fmt,
- ...);
-gchar * camel_pop3_command_get_additional_data
- (CamelPOP3Store *store,
- gint total,
- GError **error);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]