[evolution-kolab/ek-wip-porting] EBookBackendKolabFactory: rewrite to 3.x E-D-S API



commit d264fcaa81ac0bf1bbeeda6fb1e76e815337cb69
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Fri Dec 9 19:21:06 2011 +0100

    EBookBackendKolabFactory: rewrite to 3.x E-D-S API
    
    * use new GTypeModule API
    * let E-D-S handle address book creation
    * removed GHashTable of KolabMailAccess objects
      (will need to live as a static in e-book-backend-kolab.c)

 src/addressbook/e-book-backend-kolab-factory.c |  113 ++++++++----------------
 1 files changed, 38 insertions(+), 75 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-kolab-factory.c b/src/addressbook/e-book-backend-kolab-factory.c
index 7ac513c..a263fd3 100644
--- a/src/addressbook/e-book-backend-kolab-factory.c
+++ b/src/addressbook/e-book-backend-kolab-factory.c
@@ -13,12 +13,12 @@
  * 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
@@ -26,102 +26,65 @@
 
 /*----------------------------------------------------------------------------*/
 
-#include "e-book-backend-kolab.h"
-
-#include <libekolabutil/kolab-util-camel.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
-#include <libebackend/e-data-server-module.h>
 #include <libedata-book/e-book-backend-factory.h>
+#include <libekolabutil/kolab-util-camel.h>
 
-typedef struct {
-	EBookBackendFactory      parent_object;
-} EBookBackendKolab2Factory;
+#include "e-book-backend-kolab.h"
 
-typedef struct {
-	EBookBackendFactoryClass parent_class;
-} EBookBackendKolab2FactoryClass;
+/*----------------------------------------------------------------------------*/
 
-static GHashTable *koma_objects = NULL;
+#define FACTORY_NAME "kolab2"
 
-static void
-_kolab2_factory_instance_init (EBookBackendKolab2Factory *factory)
-{
-	(void) factory;
-}
+/*----------------------------------------------------------------------------*/
 
-static const gchar *
-_kolab2_get_protocol (EBookBackendFactory *factory)
-{
-	(void) factory;
-	return KOLAB_CAMEL_PROVIDER_PROTOCOL;
-}
+/* factory types */
+typedef EBookBackendFactory EBookBackendKolabFactory;
+typedef EBookBackendFactoryClass EBookBackendKolabFactoryClass;
 
-static EBookBackend*
-_kolab2_new_backend (EBookBackendFactory *factory)
-{
-	EBookBackend *new_backend = NULL;
+/* module entry points */
+void e_module_load (GTypeModule *type_module);
+void e_module_unload (GTypeModule *type_module);
 
-	(void) factory;
+/* forward declarations */
+GType e_book_backend_kolab_factory_get_type (void);
 
-	new_backend = e_book_backend_kolab_new ();
-	if (koma_objects == NULL)
-		koma_objects = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
-	e_book_backend_kolab_set_koma_table (E_BOOK_BACKEND_KOLAB (new_backend), koma_objects);
-	return new_backend;
-}
+G_DEFINE_DYNAMIC_TYPE (EBookBackendKolabFactory,
+                       e_book_backend_kolab_factory,
+                       E_TYPE_BOOK_BACKEND_FACTORY)
 
 static void
-_kolab2_factory_class_init (EBookBackendKolab2FactoryClass *klass)
+e_book_backend_kolab_factory_class_init (EBookBackendFactoryClass *klass)
 {
-	E_BOOK_BACKEND_FACTORY_CLASS (klass)->get_protocol = _kolab2_get_protocol;
-	E_BOOK_BACKEND_FACTORY_CLASS (klass)->new_backend = _kolab2_new_backend;
+	klass->factory_name = FACTORY_NAME;
+	klass->backend_type = E_TYPE_BOOK_BACKEND_KOLAB;
 }
 
-static GType
-_kolab2_factory_get_type (GTypeModule *module)
+static void
+e_book_backend_kolab_factory_class_finalize (EBookBackendFactoryClass *klass)
 {
-	GType type;
-	
-	const GTypeInfo info = {
-		sizeof (EBookBackendKolab2FactoryClass),
-		NULL, /* base_class_init */
-		NULL, /* base_class_finalize */
-		(GClassInitFunc)  _kolab2_factory_class_init,
-		NULL, /* class_finalize */
-		NULL, /* class_data */
-		sizeof (EBookBackendKolab2Factory),
-		0,    /* n_preallocs */
-		(GInstanceInitFunc) _kolab2_factory_instance_init,
-		NULL /* GTypeValueTable */
-	};
-
-	type = g_type_module_register_type (module,
-					    E_TYPE_BOOK_BACKEND_FACTORY,
-					    "EBookBackendKolab2Factory",
-					    &info, 0);
-
-	return type;
+	(void)klass;
 }
 
-static GType kolab_type;
-
-void
-eds_module_initialize (GTypeModule *module)
+static void
+e_book_backend_kolab_factory_init (EBookBackendFactory *factory)
 {
-	g_debug ("%s() called.", __func__);
-	kolab_type = _kolab2_factory_get_type (module);
+	(void)factory;
 }
 
-void
-eds_module_shutdown (void)
+G_MODULE_EXPORT void
+e_module_load (GTypeModule *type_module)
 {
-	g_debug ("%s() from the EBookBackendKolabFactory called.", __func__);
+	e_book_backend_kolab_factory_register_type (type_module);
 }
 
-void
-eds_module_list_types (const GType **types, gint *num_types)
+G_MODULE_EXPORT void
+e_module_unload (GTypeModule *type_module)
 {
-	g_debug ("%s() called.", __func__);
-	*types = &kolab_type;
-	*num_types = 1;
+	(void)type_module;
 }
+
+/*----------------------------------------------------------------------------*/



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