[evolution-data-server] Add CamelSpoolSettings.



commit ea4b16409f268a67572c54440e6bea25fa912fff
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat Jul 9 12:25:29 2011 -0400

    Add CamelSpoolSettings.
    
    CamelSpoolSettings replaces the various URL parameters used in
    CamelSpoolStore with equivalent GObject properties.
    
    Adapt the spool provider to use CamelSpoolSettings.

 camel/providers/local/Makefile.am            |    2 +
 camel/providers/local/camel-spool-folder.c   |   25 +++--
 camel/providers/local/camel-spool-settings.c |  142 ++++++++++++++++++++++++++
 camel/providers/local/camel-spool-settings.h |   67 ++++++++++++
 camel/providers/local/camel-spool-store.c    |    3 +-
 5 files changed, 226 insertions(+), 13 deletions(-)
---
diff --git a/camel/providers/local/Makefile.am b/camel/providers/local/Makefile.am
index e3ecab3..8c33df2 100644
--- a/camel/providers/local/Makefile.am
+++ b/camel/providers/local/Makefile.am
@@ -6,6 +6,7 @@ SYSDEP_PROVIDER_SOURCES =
 else
 SYSDEP_PROVIDER_SOURCES = \
 	camel-spool-folder.c			\
+	camel-spool-settings.c			\
 	camel-spool-store.c			\
 	camel-spool-summary.c
 endif
@@ -50,6 +51,7 @@ noinst_HEADERS =				\
 	camel-maildir-store.h			\
 	camel-maildir-summary.h			\
 	camel-spool-folder.h			\
+	camel-spool-settings.h			\
 	camel-spool-store.h			\
 	camel-spool-summary.h			\
 	camel-local-private.h
diff --git a/camel/providers/local/camel-spool-folder.c b/camel/providers/local/camel-spool-folder.c
index 8e86fd9..8125a22 100644
--- a/camel/providers/local/camel-spool-folder.c
+++ b/camel/providers/local/camel-spool-folder.c
@@ -35,6 +35,7 @@
 #include <glib/gi18n-lib.h>
 
 #include "camel-spool-folder.h"
+#include "camel-spool-settings.h"
 #include "camel-spool-store.h"
 #include "camel-spool-summary.h"
 
@@ -144,8 +145,14 @@ camel_spool_folder_new (CamelStore *parent_store,
 	gboolean use_xstatus_headers;
 	gchar *basename;
 
-	use_xstatus_headers = camel_spool_store_get_use_xstatus_headers (
-		CAMEL_SPOOL_STORE (parent_store));
+	service = CAMEL_SERVICE (parent_store);
+	settings = camel_service_get_settings (service);
+
+	filter_inbox = camel_store_settings_get_filter_inbox (
+		CAMEL_STORE_SETTINGS (settings));
+
+	use_xstatus_headers = camel_spool_settings_get_use_xstatus_headers (
+		CAMEL_SPOOL_SETTINGS (settings));
 
 	basename = g_path_get_basename (full_name);
 
@@ -154,22 +161,16 @@ camel_spool_folder_new (CamelStore *parent_store,
 		"display-name", basename, "full-name", full_name,
 		"parent-store", parent_store, NULL);
 
-	service = CAMEL_SERVICE (parent_store);
-	settings = camel_service_get_settings (service);
-
-	filter_inbox = camel_store_settings_get_filter_inbox (
-		CAMEL_STORE_SETTINGS (settings));
-
 	if (filter_inbox && strcmp (full_name, "INBOX") == 0)
 		folder->folder_flags |= CAMEL_FOLDER_FILTER_RECENT;
 	flags &= ~CAMEL_STORE_FOLDER_BODY_INDEX;
 
 	folder = (CamelFolder *) camel_local_folder_construct (
 		(CamelLocalFolder *) folder, flags, cancellable, error);
-	if (folder) {
-		if (camel_url_get_param (url, "xstatus"))
-			camel_mbox_summary_xstatus ((CamelMboxSummary *) folder->summary, TRUE);
-	}
+
+	if (folder != NULL && use_xstatus_headers)
+		camel_mbox_summary_xstatus (
+			CAMEL_MBOX_SUMMARY (folder->summary), TRUE);
 
 	g_free (basename);
 
diff --git a/camel/providers/local/camel-spool-settings.c b/camel/providers/local/camel-spool-settings.c
new file mode 100644
index 0000000..38218f4
--- /dev/null
+++ b/camel/providers/local/camel-spool-settings.c
@@ -0,0 +1,142 @@
+/*
+ * camel-spool-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-spool-settings.h"
+
+#define CAMEL_SPOOL_SETTINGS_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), CAMEL_TYPE_SPOOL_SETTINGS, CamelSpoolSettingsPrivate))
+
+struct _CamelSpoolSettingsPrivate {
+	gboolean use_xstatus_headers;
+};
+
+enum {
+	PROP_0,
+	PROP_USE_XSTATUS_HEADERS
+};
+
+G_DEFINE_TYPE (
+	CamelSpoolSettings,
+	camel_spool_settings,
+	CAMEL_TYPE_STORE_SETTINGS)
+
+static void
+spool_settings_set_property (GObject *object,
+                             guint property_id,
+                             const GValue *value,
+                             GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_USE_XSTATUS_HEADERS:
+			camel_spool_settings_set_use_xstatus_headers (
+				CAMEL_SPOOL_SETTINGS (object),
+				g_value_get_boolean (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+spool_settings_get_property (GObject *object,
+                             guint property_id,
+                             GValue *value,
+                             GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_USE_XSTATUS_HEADERS:
+			g_value_set_boolean (
+				value,
+				camel_spool_settings_get_use_xstatus_headers (
+				CAMEL_SPOOL_SETTINGS (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+camel_spool_settings_class_init (CamelSpoolSettingsClass *class)
+{
+	GObjectClass *object_class;
+
+	g_type_class_add_private (class, sizeof (CamelSpoolSettingsPrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = spool_settings_set_property;
+	object_class->get_property = spool_settings_get_property;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_USE_XSTATUS_HEADERS,
+		g_param_spec_boolean (
+			"use-xstatus-headers",
+			"Use X-Status Headers",
+			"Whether to use X-Status headers",
+			FALSE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT |
+			G_PARAM_STATIC_STRINGS));
+}
+
+static void
+camel_spool_settings_init (CamelSpoolSettings *settings)
+{
+	settings->priv = CAMEL_SPOOL_SETTINGS_GET_PRIVATE (settings);
+}
+
+/**
+ * camel_spool_settings_get_use_xstatus_headers:
+ * @settings: a #CamelSpoolSettings
+ *
+ * Returns whether to utilize both "Status" and "X-Status" headers for
+ * interoperability with mbox-based mail clients like Elm, Pine and Mutt.
+ *
+ * Returns: whether to use "X-Status" headers
+ *
+ * Since: 3.2
+ **/
+gboolean
+camel_spool_settings_get_use_xstatus_headers (CamelSpoolSettings *settings)
+{
+	g_return_val_if_fail (CAMEL_IS_SPOOL_SETTINGS (settings), FALSE);
+
+	return settings->priv->use_xstatus_headers;
+}
+
+/**
+ * camel_spool_settings_set_use_xstatus_headers:
+ * @settings: a #CamelSpoolSettings
+ * @use_xstatus_headers: whether to use "X-Status" headers
+ *
+ * Sets whether to utilize both "Status" and "X-Status" headers for
+ * interoperability with mbox-based mail clients like Elm, Pine and Mutt.
+ *
+ * Since: 3.2
+ **/
+void
+camel_spool_settings_set_use_xstatus_headers (CamelSpoolSettings *settings,
+                                              gboolean use_xstatus_headers)
+{
+	g_return_if_fail (CAMEL_IS_SPOOL_SETTINGS (settings));
+
+	settings->priv->use_xstatus_headers = use_xstatus_headers;
+
+	g_object_notify (G_OBJECT (settings), "use-xstatus-headers");
+}
diff --git a/camel/providers/local/camel-spool-settings.h b/camel/providers/local/camel-spool-settings.h
new file mode 100644
index 0000000..f733f93
--- /dev/null
+++ b/camel/providers/local/camel-spool-settings.h
@@ -0,0 +1,67 @@
+/*
+ * camel-spool-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_SPOOL_SETTINGS_H
+#define CAMEL_SPOOL_SETTINGS_H
+
+#include <camel/camel.h>
+
+/* Standard GObject macros */
+#define CAMEL_TYPE_SPOOL_SETTINGS \
+	(camel_spool_settings_get_type ())
+#define CAMEL_SPOOL_SETTINGS(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), CAMEL_TYPE_SPOOL_SETTINGS, CamelSpoolSettings))
+#define CAMEL_SPOOL_SETTINGS_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), CAMEL_TYPE_SPOOL_SETTINGS, CamelSpoolSettingsClass))
+#define CAMEL_IS_SPOOL_SETTINGS(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), CAMEL_TYPE_SPOOL_SETTINGS))
+#define CAMEL_IS_SPOOL_SETTINGS_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), CAMEL_TYPE_SPOOL_SETTINGS))
+#define CAMEL_SPOOL_SETTINGS_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), CAMEL_TYPE_SPOOL_SETTINGS, CamelSpoolSettingsClass))
+
+G_BEGIN_DECLS
+
+typedef struct _CamelSpoolSettings CamelSpoolSettings;
+typedef struct _CamelSpoolSettingsClass CamelSpoolSettingsClass;
+typedef struct _CamelSpoolSettingsPrivate CamelSpoolSettingsPrivate;
+
+struct _CamelSpoolSettings {
+	CamelStoreSettings parent;
+	CamelSpoolSettingsPrivate *priv;
+};
+
+struct _CamelSpoolSettingsClass {
+	CamelStoreSettingsClass parent_class;
+};
+
+GType		camel_spool_settings_get_type	(void) G_GNUC_CONST;
+gboolean	camel_spool_settings_get_use_xstatus_headers
+						(CamelSpoolSettings *settings);
+void		camel_spool_settings_set_use_xstatus_headers
+						(CamelSpoolSettings *settings,
+						 gboolean use_xstatus_headers);
+
+G_END_DECLS
+
+#endif /* CAMEL_SPOOL_SETTINGS_H */
diff --git a/camel/providers/local/camel-spool-store.c b/camel/providers/local/camel-spool-store.c
index 5d89392..14589e4 100644
--- a/camel/providers/local/camel-spool-store.c
+++ b/camel/providers/local/camel-spool-store.c
@@ -36,6 +36,7 @@
 #include <glib/gi18n-lib.h>
 
 #include "camel-spool-folder.h"
+#include "camel-spool-settings.h"
 #include "camel-spool-store.h"
 
 #define CAMEL_SPOOL_STORE_GET_PRIVATE(obj) \
@@ -610,6 +611,7 @@ camel_spool_store_class_init (CamelSpoolStoreClass *class)
 	g_type_class_add_private (class, sizeof (CamelSpoolStorePrivate));
 
 	service_class = CAMEL_SERVICE_CLASS (class);
+	service_class->settings_type = CAMEL_TYPE_SPOOL_SETTINGS;
 	service_class->get_name = spool_store_get_name;
 
 	store_class = CAMEL_STORE_CLASS (class);
@@ -638,4 +640,3 @@ camel_spool_store_init (CamelSpoolStore *spool_store)
 {
 	spool_store->priv = CAMEL_SPOOL_STORE_GET_PRIVATE (spool_store);
 }
-



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