[evolution-kolab] ECalBackendKolab: assign each cal backend its own KolabMailAccess instance
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab] ECalBackendKolab: assign each cal backend its own KolabMailAccess instance
- Date: Fri, 7 Sep 2012 10:07:53 +0000 (UTC)
commit f19845d84c793fdd3bb6151721d9b80d146bce68
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Fri Sep 7 11:48:10 2012 +0200
ECalBackendKolab: assign each cal backend its own KolabMailAccess instance
* each backend has its own cache directory,
so we need to write KolabMailAccess cache
data into these (i.e., configure KolabMailAccess
accordingly)
* once each backend instance is given its own
E-D-S process, we cannot share KolabMailAccess
instances among backend instances any longer
anyway
src/calendar/e-cal-backend-kolab.c | 129 +++++++++++-------------------------
1 files changed, 39 insertions(+), 90 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-kolab.c b/src/calendar/e-cal-backend-kolab.c
index f693a93..0efd719 100644
--- a/src/calendar/e-cal-backend-kolab.c
+++ b/src/calendar/e-cal-backend-kolab.c
@@ -59,10 +59,7 @@
(g_type_class_unref (g_type_class_ref (type)))
/*----------------------------------------------------------------------------*/
-/* table of KolabMailAccess objects */
-static GHashTable *koma_objects = NULL;
-static GMutex koma_objects_lock;
static GMutex active_cal_views_lock;
/*----------------------------------------------------------------------------*/
@@ -272,7 +269,6 @@ cal_backend_kolab_open (ECalBackendSync *backend,
CamelKolabIMAPXSettings *kolab_settings = NULL;
CamelNetworkSettings *network_settings = NULL;
KolabSettingsHandler *ksettings = NULL;
- KolabMailAccess *tmp_koma = NULL;
KolabSyncStrategyID sync_value = KOLAB_SYNC_STRATEGY_DEFAULT;
icalcomponent_kind icalkind = ICAL_VEVENT_COMPONENT;
const gchar *extension_name = NULL;
@@ -281,8 +277,6 @@ cal_backend_kolab_open (ECalBackendSync *backend,
gchar *cache_filename = NULL;
gchar *servername = NULL;
gchar *username = NULL;
- gchar *user_at_server = NULL;
- gchar *tmp_key = NULL;
gboolean online = FALSE;
gboolean ok = FALSE;
GError *tmp_err = NULL;
@@ -293,8 +287,6 @@ cal_backend_kolab_open (ECalBackendSync *backend,
/* cancellable may be NULL */
(void)only_if_exists; /* FIXME */
- g_mutex_lock (&koma_objects_lock);
-
self = E_CAL_BACKEND_KOLAB (backend);
priv = E_CAL_BACKEND_KOLAB_PRIVATE (self);
@@ -333,6 +325,12 @@ cal_backend_kolab_open (ECalBackendSync *backend,
g_debug ("%s()[%u] servername = %s", __func__, __LINE__, servername);
g_debug ("%s()[%u] username = %s", __func__, __LINE__, username);
+ /* TODO this is sort of hackish, we cannot be sure that
+ * 'user server' is truly the Kolab email address
+ * of the Kolab user
+ */
+ priv->user_email = g_strdup_printf ("%s %s", username, servername);
+
/* Initialize backend cache */
if (priv->cal_cache != NULL) {
g_object_unref (priv->cal_cache);
@@ -350,52 +348,10 @@ cal_backend_kolab_open (ECalBackendSync *backend,
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));
+ online = e_backend_get_online (E_BACKEND (backend));
foldername = kolab_util_backend_get_foldername (E_BACKEND (backend));
- /* Check whether we have a KolabMailAccess (KoMA) instance already */
- user_at_server = g_strdup_printf ("%s %s",
- username, servername);
- ok = g_hash_table_lookup_extended (koma_objects,
- user_at_server,
- (gpointer *) &tmp_key,
- (gpointer *) &tmp_koma);
-
- if (ok) {
- /* There already is a KoMA instance for user_at_server.
- * Use it and return
- */
- g_object_ref (tmp_koma);
- priv->cal_koma = tmp_koma;
- ksettings = kolab_mail_access_get_settings_handler (priv->cal_koma);
- kolab_util_backend_prepare_settings (ksettings,
- NULL,
- NULL,
- foldername,
- &sync_value);
-
- (void) kolab_util_backend_deploy_mode_by_backend (priv->cal_koma,
- online,
- cancellable,
- &tmp_err);
- goto exit;
- }
-
- /* Nope, we need to setup a new KoMA instance and a settings handler */
-
- /* init subsystems (these are no-ops if already called before) */
- kolab_util_glib_init ();
- kolab_util_http_init ();
- /* libcamel
- * Curl init may configure the underlying SSL lib,
- * but as far as SSL goes, we want Camel to rule here
- * TODO check whether Camel session needs to be initialized before or after libcurl.
- */
- ok = kolab_util_camel_init (&tmp_err);
- if (! ok)
- goto exit;
-
/* Configure settings handler */
ksettings = kolab_settings_handler_new (kolab_settings);
ok = kolab_settings_handler_configure (ksettings,
@@ -416,12 +372,6 @@ cal_backend_kolab_open (ECalBackendSync *backend,
/* create new KolabMailAccess instance */
priv->cal_koma = KOLAB_MAIL_ACCESS (g_object_new (KOLAB_TYPE_MAIL_ACCESS, NULL));
- g_object_add_toggle_ref (G_OBJECT (priv->cal_koma),
- kolab_util_backend_koma_table_cleanup_cb,
- koma_objects);
- g_hash_table_insert (koma_objects,
- user_at_server,
- priv->cal_koma);
/* configure and bring up KolabMailAccess instance */
ok = kolab_mail_access_configure (priv->cal_koma,
@@ -437,12 +387,6 @@ cal_backend_kolab_open (ECalBackendSync *backend,
if (! ok)
goto exit;
- /* TODO this is sort of hackish, we cannot be sure that
- * 'user server' is truly the Kolab email address
- * of the Kolab user
- */
- priv->user_email = g_strdup (user_at_server);
-
(void) kolab_util_backend_deploy_mode_by_backend (priv->cal_koma,
online,
cancellable,
@@ -451,15 +395,10 @@ cal_backend_kolab_open (ECalBackendSync *backend,
if (ksettings != NULL)
g_object_unref (ksettings);
-
- g_mutex_unlock (&koma_objects_lock);
-
if (servername != NULL)
g_free (servername);
if (username != NULL)
g_free (username);
- if (user_at_server != NULL)
- g_free (user_at_server);
/* do we have an error set? if so, propagate and return */
if (tmp_err != NULL) {
@@ -483,33 +422,39 @@ cal_backend_kolab_remove (ECalBackendSync *backend,
GError **error)
{
ECalBackendKolab *self = NULL;
- /* ECalBackendKolabPrivate *priv = NULL; */
+ ECalBackendKolabPrivate *priv = NULL;
+ GError *tmp_err = NULL;
+ gboolean ok = FALSE;
g_return_if_fail (error == NULL || *error == NULL);
e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_KOLAB (backend), InvalidArg);
+ /* cancellable may be NULL */
e_return_data_cal_error_if_fail (E_IS_DATA_CAL (cal), InvalidArg);
- (void)cancellable; /* FIXME */ /* cancellable may be NULL */
self = E_CAL_BACKEND_KOLAB (backend);
- /* priv = E_CAL_BACKEND_KOLAB_PRIVATE (self); */
-
- g_warning ("%s: FIXME implement me", __func__);
+ priv = E_CAL_BACKEND_KOLAB_PRIVATE (self);
-#if 0 /* FIXME old */
if (priv->cal_koma != NULL) {
- g_object_unref (priv->cal_koma);
- priv->cal_koma = NULL;
+ ok = kolab_mail_access_shutdown (priv->cal_koma,
+ cancellable,
+ &tmp_err);
+ if (ok) {
+ g_object_unref (priv->cal_koma);
+ priv->cal_koma = NULL;
+ } else {
+ g_propagate_error (error, tmp_err);
+ }
}
- /* Remove backend cache */
if (priv->cal_cache != NULL) {
(void) e_file_cache_remove (E_FILE_CACHE (priv->cal_cache));
g_object_unref (priv->cal_cache);
priv->cal_cache = NULL;
}
-#endif
- cal_backend_kolab_notify_removed (self);
+ if (ok) {
+ cal_backend_kolab_notify_removed (self);
+ }
}
static void
@@ -1918,14 +1863,7 @@ e_cal_backend_kolab_init (ECalBackendKolab *backend)
{
ECalBackendKolab *self = E_CAL_BACKEND_KOLAB (backend);
ECalBackendKolabPrivate *priv = E_CAL_BACKEND_KOLAB_PRIVATE (self);
-
- g_mutex_lock (&koma_objects_lock);
- if (koma_objects == NULL)
- koma_objects = g_hash_table_new_full (g_direct_hash,
- g_direct_equal,
- g_free,
- g_object_unref);
- g_mutex_unlock (&koma_objects_lock);
+ GError *tmp_err = NULL;
g_debug ("%s()[%u] called.", __func__, __LINE__);
@@ -1937,6 +1875,20 @@ e_cal_backend_kolab_init (ECalBackendKolab *backend)
priv->source_type = 0;
priv->mode_switch_err = NULL;
+ /* init subsystems (these are no-ops if already called before) */
+ kolab_util_glib_init ();
+ kolab_util_folder_init ();
+ kolab_util_http_init ();
+ /* libcamel
+ * Curl init may configure the underlying SSL lib,
+ * but as far as SSL goes, we want Camel to rule here
+ * TODO check whether Camel session needs to be initialized before or after libcurl.
+ */
+ if (! kolab_util_camel_init (&tmp_err)) {
+ g_error ("%s()[%u]: %s", __func__, __LINE__, tmp_err->message);
+ return;
+ }
+
g_signal_connect (E_BACKEND (backend), "notify::online", G_CALLBACK (cal_backend_kolab_signal_online_cb), NULL);
} /* e_cal_backend_kolab_init () */
@@ -1948,13 +1900,10 @@ e_cal_backend_kolab_dispose (GObject *object)
g_debug ("%s()[%u] called.", __func__, __LINE__);
- g_warning ("%s()[%u] FIXME KolabMailAccess (table) disposal", __func__, __LINE__);
-#if 0 /* FIXME (check g_object_toggle_ref cleanup callback) */
if (priv->cal_koma != NULL) {
g_object_unref (priv->cal_koma);
priv->cal_koma = NULL;
}
-#endif
if (priv->default_zone != NULL) {
g_object_unref (priv->default_zone);
priv->default_zone = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]