[evolution-kolab] KolabSettingsHandler: Add a "camel-settings" property.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab] KolabSettingsHandler: Add a "camel-settings" property.
- Date: Thu, 12 Jul 2012 12:43:10 +0000 (UTC)
commit ac3a3c737ae7262934170df5e67095a8748ce779
Author: Matthew Barnes <mbarnes redhat com>
Date: Mon Jul 2 08:54:48 2012 -0400
KolabSettingsHandler: Add a "camel-settings" property.
Add a construct-only "camel-settings" property which is now passed in
through camel_settings_handler_new().
Remove camel_settings_handler_set_settings().
This ensures any KolabSettingsHandler carries an authoritative
CamelKolabIMAPXSettings which is bound to a collection ESource.
src/addressbook/e-book-backend-kolab.c | 3 +-
src/calendar/e-cal-backend-kolab.c | 3 +-
src/libekolab/kolab-settings-handler.c | 92 ++++++++++++++++----
src/libekolab/kolab-settings-handler.h | 3 +-
.../integration/libekolab/test-kolab-mail-access.c | 8 ++-
5 files changed, 82 insertions(+), 27 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-kolab.c b/src/addressbook/e-book-backend-kolab.c
index 852e0eb..709d5ff 100644
--- a/src/addressbook/e-book-backend-kolab.c
+++ b/src/addressbook/e-book-backend-kolab.c
@@ -340,8 +340,7 @@ e_book_backend_kolab_open (EBookBackendSync *backend,
goto exit;
/* Configure settings handler */
- ksettings = kolab_settings_handler_new ();
- kolab_settings_handler_set_camel_settings (ksettings, kolab_settings);
+ ksettings = kolab_settings_handler_new (kolab_settings);
ok = kolab_settings_handler_configure (ksettings,
KOLAB_FOLDER_CONTEXT_CONTACT,
&tmp_err);
diff --git a/src/calendar/e-cal-backend-kolab.c b/src/calendar/e-cal-backend-kolab.c
index c948fb4..df16c80 100644
--- a/src/calendar/e-cal-backend-kolab.c
+++ b/src/calendar/e-cal-backend-kolab.c
@@ -400,8 +400,7 @@ e_cal_backend_kolab_open (ECalBackendSync *backend,
goto exit;
/* Configure settings handler */
- ksettings = kolab_settings_handler_new ();
- kolab_settings_handler_set_camel_settings (ksettings, kolab_settings);
+ ksettings = kolab_settings_handler_new (kolab_settings);
ok = kolab_settings_handler_configure (ksettings,
KOLAB_FOLDER_CONTEXT_CALENDAR,
&tmp_err);
diff --git a/src/libekolab/kolab-settings-handler.c b/src/libekolab/kolab-settings-handler.c
index deb3f12..069d0fb 100644
--- a/src/libekolab/kolab-settings-handler.c
+++ b/src/libekolab/kolab-settings-handler.c
@@ -55,6 +55,11 @@ struct _KolabSettingsHandlerPrivate
GHashTable *sdata_tbl;
};
+enum {
+ PROP_0,
+ PROP_CAMEL_SETTINGS
+};
+
#define KOLAB_SETTINGS_HANDLER_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), KOLAB_TYPE_SETTINGS_HANDLER, KolabSettingsHandlerPrivate))
G_DEFINE_TYPE (KolabSettingsHandler, kolab_settings_handler, G_TYPE_OBJECT)
@@ -346,6 +351,55 @@ kolab_settings_handler_init (KolabSettingsHandler *self)
}
static void
+kolab_settings_handler_set_camel_settings (KolabSettingsHandler *ksettings,
+ CamelKolabIMAPXSettings *camel_settings)
+{
+ g_return_if_fail (CAMEL_IS_KOLAB_IMAPX_SETTINGS (camel_settings));
+ g_return_if_fail (ksettings->priv->camel_settings == NULL);
+
+ ksettings->priv->camel_settings = g_object_ref (camel_settings);
+}
+
+static void
+kolab_settings_handler_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_CAMEL_SETTINGS:
+ kolab_settings_handler_set_camel_settings (
+ KOLAB_SETTINGS_HANDLER (object),
+ g_value_get_object (value));
+ return;
+ default:
+ break;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+kolab_settings_handler_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_CAMEL_SETTINGS:
+ g_value_set_object (
+ value,
+ kolab_settings_handler_get_camel_settings (
+ KOLAB_SETTINGS_HANDLER (object)));
+ return;
+ default:
+ break;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
kolab_settings_handler_dispose (GObject *object)
{
KolabSettingsHandlerPrivate *priv = NULL;
@@ -389,14 +443,31 @@ kolab_settings_handler_class_init (KolabSettingsHandlerClass *klass)
g_type_class_add_private (klass, sizeof (KolabSettingsHandlerPrivate));
+ object_class->set_property = kolab_settings_handler_set_property;
+ object_class->get_property = kolab_settings_handler_get_property;
object_class->dispose = kolab_settings_handler_dispose;
object_class->finalize = kolab_settings_handler_finalize;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_CAMEL_SETTINGS,
+ g_param_spec_object (
+ "camel-settings",
+ "Camel Settings",
+ "An authoritative CamelKolabIMAPXSettings",
+ CAMEL_TYPE_KOLAB_IMAPX_SETTINGS,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
}
KolabSettingsHandler *
-kolab_settings_handler_new (void)
+kolab_settings_handler_new (CamelKolabIMAPXSettings *camel_settings)
{
- return g_object_new (KOLAB_TYPE_SETTINGS_HANDLER, NULL);
+ g_return_val_if_fail (CAMEL_IS_KOLAB_IMAPX_SETTINGS (camel_settings), NULL);
+
+ return g_object_new (
+ KOLAB_TYPE_SETTINGS_HANDLER,
+ "camel-settings", camel_settings, NULL);
}
/*----------------------------------------------------------------------------*/
@@ -516,23 +587,6 @@ kolab_settings_handler_get_camel_settings (KolabSettingsHandler *self)
return self->priv->camel_settings;
}
-void
-kolab_settings_handler_set_camel_settings (KolabSettingsHandler *self,
- CamelKolabIMAPXSettings *camel_settings)
-{
- g_assert (KOLAB_IS_SETTINGS_HANDLER (self));
-
- if (camel_settings != NULL) {
- g_assert (CAMEL_IS_KOLAB_IMAPX_SETTINGS (camel_settings));
- g_object_ref (camel_settings);
- }
-
- if (self->priv->camel_settings != NULL)
- g_object_unref (self->priv->camel_settings);
-
- self->priv->camel_settings = camel_settings;
-}
-
/**
* kolab_settings_handler_set_char_field:
* @self: a #KolabSettingsHandler instance
diff --git a/src/libekolab/kolab-settings-handler.h b/src/libekolab/kolab-settings-handler.h
index f3565dc..2255d6d 100644
--- a/src/libekolab/kolab-settings-handler.h
+++ b/src/libekolab/kolab-settings-handler.h
@@ -162,14 +162,13 @@ typedef enum {
GType kolab_settings_handler_get_type (void) G_GNUC_CONST;
-KolabSettingsHandler * kolab_settings_handler_new (void);
+KolabSettingsHandler * kolab_settings_handler_new (CamelKolabIMAPXSettings *camel_settings);
gboolean kolab_settings_handler_configure (KolabSettingsHandler *self, KolabFolderContextID context, GError **err);
gboolean kolab_settings_handler_bringup (KolabSettingsHandler *self, GError **err);
gboolean kolab_settings_handler_shutdown (KolabSettingsHandler *self, GError **err);
CamelKolabIMAPXSettings * kolab_settings_handler_get_camel_settings (KolabSettingsHandler *self);
-void kolab_settings_handler_set_camel_settings (KolabSettingsHandler *self, CamelKolabIMAPXSettings *camel_settings);
gboolean kolab_settings_handler_set_char_field (KolabSettingsHandler *self, KolabSettingsHandlerCharFieldID field_id, gchar *value, GError **err);
const gchar* kolab_settings_handler_get_char_field (KolabSettingsHandler *self, KolabSettingsHandlerCharFieldID field_id, GError **err);
diff --git a/src/tests/integration/libekolab/test-kolab-mail-access.c b/src/tests/integration/libekolab/test-kolab-mail-access.c
index 50884c4..23552f8 100644
--- a/src/tests/integration/libekolab/test-kolab-mail-access.c
+++ b/src/tests/integration/libekolab/test-kolab-mail-access.c
@@ -269,6 +269,7 @@ test_kolab_mail_access (KolabFolderContextID context)
{
KolabMailAccess *kmailaccess = NULL;
KolabSettingsHandler *ksettings = NULL;
+ CamelKolabIMAPXSettings *camel_settings;
gboolean ok = FALSE;
gboolean rval = TRUE;
GError *tmp_err = NULL;
@@ -278,8 +279,11 @@ test_kolab_mail_access (KolabFolderContextID context)
if (! ok)
goto test_part_cleanup;
- /* create settings handler object */
- ksettings = kolab_settings_handler_new ();
+ /* create settings handler object with
+ * a dummy CamelKolabIMAPXSettings */
+ camel_settings = g_object_new (CAMEL_TYPE_KOLAB_IMAPX_SETTINGS, NULL);
+ ksettings = kolab_settings_handler_new (camel_settings);
+ g_object_unref (camel_settings);
/* configure settings */
ok = kolab_settings_handler_configure (ksettings,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]