[evolution-data-server] Add CamelNNTPSettings.



commit 25ff499b29794d615761352e78084800d130cd6a
Author: Matthew Barnes <mbarnes redhat com>
Date:   Fri Jul 15 13:59:30 2011 -0400

    Add CamelNNTPSettings.
    
    CamelNNTPSettings replaces the various URL parameters used in
    CamelNNTPStore with equivalent GObject properties.
    
    Adapt the nntp provider to use CamelNNTPSettings.

 camel/providers/nntp/Makefile.am           |    2 +
 camel/providers/nntp/camel-nntp-provider.c |   12 +-
 camel/providers/nntp/camel-nntp-settings.c |  238 ++++++++++++++++++++++++++++
 camel/providers/nntp/camel-nntp-settings.h |   73 +++++++++
 camel/providers/nntp/camel-nntp-store.c    |  194 ++++++-----------------
 camel/providers/nntp/camel-nntp-store.h    |    2 -
 6 files changed, 371 insertions(+), 150 deletions(-)
---
diff --git a/camel/providers/nntp/Makefile.am b/camel/providers/nntp/Makefile.am
index e44bf8d..5197c3f 100644
--- a/camel/providers/nntp/Makefile.am
+++ b/camel/providers/nntp/Makefile.am
@@ -15,6 +15,7 @@ libcamelnntp_la_CPPFLAGS = \
 libcamelnntp_la_SOURCES = 			\
 	camel-nntp-folder.c			\
 	camel-nntp-provider.c			\
+	camel-nntp-settings.c			\
 	camel-nntp-store-summary.c		\
 	camel-nntp-store.c			\
 	camel-nntp-stream.c			\
@@ -24,6 +25,7 @@ noinst_HEADERS =				\
 	camel-nntp-folder.h			\
 	camel-nntp-private.h			\
 	camel-nntp-resp-codes.h			\
+	camel-nntp-settings.h			\
 	camel-nntp-store-summary.h		\
 	camel-nntp-store.h			\
 	camel-nntp-stream.h			\
diff --git a/camel/providers/nntp/camel-nntp-provider.c b/camel/providers/nntp/camel-nntp-provider.c
index 3210193..c4c504d 100644
--- a/camel/providers/nntp/camel-nntp-provider.c
+++ b/camel/providers/nntp/camel-nntp-provider.c
@@ -40,19 +40,19 @@ static gint nntp_url_equal (gconstpointer a, gconstpointer b);
 static CamelProviderConfEntry nntp_conf_entries[] = {
 	{ CAMEL_PROVIDER_CONF_SECTION_START, "folders", NULL,
 	  N_("Folders") },
-	{ CAMEL_PROVIDER_CONF_CHECKBOX, "show_short_notation", NULL,
+	{ CAMEL_PROVIDER_CONF_CHECKBOX, "short-folder-names", NULL,
 	  N_("_Show folders in short notation (e.g. c.o.linux rather than comp.os.linux)"), "1" },
-	{ CAMEL_PROVIDER_CONF_CHECKBOX, "folder_hierarchy_relative", NULL,
+	{ CAMEL_PROVIDER_CONF_CHECKBOX, "folder-hierarchy-relative", NULL,
 	  N_("In the subscription _dialog, show relative folder names"), "1" },
 	{ CAMEL_PROVIDER_CONF_SECTION_END },
 	{ CAMEL_PROVIDER_CONF_END }
 };
 
 CamelProviderPortEntry nntp_port_entries[] = {
-						  { 119, N_("Default NNTP port"), FALSE },
-						  { 563, N_("NNTP over SSL"), TRUE },
-						  { 0, NULL, 0 }
-					     };
+	{ 119, N_("Default NNTP port"), FALSE },
+	{ 563, N_("NNTP over SSL"), TRUE },
+	{ 0, NULL, 0 }
+};
 
 static CamelProvider news_provider = {
 	"nntp",
diff --git a/camel/providers/nntp/camel-nntp-settings.c b/camel/providers/nntp/camel-nntp-settings.c
new file mode 100644
index 0000000..2ce87ac
--- /dev/null
+++ b/camel/providers/nntp/camel-nntp-settings.c
@@ -0,0 +1,238 @@
+/*
+ * camel-nntp-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-nntp-settings.h"
+
+#define CAMEL_NNTP_SETTINGS_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), CAMEL_TYPE_NNTP_SETTINGS, CamelNNTPSettingsPrivate))
+
+struct _CamelNNTPSettingsPrivate {
+	gboolean folder_hierarchy_relative;
+	gboolean short_folder_names;
+};
+
+enum {
+	PROP_0,
+	PROP_FOLDER_HIERARCHY_RELATIVE,
+	PROP_SECURITY_METHOD,
+	PROP_SHORT_FOLDER_NAMES
+};
+
+G_DEFINE_TYPE_WITH_CODE (
+	CamelNNTPSettings,
+	camel_nntp_settings,
+	CAMEL_TYPE_OFFLINE_SETTINGS,
+	G_IMPLEMENT_INTERFACE (
+		CAMEL_TYPE_NETWORK_SETTINGS, NULL))
+
+static void
+nntp_settings_set_property (GObject *object,
+                            guint property_id,
+                            const GValue *value,
+                            GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_FOLDER_HIERARCHY_RELATIVE:
+			camel_nntp_settings_set_folder_hierarchy_relative (
+				CAMEL_NNTP_SETTINGS (object),
+				g_value_get_boolean (value));
+			return;
+
+		case PROP_SECURITY_METHOD:
+			camel_network_settings_set_security_method (
+				CAMEL_NETWORK_SETTINGS (object),
+				g_value_get_enum (value));
+			return;
+
+		case PROP_SHORT_FOLDER_NAMES:
+			camel_nntp_settings_set_short_folder_names (
+				CAMEL_NNTP_SETTINGS (object),
+				g_value_get_boolean (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+nntp_settings_get_property (GObject *object,
+                            guint property_id,
+                            GValue *value,
+                            GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_FOLDER_HIERARCHY_RELATIVE:
+			g_value_set_boolean (
+				value,
+				camel_nntp_settings_get_folder_hierarchy_relative (
+				CAMEL_NNTP_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_SHORT_FOLDER_NAMES:
+			g_value_set_boolean (
+				value,
+				camel_nntp_settings_get_short_folder_names (
+				CAMEL_NNTP_SETTINGS (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+camel_nntp_settings_class_init (CamelNNTPSettingsClass *class)
+{
+	GObjectClass *object_class;
+
+	g_type_class_add_private (class, sizeof (CamelNNTPSettingsPrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = nntp_settings_set_property;
+	object_class->get_property = nntp_settings_get_property;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_FOLDER_HIERARCHY_RELATIVE,
+		g_param_spec_boolean (
+			"folder-hierarchy-relative",
+			"Folder Hierarchy Relative",
+			"Show relative folder names when subscribing",
+			FALSE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT |
+			G_PARAM_STATIC_STRINGS));
+
+	/* Inherited from CamelNetworkSettings. */
+	g_object_class_override_property (
+		object_class,
+		PROP_SECURITY_METHOD,
+		"security-method");
+
+	g_object_class_install_property (
+		object_class,
+		PROP_SHORT_FOLDER_NAMES,
+		g_param_spec_boolean (
+			"short-folder-names",
+			"Short Folder Names",
+			"Use shortened folder names",
+			FALSE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT |
+			G_PARAM_STATIC_STRINGS));
+}
+
+static void
+camel_nntp_settings_init (CamelNNTPSettings *settings)
+{
+	settings->priv = CAMEL_NNTP_SETTINGS_GET_PRIVATE (settings);
+}
+
+/**
+ * camel_nntp_settings_get_folder_hierarchy_relative:
+ * @settings: a #CamelNNTPSettings
+ *
+ * Returns whether to show relative folder names when allowing users to
+ * subscribe to folders.  Since newsgroup folder names reveal the absolute
+ * path to the folder (e.g. comp.os.linux), displaying the full folder name
+ * in a complete hierarchical listing of the news server is redundant, but
+ * possibly harder to read.
+ *
+ * Returns: whether to show relative folder names
+ *
+ * Since: 3.2
+ **/
+gboolean
+camel_nntp_settings_get_folder_hierarchy_relative (CamelNNTPSettings *settings)
+{
+	g_return_val_if_fail (CAMEL_IS_NNTP_SETTINGS (settings), FALSE);
+
+	return settings->priv->folder_hierarchy_relative;
+}
+
+/**
+ * camel_nntp_settings_set_folder_hierarchy_relative:
+ * @settings: a #CamelNNTPSettings
+ * @folder_hierarchy_relative: whether to show relative folder names
+ *
+ * Sets whether to show relative folder names when allowing users to
+ * subscribe to folders.  Since newsgroup folder names reveal the absolute
+ * path to the folder (e.g. comp.os.linux), displaying the full folder name
+ * in a complete hierarchical listing of the news server is redundant, but
+ * possibly harder to read.
+ *
+ * Since: 3.2
+ **/
+void
+camel_nntp_settings_set_folder_hierarchy_relative (CamelNNTPSettings *settings,
+                                                   gboolean folder_hierarchy_relative)
+{
+	g_return_if_fail (CAMEL_IS_NNTP_SETTINGS (settings));
+
+	settings->priv->folder_hierarchy_relative = folder_hierarchy_relative;
+
+	g_object_notify (G_OBJECT (settings), "folder-hierarchy-relative");
+}
+
+/**
+ * camel_nntp_settings_get_short_folder_names:
+ * @settings: a #CamelNNTPSettings
+ *
+ * Returns whether to use shortened folder names (e.g. c.o.linux rather
+ * than comp.os.linux).
+ *
+ * Returns: whether to show shortened folder names
+ *
+ * Since: 3.2
+ **/
+gboolean
+camel_nntp_settings_get_short_folder_names (CamelNNTPSettings *settings)
+{
+	g_return_val_if_fail (CAMEL_IS_NNTP_SETTINGS (settings), FALSE);
+
+	return settings->priv->short_folder_names;
+}
+
+/**
+ * camel_nntp_settings_set_short_folder_names:
+ * @settings: a #CamelNNTPSettings
+ * @short_folder_names: whether to show shortened folder names
+ *
+ * Sets whether to show shortened folder names (e.g. c.o.linux rather than
+ * comp.os.linux).
+ *
+ * Since: 3.2
+ **/
+void
+camel_nntp_settings_set_short_folder_names (CamelNNTPSettings *settings,
+                                            gboolean short_folder_names)
+{
+	g_return_if_fail (CAMEL_IS_NNTP_SETTINGS (settings));
+
+	settings->priv->short_folder_names = short_folder_names;
+
+	g_object_notify (G_OBJECT (settings), "short-folder-names");
+}
+
diff --git a/camel/providers/nntp/camel-nntp-settings.h b/camel/providers/nntp/camel-nntp-settings.h
new file mode 100644
index 0000000..0634c9f
--- /dev/null
+++ b/camel/providers/nntp/camel-nntp-settings.h
@@ -0,0 +1,73 @@
+/*
+ * camel-nntp-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_NNTP_SETTINGS_H
+#define CAMEL_NNTP_SETTINGS_H
+
+#include <camel/camel.h>
+
+/* Standard GObject macros */
+#define CAMEL_TYPE_NNTP_SETTINGS \
+	(camel_nntp_settings_get_type ())
+#define CAMEL_NNTP_SETTINGS(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), CAMEL_TYPE_NNTP_SETTINGS, CamelNNTPSettings))
+#define CAMEL_NNTP_SETTINGS_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), CAMEL_TYPE_NNTP_SETTINGS, CamelNNTPSettingsClass))
+#define CAMEL_IS_NNTP_SETTINGS(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), CAMEL_TYPE_NNTP_SETTINGS))
+#define CAMEL_IS_NNTP_SETTINGS_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), CAMEL_TYPE_NNTP_SETTINGS))
+#define CAMEL_NNTP_SETTINGS_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), CAMEL_TYPE_NNTP_SETTINGS, CamelNNTPSettingsClass))
+
+G_BEGIN_DECLS
+
+typedef struct _CamelNNTPSettings CamelNNTPSettings;
+typedef struct _CamelNNTPSettingsClass CamelNNTPSettingsClass;
+typedef struct _CamelNNTPSettingsPrivate CamelNNTPSettingsPrivate;
+
+struct _CamelNNTPSettings {
+	CamelOfflineSettings parent;
+	CamelNNTPSettingsPrivate *priv;
+};
+
+struct _CamelNNTPSettingsClass {
+	CamelOfflineSettingsClass parent_class;
+};
+
+GType		camel_nntp_settings_get_type
+					(void) G_GNUC_CONST;
+gboolean	camel_nntp_settings_get_folder_hierarchy_relative
+					(CamelNNTPSettings *settings);
+void		camel_nntp_settings_set_folder_hierarchy_relative
+					(CamelNNTPSettings *settings,
+					 gboolean folder_hierarchy_relative);
+gboolean	camel_nntp_settings_get_short_folder_names
+					(CamelNNTPSettings *settings);
+void		camel_nntp_settings_set_short_folder_names
+					(CamelNNTPSettings *settings,
+					 gboolean short_folder_names);
+
+G_END_DECLS
+
+#endif /* CAMEL_NNTP_SETTINGS_H */
diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c
index 9426606..746aa93 100644
--- a/camel/providers/nntp/camel-nntp-store.c
+++ b/camel/providers/nntp/camel-nntp-store.c
@@ -33,22 +33,19 @@
 
 #include <glib/gi18n-lib.h>
 
-#include "camel-nntp-summary.h"
-#include "camel-nntp-store.h"
-#include "camel-nntp-store-summary.h"
 #include "camel-nntp-folder.h"
 #include "camel-nntp-private.h"
 #include "camel-nntp-resp-codes.h"
+#include "camel-nntp-settings.h"
+#include "camel-nntp-store-summary.h"
+#include "camel-nntp-store.h"
+#include "camel-nntp-summary.h"
 
 #ifdef G_OS_WIN32
 #include <winsock2.h>
 #include <ws2tcpip.h>
 #endif
 
-#define CAMEL_NNTP_STORE_GET_PRIVATE(obj) \
-	(G_TYPE_INSTANCE_GET_PRIVATE \
-	((obj), CAMEL_TYPE_NNTP_STORE, CamelNNTPStorePrivate))
-
 #define w(x)
 #define dd(x) (camel_debug("nntp")?(x):0)
 
@@ -57,17 +54,6 @@
 
 #define DUMP_EXTENSIONS
 
-struct _CamelNNTPStorePrivate {
-	gint placeholder;
-};
-
-enum {
-	PROP_0,
-	PROP_DEFAULT_PORT,
-	PROP_SECURITY_METHOD,
-	PROP_SERVICE_NAME
-};
-
 static GInitableIface *parent_initable_interface;
 
 /* Forward Declarations */
@@ -167,55 +153,6 @@ camel_nntp_try_authenticate (CamelNNTPStore *store,
 }
 
 static void
-nntp_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_uint (value));
-			return;
-	}
-
-	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-nntp_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_uint (
-				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
 nntp_store_dispose (GObject *object)
 {
 	CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (object);
@@ -276,32 +213,6 @@ nntp_store_finalize (GObject *object)
 	G_OBJECT_CLASS (camel_nntp_store_parent_class)->finalize (object);
 }
 
-static void
-nntp_store_constructed (GObject *object)
-{
-	CamelURL *url;
-	const gchar *use_ssl;
-
-	/* Chain up to parent's constructed() method. */
-	G_OBJECT_CLASS (camel_nntp_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 gboolean
 nntp_can_work_offline (CamelDiscoStore *store)
 {
@@ -797,14 +708,23 @@ nntp_store_get_subscribed_folder_info (CamelNNTPStore *store,
                                        GCancellable *cancellable,
                                        GError **error)
 {
-	gint i;
+	CamelService *service;
+	CamelSettings *settings;
 	CamelStoreInfo *si;
 	CamelFolderInfo *first = NULL, *last = NULL, *fi = NULL;
+	gboolean short_folder_names;
+	gint i;
 
 	/* since we do not do a tree, any request that is not for root is sure to give no results */
 	if (top != NULL && top[0] != 0)
 		return NULL;
 
+	service = CAMEL_SERVICE (store);
+	settings = camel_service_get_settings (service);
+
+	short_folder_names = camel_nntp_settings_get_short_folder_names (
+		CAMEL_NNTP_SETTINGS (settings));
+
 	for (i=0;(si = camel_store_summary_index ((CamelStoreSummary *) store->summary, i));i++) {
 		if (si == NULL)
 			continue;
@@ -837,7 +757,7 @@ nntp_store_get_subscribed_folder_info (CamelNNTPStore *store,
 					g_object_unref (folder);
 				}
 			}
-			fi = nntp_folder_info_from_store_info (store, store->do_short_folder_notation, si);
+			fi = nntp_folder_info_from_store_info (store, short_folder_names, si);
 			fi->flags |= CAMEL_FOLDER_NOINFERIORS | CAMEL_FOLDER_NOCHILDREN | CAMEL_FOLDER_SYSTEM;
 			if (last)
 				last->next = fi;
@@ -935,6 +855,8 @@ nntp_store_get_cached_folder_info (CamelNNTPStore *store,
                                    guint flags,
                                    GError **error)
 {
+	CamelService *service;
+	CamelSettings *settings;
 	gint i;
 	gint subscribed_or_flag = (flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED) ? 0 : 1,
 	    root_or_flag = (orig_top == NULL || orig_top[0] == '\0') ? 1 : 0,
@@ -943,10 +865,18 @@ nntp_store_get_cached_folder_info (CamelNNTPStore *store,
 	CamelStoreInfo *si;
 	CamelFolderInfo *first = NULL, *last = NULL, *fi = NULL;
 	GHashTable *known; /* folder name to folder info */
+	gboolean folder_hierarchy_relative;
 	gchar *tmpname;
 	gchar *top = g_strconcat(orig_top?orig_top:"", ".", NULL);
 	gint toplen = strlen (top);
 
+	service = CAMEL_SERVICE (store);
+	settings = camel_service_get_settings (service);
+
+	folder_hierarchy_relative =
+		camel_nntp_settings_get_folder_hierarchy_relative (
+		CAMEL_NNTP_SETTINGS (settings));
+
 	known = g_hash_table_new (g_str_hash, g_str_equal);
 
 	for (i = 0; (si = camel_store_summary_index ((CamelStoreSummary *) store->summary, i)); i++) {
@@ -957,7 +887,7 @@ nntp_store_get_cached_folder_info (CamelNNTPStore *store,
 				fi = nntp_folder_info_from_store_info (store, FALSE, si);
 				if (!fi)
 					continue;
-				if (store->folder_hierarchy_relative) {
+				if (folder_hierarchy_relative) {
 					g_free (fi->display_name);
 					fi->display_name = g_strdup (si->path + ((toplen == 1) ? 0 : toplen));
 				}
@@ -975,7 +905,7 @@ nntp_store_get_cached_folder_info (CamelNNTPStore *store,
 						continue;
 
 					fi->flags |= CAMEL_FOLDER_NOSELECT;
-					if (store->folder_hierarchy_relative) {
+					if (folder_hierarchy_relative) {
 						g_free (fi->display_name);
 						fi->display_name = g_strdup (tmpname + ((toplen==1) ? 0 : toplen));
 					}
@@ -1220,10 +1150,19 @@ nntp_store_subscribe_folder_sync (CamelStore *store,
                                   GError **error)
 {
 	CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (store);
+	CamelService *service;
+	CamelSettings *settings;
 	CamelStoreInfo *si;
 	CamelFolderInfo *fi;
+	gboolean short_folder_names;
 	gboolean success = TRUE;
 
+	service = CAMEL_SERVICE (store);
+	settings = camel_service_get_settings (service);
+
+	short_folder_names = camel_nntp_settings_get_short_folder_names (
+		CAMEL_NNTP_SETTINGS (settings));
+
 	camel_service_lock (CAMEL_SERVICE (nntp_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 
 	si = camel_store_summary_path (CAMEL_STORE_SUMMARY (nntp_store->summary), folder_name);
@@ -1238,7 +1177,7 @@ nntp_store_subscribe_folder_sync (CamelStore *store,
 	} else {
 		if (!(si->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED)) {
 			si->flags |= CAMEL_STORE_INFO_FOLDER_SUBSCRIBED;
-			fi = nntp_folder_info_from_store_info (nntp_store, nntp_store->do_short_folder_notation, si);
+			fi = nntp_folder_info_from_store_info (nntp_store, short_folder_names, si);
 			fi->flags |= CAMEL_FOLDER_NOINFERIORS | CAMEL_FOLDER_NOCHILDREN;
 			camel_store_summary_touch ((CamelStoreSummary *) nntp_store->summary);
 			camel_store_summary_save ((CamelStoreSummary *) nntp_store->summary);
@@ -1261,10 +1200,19 @@ nntp_store_unsubscribe_folder_sync (CamelStore *store,
                                     GError **error)
 {
 	CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (store);
+	CamelService *service;
+	CamelSettings *settings;
 	CamelFolderInfo *fi;
 	CamelStoreInfo *fitem;
+	gboolean short_folder_names;
 	gboolean success = TRUE;
 
+	service = CAMEL_SERVICE (store);
+	settings = camel_service_get_settings (service);
+
+	short_folder_names = camel_nntp_settings_get_short_folder_names (
+		CAMEL_NNTP_SETTINGS (settings));
+
 	camel_service_lock (CAMEL_SERVICE (nntp_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 
 	fitem = camel_store_summary_path (CAMEL_STORE_SUMMARY (nntp_store->summary), folder_name);
@@ -1279,7 +1227,7 @@ nntp_store_unsubscribe_folder_sync (CamelStore *store,
 	} else {
 		if (fitem->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED) {
 			fitem->flags &= ~CAMEL_STORE_INFO_FOLDER_SUBSCRIBED;
-			fi = nntp_folder_info_from_store_info (nntp_store, nntp_store->do_short_folder_notation, fitem);
+			fi = nntp_folder_info_from_store_info (nntp_store, short_folder_names, fitem);
 			camel_store_summary_touch ((CamelStoreSummary *) nntp_store->summary);
 			camel_store_summary_save ((CamelStoreSummary *) nntp_store->summary);
 			camel_service_unlock (CAMEL_SERVICE (nntp_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
@@ -1389,16 +1337,6 @@ nntp_store_initable_init (GInitable *initable,
 	camel_url_free (summary_url);
 	camel_store_summary_load ((CamelStoreSummary *) nntp_store->summary);
 
-	/* get options */
-	if (camel_url_get_param (url, "show_short_notation"))
-		nntp_store->do_short_folder_notation = TRUE;
-	else
-		nntp_store->do_short_folder_notation = FALSE;
-	if (camel_url_get_param (url, "folder_hierarchy_relative"))
-		nntp_store->folder_hierarchy_relative = TRUE;
-	else
-		nntp_store->folder_hierarchy_relative = FALSE;
-
 	/* setup store-wide cache */
 	nntp_store->cache = camel_data_cache_new (user_data_dir, error);
 	if (nntp_store->cache == NULL)
@@ -1412,13 +1350,11 @@ nntp_store_initable_init (GInitable *initable,
 }
 
 static const gchar *
-nntp_store_get_service_name (CamelNetworkService *service)
+nntp_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 = "nntps";
@@ -1433,13 +1369,11 @@ nntp_store_get_service_name (CamelNetworkService *service)
 }
 
 static guint16
-nntp_store_get_default_port (CamelNetworkService *service)
+nntp_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 = NNTPS_PORT;
@@ -1461,16 +1395,12 @@ camel_nntp_store_class_init (CamelNNTPStoreClass *class)
 	CamelStoreClass *store_class;
 	CamelDiscoStoreClass *disco_store_class;
 
-	g_type_class_add_private (class, sizeof (CamelNNTPStorePrivate));
-
 	object_class = G_OBJECT_CLASS (class);
-	object_class->set_property = nntp_store_set_property;
-	object_class->get_property = nntp_store_get_property;
 	object_class->dispose = nntp_store_dispose;
 	object_class->finalize = nntp_store_finalize;
-	object_class->constructed = nntp_store_constructed;
 
 	service_class = CAMEL_SERVICE_CLASS (class);
+	service_class->settings_type = CAMEL_TYPE_NNTP_SETTINGS;
 	service_class->get_name = nntp_store_get_name;
 	service_class->query_auth_types_sync = nntp_store_query_auth_types_sync;
 
@@ -1496,24 +1426,6 @@ camel_nntp_store_class_init (CamelNNTPStoreClass *class)
 	disco_store_class->get_folder_info_online = nntp_get_folder_info_online;
 	disco_store_class->get_folder_info_resyncing = nntp_get_folder_info_online;
 	disco_store_class->get_folder_info_offline = nntp_get_folder_info_offline;
-
-	/* 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
@@ -1536,8 +1448,6 @@ camel_nntp_store_init (CamelNNTPStore *nntp_store)
 {
 	CamelStore *store = CAMEL_STORE (nntp_store);
 
-	nntp_store->priv = CAMEL_NNTP_STORE_GET_PRIVATE (nntp_store);
-
 	store->flags = CAMEL_STORE_SUBSCRIPTIONS;
 
 	nntp_store->mem = (CamelStreamMem *) camel_stream_mem_new ();
diff --git a/camel/providers/nntp/camel-nntp-store.h b/camel/providers/nntp/camel-nntp-store.h
index 6d16071..c1d6dbe 100644
--- a/camel/providers/nntp/camel-nntp-store.h
+++ b/camel/providers/nntp/camel-nntp-store.h
@@ -90,8 +90,6 @@ struct _CamelNNTPStore {
 	guint32 extensions;
 
 	guint posting_allowed:1;
-	guint do_short_folder_notation:1;
-	guint folder_hierarchy_relative:1;
 	gboolean password_reprompt;
 
 	struct _CamelNNTPStoreSummary *summary;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]