[evolution-kolab/ek-wip-porting] CamelKolabIMAPXConnManager: cleanup subclassing



commit 1b2611da7566e1b78dbe1951af7c4d05d06f635d
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Fri Jan 13 19:48:08 2012 +0100

    CamelKolabIMAPXConnManager: cleanup subclassing
    
    * removed API functions
    * moved implementation to class functions, accessible
      now via the parent class' API functions
    * sanitization of type checking in class functions

 src/camel/camel-kolab-imapx-conn-manager.c |  185 ++++++++++++++--------------
 src/camel/camel-kolab-imapx-conn-manager.h |   20 ---
 2 files changed, 93 insertions(+), 112 deletions(-)
---
diff --git a/src/camel/camel-kolab-imapx-conn-manager.c b/src/camel/camel-kolab-imapx-conn-manager.c
index 9ca87ee..b3d9504 100644
--- a/src/camel/camel-kolab-imapx-conn-manager.c
+++ b/src/camel/camel-kolab-imapx-conn-manager.c
@@ -33,7 +33,7 @@
 
 /*----------------------------------------------------------------------------*/
 
-/* dupe of enum in providers/imapx/camel-imapx-conn-manager.c */
+/* dupe of enum in camel/providers/imapx/camel-imapx-conn-manager.c */
 enum {
 	PROP_0,
 	PROP_STORE
@@ -42,7 +42,7 @@ enum {
 G_DEFINE_TYPE (CamelKolabIMAPXConnManager, camel_kolab_imapx_conn_manager, CAMEL_TYPE_IMAPX_EXTD_CONN_MANAGER)
 
 /*----------------------------------------------------------------------------*/
-/* object/class init */
+/* object init */
 
 static void
 camel_kolab_imapx_conn_manager_init (CamelKolabIMAPXConnManager *self)
@@ -66,71 +66,29 @@ camel_kolab_imapx_conn_manager_finalize (GObject *object)
 	G_OBJECT_CLASS (camel_kolab_imapx_conn_manager_parent_class)->finalize (object);
 }
 
-static void
-camel_kolab_imapx_conn_manager_class_init (CamelKolabIMAPXConnManagerClass *klass)
-{
-	GObjectClass *object_class = G_OBJECT_CLASS (klass);
-	GObjectClass *gobj_p_class = NULL;
-
-	gobj_p_class = G_OBJECT_CLASS (camel_kolab_imapx_conn_manager_parent_class);
-	object_class->set_property = gobj_p_class->set_property;
-	object_class->get_property = gobj_p_class->get_property;
-
-	object_class->dispose = camel_kolab_imapx_conn_manager_dispose;
-	object_class->finalize = camel_kolab_imapx_conn_manager_finalize;
-
-	/* duped from parent */
-	g_object_class_install_property (object_class,
-	                                 PROP_STORE,
-	                                 g_param_spec_object ("store",
-	                                                      "Store",
-	                                                      "The CamelStore to which we belong",
-	                                                      CAMEL_TYPE_STORE,
-	                                                      G_PARAM_READWRITE |
-	                                                      G_PARAM_CONSTRUCT_ONLY |
-	                                                      G_PARAM_STATIC_STRINGS));
-}
-
 /*----------------------------------------------------------------------------*/
-/* API functions */
-
-CamelKolabIMAPXConnManager*
-camel_kolab_imapx_conn_manager_new (CamelKolabIMAPXStore *store)
-{
-	CamelKolabIMAPXConnManager *self = NULL;
-
-	g_return_val_if_fail (CAMEL_IS_KOLAB_IMAPX_STORE (store), NULL);
-
-	self = g_object_new (CAMEL_TYPE_KOLAB_IMAPX_CONN_MANAGER,
-	                     "store",
-	                     CAMEL_STORE (store),
-	                     NULL);
-	return self;
-}
+/* class functions */
 
-CamelKolabIMAPXStore*
-camel_kolab_imapx_conn_manager_get_store (CamelKolabIMAPXConnManager *self)
+static CamelStore*
+kolab_imapx_conn_manager_get_store (CamelIMAPXConnManager *self)
 {
-	CamelIMAPXExtdStore *store = NULL;
-	CamelIMAPXExtdConnManager *con_man = NULL;
+	CamelStore *store = NULL;
 
-	g_return_val_if_fail (CAMEL_IS_KOLAB_IMAPX_CONN_MANAGER (self), NULL);
+	g_assert (CAMEL_IS_KOLAB_IMAPX_CONN_MANAGER (self));
 
-	con_man = CAMEL_IMAPX_EXTD_CONN_MANAGER (self);
-	store = camel_imapx_extd_conn_manager_get_store (con_man);
+	store = camel_imapx_extd_conn_manager_get_store (self);
+	g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (store));
 
-	return CAMEL_KOLAB_IMAPX_STORE (store);
+	return store;
 }
 
-CamelKolabIMAPXServer*
-camel_kolab_imapx_conn_manager_get_connection (CamelKolabIMAPXConnManager *self,
-                                               const gchar *foldername,
-                                               GCancellable *cancellable,
-                                               GError **err)
+static CamelIMAPXServer*
+kolab_imapx_conn_manager_get_connection (CamelIMAPXConnManager *self,
+                                         const gchar *foldername,
+                                         GCancellable *cancellable,
+                                         GError **err)
 {
-	CamelIMAPXExtdServer *es = NULL;
-	CamelKolabIMAPXServer *ks = NULL;
-	CamelIMAPXExtdConnManager *con_man = NULL;
+	CamelIMAPXServer *server = NULL;
 	GError *tmp_err = NULL;
 
 	g_assert (CAMEL_IS_KOLAB_IMAPX_CONN_MANAGER (self));
@@ -138,64 +96,107 @@ camel_kolab_imapx_conn_manager_get_connection (CamelKolabIMAPXConnManager *self,
 	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, NULL);
 
-	con_man = CAMEL_IMAPX_EXTD_CONN_MANAGER (self);
-	es = camel_imapx_extd_conn_manager_get_connection (con_man,
-	                                                   foldername,
-	                                                   cancellable,
-	                                                   &tmp_err);
-	if (es == NULL) {
-		g_propagate_error (err, tmp_err);
+	server = camel_imapx_extd_conn_manager_get_connection (self,
+	                                                       foldername,
+	                                                       cancellable,
+	                                                       &tmp_err);
+	if (server == NULL) {
+		if (tmp_err != NULL)
+			g_propagate_error (err, tmp_err);
 		return NULL;
 	}
 
-	ks = CAMEL_KOLAB_IMAPX_SERVER (es);
+	g_assert (CAMEL_IS_KOLAB_IMAPX_SERVER (server));
 
-	return ks;
+	return server;
 }
 
-void
-camel_kolab_imapx_conn_manager_close_connections (CamelKolabIMAPXConnManager *self)
+static void
+kolab_imapx_conn_manager_close_connections (CamelIMAPXConnManager *self)
 {
-	CamelIMAPXExtdConnManager *con_man = NULL;
-
 	g_assert (CAMEL_IS_KOLAB_IMAPX_CONN_MANAGER (self));
 
-	con_man = CAMEL_IMAPX_EXTD_CONN_MANAGER (self);
-	camel_imapx_extd_conn_manager_close_connections (con_man);
+	camel_imapx_extd_conn_manager_close_connections (self);
 }
 
-GList*
-camel_kolab_imapx_conn_manager_get_connections (CamelKolabIMAPXConnManager *self)
+static GList*
+kolab_imapx_conn_manager_get_connections (CamelIMAPXConnManager *self)
 {
 	GList *cn = NULL;
-	CamelIMAPXExtdConnManager *con_man = NULL;
 
 	g_assert (CAMEL_IS_KOLAB_IMAPX_CONN_MANAGER (self));
 
-	con_man = CAMEL_IMAPX_EXTD_CONN_MANAGER (self);
-	cn = camel_imapx_extd_conn_manager_get_connections (con_man);
+	cn = camel_imapx_extd_conn_manager_get_connections (self);
+
+	/* TODO type-check list elements? */
 
 	return cn;
 }
 
-void
-camel_kolab_imapx_conn_manager_update_con_info (CamelKolabIMAPXConnManager *self,
-                                                CamelKolabIMAPXServer *server,
-                                                const gchar *foldername)
+static void
+kolab_imapx_conn_manager_update_con_info (CamelIMAPXConnManager *self,
+                                          CamelIMAPXServer *server,
+                                          const gchar *foldername)
 {
-	CamelIMAPXExtdConnManager *con_man = NULL;
-	CamelIMAPXExtdServer *es = NULL;
-
-	g_assert (CAMEL_IS_KOLAB_IMAPX_CONN_MANAGER (con_man));
-	g_assert (CAMEL_IS_KOLAB_IMAPX_SERVER (server));
+	g_assert (CAMEL_IS_KOLAB_IMAPX_CONN_MANAGER (self));
+	g_assert (CAMEL_IS_IMAPX_SERVER (server));
 	g_assert (foldername != NULL);
 
-	con_man = CAMEL_IMAPX_EXTD_CONN_MANAGER (self);
-	es = CAMEL_IMAPX_EXTD_SERVER (server);
-
-	camel_imapx_extd_conn_manager_update_con_info (con_man,
-	                                               es,
+	camel_imapx_extd_conn_manager_update_con_info (self,
+	                                               server,
 	                                               foldername);
 }
 
 /*----------------------------------------------------------------------------*/
+/* class init */
+
+static void
+camel_kolab_imapx_conn_manager_class_init (CamelKolabIMAPXConnManagerClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	GObjectClass *gobj_p_class = NULL;
+	CamelIMAPXExtdConnManagerClass *parent_class = CAMEL_IMAPX_EXTD_CONN_MANAGER_CLASS (klass);
+
+	gobj_p_class = G_OBJECT_CLASS (camel_kolab_imapx_conn_manager_parent_class);
+	object_class->set_property = gobj_p_class->set_property;
+	object_class->get_property = gobj_p_class->get_property;
+
+	object_class->dispose = camel_kolab_imapx_conn_manager_dispose;
+	object_class->finalize = camel_kolab_imapx_conn_manager_finalize;
+
+	parent_class->get_store = kolab_imapx_conn_manager_get_store;
+	parent_class->get_connection = kolab_imapx_conn_manager_get_connection;
+	parent_class->close_connections = kolab_imapx_conn_manager_close_connections;
+	parent_class->get_connections = kolab_imapx_conn_manager_get_connections;
+	parent_class->update_con_info = kolab_imapx_conn_manager_update_con_info;
+
+	/* duped from parent */
+	g_object_class_install_property (object_class,
+	                                 PROP_STORE,
+	                                 g_param_spec_object ("store",
+	                                                      "Store",
+	                                                      "The CamelStore to which we belong",
+	                                                      CAMEL_TYPE_STORE,
+	                                                      G_PARAM_READWRITE |
+	                                                      G_PARAM_CONSTRUCT_ONLY |
+	                                                      G_PARAM_STATIC_STRINGS));
+}
+
+/*----------------------------------------------------------------------------*/
+/* API functions */
+
+CamelKolabIMAPXConnManager*
+camel_kolab_imapx_conn_manager_new (CamelKolabIMAPXStore *store)
+{
+	CamelKolabIMAPXConnManager *self = NULL;
+
+	g_return_val_if_fail (CAMEL_IS_KOLAB_IMAPX_STORE (store), NULL);
+
+	self = g_object_new (CAMEL_TYPE_KOLAB_IMAPX_CONN_MANAGER,
+	                     "store",
+	                     CAMEL_STORE (store),
+	                     NULL);
+	return self;
+}
+
+/*----------------------------------------------------------------------------*/
diff --git a/src/camel/camel-kolab-imapx-conn-manager.h b/src/camel/camel-kolab-imapx-conn-manager.h
index 5e2168c..fd0b2a4 100644
--- a/src/camel/camel-kolab-imapx-conn-manager.h
+++ b/src/camel/camel-kolab-imapx-conn-manager.h
@@ -79,26 +79,6 @@ camel_kolab_imapx_conn_manager_get_type (void);
 CamelKolabIMAPXConnManager*
 camel_kolab_imapx_conn_manager_new (CamelKolabIMAPXStore *store);
 
-CamelKolabIMAPXStore*
-camel_kolab_imapx_conn_manager_get_store (CamelKolabIMAPXConnManager *self);
-
-CamelKolabIMAPXServer*
-camel_kolab_imapx_conn_manager_get_connection (CamelKolabIMAPXConnManager *self,
-                                               const gchar *foldername,
-                                               GCancellable *cancellable,
-                                               GError **err);
-
-void
-camel_kolab_imapx_conn_manager_close_connections (CamelKolabIMAPXConnManager *self);
-
-GList*
-camel_kolab_imapx_conn_manager_get_connections (CamelKolabIMAPXConnManager *self);
-
-void
-camel_kolab_imapx_conn_manager_update_con_info (CamelKolabIMAPXConnManager *self,
-                                                CamelKolabIMAPXServer *server,
-                                                const gchar *foldername);
-
 G_END_DECLS
 
 /*----------------------------------------------------------------------------*/



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