[evolution-data-server] Adapt EBookBackendFile to libedata-book changes.



commit c4129c17eba87af3594c24f00359505b43e74765
Author: Matthew Barnes <mbarnes redhat com>
Date:   Fri Sep 9 13:18:13 2011 -0400

    Adapt EBookBackendFile to libedata-book changes.

 .../backends/file/e-book-backend-file-factory.c    |   63 +++++--------------
 addressbook/backends/file/e-book-backend-file.c    |   22 +++----
 addressbook/backends/file/e-book-backend-file.h    |   49 ++++++++++-----
 3 files changed, 59 insertions(+), 75 deletions(-)
---
diff --git a/addressbook/backends/file/e-book-backend-file-factory.c b/addressbook/backends/file/e-book-backend-file-factory.c
index 05898d5..e67c50f 100644
--- a/addressbook/backends/file/e-book-backend-file-factory.c
+++ b/addressbook/backends/file/e-book-backend-file-factory.c
@@ -21,27 +21,21 @@
  * Authors: Chris Toshok <toshok ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
-#include <string.h>
-
-#include "libebackend/e-data-server-module.h"
-#include "libedata-book/e-book-backend-factory.h"
+#include <libedata-book/e-book-backend-factory.h>
 #include "e-book-backend-file.h"
 
-typedef struct _EBookBackendFileFactory EBookBackendFileFactory;
-typedef struct _EBookBackendFileFactoryClass EBookBackendFileFactoryClass;
+#define FACTORY_NAME "local"
 
-struct _EBookBackendFileFactory {
-	EBookBackendFactory parent;
-};
+typedef EBookBackendFactory EBookBackendFileFactory;
+typedef EBookBackendFactoryClass EBookBackendFileFactoryClass;
 
-struct _EBookBackendFileFactoryClass {
-	EBookBackendFactoryClass parent_class;
-};
+/* Module Entry Points */
+void e_module_load (GTypeModule *type_module);
+void e_module_unload (GTypeModule *type_module);
 
+/* Forward Declarations */
 GType e_book_backend_file_factory_get_type (void);
 
 G_DEFINE_DYNAMIC_TYPE (
@@ -49,54 +43,31 @@ G_DEFINE_DYNAMIC_TYPE (
 	e_book_backend_file_factory,
 	E_TYPE_BOOK_BACKEND_FACTORY)
 
-static const gchar *
-book_backend_file_factory_get_protocol (EBookBackendFactory *factory)
-{
-	return "local";
-}
-
-static EBookBackend *
-book_backend_file_factory_new_backend (EBookBackendFactory *factory)
-{
-	return e_book_backend_file_new ();
-}
-
 static void
-e_book_backend_file_factory_class_init (EBookBackendFileFactoryClass *class)
+e_book_backend_file_factory_class_init (EBookBackendFactoryClass *class)
 {
-	EBookBackendFactoryClass *factory_class;
-
-	factory_class = E_BOOK_BACKEND_FACTORY_CLASS (class);
-	factory_class->get_protocol = book_backend_file_factory_get_protocol;
-	factory_class->new_backend = book_backend_file_factory_new_backend;
+	class->factory_name = FACTORY_NAME;
+	class->backend_type = E_TYPE_BOOK_BACKEND_FILE;
 }
 
 static void
-e_book_backend_file_factory_class_finalize (EBookBackendFileFactoryClass *class)
+e_book_backend_file_factory_class_finalize (EBookBackendFactoryClass *class)
 {
 }
 
 static void
-e_book_backend_file_factory_init (EBookBackendFileFactory *factory)
+e_book_backend_file_factory_init (EBookBackendFactory *factory)
 {
 }
 
-void
-eds_module_initialize (GTypeModule *type_module)
+G_MODULE_EXPORT void
+e_module_load (GTypeModule *type_module)
 {
 	e_book_backend_file_factory_register_type (type_module);
 }
 
-void
-eds_module_shutdown (void)
-{
-}
-
-void
-eds_module_list_types (const GType **types,
-                       gint *num_types)
+G_MODULE_EXPORT void
+e_module_unload (GTypeModule *type_module)
 {
-	*types = &e_book_backend_file_factory_type_id;
-	*num_types = 1;
 }
 
diff --git a/addressbook/backends/file/e-book-backend-file.c b/addressbook/backends/file/e-book-backend-file.c
index 596a902..7f2f330 100644
--- a/addressbook/backends/file/e-book-backend-file.c
+++ b/addressbook/backends/file/e-book-backend-file.c
@@ -1176,7 +1176,7 @@ e_book_backend_file_open (EBookBackendSync *backend,
 	EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend);
 	gchar            *dirname, *filename;
 	gboolean          readonly = TRUE;
-	ESource          *source = e_book_backend_get_source (E_BOOK_BACKEND (backend));
+	ESource          *source;
 	gint              db_error;
 	DB               *db;
 	DB_ENV           *env;
@@ -1186,6 +1186,7 @@ e_book_backend_file_open (EBookBackendSync *backend,
 	gboolean create_default_vcard = FALSE;
 #endif
 
+	source = e_backend_get_source (E_BACKEND (backend));
 	dirname = e_book_backend_file_extract_path_from_source (source);
 	filename = g_build_filename (dirname, "addressbook.db", NULL);
 
@@ -1499,8 +1500,8 @@ e_book_backend_file_get_backend_property (EBookBackendSync *backend,
 }
 
 static void
-e_book_backend_file_set_online (EBookBackend *backend,
-                                gboolean is_online)
+e_book_backend_file_notify_online_cb (EBookBackend *backend,
+                                      GParamSpec *pspec)
 {
 	if (e_book_backend_is_opened (backend))
 		e_book_backend_notify_online (backend, TRUE);
@@ -1571,15 +1572,6 @@ e_book_backend_file_notify_update (EBookBackend *backend,
 	e_book_backend_foreach_view (backend, view_notify_update, &data);
 }
 
-/**
- * e_book_backend_file_new:
- */
-EBookBackend *
-e_book_backend_file_new (void)
-{
-	return g_object_new (E_TYPE_BOOK_BACKEND_FILE, NULL);
-}
-
 static void
 e_book_backend_file_dispose (GObject *object)
 {
@@ -1684,7 +1676,6 @@ e_book_backend_file_class_init (EBookBackendFileClass *klass)
 	/* Set the virtual methods. */
 	backend_class->start_book_view		= e_book_backend_file_start_book_view;
 	backend_class->stop_book_view		= e_book_backend_file_stop_book_view;
-	backend_class->set_online		= e_book_backend_file_set_online;
 	backend_class->sync			= e_book_backend_file_sync;
 	backend_class->notify_update            = e_book_backend_file_notify_update;
 
@@ -1722,4 +1713,9 @@ e_book_backend_file_init (EBookBackendFile *backend)
 	priv             = g_new0 (EBookBackendFilePrivate, 1);
 
 	backend->priv = priv;
+
+	g_signal_connect (
+		backend, "notify::online",
+		G_CALLBACK (e_book_backend_file_notify_online_cb), NULL);
 }
+
diff --git a/addressbook/backends/file/e-book-backend-file.h b/addressbook/backends/file/e-book-backend-file.h
index 981c41f..4c64ddf 100644
--- a/addressbook/backends/file/e-book-backend-file.h
+++ b/addressbook/backends/file/e-book-backend-file.h
@@ -23,31 +23,48 @@
  *          Hans Petter Jansson <hpj novell com>
  */
 
-#ifndef __E_BOOK_BACKEND_FILE_H__
-#define __E_BOOK_BACKEND_FILE_H__
+#ifndef E_BOOK_BACKEND_FILE_H
+#define E_BOOK_BACKEND_FILE_H
 
 #include <libedata-book/e-book-backend-sync.h>
 
-#define E_TYPE_BOOK_BACKEND_FILE        (e_book_backend_file_get_type ())
-#define E_BOOK_BACKEND_FILE(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_BOOK_BACKEND_FILE, EBookBackendFile))
-#define E_BOOK_BACKEND_FILE_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), E_TYPE_BOOK_BACKEND_FILE, EBookBackendFileClass))
-#define E_IS_BOOK_BACKEND_FILE(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_BOOK_BACKEND_FILE))
-#define E_IS_BOOK_BACKEND_FILE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_BOOK_BACKEND_FILE))
-#define E_BOOK_BACKEND_FILE_GET_CLASS(k) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_BOOK_BACKEND_FILE, EBookBackendFileClass))
+/* Standard GObject macros */
+#define E_TYPE_BOOK_BACKEND_FILE \
+	(e_book_backend_file_get_type ())
+#define E_BOOK_BACKEND_FILE(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_BOOK_BACKEND_FILE, EBookBackendFile))
+#define E_BOOK_BACKEND_FILE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_BOOK_BACKEND_FILE, EBookBackendFileClass))
+#define E_IS_BOOK_BACKEND_FILE(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_BOOK_BACKEND_FILE))
+#define E_IS_BOOK_BACKEND_FILE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_BOOK_BACKEND_FILE))
+#define E_BOOK_BACKEND_FILE_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_BOOK_BACKEND_FILE, EBookBackendFileClass))
 
+G_BEGIN_DECLS
+
+typedef struct _EBookBackendFile EBookBackendFile;
+typedef struct _EBookBackendFileClass EBookBackendFileClass;
 typedef struct _EBookBackendFilePrivate EBookBackendFilePrivate;
 
-typedef struct {
-	EBookBackendSync         parent_object;
+struct _EBookBackendFile {
+	EBookBackendSync parent;
 	EBookBackendFilePrivate *priv;
-} EBookBackendFile;
+};
 
-typedef struct {
+struct _EBookBackendFileClass {
 	EBookBackendSyncClass parent_class;
-} EBookBackendFileClass;
+};
+
+GType		e_book_backend_file_get_type	(void);
 
-EBookBackend *e_book_backend_file_new      (void);
-GType       e_book_backend_file_get_type (void);
+G_END_DECLS
 
-#endif /* __E_BOOK_BACKEND_FILE_H__ */
+#endif /* E_BOOK_BACKEND_FILE_H */
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]