[evolution-kolab/ek-wip-porting] EBookBackendKolab: rewrite to 3.x E-D-S API (started)
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/ek-wip-porting] EBookBackendKolab: rewrite to 3.x E-D-S API (started)
- Date: Fri, 9 Dec 2011 18:30:15 +0000 (UTC)
commit 1eafe537b56b7e549eec9a1a46815f1bfabe97df
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Fri Dec 9 19:25:41 2011 +0100
EBookBackendKolab: rewrite to 3.x E-D-S API (started)
* added skeleton implementations for EBookBackend(Sync)
virtual functions
* removed old public API functions
* moved old code into probably-fitting places,
commented out (to be ported later)
src/addressbook/e-book-backend-kolab.c | 1232 ++++++++++++++++++--------------
src/addressbook/e-book-backend-kolab.h | 104 ++-
src/addressbook/kolab-util-contact.h | 15 +-
3 files changed, 774 insertions(+), 577 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-kolab.c b/src/addressbook/e-book-backend-kolab.c
index 1605600..8790626 100644
--- a/src/addressbook/e-book-backend-kolab.c
+++ b/src/addressbook/e-book-backend-kolab.c
@@ -1,47 +1,63 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/***************************************************************************
+ * e-book-backend-kolab.c
+ *
+ * 2010
+ * Copyright 2010 Christian Hilberg
+ * <hilberg kernelconcepts de>
+ * and Silvan Marco Fin <silvan kernelconcepts de> in 2011
+ ****************************************************************************/
+
/*
- * evolution-kolab
- * Copyright (C) 2010 Christian Hilberg <hilberg kernelconcepts de>
- * and 2011 Silvan Marco Fin <silvan kernelconcepts de>
- *
- * evolution-kolab 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 3 of the License, or
- * (at your option) any later version.
- *
- * evolution-kolab 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, see <http://www.gnu.org/licenses/>.
+ * 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-book-backend-kolab.h"
-#include "kolab-util-contact.h"
-#include "kolab-util-contact-cache.h"
+/*----------------------------------------------------------------------------*/
-#include <libekolab/kolab-types.h>
-#include <libekolab/kolab-mail-access.h>
-#include <libekolab/kolab-settings-handler.h>
-#include <libekolabutil/kolab-util-camel.h>
-#include <libekolabutil/kolab-util-http.h>
-#include <libekolabutil/kolab-util-glib.h>
+#include <glib.h>
+#include <glib-object.h>
#include <libedata-book/e-data-book-view.h>
#include <libedata-book/e-book-backend-sync.h>
#include <libedata-book/e-book-backend-cache.h>
-#include <camel/camel-exception.h>
-#include <camel/camel-url.h>
-#include <glib.h>
-#include <glib/gprintf.h>
+#include <libekolabutil/camel-system-headers.h>
+#include <libekolabutil/kolab-util-camel.h>
+#include <libekolabutil/kolab-util-http.h>
+#include <libekolabutil/kolab-util-glib.h>
+
+#include <libekolab/kolab-types.h>
+#include <libekolab/kolab-mail-access.h>
+#include <libekolab/kolab-settings-handler.h>
+
+#include "kolab-util-contact.h"
+#include "kolab-util-contact-cache.h"
+
+#include "e-book-backend-kolab.h"
+
+/*----------------------------------------------------------------------------*/
+/* table of KolabMailAccess objects */
+
+/* static GHashTable *koma_objects = NULL; */
+
+/*----------------------------------------------------------------------------*/
typedef struct _EBookBackendKolabPrivate EBookBackendKolabPrivate;
struct _EBookBackendKolabPrivate
{
- GNOME_Evolution_Addressbook_BookMode book_mode;
+ /* GNOME_Evolution_Addressbook_BookMode book_mode; */
EBookBackendCache *book_cache;
KolabMailAccess *book_koma;
gchar *book_uri;
@@ -54,23 +70,198 @@ struct _EBookBackendKolabPrivate
G_DEFINE_TYPE (EBookBackendKolab, e_book_backend_kolab, E_TYPE_BOOK_BACKEND_SYNC)
-/* Forward declarations for interal use */
+/*----------------------------------------------------------------------------*/
+/* internal statics */
+
+static void
+e_book_backend_kolab_open (EBookBackendSync *self,
+ EDataBook *book,
+ GCancellable *cancellable,
+ gboolean only_if_exists,
+ GError **err)
+{
+ g_assert (E_IS_BOOK_BACKEND_SYNC (self));
+ g_assert (E_IS_DATA_BOOK (book));
+ (void)cancellable; /* FIXME */ /* cancellable may be NULL */
+ (void)only_if_exists; /* FIXME */
+ g_return_if_fail (err == NULL || *err == NULL);
+
+ g_error ("%s: FIXME implement me", __func__);
-static void e_book_backend_kolab_set_mode (EBookBackend *backend, GNOME_Evolution_Addressbook_BookMode mode);
+#if 0 /* FIXME old*/
+ g_debug ("%s()[%u] called.", __func__, __LINE__);
-/* implementation of parent class' virtual methods */
+ 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 (&error);
+ if (! ok) {
+ status = kolab_util_contact_map_error (error);
+ g_warning ("%s()[%u]: %s",
+ __func__, __LINE__, error->message);
+ g_error_free (error);
+ error = NULL;
+ }
-static EBookBackendSyncStatus
-e_book_backend_kolab_remove (EBookBackendSync *backend,
+ priv->book_uri = e_source_get_uri(source);
+ g_debug ("%s()[%u] uri = %s",
+ __func__, __LINE__, priv->book_uri);
+
+ cex = camel_exception_new ();
+ c_url = camel_url_new (priv->book_uri, cex);
+ if (c_url == NULL) {
+ g_warning ("%s()[%u]: %s",
+ __func__, __LINE__, camel_exception_get_description (cex));
+ camel_exception_free (cex);
+ status = GNOME_Evolution_Addressbook_OtherError;
+ }
+ servername = g_strdup (c_url->host);
+ username = g_strdup (c_url->user);
+ camel_url_free (c_url);
+ g_debug ("%s()[%u] servername = %s",
+ __func__, __LINE__, servername);
+ g_debug ("%s()[%u] username = %s",
+ __func__, __LINE__, username);
+
+ /* Initialize backend cache */
+ if (priv->book_cache != NULL) {
+ g_object_unref (priv->book_cache);
+ }
+ priv->book_cache = e_book_backend_cache_new (priv->book_uri);
+ ok = e_file_cache_clean (E_FILE_CACHE (priv->book_cache));
+ g_debug (" + Book cache cleaning %s.", ok ? "was successful" : "FAILED");
+
+ /* Prepare data from sync strategy property */
+ sync_prop = e_source_get_property (source, KOLAB_SYNC_STRATEGY_PROP);
+ sync_value = kolab_util_misc_sync_value_from_property (sync_prop);
+ sourcename = kolab_util_backend_get_relative_path_from_uri (priv->book_uri);
+
+ user_at_server = g_strdup_printf ("%s %s",
+ username, servername);
+
+ ok = g_hash_table_lookup_extended (priv->koma_table,
+ user_at_server,
+ (gpointer *) &tmp_key,
+ (gpointer *) &tmp_koma);
+ if (ok) {
+ /* There is already a KoMA instance for $servername. Use it and return */
+ g_object_ref (tmp_koma);
+ priv->book_koma = tmp_koma;
+ g_free (servername);
+ g_free (username);
+ g_free (user_at_server);
+ ksettings = kolab_mail_access_get_settings_handler (priv->book_koma);
+ kolab_util_backend_prepare_settings (ksettings,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ sourcename,
+ &sync_value);
+ goto notifications;
+ }
+ /* Otherwise we need to setup a new KoMA instance and a settings handler */
+
+ /* Configure settings handler */
+ ksettings = KOLAB_SETTINGS_HANDLER (g_object_new (KOLAB_TYPE_SETTINGS_HANDLER, NULL));
+ (void) kolab_settings_handler_configure (ksettings,
+ KOLAB_FOLDER_CONTEXT_CONTACT,
+ &error);
+ if (error != NULL) {
+ g_warning ("%s()[%u]: %s",
+ __func__, __LINE__, error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+ (void) kolab_settings_handler_bringup (ksettings,
+ &error);
+ if (error != NULL) {
+ g_warning ("%s()[%u]: %s",
+ __func__, __LINE__, error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+ kolab_util_backend_prepare_settings (ksettings,
+ source,
+ servername,
+ username,
+ NULL,
+ sourcename,
+ &sync_value);
+
+ g_free (servername);
+ g_free (username);
+ g_free (sourcename);
+
+ priv->book_koma = KOLAB_MAIL_ACCESS (g_object_new (KOLAB_TYPE_MAIL_ACCESS, NULL));
+ g_object_add_toggle_ref (G_OBJECT (priv->book_koma),
+ kolab_util_backend_koma_table_cleanup_cb,
+ priv->koma_table);
+ g_hash_table_insert (priv->koma_table,
+ user_at_server,
+ priv->book_koma);
+
+ kolab_mail_access_configure (priv->book_koma,
+ ksettings,
+ &error);
+ g_object_unref (ksettings);
+ if (error != NULL) {
+ status = kolab_util_contact_map_error (error);
+ g_warning ("%s()[%u]: %s",
+ __func__, __LINE__, error->message);
+ g_error_free (error);
+ return status;
+ }
+ kolab_mail_access_bringup (priv->book_koma,
+ &error);
+ if (error != NULL) {
+ status = kolab_util_contact_map_error (error);
+ g_warning ("%s()[%u]: %s",
+ __func__, __LINE__, error->message);
+ g_error_free (error);
+ return status;
+ }
+
+ notifications:
+ /* e_book_backend_kolab_set_mode (backend, priv->book_mode); */
+ tmp_mode = kolab_mail_access_get_opmode (priv->book_koma, &error);
+ if (error != NULL) {
+ g_warning ("%s()[%u]: %s",
+ __func__, __LINE__, error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+
+ e_book_backend_notify_auth_required (backend);
+ e_book_backend_set_is_loaded (backend, TRUE);
+ e_book_backend_notify_connection_status (backend,
+ tmp_mode = KOLAB_MAIL_ACCESS_OPMODE_ONLINE ? TRUE : FALSE);
+ e_book_backend_set_is_writable (backend, TRUE);
+ e_book_backend_notify_writable (backend, TRUE);
+
+ return GNOME_Evolution_Addressbook_Success;
+#endif /* FIXME */
+}
+
+static void
+e_book_backend_kolab_remove (EBookBackendSync *self,
EDataBook *book,
- guint32 opid)
+ GCancellable *cancellable,
+ GError **err)
{
- EBookBackendKolab *kolab = E_BOOK_BACKEND_KOLAB (backend);
- EBookBackendKolabPrivate *priv = E_BOOK_BACKEND_KOLAB_PRIVATE (kolab);
+ g_assert (E_IS_BOOK_BACKEND_SYNC (self));
+ g_assert (E_IS_DATA_BOOK (book));
+ (void)cancellable; /* FIXME */ /* cancellable may be NULL */
+ g_return_if_fail (err == NULL || *err == NULL);
- (void) book;
- (void) opid;
-g_debug ("%s()[%u] called.", __func__, __LINE__);
+ g_error ("%s: FIXME implement me", __func__);
+
+#if 0 /* FIXME old */
+ g_debug ("%s()[%u] called.", __func__, __LINE__);
if (e_book_backend_is_loaded (E_BOOK_BACKEND (backend)) != FALSE) {
g_object_unref (priv->book_koma);
priv->book_koma = NULL;
@@ -89,71 +280,140 @@ g_debug ("%s()[%u] called.", __func__, __LINE__);
e_book_backend_set_is_loaded (E_BOOK_BACKEND (backend), FALSE);
return GNOME_Evolution_Addressbook_Success;
-} /* e_book_backend_kolab_remove () */
-
-static EBookBackendSyncStatus
-e_book_backend_kolab_create_contact (EBookBackendSync *backend,
- EDataBook *book,
- guint32 opid,
- const gchar *vcard,
- EContact **contact)
+#endif /* FIXME*/
+
+}
+
+static void
+e_book_backend_kolab_refresh (EBookBackendSync *self,
+ EDataBook *book,
+ GCancellable *cancellable,
+ GError **err)
{
- EBookBackendKolab *kolab = E_BOOK_BACKEND_KOLAB (backend);
- EBookBackendKolabPrivate *priv = E_BOOK_BACKEND_KOLAB_PRIVATE (kolab);
- GError *error = NULL;
- EBookBackendSyncStatus status = GNOME_Evolution_Addressbook_Success;
+ g_assert (E_IS_BOOK_BACKEND_SYNC (self));
+ g_assert (E_IS_DATA_BOOK (book));
+ (void)cancellable; /* FIXME */ /* cancellable may be NULL */
+ g_return_if_fail (err == NULL || *err == NULL);
+
+ g_error ("%s: FIXME implement me", __func__);
+}
+
+static gboolean
+e_book_backend_kolab_get_backend_property (EBookBackendSync *self,
+ EDataBook *book,
+ GCancellable *cancellable,
+ const gchar *prop_name,
+ gchar **prop_value,
+ GError **err)
+{
+ g_assert (E_IS_BOOK_BACKEND_SYNC (self));
+ g_assert (E_IS_DATA_BOOK (book));
+ (void)cancellable; /* FIXME */ /* cancellable may be NULL */
+ (void)prop_name; /* FIXME */
+ (void)prop_value; /* FIXME */
+ g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+ g_error ("%s: FIXME implement me", __func__);
+}
+
+static gboolean
+e_book_backend_kolab_set_backend_property (EBookBackendSync *self,
+ EDataBook *book,
+ GCancellable *cancellable,
+ const gchar *prop_name,
+ const gchar *prop_value,
+ GError **err)
+{
+ g_assert (E_IS_BOOK_BACKEND_SYNC (self));
+ g_assert (E_IS_DATA_BOOK (book));
+ (void)cancellable; /* FIXME */ /* cancellable may be NULL */
+ (void)prop_name; /* FIXME */
+ (void)prop_value; /* FIXME */
+ g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+ g_error ("%s: FIXME implement me", __func__);
+}
+
+static void
+e_book_backend_kolab_create_contacts (EBookBackendSync *self,
+ EDataBook *book,
+ GCancellable *cancellable,
+ const GSList *vcards,
+ GSList **added_contacts,
+ GError **err)
+{
+ g_assert (E_IS_BOOK_BACKEND_SYNC (self));
+ g_assert (E_IS_DATA_BOOK (book));
+ (void)cancellable; /* FIXME */ /* cancellable may be NULL */
+ (void)vcards; /* FIXME */
+ (void)added_contacts; /* FIXME */
+ g_return_if_fail (err == NULL || *err == NULL);
+
+ g_error ("%s: FIXME implement me", __func__);
+
+#if 0 /* FIXME old */
+ g_debug ("%s()[%u] called.", __func__, __LINE__);
- (void) book;
- (void) opid;
-g_debug ("%s()[%u] called.", __func__, __LINE__);
-
*contact = e_contact_new_from_vcard (vcard);
if (*contact == NULL) {
- g_warning ("%s()[%u] error creating contact from vcard:\n%s", __func__, __LINE__, vcard);
+ g_warning ("%s()[%u] error creating contact from vcard:\n%s",
+ __func__, __LINE__, vcard);
return GNOME_Evolution_Addressbook_OtherError;
}
- kolab_util_contact_cache_assure_uid_on_econtact (priv->book_cache, priv->book_koma, priv->book_uri, *contact, FALSE, &error);
+ kolab_util_contact_cache_assure_uid_on_econtact (priv->book_cache,
+ priv->book_koma,
+ priv->book_uri,
+ *contact,
+ FALSE,
+ &error);
if (error != NULL) {
status = kolab_util_contact_map_error (error);
- g_warning ("%s()[%u]: %s.", __func__, __LINE__, error->message);
+ g_warning ("%s()[%u]: %s.",
+ __func__, __LINE__, error->message);
g_error_free (error);
g_object_unref (*contact);
*contact = NULL;
return status;
}
- kolab_util_contact_store (*contact, priv->book_koma, priv->book_uri, &error);
+ kolab_util_contact_store (*contact,
+ priv->book_koma,
+ priv->book_uri,
+ &error);
if (error != NULL) {
status = kolab_util_contact_map_error (error);
- g_warning ("%s()[%u]: %s", __func__, __LINE__, error->message);
+ g_warning ("%s()[%u]: %s",
+ __func__, __LINE__, error->message);
g_error_free (error);
g_object_unref (*contact);
*contact = NULL;
return status;
}
- /* [FIXME speed] e_book_backend_cache_add_contact (priv->book_cache, *contact); */
-
return GNOME_Evolution_Addressbook_Success;
-} /* e_book_backend_kolab_create_contact () */
+#endif /* FIXME */
+}
-static EBookBackendSyncStatus
-e_book_backend_kolab_remove_contacts (EBookBackendSync *backend,
- EDataBook *book,
- guint32 opid,
- GList *id_list,
- GList **removed_ids)
+static void
+e_book_backend_kolab_remove_contacts (EBookBackendSync *self,
+ EDataBook *book,
+ GCancellable *cancellable,
+ const GSList *id_list,
+ GSList **removed_ids,
+ GError **err)
{
- EBookBackendKolab *kolab = E_BOOK_BACKEND_KOLAB (backend);
- EBookBackendKolabPrivate *priv = E_BOOK_BACKEND_KOLAB_PRIVATE (kolab);
- gchar *sourcename = NULL;
- GList *it = NULL;
- gboolean ok;
- GError *error = NULL;
- (void) book;
- (void) opid;
-g_debug ("%s()[%u] called.", __func__, __LINE__);
+ g_assert (E_IS_BOOK_BACKEND_SYNC (self));
+ g_assert (E_IS_DATA_BOOK (book));
+ (void)cancellable; /* FIXME */ /* cancellable may be NULL */
+ (void)id_list; /* FIXME */
+ (void)removed_ids; /* FIXME */
+ g_return_if_fail (err == NULL || *err == NULL);
+
+ g_error ("%s: FIXME implement me", __func__);
+
+#if 0 /* FIXME old */
+ g_debug ("%s()[%u] called.", __func__, __LINE__);
sourcename = kolab_util_backend_get_relative_path_from_uri (priv->book_uri);
for (it = g_list_first (id_list); it != NULL; it = g_list_next (it)) {
gchar *uid = it->data;
@@ -163,34 +423,35 @@ g_debug ("%s()[%u] called.", __func__, __LINE__);
g_error_free (error);
error = NULL;
} else {
-#if 0 /* [FIXME speed] */
- ok = e_book_backend_cache_remove_contact (priv->book_cache, uid);
- if (ok)
-#endif
- *removed_ids = g_list_append (*removed_ids, g_strdup(uid));
+ *removed_ids = g_list_append (*removed_ids, g_strdup(uid));
}
}
g_free (sourcename);
return GNOME_Evolution_Addressbook_Success;
-} /* e_book_backend_kolab_remove_contacts ()*/
-
-static EBookBackendSyncStatus
-e_book_backend_kolab_modify_contact (EBookBackendSync *backend,
- EDataBook *book,
- guint32 opid,
- const gchar *vcard,
- EContact **contact)
+#endif /* FIXME */
+}
+
+static void
+e_book_backend_kolab_modify_contacts (EBookBackendSync *self,
+ EDataBook *book,
+ GCancellable *cancellable,
+ const GSList *vcards,
+ GSList **modified_contacts,
+ GError **err)
{
- EBookBackendKolab *kolab = E_BOOK_BACKEND_KOLAB (backend);
- EBookBackendKolabPrivate *priv = E_BOOK_BACKEND_KOLAB_PRIVATE (kolab);
- GError *error = NULL;
- EBookBackendSyncStatus status = GNOME_Evolution_Addressbook_Success;
-
- (void) book;
- (void) opid;
-g_debug ("%s()[%u] called.", __func__, __LINE__);
-
+ g_assert (E_IS_BOOK_BACKEND_SYNC (self));
+ g_assert (E_IS_DATA_BOOK (book));
+ (void)cancellable; /* FIXME */ /* cancellable may be NULL */
+ (void)vcards; /* FIXME */
+ (void)modified_contacts; /* FIXME */
+ g_return_if_fail (err == NULL || *err == NULL);
+
+ g_error ("%s: FIXME implement me", __func__);
+
+#if 0 /* FIXME old */
+ g_debug ("%s()[%u] called.", __func__, __LINE__);
+
*contact = e_contact_new_from_vcard (vcard);
if (*contact == NULL) {
g_warning ("%s()[%u] error creating contact from vcard:\n%s", __func__, __LINE__, vcard);
@@ -207,76 +468,96 @@ g_debug ("%s()[%u] called.", __func__, __LINE__);
return status;
}
- /* [FIXME speed] e_book_backend_cache_add_contact (priv->book_cache, *contact); */
-
return GNOME_Evolution_Addressbook_Success;
-} /* e_book_backend_kolab_modify_contact () */
+#endif /* FIXME */
+}
-static EBookBackendSyncStatus
-e_book_backend_kolab_get_contact (EBookBackendSync *backend,
+static void
+e_book_backend_kolab_get_contact (EBookBackendSync *self,
EDataBook *book,
- guint32 opid,
+ GCancellable *cancellable,
const gchar *id,
- gchar **vcard)
+ gchar **vcard,
+ GError **err)
{
- EBookBackendKolab *kolab = E_BOOK_BACKEND_KOLAB (backend);
- EBookBackendKolabPrivate *priv = E_BOOK_BACKEND_KOLAB_PRIVATE (kolab);
- EContact *econtact = NULL;
- GError *error = NULL;
- EBookBackendSyncStatus status = GNOME_Evolution_Addressbook_Success;
-
- (void) book;
- (void) opid;
-g_debug ("%s()[%u] called.", __func__, __LINE__);
-
- econtact = kolab_util_contact_cache_get_object (priv->book_cache, priv->book_koma, priv->book_uri, id, FALSE, &error);
+ g_assert (E_IS_BOOK_BACKEND_SYNC (self));
+ g_assert (E_IS_DATA_BOOK (book));
+ (void)cancellable; /* FIXME */ /* cancellable may be NULL */
+ (void)id; /* FIXME */
+ (void)vcard; /* FIXME */
+ g_return_if_fail (err == NULL || *err == NULL);
+
+ g_error ("%s: FIXME implement me", __func__);
+
+#if 0 /* FIXME old */
+ g_debug ("%s()[%u] called.", __func__, __LINE__);
+
+ econtact = kolab_util_contact_cache_get_object (priv->book_cache,
+ priv->book_koma,
+ priv->book_uri,
+ id, FALSE,
+ &error);
if (error != NULL) {
status = kolab_util_contact_map_error (error);
- g_warning ("%s()[%u]: %s", __func__, __LINE__, error->message);
+ g_warning ("%s()[%u]: %s",
+ __func__, __LINE__, error->message);
g_error_free (error);
*vcard = NULL;
return status;
}
- *vcard = e_vcard_to_string (E_VCARD (econtact), EVC_FORMAT_VCARD_30);
+ *vcard = e_vcard_to_string (E_VCARD (econtact),
+ EVC_FORMAT_VCARD_30);
g_object_unref (econtact);
return GNOME_Evolution_Addressbook_Success;
+#endif /* FIXME */
}
-static EBookBackendSyncStatus
-e_book_backend_kolab_get_contact_list (EBookBackendSync *backend,
- EDataBook *book,
- guint32 opid,
- const gchar *query,
- GList **contacts)
+static void
+e_book_backend_kolab_get_contact_list (EBookBackendSync *self,
+ EDataBook *book,
+ GCancellable *cancellable,
+ const gchar *query,
+ GSList **contacts,
+ GError **err)
{
- EBookBackendKolab *kolab = E_BOOK_BACKEND_KOLAB (backend);
- EBookBackendKolabPrivate *priv = E_BOOK_BACKEND_KOLAB_PRIVATE (kolab);
- EBookBackendSyncStatus status = GNOME_Evolution_Addressbook_Success;
- GList *econtact_list = NULL;
- GList *it = NULL;
- GError *error = NULL;
- (void) book;
- (void) opid;
-g_debug ("%s()[%u] called.", __func__, __LINE__);
-g_debug (" + query: %s", query);
+ g_assert (E_IS_BOOK_BACKEND_SYNC (self));
+ g_assert (E_IS_DATA_BOOK (book));
+ (void)cancellable; /* FIXME */ /* cancellable may be NULL */
+ (void)query; /* FIXME */
+ (void)contacts; /* FIXME */
+ g_return_if_fail (err == NULL || *err == NULL);
+
+ g_error ("%s: FIXME implement me", __func__);
+
+#if 0 /* FIXME old */
+ g_debug ("%s()[%u] called.", __func__, __LINE__);
+ g_debug (" + query: %s", query);
/* Update the cache to contain all data requested. */
- kolab_util_contact_cache_update_on_query (priv->book_cache, priv->book_koma, query, priv->book_uri);
+ kolab_util_contact_cache_update_on_query (priv->book_cache,
+ priv->book_koma,
+ query,
+ priv->book_uri);
/* Fetch information from BackendCache */;
- /* [FIXME speed] econtact_list = e_book_backend_cache_get_contacts (priv->book_cache, query); */
- econtact_list = kolab_util_contact_cache_get_contacts (priv->book_cache, priv->book_koma, query, priv->book_uri, &error);
+ econtact_list = kolab_util_contact_cache_get_contacts (priv->book_cache,
+ priv->book_koma,
+ query,
+ priv->book_uri,
+ &error);
if (error != NULL) {
status = kolab_util_contact_map_error (error);
- g_warning ("%s()[%u]: %s", __func__, __LINE__, error->message);
+ g_warning ("%s()[%u]: %s",
+ __func__, __LINE__, error->message);
g_error_free (error);
*contacts = NULL;
return status;
}
for (it = g_list_first (econtact_list); it != NULL; it = g_list_next (it)) {
EContact *econtact = it->data;
- gchar *vcard = e_vcard_to_string (E_VCARD (econtact), EVC_FORMAT_VCARD_30);
+ gchar *vcard = e_vcard_to_string (E_VCARD (econtact),
+ EVC_FORMAT_VCARD_30);
*contacts = g_list_append (*contacts, vcard);
g_object_unref (econtact);
}
@@ -284,357 +565,333 @@ g_debug (" + query: %s", query);
g_list_free (econtact_list);
return GNOME_Evolution_Addressbook_Success;
-} /* e_book_backend_kolab_get_contact_list () */
+#endif /* FIXME */
+}
-static EBookBackendSyncStatus
-e_book_backend_kolab_get_changes (EBookBackendSync *backend,
- EDataBook *book,
- guint32 opid,
- const gchar *change_id,
- GList **changes)
+static void
+e_book_backend_kolab_get_contact_list_uids (EBookBackendSync *self,
+ EDataBook *book,
+ GCancellable *cancellable,
+ const gchar *query,
+ GSList **contacts_uids,
+ GError **err)
{
- (void)backend;
- (void)book;
- (void)opid;
- (void)change_id;
- (void)changes;
-
- g_warning ("Unimplemented method called: %s\n", __func__);
- return GNOME_Evolution_Addressbook_OtherError;
+ g_assert (E_IS_BOOK_BACKEND_SYNC (self));
+ g_assert (E_IS_DATA_BOOK (book));
+ (void)cancellable; /* FIXME */ /* cancellable may be NULL */
+ (void)query; /* FIXME */
+ (void)contacts_uids; /* FIXME */
+ g_return_if_fail (err == NULL || *err == NULL);
+
+ g_error ("%s: FIXME implement me", __func__);
}
-static EBookBackendSyncStatus
-e_book_backend_kolab_authenticate_user (EBookBackendSync *backend,
- EDataBook *book,
- guint32 opid,
- const gchar *user,
- const gchar *passwd,
- const gchar *auth_method)
+static void
+e_book_backend_kolab_authenticate_user (EBookBackendSync *self,
+ GCancellable *cancellable,
+ ECredentials *credentials,
+ GError **err)
{
- EBookBackendKolab *kolab = E_BOOK_BACKEND_KOLAB (backend);
- EBookBackendKolabPrivate *priv = E_BOOK_BACKEND_KOLAB_PRIVATE (kolab);
- KolabSettingsHandler *ksettings = NULL;
- const gchar *tmp_user = NULL;
- gchar *sourcename = NULL;
- gchar *password_placeholder = NULL;
- GError *error = NULL;
- gboolean ok;
- (void) book;
- (void) opid;
-g_debug ("%s()[%u] called.", __func__, __LINE__);
-g_debug (" + user: %s\n + auth_method: %s", user, auth_method);
-g_debug ("%s()[%u] username = %s", __func__, __LINE__, user);
-g_debug ("%s()[%u] auth_method = %s", __func__, __LINE__, auth_method);
+ g_assert (E_IS_BOOK_BACKEND_SYNC (self));
+ (void)cancellable; /* FIXME */ /* cancellable may be NULL */
+ (void)credentials; /* FIXME */
+ g_return_if_fail (err == NULL || *err == NULL);
+
+ g_error ("%s: FIXME implement me", __func__);
+
+#if 0 /* FIXME old */
+ g_debug ("%s()[%u] called.",
+ __func__, __LINE__);
+ g_debug (" + user: %s\n + auth_method: %s",
+ user, auth_method);
+ g_debug ("%s()[%u] username = %s",
+ __func__, __LINE__, user);
+ g_debug ("%s()[%u] auth_method = %s",
+ __func__, __LINE__, auth_method);
password_placeholder = g_strdup (passwd);
password_placeholder = g_strcanon (password_placeholder, "", '*');
-g_debug ("%s()[%u] password = %s", __func__, __LINE__, password_placeholder);
+ g_debug ("%s()[%u] password = %s",
+ __func__, __LINE__, password_placeholder);
g_free (password_placeholder);
ksettings = kolab_mail_access_get_settings_handler (priv->book_koma);
- tmp_user = kolab_settings_handler_get_char_field (ksettings, KOLAB_SETTINGS_HANDLER_CHAR_FIELD_KOLAB_USER_NAME, &error);
+ tmp_user = kolab_settings_handler_get_char_field (ksettings,
+ KOLAB_SETTINGS_HANDLER_CHAR_FIELD_KOLAB_USER_NAME,
+ &error);
if (error != NULL) {
- g_warning ("%s()[%u]: %s", __func__, __LINE__, error->message);
+ g_warning ("%s()[%u]: %s",
+ __func__, __LINE__, error->message);
g_error_free (error);
error = NULL;
}
if (g_strcmp0 (tmp_user, user) != 0)
- g_warning (" + username from argument and username in KolabSettingsHandler do not match: %s vs. %s", tmp_user, user);
+ g_warning (" + username from argument and username in "
+ "KolabSettingsHandler do not match: %s vs. %s",
+ tmp_user, user);
sourcename = kolab_util_backend_get_relative_path_from_uri (priv->book_uri);
-
- kolab_util_backend_prepare_settings (ksettings, NULL, NULL, NULL, passwd, NULL, NULL);
- priv->auth_received = TRUE;
- ok = kolab_util_contact_deploy_mode_by_backend (priv->book_koma, priv->book_mode);
+ kolab_util_backend_prepare_settings (ksettings,
+ NULL,
+ NULL,
+ NULL,
+ passwd,
+ NULL,
+ NULL);
- return GNOME_Evolution_Addressbook_Success;
-} /* e_book_backend_kolab_authenticate_user () */
+ priv->auth_received = TRUE;
+ ok = kolab_util_contact_deploy_mode_by_backend (priv->book_koma,
+ priv->book_mode);
-static EBookBackendSyncStatus
-e_book_backend_kolab_get_required_fields (EBookBackendSync *backend,
- EDataBook *book,
- guint32 opid,
- GList **fields)
-{
- (void) backend;
- (void) book;
- (void) opid;
-g_debug ("%s()[%u] called.", __func__, __LINE__);
- *fields = NULL;
return GNOME_Evolution_Addressbook_Success;
-} /* e_book_backend_kolab_get_contact_list () */
+#endif /* FIXME */
+}
-static EBookBackendSyncStatus
-e_book_backend_kolab_get_supported_fields (EBookBackendSync *backend,
- EDataBook *book,
- guint32 opid,
- GList **fields)
+static void
+e_book_backend_kolab_start_book_view (EBookBackend *self,
+ EDataBookView *book_view)
{
- int i;
- (void) backend;
- (void) book;
- (void) opid;
-g_debug ("%s()[%u] called.", __func__, __LINE__);
- for (i=E_CONTACT_FIELD_FIRST; i<E_CONTACT_FIELD_LAST; i++)
- *fields = g_list_append (*fields, g_strdup (e_contact_field_name (i)));
+ g_assert (E_IS_BOOK_BACKEND_SYNC (self));
+ g_assert (E_IS_DATA_BOOK_VIEW (book_view));
- if (*fields == NULL)
- return GNOME_Evolution_Addressbook_OtherError;
+#if 0 /* FIXME old */
+ g_debug ("%s()[%u] called.", __func__, __LINE__);
+ /* This should not be necessary, if everything works as expected,
+ * ..._start_book_view () will not be issued, if the KoMA was not
+ * configured correctly.
+ */
+ koma_mode = kolab_mail_access_get_opmode (priv->book_koma, &error);
+ if (error != NULL) {
+ g_warning ("%s()[%u]: %s", __func__, __LINE__, error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+ if (koma_mode < KOLAB_MAIL_ACCESS_OPMODE_OFFLINE) {
+ g_error ("%s()[%u]: %s called while the KolabMailAccess was "
+ "not ready! Should not happen, forcing exit.",
+ __func__, __LINE__, __func__);
+ }
+ if ((koma_mode < KOLAB_MAIL_ACCESS_OPMODE_ONLINE) &&
+ (priv->book_mode == GNOME_Evolution_Addressbook_MODE_REMOTE)) {
+ g_warning ("%s()[%u]: %s called before authentication took place. "
+ "Requesting auth now.",
+ __func__, __LINE__, __func__);
+ e_book_backend_notify_auth_required (backend);
+ return;
+ }
- return GNOME_Evolution_Addressbook_Success;
-} /* e_book_backend_kolab_get_supported_fields () */
+ query = e_data_book_view_get_card_query (book_view);
+ /* First update the BackendCache to the current situation. */
+ kolab_util_contact_cache_update_on_query (priv->book_cache,
+ priv->book_koma,
+ query,
+ priv->book_uri);
+ /* econtact_list = e_book_backend_cache_get_contacts (priv->book_cache, query); */
+ econtact_list = kolab_util_contact_cache_get_contacts (priv->book_cache,
+ priv->book_koma,
+ query,
+ priv->book_uri,
+ &error);
+ if (error != NULL) {
+ g_warning ("%s()[%u]: %s",
+ __func__, __LINE__, error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+ /* Then deliver requests from there. */
+ for (it = g_list_first (econtact_list); it != NULL; it = g_list_next (it)) {
+ EContact *econtact = it->data;
+ e_data_book_view_notify_update (book_view, econtact);
+ g_object_unref (econtact);
+ }
-static EBookBackendSyncStatus
-e_book_backend_kolab_get_supported_auth_methods (EBookBackendSync *backend,
- EDataBook *book,
- guint32 opid,
- GList **methods)
+ g_list_free (econtact_list);
+ g_free (sourcename);
+
+ e_data_book_view_notify_complete (book_view,
+ GNOME_Evolution_Addressbook_Success);
+#endif /* FIXME */
+}
+
+static void
+e_book_backend_kolab_stop_book_view (EBookBackend *self,
+ EDataBookView *book_view)
{
- gchar *auth_method = g_strdup ("plain/password");
- (void) backend;
- (void) book;
- (void) opid;
-g_debug ("%s()[%u] called.", __func__, __LINE__);
- *methods = g_list_append (*methods, auth_method);
+ g_assert (E_IS_BOOK_BACKEND_SYNC (self));
+ g_assert (E_IS_DATA_BOOK_VIEW (book_view));
+}
- return GNOME_Evolution_Addressbook_Success;
-} /* e_book_backend_kolab_get_supported_auth_methods () */
+static void
+e_book_backend_kolab_notify_update (EBookBackend *self,
+ const EContact *contact)
+{
+ g_assert (E_IS_BOOK_BACKEND_SYNC (self));
+ g_assert (E_IS_CONTACT (contact));
+}
-static GNOME_Evolution_Addressbook_CallStatus
-e_book_backend_kolab_load_source (EBookBackend *backend,
- ESource *source,
- gboolean only_if_exists)
+/*----------------------------------------------------------------------------*/
+/* object/class init */
+
+static void
+e_book_backend_kolab_init (EBookBackendKolab *backend)
{
- EBookBackendKolab *kolab = E_BOOK_BACKEND_KOLAB (backend);
- EBookBackendKolabPrivate *priv = E_BOOK_BACKEND_KOLAB_PRIVATE (kolab);
- GNOME_Evolution_Addressbook_CallStatus status = GNOME_Evolution_Addressbook_Success;
- KolabSettingsHandler *ksettings = NULL;
- KolabMailAccess *tmp_koma = NULL;
- CamelException *cex = NULL;
- CamelURL *c_url = NULL;
- gchar *servername = NULL;
- gchar *username = NULL;
- gchar *user_at_server = NULL;
- gchar *tmp_key = NULL;
- GError *error = NULL;
- const gchar *sync_prop = NULL;
- gchar *sourcename = NULL;
- KolabSyncStrategyID sync_value;
- KolabMailAccessOpmodeID tmp_mode;
- gboolean ok;
- (void) only_if_exists;
-g_debug ("%s()[%u] called.", __func__, __LINE__);
+ EBookBackendKolabPrivate *priv = E_BOOK_BACKEND_KOLAB_PRIVATE (backend);
- 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 (&error);
- if (! ok) {
- status = kolab_util_contact_map_error (error);
- g_warning ("%s()[%u]: %s", __func__, __LINE__, error->message);
- g_error_free (error);
- error = NULL;
- }
-
- priv->book_uri = e_source_get_uri(source);
- g_debug ("%s()[%u] uri = %s", __func__, __LINE__, priv->book_uri);
+ g_debug ("%s()[%u] called.", __func__, __LINE__);
- cex = camel_exception_new ();
- c_url = camel_url_new (priv->book_uri, cex);
- if (c_url == NULL) {
- g_warning ("%s()[%u]: %s", __func__, __LINE__, camel_exception_get_description (cex));
- camel_exception_free (cex);
- status = GNOME_Evolution_Addressbook_OtherError;
- }
- servername = g_strdup (c_url->host);
- username = g_strdup (c_url->user);
- camel_url_free (c_url);
- g_debug ("%s()[%u] servername = %s", __func__, __LINE__, servername);
- g_debug ("%s()[%u] username = %s", __func__, __LINE__, username);
+ /* priv->book_mode = E_DATA_BOOK_MODE_LOCAL; */ /* Start in local mode for now. */
+ priv->book_cache = NULL;
+ priv->book_uri = NULL;
+ priv->koma_table = NULL;
+ priv->book_koma = NULL;
+ priv->auth_received = FALSE;
+} /* e_book_backend_kolab_init () */
- /* Initialize backend cache */
+static void
+e_book_backend_kolab_dispose (GObject *object)
+{
+ EBookBackend *self = E_BOOK_BACKEND (object);
+ EBookBackendKolabPrivate *priv = E_BOOK_BACKEND_KOLAB_PRIVATE (self);
+
+ g_debug ("%s()[%u] called.", __func__, __LINE__);
+#if 0 /* FIXME */
+ if (e_book_backend_is_loaded (self)) {
+ e_book_backend_set_is_writable (self, FALSE);
+ e_book_backend_notify_writable (self, FALSE);
+ e_book_backend_notify_connection_status (self, FALSE);
+ e_book_backend_set_is_loaded (self, FALSE);
+ g_object_unref (priv->book_koma);
+ priv->book_koma = NULL;
+ }
+#endif
if (priv->book_cache != NULL) {
+ (void) e_file_cache_remove (E_FILE_CACHE (priv->book_cache));
g_object_unref (priv->book_cache);
+ priv->book_cache = NULL;
}
- priv->book_cache = e_book_backend_cache_new (priv->book_uri);
- ok = e_file_cache_clean (E_FILE_CACHE (priv->book_cache));
- g_debug (" + Book cache cleaning %s.", ok ? "was successful" : "FAILED");
+}
- /* Prepare data from sync strategy property */
- sync_prop = e_source_get_property (source, KOLAB_SYNC_STRATEGY_PROP);
- sync_value = kolab_util_misc_sync_value_from_property (sync_prop);
- sourcename = kolab_util_backend_get_relative_path_from_uri (priv->book_uri);
+static void
+e_book_backend_kolab_finalize (GObject *object)
+{
+ EBookBackendKolabPrivate *priv = E_BOOK_BACKEND_KOLAB_PRIVATE (object);
- user_at_server = g_strdup_printf ("%s %s", username, servername);
+ g_debug ("%s()[%u] called.", __func__, __LINE__);
- ok = g_hash_table_lookup_extended (priv->koma_table, user_at_server, (gpointer *) &tmp_key, (gpointer *) &tmp_koma);
- if (ok) {
- /* There is already a KoMA instance for $servername. Use it and return */
- g_object_ref (tmp_koma);
- priv->book_koma = tmp_koma;
- g_free (servername);
- g_free (username);
- g_free (user_at_server);
- ksettings = kolab_mail_access_get_settings_handler (priv->book_koma);
- kolab_util_backend_prepare_settings (ksettings, NULL, NULL, NULL, NULL, sourcename, &sync_value);
- goto notifications;
- }
- /* Otherwise we need to setup a new KoMA instance and a settings handler */
+ if (priv->book_uri != NULL)
+ g_free (priv->book_uri);
- /* Configure settings handler */
- ksettings = KOLAB_SETTINGS_HANDLER (g_object_new (KOLAB_TYPE_SETTINGS_HANDLER, NULL));
- (void) kolab_settings_handler_configure (ksettings, KOLAB_FOLDER_CONTEXT_CONTACT, &error);
- if (error != NULL) {
- g_warning ("%s()[%u]: %s", __func__, __LINE__, error->message);
- g_error_free (error);
- error = NULL;
- }
- (void) kolab_settings_handler_bringup (ksettings, &error);
- if (error != NULL) {
- g_warning ("%s()[%u]: %s", __func__, __LINE__, error->message);
- g_error_free (error);
- error = NULL;
- }
- kolab_util_backend_prepare_settings (ksettings, source, servername, username, NULL, sourcename, &sync_value);
+ G_OBJECT_CLASS (e_book_backend_kolab_parent_class)->finalize (object);
+} /* e_book_backend_kolab_finalize () */
- g_free (servername);
- g_free (username);
- g_free (sourcename);
+static void
+e_book_backend_kolab_class_init (EBookBackendKolabClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+ EBookBackendClass *backend_class = E_BOOK_BACKEND_CLASS (klass);
+ EBookBackendSyncClass *sync_class = E_BOOK_BACKEND_SYNC_CLASS (klass);
- priv->book_koma = KOLAB_MAIL_ACCESS (g_object_new (KOLAB_TYPE_MAIL_ACCESS, NULL));
- g_object_add_toggle_ref (G_OBJECT (priv->book_koma), kolab_util_backend_koma_table_cleanup_cb, priv->koma_table);
- g_hash_table_insert (priv->koma_table, user_at_server, priv->book_koma);
+ g_debug ("%s()[%u] called.", __func__, __LINE__);
- kolab_mail_access_configure (priv->book_koma, ksettings, &error);
- g_object_unref (ksettings);
- if (error != NULL) {
- status = kolab_util_contact_map_error (error);
- g_warning ("%s()[%u]: %s", __func__, __LINE__, error->message);
- g_error_free (error);
- return status;
- }
- kolab_mail_access_bringup (priv->book_koma, &error);
- if (error != NULL) {
- status = kolab_util_contact_map_error (error);
- g_warning ("%s()[%u]: %s", __func__, __LINE__, error->message);
- g_error_free (error);
- return status;
- }
+ g_type_class_add_private (klass, sizeof (EBookBackendKolabPrivate));
-notifications:
- /* e_book_backend_kolab_set_mode (backend, priv->book_mode); */
- tmp_mode = kolab_mail_access_get_opmode (priv->book_koma, &error);
- if (error != NULL) {
- g_warning ("%s()[%u]: %s", __func__, __LINE__, error->message);
- g_error_free (error);
- error = NULL;
- }
-
- e_book_backend_notify_auth_required (backend);
- e_book_backend_set_is_loaded (backend, TRUE);
- e_book_backend_notify_connection_status (backend, tmp_mode = KOLAB_MAIL_ACCESS_OPMODE_ONLINE ? TRUE : FALSE);
- e_book_backend_set_is_writable (backend, TRUE);
- e_book_backend_notify_writable (backend, TRUE);
+ /* Sync backend class functions */
+ sync_class->open_sync = e_book_backend_kolab_open;
+ sync_class->remove_sync = e_book_backend_kolab_remove;
+ sync_class->refresh_sync = e_book_backend_kolab_refresh;
+ sync_class->get_backend_property_sync = e_book_backend_kolab_get_backend_property;
+ sync_class->set_backend_property_sync = e_book_backend_kolab_set_backend_property;
+ sync_class->create_contacts_sync = e_book_backend_kolab_create_contacts;
+ sync_class->remove_contacts_sync = e_book_backend_kolab_remove_contacts;
+ sync_class->modify_contacts_sync = e_book_backend_kolab_modify_contacts;
+ sync_class->get_contact_sync = e_book_backend_kolab_get_contact;
+ sync_class->get_contact_list_sync = e_book_backend_kolab_get_contact_list;
+ sync_class->get_contact_list_uids_sync = e_book_backend_kolab_get_contact_list_uids;
+ sync_class->authenticate_user_sync = e_book_backend_kolab_authenticate_user;
- return GNOME_Evolution_Addressbook_Success;
-} /* e_book_backend_kolab_load_source () */
+ /* Backend parent class methods methods not covered in the sync backend part */
+ backend_class->start_book_view = e_book_backend_kolab_start_book_view;
+ backend_class->stop_book_view = e_book_backend_kolab_stop_book_view;
+ backend_class->notify_update = e_book_backend_kolab_notify_update;
-static gchar *
-e_book_backend_kolab_get_static_capabilities (EBookBackend *backend)
+ object_class->dispose = e_book_backend_kolab_dispose;
+ object_class->finalize = e_book_backend_kolab_finalize;
+} /* e_book_backend_kolab_class_init () */
+
+
+/*----------------------------------------------------------------------------*/
+/* public API */
+
+
+/*----------------------------------------------------------------------------*/
+
+#if 0 /* FIXME old */
+
+static EBookBackendSyncStatus
+e_book_backend_kolab_get_required_fields (EBookBackendSync *backend,
+ EDataBook *book,
+ guint32 opid,
+ GList **fields)
{
(void) backend;
-g_debug ("%s()[%u] called.", __func__, __LINE__);
- return g_strdup ("kolab,do-initial-query,contact-lists");
-} /* e_book_backend_kolab_get_static_capabilities () */
+ (void) book;
+ (void) opid;
+ g_debug ("%s()[%u] called.", __func__, __LINE__);
+ *fields = NULL;
+ return GNOME_Evolution_Addressbook_Success;
+} /* e_book_backend_kolab_get_contact_list () */
-static void
-e_book_backend_kolab_start_book_view (EBookBackend *backend,
- EDataBookView *book_view)
+static EBookBackendSyncStatus
+e_book_backend_kolab_get_supported_fields (EBookBackendSync *backend,
+ EDataBook *book,
+ guint32 opid,
+ GList **fields)
{
- EBookBackendKolab *kolab = E_BOOK_BACKEND_KOLAB (backend);
- EBookBackendKolabPrivate *priv = E_BOOK_BACKEND_KOLAB_PRIVATE (kolab);
- KolabMailAccessOpmodeID koma_mode;
- const gchar *query = NULL;
- gchar *sourcename = NULL;
- GList *econtact_list = NULL;
- GError *error = NULL;
- GList *it = NULL;
-g_debug ("%s()[%u] called.", __func__, __LINE__);
- /* This should not be necessary, if everything works as expected,
- * ..._start_book_view () will not be issued, if the KoMA was not
- * configured correctly.
- */
- koma_mode = kolab_mail_access_get_opmode (priv->book_koma, &error);
- if (error != NULL) {
- g_warning ("%s()[%u]: %s", __func__, __LINE__, error->message);
- g_error_free (error);
- error = NULL;
- }
- if (koma_mode < KOLAB_MAIL_ACCESS_OPMODE_OFFLINE) {
- g_error ("%s()[%u]: %s called while the KolabMailAccess was not ready! Should not happen, forcing exit.", __func__, __LINE__, __func__);
- }
- if ((koma_mode < KOLAB_MAIL_ACCESS_OPMODE_ONLINE) &&
- (priv->book_mode == GNOME_Evolution_Addressbook_MODE_REMOTE)) {
- g_warning ("%s()[%u]: %s called before authentication took place. Requesting auth now.", __func__, __LINE__, __func__);
- e_book_backend_notify_auth_required (backend);
- return;
- }
-
- query = e_data_book_view_get_card_query (book_view);
- /* First update the BackendCache to the current situation. */
- kolab_util_contact_cache_update_on_query (priv->book_cache, priv->book_koma, query, priv->book_uri);
- /* econtact_list = e_book_backend_cache_get_contacts (priv->book_cache, query); */
- econtact_list = kolab_util_contact_cache_get_contacts (priv->book_cache, priv->book_koma, query, priv->book_uri, &error);
- if (error != NULL) {
- g_warning ("%s()[%u]: %s", __func__, __LINE__, error->message);
- g_error_free (error);
- error = NULL;
- }
- /* Then deliver requests from there. */
- for (it = g_list_first (econtact_list); it != NULL; it = g_list_next (it)) {
- EContact *econtact = it->data;
- e_data_book_view_notify_update (book_view, econtact);
- g_object_unref (econtact);
- }
+ int i;
+ (void) backend;
+ (void) book;
+ (void) opid;
+ g_debug ("%s()[%u] called.", __func__, __LINE__);
+ for (i=E_CONTACT_FIELD_FIRST; i<E_CONTACT_FIELD_LAST; i++)
+ *fields = g_list_append (*fields, g_strdup (e_contact_field_name (i)));
- g_list_free (econtact_list);
- g_free (sourcename);
+ if (*fields == NULL)
+ return GNOME_Evolution_Addressbook_OtherError;
- e_data_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_Success);
-} /* e_book_backend_kolab_start_book_view () */
+ return GNOME_Evolution_Addressbook_Success;
+} /* e_book_backend_kolab_get_supported_fields () */
-static void
-e_book_backend_kolab_stop_book_view (EBookBackend *backend,
- EDataBookView *book_view)
+static EBookBackendSyncStatus
+e_book_backend_kolab_get_supported_auth_methods (EBookBackendSync *backend,
+ EDataBook *book,
+ guint32 opid,
+ GList **methods)
{
+ gchar *auth_method = g_strdup ("plain/password");
(void) backend;
- (void) book_view;
-g_debug ("%s()[%u] called.", __func__, __LINE__);
- /* What to do in a sync backend with this? */
-}
+ (void) book;
+ (void) opid;
+ g_debug ("%s()[%u] called.", __func__, __LINE__);
+ *methods = g_list_append (*methods, auth_method);
+
+ return GNOME_Evolution_Addressbook_Success;
+} /* e_book_backend_kolab_get_supported_auth_methods () */
-static GNOME_Evolution_Addressbook_CallStatus
-e_book_backend_kolab_cancel_operation (EBookBackend *backend,
- EDataBook *book)
+static gchar *
+e_book_backend_kolab_get_static_capabilities (EBookBackend *backend)
{
- (void)backend;
- (void)book;
-
- g_warning ("Unimplemented method called: %s\n", __func__);
- return GNOME_Evolution_Addressbook_OtherError;
-}
+ (void) backend;
+ g_debug ("%s()[%u] called.", __func__, __LINE__);
+ return g_strdup ("kolab,do-initial-query,contact-lists");
+} /* e_book_backend_kolab_get_static_capabilities () */
/**
* e_book_backend_kolab_set_mode:
* @backend: A Kolab addressbook backend.
* @mode: Mode to change to.
- *
+ *
* Sets the mode of the addressbook backend to the given mode.
*/
-static void
+static void
e_book_backend_kolab_set_mode (EBookBackend *backend,
GNOME_Evolution_Addressbook_BookMode mode)
{
@@ -642,11 +899,12 @@ e_book_backend_kolab_set_mode (EBookBackend *backend,
EBookBackendKolabPrivate *priv = E_BOOK_BACKEND_KOLAB_PRIVATE (kolab);
KolabMailAccessOpmodeID koma_mode;
KolabMailAccessOpmodeID tmp_mode;
-g_debug ("%s()[%u] called with mode: %u.", __func__, __LINE__, mode);
+ g_debug ("%s()[%u] called with mode: %u.", __func__, __LINE__, mode);
switch (mode) {
case GNOME_Evolution_Addressbook_MODE_ANY:
case GNOME_Evolution_Addressbook_MODE_REMOTE:
- g_debug (" + got argument E_DATA_BOOK_MODE_ANY/E_DATA_BOOK_MODE_REMOTE, switching backend_mode to E_DATA_BOOK_MODE_REMOTE.");
+ g_debug (" + got argument E_DATA_BOOK_MODE_ANY/E_DATA_BOOK_MODE_REMOTE, "
+ "switching backend_mode to E_DATA_BOOK_MODE_REMOTE.");
priv->book_mode = GNOME_Evolution_Addressbook_MODE_REMOTE;
koma_mode = KOLAB_MAIL_ACCESS_OPMODE_ONLINE;
break;
@@ -656,15 +914,18 @@ g_debug ("%s()[%u] called with mode: %u.", __func__, __LINE__, mode);
koma_mode = KOLAB_MAIL_ACCESS_OPMODE_OFFLINE;
break;
default:
- g_error ("%s() ran into an unknown arguments for mode, value %u. This should not happen.", __func__, mode);
+ g_error ("%s() ran into an unknown arguments for mode, value %u. "
+ "This should not happen.", __func__, mode);
}
if (priv->auth_received == TRUE)
- tmp_mode = kolab_util_contact_deploy_mode_by_koma (priv->book_koma, koma_mode);
+ tmp_mode = kolab_util_contact_deploy_mode_by_koma (priv->book_koma,
+ koma_mode);
else
tmp_mode = KOLAB_MAIL_ACCESS_OPMODE_OFFLINE;
- e_book_backend_notify_connection_status (backend, tmp_mode = KOLAB_MAIL_ACCESS_OPMODE_ONLINE ? TRUE : FALSE);
+ e_book_backend_notify_connection_status (backend,
+ tmp_mode = KOLAB_MAIL_ACCESS_OPMODE_ONLINE ? TRUE : FALSE);
} /* e_book_backend_kolab_set_mode () */
/**
@@ -674,7 +935,7 @@ g_debug ("%s()[%u] called with mode: %u.", __func__, __LINE__, mode);
*
* This method has to be called before any other method which accesses
* Kolab infrastructure. In this case it should be called from
- * e-book-backend-kolab-factory during creation of a new EBookBackendKolab
+ * e-book-backend-kolab-factory during creation of a new EBookBackendKolab
* instance.
*/
void
@@ -691,105 +952,14 @@ EBookBackend *
e_book_backend_kolab_new ()
{
EBookBackendKolab *kolab = NULL;
-g_debug ("%s()[%u] called.", __func__, __LINE__);
+ g_debug ("%s()[%u] called.", __func__, __LINE__);
kolab = g_object_new (E_TYPE_BOOK_BACKEND_KOLAB, NULL);
/* At this point there may be some more initialization before returning
* kolab.
*/
-
+
return E_BOOK_BACKEND (kolab);
} /* e_book_backend_kolab_new () */
-static void
-e_book_backend_kolab_init (EBookBackendKolab *kolab)
-{
- /* TODO: Add initialization code here */
- EBookBackendKolabPrivate *priv = E_BOOK_BACKEND_KOLAB_PRIVATE (kolab);
-g_debug ("%s()[%u] called.", __func__, __LINE__);
- priv->book_mode = E_DATA_BOOK_MODE_LOCAL; /* Start in local mode for now. */
- priv->book_cache = NULL;
- priv->book_uri = NULL;
- priv->koma_table = NULL;
- priv->book_koma = NULL;
- priv->auth_received = FALSE;
-} /* e_book_backend_kolab_init () */
-
-static void
-e_book_backend_kolab_dispose (GObject *object)
-{
- EBookBackendKolabPrivate *priv = E_BOOK_BACKEND_KOLAB_PRIVATE (object);
-g_debug ("%s()[%u] called.", __func__, __LINE__);
- if (e_book_backend_is_loaded (E_BOOK_BACKEND (object))) {
- e_book_backend_set_is_writable (E_BOOK_BACKEND (object), FALSE);
- e_book_backend_notify_writable (E_BOOK_BACKEND (object), FALSE);
- e_book_backend_notify_connection_status (E_BOOK_BACKEND (object), FALSE);
- e_book_backend_set_is_loaded (E_BOOK_BACKEND (object), FALSE);
- g_object_unref (priv->book_koma);
- priv->book_koma = NULL;
- }
- if (priv->book_cache != NULL) {
- (void) e_file_cache_remove (E_FILE_CACHE (priv->book_cache));
- g_object_unref (priv->book_cache);
- priv->book_cache = NULL;
- }
- if (priv->book_uri != NULL) {
- g_free (priv->book_uri);
- priv->book_uri = NULL;
- }
-}
-
-static void
-e_book_backend_kolab_finalize (GObject *object)
-{
-g_debug ("%s()[%u] called.", __func__, __LINE__);
-
- G_OBJECT_CLASS (e_book_backend_kolab_parent_class)->finalize (object);
-} /* e_book_backend_kolab_finalize () */
-
-static void
-e_book_backend_kolab_class_init (EBookBackendKolabClass *klass)
-{
- GObjectClass* object_class = G_OBJECT_CLASS (klass);
- EBookBackendClass *backend_class = E_BOOK_BACKEND_CLASS (klass);
- EBookBackendSyncClass *sync_class = E_BOOK_BACKEND_SYNC_CLASS (klass);
-g_debug ("%s()[%u] called.", __func__, __LINE__);
- g_type_class_add_private (klass, sizeof (EBookBackendKolabPrivate));
-
- /* Sync backend class methods */
- sync_class->remove_sync = e_book_backend_kolab_remove;
- sync_class->create_contact_sync = e_book_backend_kolab_create_contact;
- sync_class->remove_contacts_sync = e_book_backend_kolab_remove_contacts;
- sync_class->modify_contact_sync = e_book_backend_kolab_modify_contact;
- sync_class->get_contact_sync = e_book_backend_kolab_get_contact;
- sync_class->get_contact_list_sync = e_book_backend_kolab_get_contact_list;
- sync_class->get_changes_sync = e_book_backend_kolab_get_changes;
- sync_class->authenticate_user_sync = e_book_backend_kolab_authenticate_user;
- sync_class->get_required_fields_sync = e_book_backend_kolab_get_required_fields;
- sync_class->get_supported_fields_sync = e_book_backend_kolab_get_supported_fields;
- sync_class->get_supported_auth_methods_sync = e_book_backend_kolab_get_supported_auth_methods;
-
- /* Backend parent class methods methods covered in the sync backend part
- * are commented. */
- backend_class->load_source = e_book_backend_kolab_load_source;
- /* backend_class->remove; */
- backend_class->get_static_capabilities = e_book_backend_kolab_get_static_capabilities;
- /* backend_class->create_contact; */
- /* backend_class->remove_contacts; */
- /* backend_class->modify_contact; */
- /* backend_class->get_contact; */
- /* backend_class->get_contact_list; */
- backend_class->start_book_view = e_book_backend_kolab_start_book_view;
- backend_class->stop_book_view = e_book_backend_kolab_stop_book_view;
- /* backend_class->get_changes; */
- /* backend_class->authenticate_user; */
- /* backend_class->get_required_fields */
- /* backend_class->get_supported_fields; */
- /* backend_class->get_supported_auth_methods; */
- backend_class->cancel_operation = e_book_backend_kolab_cancel_operation;
- backend_class->set_mode = e_book_backend_kolab_set_mode;
-
- object_class->finalize = e_book_backend_kolab_finalize;
- object_class->dispose = e_book_backend_kolab_dispose;
-} /* e_book_backend_kolab_class_init () */
-
+#endif /* FIXME old */
diff --git a/src/addressbook/e-book-backend-kolab.h b/src/addressbook/e-book-backend-kolab.h
index be6284d..e2e7906 100644
--- a/src/addressbook/e-book-backend-kolab.h
+++ b/src/addressbook/e-book-backend-kolab.h
@@ -1,63 +1,87 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/***************************************************************************
+ * e-book-backend-kolab.h
+ *
+ * 2010
+ * Copyright 2010 Christian Hilberg
+ * <hilberg kernelconcepts de>
+ * and Silvan Marco Fin <silvan kernelconcepts de> in 2011
+ ****************************************************************************/
+
/*
- * evolution-kolab
- * Copyright (C) 2010 Christian Hilberg <hilberg kernelconcepts de>
- * and 2011 Silvan Marco Fin <silvan kernelconcepts de>
- *
- * evolution-kolab 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 3 of the License, or
- * (at your option) any later version.
- *
- * evolution-kolab 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, see <http://www.gnu.org/licenses/>.
+ * 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_BOOK_BACKEND_KOLAB_H_
#define _E_BOOK_BACKEND_KOLAB_H_
-#include <glib-object.h>
-#include <libedata-book/e-book-backend.h>
+/*----------------------------------------------------------------------------*/
+
#include <libedata-book/e-book-backend-sync.h>
-G_BEGIN_DECLS
+/*----------------------------------------------------------------------------*/
-/**
- * SECTION:e-book-backend-kolab
- * @title: EBookBackendKolab
- * @short_description: Evolution addressbook backend API implementation for Evolution-Kolab plugin.
- */
+/* Standard GObject macros */
+#define E_TYPE_BOOK_BACKEND_KOLAB \
+ (e_book_backend_kolab_get_type ())
+#define E_BOOK_BACKEND_KOLAB(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_BOOK_BACKEND_KOLAB, EBookBackendKolab))
+#define E_BOOK_BACKEND_KOLAB__CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_BOOK_BACKEND_KOLAB, EBookBackendKolabClass))
+#define E_IS_BOOK_BACKEND_KOLAB(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_BOOK_BACKEND_KOLAB))
+#define E_IS_BOOK_BACKEND_KOLAB_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_BOOK_BACKEND_KOLAB))
+#define E_BOOK_BACKEND_KOLAB_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_BOOK_BACKEND_KOLAB, EBookBackendKolabClass))
-#define E_TYPE_BOOK_BACKEND_KOLAB (e_book_backend_kolab_get_type ())
-#define E_BOOK_BACKEND_KOLAB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_BOOK_BACKEND_KOLAB, EBookBackendKolab))
-#define E_BOOK_BACKEND_KOLAB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_BOOK_BACKEND_KOLAB, EBookBackendKolabClass))
-#define E_IS_BOOK_BACKEND_KOLAB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_BOOK_BACKEND_KOLAB))
-#define E_IS_BOOK_BACKEND_KOLAB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_BOOK_BACKEND_KOLAB))
-#define E_BOOK_BACKEND_KOLAB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_BOOK_BACKEND_KOLAB, EBookBackendKolabClass))
+G_BEGIN_DECLS
-typedef struct _EBookBackendKolabClass EBookBackendKolabClass;
typedef struct _EBookBackendKolab EBookBackendKolab;
+struct _EBookBackendKolab {
+ EBookBackendSync parent_object;
+};
-struct _EBookBackendKolabClass
-{
+typedef struct _EBookBackendKolabClass EBookBackendKolabClass;
+struct _EBookBackendKolabClass {
EBookBackendSyncClass parent_class;
};
-struct _EBookBackendKolab
-{
- EBookBackendSync parent_instance;
-};
+GType
+e_book_backend_kolab_get_type (void) G_GNUC_CONST;
-EBookBackend* e_book_backend_kolab_new (void);
-GType e_book_backend_kolab_get_type (void) G_GNUC_CONST;
+#if 0
+EBookBackend*
+e_book_backend_kolab_new (void);
-void e_book_backend_kolab_set_koma_table (EBookBackendKolab *kolab, GHashTable *koma_objects);
+void
+e_book_backend_kolab_set_koma_table (EBookBackendKolab *kolab,
+ GHashTable *koma_objects);
+#endif
G_END_DECLS
+/*----------------------------------------------------------------------------*/
+
#endif /* _E_BOOK_BACKEND_KOLAB_H_ */
+
+/*----------------------------------------------------------------------------*/
diff --git a/src/addressbook/kolab-util-contact.h b/src/addressbook/kolab-util-contact.h
index 5c7daa2..725779a 100644
--- a/src/addressbook/kolab-util-contact.h
+++ b/src/addressbook/kolab-util-contact.h
@@ -2,17 +2,17 @@
/*
* evolution-kolab
* Copyright (C) Silvan Marco Fin 2011 <silvan kernelconcepts de>
- *
+ *
* evolution-kolab 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 3 of the License, or
* (at your option) any later version.
- *
+ *
* evolution-kolab 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, see <http://www.gnu.org/licenses/>.
*/
@@ -20,21 +20,24 @@
#ifndef _KOLAB_UTIL_CONTACT_H_
#define _KOLAB_UTIL_CONTACT_H_
-#include <libekolab/kolab-mail-access.h>
-
#include <glib-object.h>
#include <libebook/e-contact.h>
#include <libedata-book/e-data-book-types.h>
#include <libedata-book/e-book-backend-sync.h>
+#include <libekolab/kolab-mail-access.h>
+
G_BEGIN_DECLS
gboolean kolab_util_contact_has_id (EContact *contact);
void kolab_util_contact_gen_uid_if_none (EContact **contact);
KolabMailAccessOpmodeID kolab_util_contact_deploy_mode_by_koma (KolabMailAccess *koma, KolabMailAccessOpmodeID koma_mode);
-gboolean kolab_util_contact_deploy_mode_by_backend (KolabMailAccess *koma, GNOME_Evolution_Addressbook_BookMode backend_mode);
void kolab_util_contact_store (EContact *econtact, KolabMailAccess *koma, const gchar *uri, GError **error);
+
+#if 0
+gboolean kolab_util_contact_deploy_mode_by_backend (KolabMailAccess *koma, GNOME_Evolution_Addressbook_BookMode backend_mode);
EBookBackendSyncStatus kolab_util_contact_map_error (GError *error);
+#endif
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]