[evolution-kolab/account-mgmt] Add ESourceKolabFolder extension.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/account-mgmt] Add ESourceKolabFolder extension.
- Date: Tue, 3 Jul 2012 14:13:23 +0000 (UTC)
commit 0d91f127abeec2e1ea22b5fa3297bc5493d473a8
Author: Matthew Barnes <mbarnes redhat com>
Date: Tue Jul 3 10:02:46 2012 -0400
Add ESourceKolabFolder extension.
Realized the sync conflict resolution strategy settings is supposed to
be per-folder. ESourceKolabFolder is derived from ESourceResource, so
it will hold both the sync strategy and folder "identity".
e.g. [Kolab Folder]
Identity=/INBOX/Contacts
SyncStrategy=newest
Also, remove the "sync-strategy" property from CamelKolabIMAPXSettings
since it's not needed for mail accounts.
src/addressbook/e-book-backend-kolab.c | 8 ++-
src/calendar/e-cal-backend-kolab.c | 8 ++-
src/libekolab/Makefile.am | 2 +
src/libekolab/camel-kolab-imapx-settings.c | 46 +---------
src/libekolab/camel-kolab-imapx-settings.h | 6 --
src/libekolab/e-source-kolab-folder.c | 134 ++++++++++++++++++++++++++++
src/libekolab/e-source-kolab-folder.h | 84 +++++++++++++++++
src/libekolab/kolab-util-backend.c | 3 +-
8 files changed, 237 insertions(+), 54 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-kolab.c b/src/addressbook/e-book-backend-kolab.c
index 2cb2b85..e38cc6a 100644
--- a/src/addressbook/e-book-backend-kolab.c
+++ b/src/addressbook/e-book-backend-kolab.c
@@ -34,6 +34,7 @@
#include <libekolabutil/kolab-util-http.h>
#include <libekolabutil/kolab-util-glib.h>
+#include <libekolab/e-source-kolab-folder.h>
#include <libekolab/camel-kolab-imapx-settings.h>
#include <libekolab/kolab-types.h>
#include <libekolab/kolab-mail-access.h>
@@ -233,11 +234,13 @@ e_book_backend_kolab_open (EBookBackendSync *backend,
EBookBackendKolabPrivate *priv = NULL;
ESourceRegistry *registry;
ESource *esource = NULL;
+ ESourceKolabFolder *extension;
CamelKolabIMAPXSettings *kolab_settings;
CamelNetworkSettings *network_settings;
KolabSettingsHandler *ksettings = NULL;
KolabMailAccess *tmp_koma = NULL;
KolabSyncStrategyID sync_value = KOLAB_SYNC_STRATEGY_DEFAULT;
+ const gchar *extension_name;
const gchar *foldername;
gchar *servername = NULL;
gchar *username = NULL;
@@ -278,7 +281,10 @@ e_book_backend_kolab_open (EBookBackendSync *backend,
g_debug ("%s()[%u] username = %s", __func__, __LINE__, username);
/* Prepare data from sync strategy property */
- sync_value = camel_kolab_imapx_settings_get_sync_strategy (kolab_settings);
+ extension_name = E_SOURCE_EXTENSION_KOLAB_FOLDER;
+ extension = e_source_get_extension (esource, extension_name);
+ sync_value = e_source_kolab_folder_get_sync_strategy (extension);
+
foldername = kolab_util_backend_get_foldername (E_BACKEND (backend));
/* Check whether we have a KolabMailAccess (KoMA) instance already */
diff --git a/src/calendar/e-cal-backend-kolab.c b/src/calendar/e-cal-backend-kolab.c
index e9acd09..c4532ae 100644
--- a/src/calendar/e-cal-backend-kolab.c
+++ b/src/calendar/e-cal-backend-kolab.c
@@ -33,6 +33,7 @@
#include <libical/ical.h>
+#include <libekolab/e-source-kolab-folder.h>
#include <libekolab/camel-kolab-imapx-settings.h>
#include <libekolab/kolab-mail-access.h>
#include <libekolab/kolab-settings-handler.h>
@@ -257,12 +258,14 @@ e_cal_backend_kolab_open (ECalBackendSync *backend,
ECalBackendKolabPrivate *priv = NULL;
ESourceRegistry *registry;
ESource *esource = NULL;
+ ESourceKolabFolder *extension;
CamelKolabIMAPXSettings *kolab_settings;
CamelNetworkSettings *network_settings;
KolabSettingsHandler *ksettings = NULL;
KolabMailAccess *tmp_koma = NULL;
KolabSyncStrategyID sync_value = KOLAB_SYNC_STRATEGY_DEFAULT;
icalcomponent_kind icalkind = ICAL_VEVENT_COMPONENT;
+ const gchar *extension_name;
const gchar *foldername;
const gchar *cache_dir;
gchar *cache_filename;
@@ -338,7 +341,10 @@ e_cal_backend_kolab_open (ECalBackendSync *backend,
g_debug (" + Cal cache cleaning %s.", ok ? "was successful" : "FAILED");
/* Prepare data from sync strategy property */
- sync_value = camel_kolab_imapx_settings_get_sync_strategy (kolab_settings);
+ extension_name = E_SOURCE_EXTENSION_KOLAB_FOLDER;
+ extension = e_source_get_extension (esource, extension_name);
+ sync_value = e_source_kolab_folder_get_sync_strategy (extension);
+
foldername = kolab_util_backend_get_foldername (E_BACKEND (backend));
/* Check whether we have a KolabMailAccess (KoMA) instance already */
diff --git a/src/libekolab/Makefile.am b/src/libekolab/Makefile.am
index 9156353..3e87713 100644
--- a/src/libekolab/Makefile.am
+++ b/src/libekolab/Makefile.am
@@ -41,6 +41,7 @@ ENUM_GENERATED = \
kolab-enumtypes.c
libekolab_la_SOURCES = \
+ e-source-kolab-folder.c \
camel-kolab-imapx-settings.c \
kolab-enumtypes.c \
kolab-data-folder-metadata.c \
@@ -49,6 +50,7 @@ libekolab_la_SOURCES = \
kolab-settings-handler.c
noinst_HEADERS = \
+ e-source-kolab-folder.h \
camel-kolab-imapx-settings.h \
kolab-backend-types.h \
kolab-data-folder-metadata.h \
diff --git a/src/libekolab/camel-kolab-imapx-settings.c b/src/libekolab/camel-kolab-imapx-settings.c
index 711e9b9..e6235cc 100644
--- a/src/libekolab/camel-kolab-imapx-settings.c
+++ b/src/libekolab/camel-kolab-imapx-settings.c
@@ -36,12 +36,10 @@
/*----------------------------------------------------------------------------*/
struct _CamelKolabIMAPXSettingsPrivate {
- KolabSyncStrategyID sync_strategy;
};
enum {
- PROP_0,
- PROP_SYNC_STRATEGY
+ PROP_0
};
#define CAMEL_KOLAB_IMAPX_SETTINGS_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CAMEL_TYPE_KOLAB_IMAPX_SETTINGS, CamelKolabIMAPXSettingsPrivate))
@@ -66,11 +64,6 @@ camel_kolab_imapx_settings_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_SYNC_STRATEGY:
- camel_kolab_imapx_settings_set_sync_strategy (
- CAMEL_KOLAB_IMAPX_SETTINGS (object),
- g_value_get_enum (value));
- return;
default:
break;
}
@@ -85,12 +78,6 @@ camel_kolab_imapx_settings_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_SYNC_STRATEGY:
- g_value_set_enum (
- value,
- camel_kolab_imapx_settings_get_sync_strategy (
- CAMEL_KOLAB_IMAPX_SETTINGS (object)));
- return;
default:
break;
}
@@ -107,18 +94,6 @@ camel_kolab_imapx_settings_class_init (CamelKolabIMAPXSettingsClass *klass)
object_class->set_property = camel_kolab_imapx_settings_set_property;
object_class->get_property = camel_kolab_imapx_settings_get_property;
-
- g_object_class_install_property (
- object_class,
- PROP_SYNC_STRATEGY,
- g_param_spec_enum (
- "sync-strategy",
- "Sync Strategy",
- "Conflict resolution strategy",
- KOLAB_TYPE_SYNC_STRATEGY_ID,
- KOLAB_SYNC_STRATEGY_DEFAULT,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
}
/*----------------------------------------------------------------------------*/
@@ -162,23 +137,4 @@ camel_kolab_imapx_settings_build_url (CamelKolabIMAPXSettings *settings)
return url;
}
-KolabSyncStrategyID
-camel_kolab_imapx_settings_get_sync_strategy (CamelKolabIMAPXSettings *settings)
-{
- g_return_val_if_fail (CAMEL_IS_KOLAB_IMAPX_SETTINGS (settings), KOLAB_SYNC_STRATEGY_DEFAULT);
-
- return settings->priv->sync_strategy;
-}
-
-void
-camel_kolab_imapx_settings_set_sync_strategy (CamelKolabIMAPXSettings *settings,
- KolabSyncStrategyID sync_strategy)
-{
- g_return_if_fail (CAMEL_IS_KOLAB_IMAPX_SETTINGS (settings));
-
- settings->priv->sync_strategy = sync_strategy;
-
- g_object_notify (G_OBJECT (settings), "sync-strategy");
-}
-
/*----------------------------------------------------------------------------*/
diff --git a/src/libekolab/camel-kolab-imapx-settings.h b/src/libekolab/camel-kolab-imapx-settings.h
index 8ad6020..5c511a9 100644
--- a/src/libekolab/camel-kolab-imapx-settings.h
+++ b/src/libekolab/camel-kolab-imapx-settings.h
@@ -78,12 +78,6 @@ camel_kolab_imapx_settings_get_type (void);
CamelURL *
camel_kolab_imapx_settings_build_url (CamelKolabIMAPXSettings *settings);
-KolabSyncStrategyID
-camel_kolab_imapx_settings_get_sync_strategy (CamelKolabIMAPXSettings *settings);
-void
-camel_kolab_imapx_settings_set_sync_strategy (CamelKolabIMAPXSettings *settings,
- KolabSyncStrategyID sync_strategy);
-
G_END_DECLS
/*----------------------------------------------------------------------------*/
diff --git a/src/libekolab/e-source-kolab-folder.c b/src/libekolab/e-source-kolab-folder.c
new file mode 100644
index 0000000..b8fd6fc
--- /dev/null
+++ b/src/libekolab/e-source-kolab-folder.c
@@ -0,0 +1,134 @@
+/*
+ * 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.1 of the License, or (at your option) any later version.
+ *
+ * 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
+ */
+
+#include "e-source-kolab-folder.h"
+
+#include "kolab-enumtypes.h"
+
+#define E_SOURCE_KOLAB_FOLDER_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_SOURCE_KOLAB_FOLDER, ESourceKolabFolderPrivate))
+
+struct _ESourceKolabFolderPrivate {
+ KolabSyncStrategyID sync_strategy;
+};
+
+enum {
+ PROP_0,
+ PROP_SYNC_STRATEGY
+};
+
+G_DEFINE_TYPE (
+ ESourceKolabFolder,
+ e_source_kolab_folder,
+ E_TYPE_SOURCE_RESOURCE)
+
+static void
+source_kolab_folder_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_SYNC_STRATEGY:
+ e_source_kolab_folder_set_sync_strategy (
+ E_SOURCE_KOLAB_FOLDER (object),
+ g_value_get_enum (value));
+ return;
+ default:
+ break;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+source_kolab_folder_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_SYNC_STRATEGY:
+ g_value_set_enum (
+ value,
+ e_source_kolab_folder_get_sync_strategy (
+ E_SOURCE_KOLAB_FOLDER (object)));
+ return;
+ default:
+ break;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+e_source_kolab_folder_class_init (ESourceKolabFolderClass *class)
+{
+ GObjectClass *object_class;
+ ESourceExtensionClass *extension_class;
+
+ g_type_class_add_private (class, sizeof (ESourceKolabFolderPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = source_kolab_folder_set_property;
+ object_class->get_property = source_kolab_folder_get_property;
+
+ extension_class = E_SOURCE_EXTENSION_CLASS (class);
+ extension_class->name = E_SOURCE_EXTENSION_KOLAB_FOLDER;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SYNC_STRATEGY,
+ g_param_spec_enum (
+ "sync-strategy",
+ "Sync Strategy",
+ "Conflict resolution strategy",
+ KOLAB_TYPE_SYNC_STRATEGY_ID,
+ KOLAB_SYNC_STRATEGY_DEFAULT,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS |
+ E_SOURCE_PARAM_SETTING));
+}
+
+static void
+e_source_kolab_folder_init (ESourceKolabFolder *extension)
+{
+ extension->priv = E_SOURCE_KOLAB_FOLDER_GET_PRIVATE (extension);
+}
+
+KolabSyncStrategyID
+e_source_kolab_folder_get_sync_strategy (ESourceKolabFolder *extension)
+{
+ g_return_val_if_fail (
+ E_IS_SOURCE_KOLAB_FOLDER (extension),
+ KOLAB_SYNC_STRATEGY_DEFAULT);
+
+ return extension->priv->sync_strategy;
+}
+
+void
+e_source_kolab_folder_set_sync_strategy (ESourceKolabFolder *extension,
+ KolabSyncStrategyID sync_strategy)
+{
+ g_return_if_fail (E_IS_SOURCE_KOLAB_FOLDER (extension));
+
+ extension->priv->sync_strategy = sync_strategy;
+
+ g_object_notify (G_OBJECT (extension), "sync-strategy");
+}
+
diff --git a/src/libekolab/e-source-kolab-folder.h b/src/libekolab/e-source-kolab-folder.h
new file mode 100644
index 0000000..5f6a7d7
--- /dev/null
+++ b/src/libekolab/e-source-kolab-folder.h
@@ -0,0 +1,84 @@
+/*
+ * 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.1 of the License, or (at your option) any later version.
+ *
+ * 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
+ */
+
+#ifndef E_SOURCE_KOLAB_FOLDER_H
+#define E_SOURCE_KOLAB_FOLDER_H
+
+#include <libedataserver/libedataserver.h>
+
+#include <libekolab/kolab-types.h>
+
+/* Standard GObject macros */
+#define E_TYPE_SOURCE_KOLAB_FOLDER \
+ (e_source_kolab_folder_get_type ())
+#define E_SOURCE_KOLAB_FOLDER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_SOURCE_KOLAB_FOLDER, ESourceKolabFolder))
+#define E_SOURCE_KOLAB_FOLDER_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_SOURCE_KOLAB_FOLDER, ESourceKolabFolderClass))
+#define E_IS_SOURCE_KOLAB_FOLDER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_SOURCE_KOLAB_FOLDER))
+#define E_IS_SOURCE_KOLAB_FOLDER_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_SOURCE_KOLAB_FOLDER))
+#define E_SOURCE_KOLAB_FOLDER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_SOURCE_KOLAB_FOLDER, ESourceKolabFolderClass))
+
+/**
+ * E_SOURCE_EXTENSION_KOLAB_FOLDER:
+ *
+ * Pass the extension name to e_source_get_extension() to access
+ * #ESourceKolabFolder. This is also used as a group name in key files.
+ **/
+#define E_SOURCE_EXTENSION_KOLAB_FOLDER "Kolab Folder"
+
+G_BEGIN_DECLS
+
+typedef struct _ESourceKolabFolder ESourceKolabFolder;
+typedef struct _ESourceKolabFolderClass ESourceKolabFolderClass;
+typedef struct _ESourceKolabFolderPrivate ESourceKolabFolderPrivate;
+
+/**
+ * ESourceKolabFolder:
+ *
+ * Contains only private data that should be read and manipulated using the
+ * functions below.
+ **/
+struct _ESourceKolabFolder {
+ ESourceResource parent;
+ ESourceKolabFolderPrivate *priv;
+};
+
+struct _ESourceKolabFolderClass {
+ ESourceResourceClass parent_class;
+};
+
+GType e_source_kolab_folder_get_type
+ (void) G_GNUC_CONST;
+KolabSyncStrategyID
+ e_source_kolab_folder_get_sync_strategy
+ (ESourceKolabFolder *extension);
+void e_source_kolab_folder_set_sync_strategy
+ (ESourceKolabFolder *extension,
+ KolabSyncStrategyID sync_strategy);
+
+G_END_DECLS
+
+#endif /* E_SOURCE_KOLAB_FOLDER_H */
+
diff --git a/src/libekolab/kolab-util-backend.c b/src/libekolab/kolab-util-backend.c
index bf231f8..6f9e56a 100644
--- a/src/libekolab/kolab-util-backend.c
+++ b/src/libekolab/kolab-util-backend.c
@@ -37,6 +37,7 @@
#include <libekolabutil/camel-system-headers.h>
#include <libekolabutil/kolab-util-camel.h>
+#include "e-source-kolab-folder.h"
#include "kolab-mail-access.h"
#include "kolab-util-backend.h"
@@ -95,7 +96,7 @@ kolab_util_backend_get_foldername (EBackend *backend)
g_return_val_if_fail (E_IS_BACKEND (backend), NULL);
source = e_backend_get_source (backend);
- extension_name = E_SOURCE_EXTENSION_RESOURCE;
+ extension_name = E_SOURCE_EXTENSION_KOLAB_FOLDER;
extension = e_source_get_extension (source, extension_name);
return e_source_resource_get_identity (extension);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]