[evolution-kolab] KolabSettingsHandler: no E-D-S restart for folder properties change
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab] KolabSettingsHandler: no E-D-S restart for folder properties change
- Date: Fri, 26 Oct 2012 18:16:03 +0000 (UTC)
commit ae800947757ec9f671e6225bc5c303b307bd5810
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Fri Oct 26 19:20:03 2012 +0200
KolabSettingsHandler: no E-D-S restart for folder properties change
* reflect changes to the "Kolab Folder" ESource extension
instantly so KolabMailAccess can pick that up on-the-fly
* needs an EBackend instance in KolabSettingsHandler,
then we read the settings values for ESource UID and
the Kolab folder sync strategy directly from the
objects which have them
* no E-D-S restart required any longer for Kolab folder
properties changes to take effect
src/addressbook/e-book-backend-kolab.c | 27 +--
src/calendar/e-cal-backend-kolab.c | 27 +--
src/collection/e-kolab-backend.c | 13 +-
src/libekolab/kolab-mail-synchronizer.c | 10 +-
src/libekolab/kolab-settings-handler.c | 370 ++++++++++----------
src/libekolab/kolab-settings-handler.h | 47 +---
.../integration/libekolab/test-kolab-mail-access.c | 18 +-
7 files changed, 203 insertions(+), 309 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-kolab.c b/src/addressbook/e-book-backend-kolab.c
index c953d8c..1fd239f 100644
--- a/src/addressbook/e-book-backend-kolab.c
+++ b/src/addressbook/e-book-backend-kolab.c
@@ -246,14 +246,9 @@ book_backend_kolab_open (EBookBackendSync *backend,
{
EBookBackendKolab *self = NULL;
EBookBackendKolabPrivate *priv = NULL;
- ESource *esource = NULL;
- ESourceKolabFolder *extension = NULL;
CamelKolabIMAPXSettings *kolab_settings = NULL;
CamelNetworkSettings *network_settings = NULL;
KolabSettingsHandler *ksettings = NULL;
- KolabSyncStrategyID sync_value = KOLAB_SYNC_STRATEGY_DEFAULT;
- const gchar *extension_name = NULL;
- const gchar *foldername = NULL;
gchar *servername = NULL;
gchar *username = NULL;
const gchar *user_home = NULL;
@@ -270,13 +265,6 @@ book_backend_kolab_open (EBookBackendSync *backend,
self = E_BOOK_BACKEND_KOLAB (backend);
priv = E_BOOK_BACKEND_KOLAB_PRIVATE (self);
- esource = e_backend_get_source (E_BACKEND (backend));
- if (! E_IS_SOURCE (esource)) {
- tmp_err = e_data_book_create_error (E_DATA_BOOK_STATUS_OTHER_ERROR,
- _("Could not get ESource for backend"));
- goto exit;
- }
-
kolab_settings = book_backend_kolab_get_collection_settings (self);
network_settings = CAMEL_NETWORK_SETTINGS (kolab_settings);
@@ -285,13 +273,7 @@ book_backend_kolab_open (EBookBackendSync *backend,
g_debug ("%s()[%u] servername = %s", __func__, __LINE__, servername);
g_debug ("%s()[%u] username = %s", __func__, __LINE__, username);
- /* Prepare data from sync strategy property */
- 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);
-
online = e_backend_get_online (E_BACKEND (backend));
- foldername = kolab_util_backend_get_foldername (E_BACKEND (backend));
/* init subsystems (these are no-ops if already called before) */
kolab_util_glib_init ();
@@ -306,7 +288,8 @@ book_backend_kolab_open (EBookBackendSync *backend,
goto exit;
/* Configure settings handler */
- ksettings = kolab_settings_handler_new (kolab_settings);
+ ksettings = kolab_settings_handler_new (kolab_settings,
+ E_BACKEND (backend));
ok = kolab_settings_handler_configure (ksettings,
KOLAB_FOLDER_CONTEXT_CONTACT,
&tmp_err);
@@ -317,12 +300,6 @@ book_backend_kolab_open (EBookBackendSync *backend,
if (! ok)
goto exit;
- kolab_util_backend_prepare_settings (ksettings,
- esource,
- NULL,
- foldername,
- &sync_value);
-
/* init the HTTP utils */
user_home = kolab_settings_handler_get_char_field (ksettings,
KOLAB_SETTINGS_HANDLER_CHAR_FIELD_USER_HOME_DIR,
diff --git a/src/calendar/e-cal-backend-kolab.c b/src/calendar/e-cal-backend-kolab.c
index 0c2498b..19bd4d1 100644
--- a/src/calendar/e-cal-backend-kolab.c
+++ b/src/calendar/e-cal-backend-kolab.c
@@ -270,15 +270,10 @@ cal_backend_kolab_open (ECalBackendSync *backend,
{
ECalBackendKolab *self = NULL;
ECalBackendKolabPrivate *priv = NULL;
- ESource *esource = NULL;
- ESourceKolabFolder *extension = NULL;
CamelKolabIMAPXSettings *kolab_settings = NULL;
CamelNetworkSettings *network_settings = NULL;
KolabSettingsHandler *ksettings = NULL;
- KolabSyncStrategyID sync_value = KOLAB_SYNC_STRATEGY_DEFAULT;
icalcomponent_kind icalkind = ICAL_VEVENT_COMPONENT;
- const gchar *extension_name = NULL;
- const gchar *foldername = NULL;
const gchar *cache_dir = NULL;
gchar *cache_filename = NULL;
gchar *servername = NULL;
@@ -317,13 +312,6 @@ cal_backend_kolab_open (ECalBackendSync *backend,
goto exit;
}
- esource = e_backend_get_source (E_BACKEND (backend));
- if (! E_IS_SOURCE (esource)) {
- tmp_err = e_data_cal_create_error (OtherError,
- _("Could not get ESource for backend"));
- goto exit;
- }
-
kolab_settings = cal_backend_kolab_get_collection_settings (self);
network_settings = CAMEL_NETWORK_SETTINGS (kolab_settings);
@@ -358,16 +346,11 @@ cal_backend_kolab_open (ECalBackendSync *backend,
ok = e_file_cache_clean (E_FILE_CACHE (priv->cal_cache));
g_debug (" + Cal cache cleaning %s.", ok ? "was successful" : "FAILED");
- /* Prepare data from sync strategy property */
- 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);
-
online = e_backend_get_online (E_BACKEND (backend));
- foldername = kolab_util_backend_get_foldername (E_BACKEND (backend));
/* Configure settings handler */
- ksettings = kolab_settings_handler_new (kolab_settings);
+ ksettings = kolab_settings_handler_new (kolab_settings,
+ E_BACKEND (backend));
ok = kolab_settings_handler_configure (ksettings,
KOLAB_FOLDER_CONTEXT_CALENDAR,
&tmp_err);
@@ -378,12 +361,6 @@ cal_backend_kolab_open (ECalBackendSync *backend,
if (! ok)
goto exit;
- kolab_util_backend_prepare_settings (ksettings,
- esource,
- NULL,
- foldername,
- &sync_value);
-
/* init the HTTP utils */
user_home = kolab_settings_handler_get_char_field (ksettings,
KOLAB_SETTINGS_HANDLER_CHAR_FIELD_USER_HOME_DIR,
diff --git a/src/collection/e-kolab-backend.c b/src/collection/e-kolab-backend.c
index c078c82..bca0337 100644
--- a/src/collection/e-kolab-backend.c
+++ b/src/collection/e-kolab-backend.c
@@ -484,7 +484,8 @@ e_kolab_backend_ref_mail_access_sync (EKolabBackend *backend,
settings = kolab_backend_get_settings (backend);
source = e_backend_get_source (E_BACKEND (backend));
- settings_handler = kolab_settings_handler_new (settings);
+ settings_handler = kolab_settings_handler_new (settings,
+ E_BACKEND (backend));
/* XXX Christian recommends KOLAB_FOLDER_CONTEXT_EMAIL here
* although the operations we need are supposed to work
@@ -501,16 +502,6 @@ e_kolab_backend_ref_mail_access_sync (EKolabBackend *backend,
return NULL;
}
- /* This must be done after configure() and bringup(). */
- success = kolab_settings_handler_set_char_field (
- settings_handler,
- KOLAB_SETTINGS_HANDLER_CHAR_FIELD_ESOURCE_UID,
- e_source_dup_uid (source), error);
- if (!success) {
- g_object_unref (settings_handler);
- return NULL;
- }
-
koma = g_object_new (KOLAB_TYPE_MAIL_ACCESS, NULL);
success = kolab_mail_access_configure (
diff --git a/src/libekolab/kolab-mail-synchronizer.c b/src/libekolab/kolab-mail-synchronizer.c
index fdcfb36..1c70179 100644
--- a/src/libekolab/kolab-mail-synchronizer.c
+++ b/src/libekolab/kolab-mail-synchronizer.c
@@ -1849,7 +1849,6 @@ kolab_mail_synchronizer_transaction_prepare (KolabMailSynchronizer *self,
KolabFolderContextID folder_context = KOLAB_FOLDER_CONTEXT_INVAL;
KolabObjectCacheStatus status = KOLAB_OBJECT_CACHE_STATUS_INVAL;
KolabObjectCacheStatus new_status = KOLAB_OBJECT_CACHE_STATUS_INVAL;
- gconstpointer sync_id_ptr = NULL;
GHashTable *changed_uids_tbl = NULL;
GList *changed_uids_lst = NULL;
gchar *uid = NULL;
@@ -1938,10 +1937,9 @@ kolab_mail_synchronizer_transaction_prepare (KolabMailSynchronizer *self,
goto cleanup;
}
- sync_id_ptr = kolab_settings_handler_get_value (priv->ksettings,
- KOLAB_SETTINGS_HANDLER_TBL_SYNCSTRATEGY,
- foldername,
- &tmp_err);
+ sync_id = kolab_settings_handler_get_uint_field (priv->ksettings,
+ KOLAB_SETTINGS_HANDLER_UINT_FIELD_FOLDER_SYNCSTRATEGY,
+ &tmp_err);
if (tmp_err != NULL) {
sync_id = KOLAB_SYNC_STRATEGY_DEFAULT;
g_warning ("%s: %s", __func__, tmp_err->message);
@@ -1949,8 +1947,6 @@ kolab_mail_synchronizer_transaction_prepare (KolabMailSynchronizer *self,
__func__, sync_id);
g_error_free (tmp_err);
tmp_err = NULL;
- } else {
- sync_id = GPOINTER_TO_UINT (sync_id_ptr);
}
g_debug ("%s: UID (%s) Folder (%s) sync strategy id (%u)",
__func__, uid, foldername, sync_id);
diff --git a/src/libekolab/kolab-settings-handler.c b/src/libekolab/kolab-settings-handler.c
index d0a16b9..54933b4 100644
--- a/src/libekolab/kolab-settings-handler.c
+++ b/src/libekolab/kolab-settings-handler.c
@@ -35,6 +35,7 @@
#include <libekolabutil/kolab-util-camel.h>
#include <libekolabutil/kolab-util-glib.h>
+#include "e-source-kolab-folder.h"
#include "kolab-util-backend.h"
#include "kolab-settings-handler.h"
@@ -43,6 +44,7 @@
struct _KolabSettingsHandlerPrivate
{
CamelKolabIMAPXSettings *camel_settings;
+ EBackend *e_backend;
gboolean is_configured;
gboolean is_up;
@@ -51,13 +53,12 @@ struct _KolabSettingsHandlerPrivate
guint sdata_uint[KOLAB_SETTINGS_HANDLER_UINT_LAST_FIELD];
gint sdata_int[KOLAB_SETTINGS_HANDLER_INT_LAST_FIELD];
gboolean sdata_bool[KOLAB_SETTINGS_HANDLER_BOOL_LAST_FIELD];
-
- GHashTable *sdata_tbl;
};
enum {
PROP_0,
- PROP_CAMEL_SETTINGS
+ PROP_CAMEL_SETTINGS,
+ PROP_E_BACKEND
};
#define KOLAB_SETTINGS_HANDLER_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), KOLAB_TYPE_SETTINGS_HANDLER, KolabSettingsHandlerPrivate))
@@ -81,7 +82,11 @@ static gboolean settings_handler_char_get_func_camel_config_dir (KolabSettingsHa
static gboolean settings_handler_char_set_func_camel_config_dir (KolabSettingsHandler*, gchar*, GError**);
static gboolean settings_handler_char_get_func_user_home_dir (KolabSettingsHandler*, GError**);
static gboolean settings_handler_char_set_func_user_home_dir (KolabSettingsHandler*, gchar*, GError**);
+static gboolean settings_handler_char_get_func_esource_uid (KolabSettingsHandler*, GError**);
+static gboolean settings_handler_char_set_func_esource_uid (KolabSettingsHandler*, gchar*, GError**);
static gboolean settings_handler_uint_set_func_folder_context (KolabSettingsHandler*, guint value, GError**);
+static gboolean settings_handler_uint_get_func_folder_syncstrategy (KolabSettingsHandler*, GError**);
+static gboolean settings_handler_uint_set_func_folder_syncstrategy (KolabSettingsHandler*, guint value, GError**);
static KolabSettingsHandlerGetFunc _kolab_settings_handler_char_get_funcs[] = {
settings_handler_char_get_func_camel_data_dir, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_CAMEL_DATA_DIR */
@@ -89,7 +94,7 @@ static KolabSettingsHandlerGetFunc _kolab_settings_handler_char_get_funcs[] = {
settings_handler_char_get_func_camel_config_dir, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_CAMEL_CONFIG_DIR */
NULL, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_CAMEL_ACCOUNT_DIR */
settings_handler_char_get_func_user_home_dir, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_USER_HOME_DIR */
- NULL, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_ESOURCE_UID */
+ settings_handler_char_get_func_esource_uid, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_ESOURCE_UID */
NULL, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_KOLAB_USER_PASSWORD */
};
@@ -99,16 +104,18 @@ static KolabSettingsHandlerCharSetFunc _kolab_settings_handler_char_set_funcs[]
settings_handler_char_set_func_camel_config_dir, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_CAMEL_CONFIG_DIR */
NULL, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_CAMEL_ACCOUNT_DIR */
settings_handler_char_set_func_user_home_dir, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_USER_HOME_DIR */
- NULL, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_ESOURCE_UID */
+ settings_handler_char_set_func_esource_uid, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_ESOURCE_UID */
NULL, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_KOLAB_USER_PASSWORD */
};
static KolabSettingsHandlerGetFunc _kolab_settings_handler_uint_get_funcs[] = {
- NULL /* KOLAB_SETTINGS_HANDLER_UINT_FIELD_FOLDER_CONTEXT */
+ NULL, /* KOLAB_SETTINGS_HANDLER_UINT_FIELD_FOLDER_CONTEXT */
+ settings_handler_uint_get_func_folder_syncstrategy /* KOLAB_SETTINGS_HANDLER_UINT_FIELD_FOLDER_SYNCSTRATEGY */
};
static KolabSettingsHandlerUintSetFunc _kolab_settings_handler_uint_set_funcs[] = {
- settings_handler_uint_set_func_folder_context /* KOLAB_SETTINGS_HANDLER_UINT_FIELD_FOLDER_CONTEXT */
+ settings_handler_uint_set_func_folder_context, /* KOLAB_SETTINGS_HANDLER_UINT_FIELD_FOLDER_CONTEXT */
+ settings_handler_uint_set_func_folder_syncstrategy /* KOLAB_SETTINGS_HANDLER_UINT_FIELD_FOLDER_SYNCSTRATEGY */
};
/*----------------------------------------------------------------------------*/
@@ -281,6 +288,53 @@ settings_handler_char_set_func_user_home_dir (KolabSettingsHandler *self, gchar
}
static gboolean
+settings_handler_char_get_func_esource_uid (KolabSettingsHandler *self,
+ GError **err)
+{
+ KolabSettingsHandlerPrivate *priv = NULL;
+ ESource *esource = NULL;
+ gchar *uid = NULL;
+
+ g_return_val_if_fail (KOLAB_IS_SETTINGS_HANDLER (self), FALSE);
+ g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+ priv = KOLAB_SETTINGS_HANDLER_PRIVATE (self);
+ g_return_val_if_fail (E_IS_BACKEND (priv->e_backend), FALSE);
+
+ esource = e_backend_get_source (priv->e_backend);
+ if (! E_IS_SOURCE (esource)) {
+ g_set_error (err,
+ KOLAB_BACKEND_ERROR,
+ KOLAB_BACKEND_ERROR_GENERIC,
+ _("Could not get ESource for backend"));
+ return FALSE;
+ }
+
+ uid = g_strdup (e_source_get_uid (esource));
+ if (priv->sdata_char[KOLAB_SETTINGS_HANDLER_CHAR_FIELD_ESOURCE_UID] != NULL)
+ g_free (priv->sdata_char[KOLAB_SETTINGS_HANDLER_CHAR_FIELD_ESOURCE_UID]);
+ priv->sdata_char[KOLAB_SETTINGS_HANDLER_CHAR_FIELD_ESOURCE_UID] = uid;
+
+ return TRUE;
+}
+
+static gboolean
+settings_handler_char_set_func_esource_uid (KolabSettingsHandler *self,
+ gchar *value,
+ GError **err)
+{
+ (void)self;
+ (void)value;
+ g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+ g_set_error (err,
+ KOLAB_BACKEND_ERROR,
+ KOLAB_BACKEND_ERROR_GENERIC,
+ _("Cannot set ESource UID, it is a read-only resource"));
+ return FALSE;
+}
+
+static gboolean
settings_handler_char_get_func_camel_config_dir (KolabSettingsHandler *self, GError **err)
{
KolabSettingsHandlerPrivate *priv = KOLAB_SETTINGS_HANDLER_PRIVATE (self);
@@ -342,6 +396,61 @@ settings_handler_uint_set_func_folder_context (KolabSettingsHandler *self, guint
return FALSE;
}
+static gboolean
+settings_handler_uint_get_func_folder_syncstrategy (KolabSettingsHandler *self,
+ GError **err)
+{
+ KolabSettingsHandlerPrivate *priv = NULL;
+ ESource *esource = NULL;
+ ESourceKolabFolder *extension = NULL;
+ KolabSyncStrategyID strategy = KOLAB_SYNC_STRATEGY_DEFAULT;
+
+ g_return_val_if_fail (KOLAB_IS_SETTINGS_HANDLER (self), FALSE);
+ g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+ priv = KOLAB_SETTINGS_HANDLER_PRIVATE (self);
+ g_return_val_if_fail (E_IS_BACKEND (priv->e_backend), FALSE);
+
+ esource = e_backend_get_source (priv->e_backend);
+ if (! E_IS_SOURCE (esource)) {
+ g_set_error (err,
+ KOLAB_BACKEND_ERROR,
+ KOLAB_BACKEND_ERROR_GENERIC,
+ _("Could not get ESource for backend"));
+ return FALSE;
+ }
+
+ if (! e_source_has_extension (esource, E_SOURCE_EXTENSION_KOLAB_FOLDER)) {
+ g_set_error (err,
+ KOLAB_BACKEND_ERROR,
+ KOLAB_BACKEND_ERROR_GENERIC,
+ _("ESource for backend has no 'Kolab Folder' extension"));
+ return FALSE;
+ }
+
+ extension = e_source_get_extension (esource, E_SOURCE_EXTENSION_KOLAB_FOLDER);
+ strategy = e_source_kolab_folder_get_sync_strategy (extension);
+ priv->sdata_uint[KOLAB_SETTINGS_HANDLER_UINT_FIELD_FOLDER_SYNCSTRATEGY] = strategy;
+
+ return TRUE;
+}
+
+static gboolean
+settings_handler_uint_set_func_folder_syncstrategy (KolabSettingsHandler *self,
+ guint value,
+ GError **err)
+{
+ (void)self;
+ (void)value;
+ g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+ g_set_error (err,
+ KOLAB_BACKEND_ERROR,
+ KOLAB_BACKEND_ERROR_GENERIC,
+ _("Cannot set Kolab Folder Sync Strategy, it is a read-only resource"));
+ return FALSE;
+}
+
/*----------------------------------------------------------------------------*/
static void
@@ -365,6 +474,7 @@ kolab_settings_handler_init (KolabSettingsHandler *self)
/* documenting initial settings (dumb fallback values) */
priv->sdata_uint[KOLAB_SETTINGS_HANDLER_UINT_FIELD_FOLDER_CONTEXT] = KOLAB_FOLDER_CONTEXT_INVAL;
+ priv->sdata_uint[KOLAB_SETTINGS_HANDLER_UINT_FIELD_FOLDER_SYNCSTRATEGY] = KOLAB_SYNC_STRATEGY_DEFAULT;
priv->sdata_int[KOLAB_SETTINGS_HANDLER_INT_FIELD_KOLAB_SERVER_IMAP_PORT] = KOLAB_SERVER_IMAP_PORT;
priv->sdata_int[KOLAB_SETTINGS_HANDLER_INT_FIELD_KOLAB_SERVER_IMAPS_PORT] = KOLAB_SERVER_IMAPS_PORT;
priv->sdata_int[KOLAB_SETTINGS_HANDLER_INT_FIELD_KOLAB_SERVER_HTTP_PORT] = KOLAB_SERVER_HTTP_PORT;
@@ -372,8 +482,6 @@ kolab_settings_handler_init (KolabSettingsHandler *self)
priv->sdata_int[KOLAB_SETTINGS_HANDLER_INT_FIELD_KOLAB_SERVER_LDAP_PORT] = KOLAB_SERVER_LDAP_PORT;
priv->sdata_int[KOLAB_SETTINGS_HANDLER_INT_FIELD_KOLAB_SERVER_LDAPS_PORT] = KOLAB_SERVER_LDAPS_PORT;
- priv->sdata_tbl = NULL;
-
priv->is_configured = FALSE;
priv->is_up = FALSE;
}
@@ -389,6 +497,16 @@ kolab_settings_handler_set_camel_settings (KolabSettingsHandler *ksettings,
}
static void
+kolab_settings_handler_set_e_backend (KolabSettingsHandler *ksettings,
+ EBackend *e_backend)
+{
+ g_return_if_fail (E_IS_BACKEND (e_backend));
+ g_return_if_fail (ksettings->priv->e_backend == NULL);
+
+ ksettings->priv->e_backend = g_object_ref (e_backend);
+}
+
+static void
kolab_settings_handler_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -400,6 +518,11 @@ kolab_settings_handler_set_property (GObject *object,
KOLAB_SETTINGS_HANDLER (object),
g_value_get_object (value));
return;
+ case PROP_E_BACKEND:
+ kolab_settings_handler_set_e_backend (
+ KOLAB_SETTINGS_HANDLER (object),
+ g_value_get_object (value));
+ return;
default:
break;
}
@@ -420,6 +543,12 @@ kolab_settings_handler_get_property (GObject *object,
kolab_settings_handler_get_camel_settings (
KOLAB_SETTINGS_HANDLER (object)));
return;
+ case PROP_E_BACKEND:
+ g_value_set_object (
+ value,
+ kolab_settings_handler_get_e_backend (
+ KOLAB_SETTINGS_HANDLER (object)));
+ return;
default:
break;
}
@@ -439,6 +568,11 @@ kolab_settings_handler_dispose (GObject *object)
priv->camel_settings = NULL;
}
+ if (priv->e_backend != NULL) {
+ g_object_unref (priv->e_backend);
+ priv->e_backend = NULL;
+ }
+
G_OBJECT_CLASS (kolab_settings_handler_parent_class)->dispose (object);
}
@@ -457,9 +591,6 @@ kolab_settings_handler_finalize (GObject *object)
g_free (priv->sdata_char[ii]);
}
- if (priv->sdata_tbl != NULL)
- g_hash_table_destroy (priv->sdata_tbl);
-
G_OBJECT_CLASS (kolab_settings_handler_parent_class)->finalize (object);
}
@@ -476,26 +607,44 @@ kolab_settings_handler_class_init (KolabSettingsHandlerClass *klass)
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));
+ 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));
+ g_object_class_install_property (object_class,
+ PROP_E_BACKEND,
+ g_param_spec_object ("e-backend",
+ "EBackend",
+ "An EBackend instance",
+ E_TYPE_BACKEND,
+ G_PARAM_READWRITE|
+ G_PARAM_CONSTRUCT_ONLY));
}
KolabSettingsHandler *
-kolab_settings_handler_new (CamelKolabIMAPXSettings *camel_settings)
+kolab_settings_handler_new (CamelKolabIMAPXSettings *camel_settings,
+ EBackend *e_backend)
{
- g_return_val_if_fail (CAMEL_IS_KOLAB_IMAPX_SETTINGS (camel_settings), NULL);
+ KolabSettingsHandler *ksettings = NULL;
- return g_object_new (
- KOLAB_TYPE_SETTINGS_HANDLER,
- "camel-settings", camel_settings, NULL);
+ g_return_val_if_fail (CAMEL_IS_KOLAB_IMAPX_SETTINGS (camel_settings), NULL);
+ /* backend may be NULL */
+
+ if (e_backend != NULL)
+ ksettings = g_object_new (KOLAB_TYPE_SETTINGS_HANDLER,
+ "camel-settings", camel_settings,
+ "e-backend", e_backend,
+ NULL);
+ else
+ ksettings = g_object_new (KOLAB_TYPE_SETTINGS_HANDLER,
+ "camel-settings", camel_settings,
+ NULL);
+
+ return ksettings;
}
/*----------------------------------------------------------------------------*/
@@ -615,6 +764,14 @@ kolab_settings_handler_get_camel_settings (KolabSettingsHandler *self)
return self->priv->camel_settings;
}
+EBackend *
+kolab_settings_handler_get_e_backend (KolabSettingsHandler *self)
+{
+ g_assert (KOLAB_IS_SETTINGS_HANDLER (self));
+
+ return self->priv->e_backend;
+}
+
/**
* kolab_settings_handler_set_char_field:
* @self: a #KolabSettingsHandler instance
@@ -933,162 +1090,3 @@ kolab_settings_handler_get_bool_field (KolabSettingsHandler *self,
}
/*----------------------------------------------------------------------------*/
-
-static GHashTable*
-kolab_settings_handler_create_table (KolabSettingsHandlerTblID tbl_id)
-{
- /* g_assert (tbl_id < KOLAB_SETTINGS_HANDLER_TBL_LAST_ID); */
-
- switch (tbl_id) {
- case KOLAB_SETTINGS_HANDLER_TBL_SYNCSTRATEGY:
- /* GINT_TO_POINTER() values (don't free()) */
- return g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- NULL);
- case KOLAB_SETTINGS_HANDLER_TBL_FOLDERCREATE:
- /* values are pointers to keys, don't free() */
- return g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- NULL);
- default:
- g_assert_not_reached ();
- }
-}
-
-/**
- * kolab_settings_handler_set_value:
- * @self: a #KolabSettingsHandler instance
- * @tbl_id: ID for the internal table to store the @value in
- * @key: the key string to reference the value with
- * @value: a pointer to the data object to store
- * @err: a #GError object (or NULL)
- *
- * Store a @value under the given @key in an internal table identified
- * by @tbl_id. Be sure that the data pointed to does not get erased as long
- * as it is accessible via @tbl_id:@key.
- *
- * The data type @value points to is determined by the @tbl_id. Each table
- * has a certain value data type associated with it (see #KolabSettingsHandlerTblID),
- * so be sure to supply only pointers to the data type this table is meant
- * for (orelse, table destruction or replacing of existing values will fail
- * miserably).
- *
- * Returns: TRUE on success,
- * FALSE otherwise (with @err set)
- */
-gboolean
-kolab_settings_handler_set_value (KolabSettingsHandler *self,
- KolabSettingsHandlerTblID tbl_id,
- const gchar *key,
- gpointer value,
- GError **err)
-{
- KolabSettingsHandlerPrivate *priv = NULL;
- GHashTable *tbl = NULL;
-
- g_assert (KOLAB_IS_SETTINGS_HANDLER (self));
- /* g_assert (tbl_id < KOLAB_SETTINGS_HANDLER_TBL_LAST_ID); */
- g_assert (key != NULL);
- g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
-
- priv = KOLAB_SETTINGS_HANDLER_PRIVATE (self);
-
- g_assert (priv->is_configured == TRUE);
- g_assert (priv->is_up == TRUE);
-
- if (priv->sdata_tbl == NULL)
- priv->sdata_tbl = g_hash_table_new_full (g_direct_hash,
- g_direct_equal,
- NULL,
- kolab_util_glib_ghashtable_gdestroy);
- tbl = g_hash_table_lookup (priv->sdata_tbl,
- GINT_TO_POINTER (tbl_id));
- if (tbl == NULL) {
- tbl = kolab_settings_handler_create_table (tbl_id);
- g_hash_table_insert (priv->sdata_tbl,
- GINT_TO_POINTER (tbl_id),
- tbl);
- }
-
- g_hash_table_replace (tbl, g_strdup (key), value);
- return TRUE;
-}
-
-/**
- * kolab_settings_handler_get_value:
- * @self: a #KolabSettingsHandler instance
- * @tbl_id: ID for the internal table to store the @value in
- * @key: the key string to reference the value with
- * @err: a #GError object (or NULL)
- *
- * Retrieve a @value under the given @key from an internal table identified
- * by @tbl_id.
- *
- * The data type @value points to is determined by the @tbl_id. Each table
- * has a certain value data type associated with it (see #KolabSettingsHandlerTblID).
- *
- * It is an error to try to retrieve a value if nothing has ever been stored
- * in any table or if a @tbl_id is given for a table into which nothing has
- * been stored before, or if there is no value stored for @key in @tbl_id
- * (@err has an error value set to #KOLAB_BACKEND_ERROR_NOTFOUND in these cases).
- *
- * Returns: a pointer to the data referenced by @tbl_id:@key on success,
- * NULL with @err set on failure or if not found
- */
-gconstpointer
-kolab_settings_handler_get_value (KolabSettingsHandler *self,
- KolabSettingsHandlerTblID tbl_id,
- const gchar *key,
- GError **err)
-{
- KolabSettingsHandlerPrivate *priv = NULL;
- GHashTable *tbl = NULL;
- gpointer value = NULL;
- gpointer orig_key = NULL;
- gboolean found = FALSE;
-
- g_assert (KOLAB_IS_SETTINGS_HANDLER (self));
- /* g_assert (tbl_id < KOLAB_SETTINGS_HANDLER_TBL_LAST_ID); */
- g_assert (key != NULL);
- g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
-
- priv = KOLAB_SETTINGS_HANDLER_PRIVATE (self);
-
- g_assert (priv->is_configured == TRUE);
- g_assert (priv->is_up == TRUE);
-
- if (priv->sdata_tbl == NULL) {
- g_set_error (err,
- KOLAB_BACKEND_ERROR,
- KOLAB_BACKEND_ERROR_NOTFOUND,
- _("Internal inconsistency detected: No settings table exists, no value has previously been set"));
- return NULL;
- }
-
- tbl = g_hash_table_lookup (priv->sdata_tbl,
- GINT_TO_POINTER (tbl_id));
- if (tbl == NULL) {
- g_set_error (err,
- KOLAB_BACKEND_ERROR,
- KOLAB_BACKEND_ERROR_NOTFOUND,
- _("Internal inconsistency detected: No settings table with ID '%i' exists"),
- tbl_id);
- return NULL;
- }
-
- found = g_hash_table_lookup_extended (tbl, key, &orig_key, &value);
- if (! found) {
- g_set_error (err,
- KOLAB_BACKEND_ERROR,
- KOLAB_BACKEND_ERROR_NOTFOUND,
- _("Internal inconsistency detected: No settings value for table ID '%i', key ID '%s', exists"),
- tbl_id, key);
- return NULL;
- }
-
- return value; /* may be NULL */
-}
-
-/*----------------------------------------------------------------------------*/
diff --git a/src/libekolab/kolab-settings-handler.h b/src/libekolab/kolab-settings-handler.h
index daab89d..7c1c81c 100644
--- a/src/libekolab/kolab-settings-handler.h
+++ b/src/libekolab/kolab-settings-handler.h
@@ -35,40 +35,11 @@
*
* This class is handles all Kolab (account) settings for the
* Kolab backends. This means (mostly) reading the settings information created by
- * the Evolution frontend and encapsulating operations concerning #EAccount and
+ * the Evolution frontend and encapsulating operations concerning
* #ESource classes. One instance of this class will live in each backend
* process and is passed to #KolabMailAccess (and by #KolabMailAccess, on to
* all of it's subordinate objects).
*
- * Some of the MAPI ExchangeMAPIAccountListener functionality will be
- * replicated, which is
- * <itemizedlist>
- * <listitem>checking for new Kolab2 account types showing up (EAccount)</listitem>
- * <listitem>creating an associated ESource object and add it to the
- * backend's ESourceGroup, so it can be advertised to the frontend</listitem>
- * </itemizedlist>
- *
- * In MAPI, #ExchangeMAPIAccountListener is part of the MAPI #EPlugin. According
- * to mbarnes, the account listener's functionality should be working in
- * backend context as well, so no need to place this into an #EPlugin (what's
- * more, again according to mbarnes, #EPlugin is going to be replaced entirely
- * by another framework, presumably #GTypeModule, so no point in creating an
- * elaborated #EPlugin now, anyway).
- *
- * This account listener could peek (new) #EAccount for (new) Kolab2 ones
- * and create #ESourceGroup elements accordingly. Since a backend process needs
- * to be started only when at least one Kolab2 #EAccount is configured, this
- * functionality might best be placed into the book/cal factory processes.
- *
- * Account management for future Evo versions is under reconstruction in present
- * dev versions (2010-12-21). GConf is being replaced by GSettings, and a new
- * notification framework is being brought up (see evolution-hackers list,
- * "Rethinking account management" threads by mbarnes et al, 2010-10/2010-11),
- * especially http://mail.gnome.org/archives/evolution-hackers/2010-December/msg00030.html
- *
- * This class encapsulates as much of the API changes between 2.3x and 3.x
- * as possible so the GConf->GSettings transition changes can be confined to
- * this class.
*/
/*----------------------------------------------------------------------------*/
@@ -91,6 +62,8 @@
#include <glib.h>
#include <glib-object.h>
+#include <libebackend/libebackend.h>
+
#include <libekolabutil/kolab-util-folder.h>
#include <libekolab/camel-kolab-imapx-settings.h>
@@ -133,6 +106,7 @@ typedef enum {
typedef enum {
KOLAB_SETTINGS_HANDLER_UINT_FIELD_FOLDER_CONTEXT = 0,
+ KOLAB_SETTINGS_HANDLER_UINT_FIELD_FOLDER_SYNCSTRATEGY,
KOLAB_SETTINGS_HANDLER_UINT_LAST_FIELD
} KolabSettingsHandlerUintFieldID;
@@ -151,21 +125,17 @@ typedef enum {
KOLAB_SETTINGS_HANDLER_BOOL_LAST_FIELD
} KolabSettingsHandlerBoolFieldID;
-typedef enum {
- KOLAB_SETTINGS_HANDLER_TBL_SYNCSTRATEGY = 0, /* sourcename:KolabSyncStrategyID */
- KOLAB_SETTINGS_HANDLER_TBL_FOLDERCREATE, /* sourcename:bool (whether to create folder if not existing) */
- KOLAB_SETTINGS_HANDLER_LAST_TBL
-} KolabSettingsHandlerTblID;
-
GType kolab_settings_handler_get_type (void) G_GNUC_CONST;
-KolabSettingsHandler * kolab_settings_handler_new (CamelKolabIMAPXSettings *camel_settings);
+KolabSettingsHandler * kolab_settings_handler_new (CamelKolabIMAPXSettings *camel_settings,
+ EBackend *e_backend);
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);
+EBackend * kolab_settings_handler_get_e_backend (KolabSettingsHandler *self);
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);
@@ -179,9 +149,6 @@ gint kolab_settings_handler_get_int_field (KolabSettingsHandler *self, KolabSett
gboolean kolab_settings_handler_set_bool_field (KolabSettingsHandler *self, KolabSettingsHandlerBoolFieldID field_id, gboolean value, GError **err);
gboolean kolab_settings_handler_get_bool_field (KolabSettingsHandler *self, KolabSettingsHandlerBoolFieldID field_id, GError **err);
-gboolean kolab_settings_handler_set_value (KolabSettingsHandler *self, KolabSettingsHandlerTblID tbl_id, const gchar *key, gpointer value, GError **err);
-gconstpointer kolab_settings_handler_get_value (KolabSettingsHandler *self, KolabSettingsHandlerTblID tbl_id, const gchar *key, GError **err);
-
G_END_DECLS
/*----------------------------------------------------------------------------*/
diff --git a/src/tests/integration/libekolab/test-kolab-mail-access.c b/src/tests/integration/libekolab/test-kolab-mail-access.c
index def2ac3..be0ea05 100644
--- a/src/tests/integration/libekolab/test-kolab-mail-access.c
+++ b/src/tests/integration/libekolab/test-kolab-mail-access.c
@@ -241,20 +241,8 @@ kolab_itest_koma_ksettings_envset (KolabSettingsHandler *ksettings,
/* We cannot sanely set a sync strategy for each folder in this testcase
* since we do not want to depend on the server folders. If no strategy
- * is set, KolabMailSynchronizer will assume the default. In order to silence
- * KolabSettingsHandler's complaints about non-existing tables when requesting
- * the sync strategy, we explicitly set the default for the INBOX.
+ * is set, KolabMailSynchronizer will assume the default.
*/
- ok = kolab_settings_handler_set_value (ksettings,
- KOLAB_SETTINGS_HANDLER_TBL_SYNCSTRATEGY,
- "INBOX",
- KOLAB_SYNC_STRATEGY_DEFAULT,
- &tmp_err);
-
- if (! ok) {
- g_propagate_error (err, tmp_err);
- return FALSE;
- }
return TRUE;
}
@@ -463,7 +451,7 @@ test_kolab_mail_access (KolabFolderContextID context)
/* 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);
+ ksettings = kolab_settings_handler_new (camel_settings, backend);
g_object_unref (camel_settings);
/* configure settings */
@@ -512,7 +500,7 @@ test_kolab_mail_access (KolabFolderContextID context)
&tmp_err);
if (! ok)
goto test_part_cleanup;
-
+
/* test folder creation and deletion */
ok = test_kolab_mail_access_create_delete_source (kmailaccess,
&tmp_err);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]