[evolution-ews/gnome-3-2] Backport camel-ews-settings from master
- From: David Woodhouse <dwmw2 src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews/gnome-3-2] Backport camel-ews-settings from master
- Date: Wed, 19 Oct 2011 19:42:13 +0000 (UTC)
commit 0f12d1957c3f2891d43e3e74e65e6df6f3a41c12
Author: David Woodhouse <David Woodhouse intel com>
Date: Wed Oct 19 20:25:32 2011 +0100
Backport camel-ews-settings from master
src/camel/Makefile.am | 2 +
src/camel/camel-ews-folder.c | 5 +-
src/camel/camel-ews-provider.c | 10 +-
src/camel/camel-ews-settings.c | 302 ++++++++++++++++++++++++++++++++++++++++
src/camel/camel-ews-settings.h | 70 +++++++++
src/camel/camel-ews-store.c | 5 +-
6 files changed, 387 insertions(+), 7 deletions(-)
---
diff --git a/src/camel/Makefile.am b/src/camel/Makefile.am
index b60251d..df08866 100644
--- a/src/camel/Makefile.am
+++ b/src/camel/Makefile.am
@@ -19,6 +19,7 @@ libcamelews_la_CPPFLAGS = \
libcamelews_la_SOURCES = \
camel-ews-folder.c \
+ camel-ews-settings.c \
camel-ews-store-summary.c \
camel-ews-store.c \
camel-ews-summary.c \
@@ -29,6 +30,7 @@ libcamelews_la_SOURCES = \
noinst_HEADERS = \
camel-ews-folder.h \
camel-ews-private.h \
+ camel-ews-settings.h \
camel-ews-store-summary.h \
camel-ews-store.h \
camel-ews-summary.h \
diff --git a/src/camel/camel-ews-folder.c b/src/camel/camel-ews-folder.c
index a6da13a..60fe972 100644
--- a/src/camel/camel-ews-folder.c
+++ b/src/camel/camel-ews-folder.c
@@ -53,6 +53,7 @@ which needs to be better organized via functions */
#include "camel-ews-store.h"
#include "camel-ews-summary.h"
#include "camel-ews-utils.h"
+#include "camel-ews-settings.h"
#include <ews-camel-common.h>
#define EWS_MAX_FETCH_COUNT 100
@@ -791,7 +792,9 @@ camel_ews_folder_new (CamelStore *store, const gchar *folder_name, const gchar *
}
if (!g_ascii_strcasecmp (folder_name, "Inbox")) {
- if (camel_url_get_param (camel_service_get_camel_url ((CamelService *) store), "filter"))
+ CamelStoreSettings *settings = CAMEL_STORE_SETTINGS (camel_service_get_settings (CAMEL_SERVICE (store)));
+
+ if (camel_store_settings_get_filter_inbox (settings))
folder->folder_flags |= CAMEL_FOLDER_FILTER_RECENT;
}
diff --git a/src/camel/camel-ews-provider.c b/src/camel/camel-ews-provider.c
index c3f9462..7a77f3d 100644
--- a/src/camel/camel-ews-provider.c
+++ b/src/camel/camel-ews-provider.c
@@ -46,18 +46,18 @@ static CamelProviderConfEntry ews_conf_entries[] = {
{ CAMEL_PROVIDER_CONF_SECTION_START, "mailcheck", NULL,
N_("Checking for new mail") },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "check_all", NULL,
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "check-all", NULL,
N_("C_heck for new messages in all folders"), "1" },
{ CAMEL_PROVIDER_CONF_SECTION_END },
{ CAMEL_PROVIDER_CONF_SECTION_START, "general", NULL, N_("Options") },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "filter", NULL,
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "filter-inbox", NULL,
N_("_Apply filters to new messages in Inbox on this server"), "0" },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "filter_junk", NULL,
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "filter-junk", NULL,
N_("Check new messages for Jun_k contents"), "0" },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "filter_junk_inbox", "filter_junk",
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "filter-junk-inbox", "filter_junk",
N_("Only check for Junk messages in the IN_BOX folder"), "0" },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "sync_offline", NULL,
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "stay-synchronized", NULL,
N_("Automatically synchroni_ze remote mail locally"), "0" },
{ CAMEL_PROVIDER_CONF_SECTION_END },
diff --git a/src/camel/camel-ews-settings.c b/src/camel/camel-ews-settings.c
new file mode 100644
index 0000000..7392332
--- /dev/null
+++ b/src/camel/camel-ews-settings.c
@@ -0,0 +1,302 @@
+/*
+ * camel-ews-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-ews-settings.h"
+
+struct _CamelEwsSettingsPrivate {
+ gboolean check_all;
+ gboolean filter_junk;
+ gboolean filter_junk_inbox;
+};
+
+enum {
+ PROP_0,
+ PROP_SECURITY_METHOD,
+ PROP_CHECK_ALL,
+ PROP_FILTER_JUNK,
+ PROP_FILTER_JUNK_INBOX
+};
+
+G_DEFINE_TYPE_WITH_CODE (
+ CamelEwsSettings,
+ camel_ews_settings,
+ CAMEL_TYPE_OFFLINE_SETTINGS,
+ G_IMPLEMENT_INTERFACE (
+ CAMEL_TYPE_NETWORK_SETTINGS, NULL))
+
+static void
+ews_settings_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_SECURITY_METHOD:
+ camel_network_settings_set_security_method (
+ CAMEL_NETWORK_SETTINGS (object),
+ g_value_get_enum (value));
+ return;
+
+ case PROP_CHECK_ALL:
+ camel_ews_settings_set_check_all (
+ CAMEL_EWS_SETTINGS (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_FILTER_JUNK:
+ camel_ews_settings_set_filter_junk (
+ CAMEL_EWS_SETTINGS (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_FILTER_JUNK_INBOX:
+ camel_ews_settings_set_filter_junk_inbox (
+ CAMEL_EWS_SETTINGS (object),
+ g_value_get_boolean (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+ews_settings_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_SECURITY_METHOD:
+ g_value_set_enum (
+ value,
+ camel_network_settings_get_security_method (
+ CAMEL_NETWORK_SETTINGS (object)));
+ return;
+
+ case PROP_CHECK_ALL:
+ g_value_set_boolean (
+ value,
+ camel_ews_settings_get_check_all (
+ CAMEL_EWS_SETTINGS (object)));
+ return;
+
+ case PROP_FILTER_JUNK:
+ g_value_set_boolean (
+ value,
+ camel_ews_settings_get_filter_junk (
+ CAMEL_EWS_SETTINGS (object)));
+ return;
+
+ case PROP_FILTER_JUNK_INBOX:
+ g_value_set_boolean (
+ value,
+ camel_ews_settings_get_filter_junk_inbox (
+ CAMEL_EWS_SETTINGS (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+ews_settings_finalize (GObject *object)
+{
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (camel_ews_settings_parent_class)->finalize (object);
+}
+
+static void
+camel_ews_settings_class_init (CamelEwsSettingsClass *class)
+{
+ GObjectClass *object_class;
+
+ g_type_class_add_private (class, sizeof (CamelEwsSettingsPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = ews_settings_set_property;
+ object_class->get_property = ews_settings_get_property;
+ object_class->finalize = ews_settings_finalize;
+
+ /* Inherited from CamelNetworkSettings. */
+ g_object_class_override_property (
+ object_class,
+ PROP_SECURITY_METHOD,
+ "security-method");
+
+ /* Newly added properties */
+ g_object_class_install_property (
+ object_class,
+ PROP_CHECK_ALL,
+ g_param_spec_boolean (
+ "check-all",
+ "Check All",
+ "Check all folders for new messages",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_FILTER_JUNK,
+ g_param_spec_boolean (
+ "filter-junk",
+ "Filter Junk",
+ "Whether to filter junk from all folders",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_FILTER_JUNK_INBOX,
+ g_param_spec_boolean (
+ "filter-junk-inbox",
+ "Filter Junk Inbox",
+ "Whether to filter junk from Inbox only",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+}
+
+static void
+camel_ews_settings_init (CamelEwsSettings *settings)
+{
+ settings->priv = G_TYPE_INSTANCE_GET_PRIVATE (settings, CAMEL_TYPE_EWS_SETTINGS, CamelEwsSettingsPrivate);
+
+}
+
+/**
+ * camel_ews_settings_get_check_all:
+ * @settings: a #CamelEwsSettings
+ *
+ * Returns whether to check all folders for new messages.
+ *
+ * Returns: whether to check all folders for new messages
+ *
+ * Since: 3.4
+ **/
+gboolean
+camel_ews_settings_get_check_all (CamelEwsSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_EWS_SETTINGS (settings), FALSE);
+
+ return settings->priv->check_all;
+}
+
+/**
+ * camel_ews_settings_set_check_all:
+ * @settings: a #CamelEwsSettings
+ * @check_all: whether to check all folders for new messages
+ *
+ * Sets whether to check all folders for new messages.
+ *
+ * Since: 3.4
+ **/
+void
+camel_ews_settings_set_check_all (CamelEwsSettings *settings,
+ gboolean check_all)
+{
+ g_return_if_fail (CAMEL_IS_EWS_SETTINGS (settings));
+
+ settings->priv->check_all = check_all;
+
+ g_object_notify (G_OBJECT (settings), "check-all");
+}
+
+/**
+ * camel_ews_settings_get_filter_junk:
+ * @settings: a #CamelEwsSettings
+ *
+ * Returns whether to automatically find and tag junk messages amongst new
+ * messages in all folders.
+ *
+ * Returns: whether to filter junk in all folders
+ *
+ * Since: 3.4
+ **/
+gboolean
+camel_ews_settings_get_filter_junk (CamelEwsSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_EWS_SETTINGS (settings), FALSE);
+
+ return settings->priv->filter_junk;
+}
+
+/**
+ * camel_ews_settings_set_filter_junk:
+ * @settings: a #CamelEwsSettings
+ * @filter_junk: whether to filter junk in all filers
+ *
+ * Sets whether to automatically find and tag junk messages amongst new
+ * messages in all folders.
+ *
+ * Since: 3.4
+ **/
+void
+camel_ews_settings_set_filter_junk (CamelEwsSettings *settings,
+ gboolean filter_junk)
+{
+ g_return_if_fail (CAMEL_IS_EWS_SETTINGS (settings));
+
+ settings->priv->filter_junk = filter_junk;
+
+ g_object_notify (G_OBJECT (settings), "filter-junk");
+}
+
+/**
+ * camel_ews_settings_get_filter_junk_inbox:
+ * @settings: a #CamelEwsSettings
+ *
+ * Returns whether to automatically find and tag junk messages amongst new
+ * messages in the Inbox folder only.
+ *
+ * Returns: whether to filter junk in Inbox only
+ *
+ * Since: 3.4
+ **/
+gboolean
+camel_ews_settings_get_filter_junk_inbox (CamelEwsSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_EWS_SETTINGS (settings), FALSE);
+
+ return settings->priv->filter_junk_inbox;
+}
+
+/**
+ * camel_ews_settings_set_filter_junk_inbox:
+ * @settings: a #CamelEwsSettings
+ * @filter_junk_inbox: whether to filter junk in Inbox only
+ *
+ * Sets whether to automatically find and tag junk messages amongst new
+ * messages in the Inbox folder only.
+ *
+ * Since: 3.4
+ **/
+void
+camel_ews_settings_set_filter_junk_inbox (CamelEwsSettings *settings,
+ gboolean filter_junk_inbox)
+{
+ g_return_if_fail (CAMEL_IS_EWS_SETTINGS (settings));
+
+ settings->priv->filter_junk_inbox = filter_junk_inbox;
+
+ g_object_notify (G_OBJECT (settings), "filter-junk-inbox");
+}
diff --git a/src/camel/camel-ews-settings.h b/src/camel/camel-ews-settings.h
new file mode 100644
index 0000000..068d040
--- /dev/null
+++ b/src/camel/camel-ews-settings.h
@@ -0,0 +1,70 @@
+/*
+ * camel-ews-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_EWS_SETTINGS_H
+#define CAMEL_EWS_SETTINGS_H
+
+#include <camel/camel.h>
+
+/* Standard GObject macros */
+#define CAMEL_TYPE_EWS_SETTINGS \
+ (camel_ews_settings_get_type ())
+#define CAMEL_EWS_SETTINGS(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), CAMEL_TYPE_EWS_SETTINGS, CamelEwsSettings))
+#define CAMEL_EWS_SETTINGS_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), CAMEL_TYPE_EWS_SETTINGS, CamelEwsSettingsClass))
+#define CAMEL_IS_EWS_SETTINGS(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), CAMEL_TYPE_EWS_SETTINGS))
+#define CAMEL_IS_EWS_SETTINGS_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), CAMEL_TYPE_EWS_SETTINGS))
+#define CAMEL_EWS_SETTINGS_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), CAMEL_TYPE_EWS_SETTINGS))
+
+G_BEGIN_DECLS
+
+typedef struct _CamelEwsSettings CamelEwsSettings;
+typedef struct _CamelEwsSettingsClass CamelEwsSettingsClass;
+typedef struct _CamelEwsSettingsPrivate CamelEwsSettingsPrivate;
+
+struct _CamelEwsSettings {
+ CamelOfflineSettings parent;
+ CamelEwsSettingsPrivate *priv;
+};
+
+struct _CamelEwsSettingsClass {
+ CamelOfflineSettingsClass parent_class;
+};
+
+GType camel_ews_settings_get_type (void) G_GNUC_CONST;
+gboolean camel_ews_settings_get_check_all (CamelEwsSettings *settings);
+void camel_ews_settings_set_check_all (CamelEwsSettings *settings,
+ gboolean check_all);
+gboolean camel_ews_settings_get_filter_junk (CamelEwsSettings *settings);
+void camel_ews_settings_set_filter_junk (CamelEwsSettings *settings,
+ gboolean filter_junk);
+gboolean camel_ews_settings_get_filter_junk_inbox (CamelEwsSettings *settings);
+void camel_ews_settings_set_filter_junk_inbox (CamelEwsSettings *settings,
+ gboolean filter_junk_inbox);
+G_END_DECLS
+
+#endif /* CAMEL_EWS_SETTINGS_H */
diff --git a/src/camel/camel-ews-store.c b/src/camel/camel-ews-store.c
index 3bf0eaa..2787d0b 100644
--- a/src/camel/camel-ews-store.c
+++ b/src/camel/camel-ews-store.c
@@ -44,6 +44,7 @@
#include "camel-ews-store.h"
#include "camel-ews-summary.h"
#include "camel-ews-utils.h"
+#include "camel-ews-settings.h"
#include "ews-esource-utils.h"
#ifdef G_OS_WIN32
@@ -799,7 +800,8 @@ ews_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, GError **error
/* Delegate decision to parent class */
return CAMEL_STORE_CLASS(camel_ews_store_parent_class)->can_refresh_folder (store, info, error) ||
- (camel_url_get_param (camel_service_get_camel_url ((CamelService *)store), "check_all") != NULL);
+ camel_ews_settings_get_check_all (CAMEL_EWS_SETTINGS (camel_service_get_settings (CAMEL_SERVICE (store))));
+
}
gboolean
@@ -872,6 +874,7 @@ camel_ews_store_class_init (CamelEwsStoreClass *class)
service_class = CAMEL_SERVICE_CLASS (class);
+ service_class->settings_type = CAMEL_TYPE_EWS_SETTINGS;
service_class->query_auth_types_sync = ews_store_query_auth_types_sync;
service_class->get_name = ews_get_name;
service_class->connect_sync = ews_connect_sync;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]