[evolution-kolab/ek-wip-porting] CamelIMAPXExtdStore: inject our own extended connection manager



commit 875783c8ae50da2ec3bf074dd133fd2fc141f253
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Tue Jan 10 11:31:43 2012 +0100

    CamelIMAPXExtdStore: inject our own extended connection manager
    
    * in the class init() function, delete an existing
      CamelIMAPXConnManager instance and bind a
      CamelIMAPXExtdConnManager instance in its place
    * in the class dispose() function, unref our own instance
      after disconnecting and make sure the parent's
      dispose() function does not try the same as well

 src/camel/providers/imapx/camel-imapx-extd-store.c |   34 ++++++++++++++++++--
 1 files changed, 31 insertions(+), 3 deletions(-)
---
diff --git a/src/camel/providers/imapx/camel-imapx-extd-store.c b/src/camel/providers/imapx/camel-imapx-extd-store.c
index b478781..92a85ec 100644
--- a/src/camel/providers/imapx/camel-imapx-extd-store.c
+++ b/src/camel/providers/imapx/camel-imapx-extd-store.c
@@ -32,6 +32,7 @@
 #include <libekolabutil/camel-system-headers.h>
 
 #include "camel-imapx-settings.h"
+#include "camel-imapx-extd-conn-manager.h"
 #include "camel-imapx-extd-store.h"
 
 /*----------------------------------------------------------------------------*/
@@ -67,16 +68,43 @@ G_DEFINE_TYPE_WITH_CODE (
 static void
 camel_imapx_extd_store_init (CamelIMAPXExtdStore *self)
 {
+	CamelIMAPXStore *istore = NULL;
+	CamelIMAPXExtdConnManager *cm = NULL;
+
 	g_assert (CAMEL_IS_IMAPX_EXTD_STORE (self));
 
-	/* FIXME implement me */
-	g_error ("%s: FIXME implement me", __func__);
+	istore = CAMEL_IMAPX_STORE (self);
+
+	/* replace existing connection manager with
+	 * our own extended version. in case we need
+	 * to explicitly reference the *extended*
+	 * version of the connection manager, we will need
+	 * to override the respective parent class functions
+	 */
+	if (istore->con_man != NULL)
+		g_object_unref (istore->con_man);
+	cm = camel_imapx_extd_conn_manager_new (self);
+	istore->con_man = CAMEL_IMAPX_CONN_MANAGER (cm);
 }
 
 static void
 camel_imapx_extd_store_dispose (GObject *object)
 {
-	g_assert (CAMEL_IS_IMAPX_EXTD_STORE (object));
+	CamelIMAPXExtdStore *self = CAMEL_IMAPX_EXTD_STORE (object);
+	CamelIMAPXStore *istore = CAMEL_IMAPX_STORE (self);
+
+	/* disconnect service and unref the connection manager.
+	 * see imapx_store_dispose() in camel-imapx-store.c
+	 */
+	if (istore->con_man != NULL) {
+		camel_service_disconnect_sync (
+			CAMEL_SERVICE (self), TRUE, NULL);
+		g_object_unref (istore->con_man);
+		istore->con_man = NULL;
+		/* this part will now be skipped
+		 * in the parent's dispose() function
+		 */
+	}
 
 	G_OBJECT_CLASS (camel_imapx_extd_store_parent_class)->dispose (object);
 }



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