[evolution-data-server] Adapt EBookBackendWebdav to libedata-book changes.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Adapt EBookBackendWebdav to libedata-book changes.
- Date: Mon, 26 Sep 2011 13:47:45 +0000 (UTC)
commit 9664d16f23285cb6db397a22f52a9b50323f2823
Author: Matthew Barnes <mbarnes redhat com>
Date: Fri Sep 9 13:19:54 2011 -0400
Adapt EBookBackendWebdav to libedata-book changes.
.../webdav/e-book-backend-webdav-factory.c | 49 ++++++++++++++----
.../backends/webdav/e-book-backend-webdav.c | 45 +++++++----------
.../backends/webdav/e-book-backend-webdav.h | 53 +++++++++++++-------
3 files changed, 91 insertions(+), 56 deletions(-)
---
diff --git a/addressbook/backends/webdav/e-book-backend-webdav-factory.c b/addressbook/backends/webdav/e-book-backend-webdav-factory.c
index 794a59d..23c0de2 100644
--- a/addressbook/backends/webdav/e-book-backend-webdav-factory.c
+++ b/addressbook/backends/webdav/e-book-backend-webdav-factory.c
@@ -18,27 +18,54 @@
*
* Author: Matthias Braun <matze braunis de>
*/
-#include <string.h>
-#include "libebackend/e-data-server-module.h"
-#include "libedata-book/e-book-backend-factory.h"
+#include <config.h>
+
+#include <libedata-book/e-book-backend-factory.h>
#include "e-book-backend-webdav.h"
-E_BOOK_BACKEND_FACTORY_SIMPLE (webdav, Webdav, e_book_backend_webdav_new)
+#define FACTORY_NAME "webdav"
+
+typedef EBookBackendFactory EBookBackendWebdavFactory;
+typedef EBookBackendFactoryClass EBookBackendWebdavFactoryClass;
+
+/* Module Entry Points */
+void e_module_load (GTypeModule *type_module);
+void e_module_unload (GTypeModule *type_module);
-static GType webdav_type;
+/* Forward Declarations */
+GType e_book_backend_webdav_factory_get_type (void);
-void eds_module_initialize (GTypeModule *module)
+G_DEFINE_DYNAMIC_TYPE (
+ EBookBackendWebdavFactory,
+ e_book_backend_webdav_factory,
+ E_TYPE_BOOK_BACKEND_FACTORY)
+
+static void
+e_book_backend_webdav_factory_class_init (EBookBackendFactoryClass *class)
{
- webdav_type = _webdav_factory_get_type (module);
+ class->factory_name = FACTORY_NAME;
+ class->backend_type = E_TYPE_BOOK_BACKEND_WEBDAV;
}
-void eds_module_shutdown (void)
+static void
+e_book_backend_webdav_factory_class_finalize (EBookBackendFactoryClass *class)
{
}
-void eds_module_list_types (const GType **types, gint *num_types)
+static void
+e_book_backend_webdav_factory_init (EBookBackendFactory *factory)
{
- *types = &webdav_type;
- *num_types = 1;
}
+
+G_MODULE_EXPORT void
+e_module_load (GTypeModule *type_module)
+{
+ e_book_backend_webdav_factory_register_type (type_module);
+}
+
+G_MODULE_EXPORT void
+e_module_unload (GTypeModule *type_module)
+{
+}
+
diff --git a/addressbook/backends/webdav/e-book-backend-webdav.c b/addressbook/backends/webdav/e-book-backend-webdav.c
index 3f2e24f..0a40fa8 100644
--- a/addressbook/backends/webdav/e-book-backend-webdav.c
+++ b/addressbook/backends/webdav/e-book-backend-webdav.c
@@ -64,7 +64,6 @@ G_DEFINE_TYPE (EBookBackendWebdav, e_book_backend_webdav, E_TYPE_BOOK_BACKEND)
static EBookBackendClass *parent_class;
struct _EBookBackendWebdavPrivate {
- gboolean is_online;
gboolean marked_for_offline;
SoupSession *session;
EProxy *proxy;
@@ -202,7 +201,7 @@ upload_contact (EBookBackendWebdav *webdav,
const gchar *property;
gboolean avoid_ifmatch;
- source = e_book_backend_get_source (E_BOOK_BACKEND (webdav));
+ source = e_backend_get_source (E_BACKEND (webdav));
uri = e_contact_get (contact, E_CONTACT_UID);
if (uri == NULL) {
@@ -316,7 +315,7 @@ e_book_backend_webdav_create_contact (EBookBackend *backend,
guint status;
gchar *status_reason = NULL;
- if (!priv->is_online) {
+ if (!e_backend_get_online (E_BACKEND (backend))) {
e_data_book_respond_create (book, opid, EDB_ERROR (REPOSITORY_OFFLINE), NULL);
return;
}
@@ -406,7 +405,7 @@ e_book_backend_webdav_remove_contacts (EBookBackend *backend,
GSList *deleted_ids = NULL;
const GSList *list;
- if (!priv->is_online) {
+ if (!e_backend_get_online (E_BACKEND (backend))) {
e_data_book_respond_remove_contacts (book, opid,
EDB_ERROR (REPOSITORY_OFFLINE), NULL);
return;
@@ -451,7 +450,7 @@ e_book_backend_webdav_modify_contact (EBookBackend *backend,
guint status;
gchar *status_reason = NULL;
- if (!priv->is_online) {
+ if (!e_backend_get_online (E_BACKEND (backend))) {
e_data_book_respond_create (book, opid,
EDB_ERROR (REPOSITORY_OFFLINE), NULL);
g_object_unref (contact);
@@ -522,7 +521,7 @@ e_book_backend_webdav_get_contact (EBookBackend *backend,
EContact *contact;
gchar *vcard;
- if (!priv->is_online) {
+ if (!e_backend_get_online (E_BACKEND (backend))) {
contact = e_book_backend_cache_get_contact (priv->cache, uid);
} else {
contact = download_contact (webdav, uid);
@@ -1037,7 +1036,7 @@ e_book_backend_webdav_start_book_view (EBookBackend *backend,
EBookBackendWebdav *webdav = E_BOOK_BACKEND_WEBDAV (backend);
EBookBackendWebdavPrivate *priv = webdav->priv;
- if (priv->is_online) {
+ if (e_backend_get_online (E_BACKEND (backend))) {
WebdavBackendSearchClosure *closure
= init_closure (book_view, E_BOOK_BACKEND_WEBDAV (backend));
@@ -1064,11 +1063,10 @@ static void
e_book_backend_webdav_stop_book_view (EBookBackend *backend,
EDataBookView *book_view)
{
- EBookBackendWebdav *webdav = E_BOOK_BACKEND_WEBDAV (backend);
WebdavBackendSearchClosure *closure;
gboolean need_join;
- if (!webdav->priv->is_online)
+ if (!e_backend_get_online (E_BACKEND (backend)))
return;
closure = get_closure (book_view);
@@ -1096,7 +1094,7 @@ e_book_backend_webdav_get_contact_list (EBookBackend *backend,
GSList *vcard_list;
GList *c;
- if (priv->is_online) {
+ if (e_backend_get_online (E_BACKEND (backend))) {
/* make sure the cache is up to date */
GError *error = download_contacts (webdav, NULL, NULL);
@@ -1137,7 +1135,7 @@ e_book_backend_webdav_get_contact_list_uids (EBookBackend *backend,
GSList *uids_list;
GList *c;
- if (priv->is_online) {
+ if (e_backend_get_online (E_BACKEND (backend))) {
/* make sure the cache is up to date */
GError *error = download_contacts (webdav, NULL, NULL);
@@ -1251,7 +1249,7 @@ e_book_backend_webdav_open (EBookBackend *backend,
/* will try fetch ctag for the first time, if it fails then sets this to FALSE */
priv->supports_getctag = TRUE;
- source = e_book_backend_get_source (backend);
+ source = e_backend_get_source (E_BACKEND (backend));
cache_dir = e_book_backend_get_cache_dir (backend);
uri = e_source_get_uri (source);
@@ -1272,7 +1270,7 @@ e_book_backend_webdav_open (EBookBackend *backend,
if (offline && g_str_equal(offline, "1"))
priv->marked_for_offline = TRUE;
- if (!priv->is_online && !priv->marked_for_offline ) {
+ if (!e_backend_get_online (E_BACKEND (backend)) && !priv->marked_for_offline ) {
soup_uri_free (suri);
e_book_backend_respond_opened (backend, book, opid, EDB_ERROR (OFFLINE_UNAVAILABLE));
return;
@@ -1360,18 +1358,14 @@ e_book_backend_webdav_remove (EBookBackend *backend,
}
static void
-e_book_backend_webdav_set_online (EBookBackend *backend,
- gboolean is_online)
+e_book_backend_webdav_notify_online_cb (EBookBackend *backend,
+ GParamSpec *pspec)
{
- EBookBackendWebdav *webdav = E_BOOK_BACKEND_WEBDAV (backend);
-
- webdav->priv->is_online = is_online;
-
/* set_mode is called before the backend is loaded */
if (!e_book_backend_is_opened (backend))
return;
- if (!is_online) {
+ if (!e_backend_get_online (E_BACKEND (backend))) {
e_book_backend_notify_readonly (backend, TRUE);
e_book_backend_notify_online (backend, FALSE);
} else {
@@ -1416,12 +1410,6 @@ e_book_backend_webdav_get_backend_property (EBookBackend *backend,
}
}
-EBookBackend *
-e_book_backend_webdav_new (void)
-{
- return g_object_new (E_TYPE_BOOK_BACKEND_WEBDAV, NULL);
-}
-
static void
e_book_backend_webdav_dispose (GObject *object)
{
@@ -1468,7 +1456,6 @@ e_book_backend_webdav_class_init (EBookBackendWebdavClass *klass)
backend_class->stop_book_view = e_book_backend_webdav_stop_book_view;
backend_class->authenticate_user = e_book_backend_webdav_authenticate_user;
backend_class->remove = e_book_backend_webdav_remove;
- backend_class->set_online = e_book_backend_webdav_set_online;
object_class->dispose = e_book_backend_webdav_dispose;
@@ -1481,5 +1468,9 @@ e_book_backend_webdav_init (EBookBackendWebdav *backend)
backend->priv = G_TYPE_INSTANCE_GET_PRIVATE (
backend, E_TYPE_BOOK_BACKEND_WEBDAV,
EBookBackendWebdavPrivate);
+
+ g_signal_connect (
+ backend, "notify::online",
+ G_CALLBACK (e_book_backend_webdav_notify_online_cb), NULL);
}
diff --git a/addressbook/backends/webdav/e-book-backend-webdav.h b/addressbook/backends/webdav/e-book-backend-webdav.h
index 60ebdbd..2e84b36 100644
--- a/addressbook/backends/webdav/e-book-backend-webdav.h
+++ b/addressbook/backends/webdav/e-book-backend-webdav.h
@@ -18,31 +18,48 @@
*
* Author: Matthias Braun <matze braunis de>
*/
-#ifndef __E_BOOK_BACKEND_WEBDAV_H__
-#define __E_BOOK_BACKEND_WEBDAV_H__
+#ifndef E_BOOK_BACKEND_WEBDAV_H
+#define E_BOOK_BACKEND_WEBDAV_H
#include <libedata-book/e-book-backend.h>
-#define E_TYPE_BOOK_BACKEND_WEBDAV (e_book_backend_webdav_get_type ())
-#define E_BOOK_BACKEND_WEBDAV(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_BOOK_BACKEND_WEBDAV, EBookBackendWebdav))
-#define E_BOOK_BACKEND_WEBDAV_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_TYPE_BOOK_BACKEND_WEBDAV, EBookBackendWebdavClass))
-#define E_IS_BOOK_BACKEND_WEBDAV(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_BOOK_BACKEND_WEBDAV))
-#define E_IS_BOOK_BACKEND_WEBDAV_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_BOOK_BACKEND_WEBDAV))
-#define E_BOOK_BACKEND_WEBDAV_GET_CLASS(k) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_BOOK_BACKEND_WEBDAV, EBookBackendWebdavClass))
+/* Standard GObject macros */
+#define E_TYPE_BOOK_BACKEND_WEBDAV \
+ (e_book_backend_webdav_get_type ())
+#define E_BOOK_BACKEND_WEBDAV(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_BOOK_BACKEND_WEBDAV, EBookBackendWebdav))
+#define E_BOOK_BACKEND_WEBDAV_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_BOOK_BACKEND_WEBDAV, EBookBackendWebdavClass))
+#define E_IS_BOOK_BACKEND_WEBDAV(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_BOOK_BACKEND_WEBDAV))
+#define E_IS_BOOK_BACKEND_WEBDAV_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_BOOK_BACKEND_WEBDAV))
+#define E_BOOK_BACKEND_WEBDAV_GET_CLASS(cls) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_BOOK_BACKEND_WEBDAV, EBookBackendWebdavClass))
+G_BEGIN_DECLS
+
+typedef struct _EBookBackendWebdav EBookBackendWebdav;
+typedef struct _EBookBackendWebdavClass EBookBackendWebdavClass;
typedef struct _EBookBackendWebdavPrivate EBookBackendWebdavPrivate;
-typedef struct {
- EBookBackend parent_object;
- EBookBackendWebdavPrivate *priv;
-} EBookBackendWebdav;
+struct _EBookBackendWebdav {
+ EBookBackend parent;
+ EBookBackendWebdavPrivate *priv;
+};
+
+struct _EBookBackendWebdavClass {
+ EBookBackendClass parent_class;
+};
-typedef struct {
- EBookBackendClass parent_class;
-} EBookBackendWebdavClass;
+GType e_book_backend_webdav_get_type (void);
-EBookBackend *e_book_backend_webdav_new (void);
-GType e_book_backend_webdav_get_type (void);
+G_END_DECLS
-#endif
+#endif /* E_BOOK_BACKEND_WEBDAV_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]