[evolution-kolab/ek-wip-porting] CamelKolabIMAPXConnManager: initial subclassing of CamelIMAPXExtdConnManager



commit a54a6a4444dad0e7bb09630d5f739e0f56924498
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Tue Jan 10 17:52:01 2012 +0100

    CamelKolabIMAPXConnManager: initial subclassing of CamelIMAPXExtdConnManager
    
    * implemented initial subclassing of CamelIMAPXExtdConnManager
      so we can inject our CamelKolabIMAPXServer into CamelKolabIMAPXStore
    * this will work the same way CamelIMAPXExtdConnManager works
      in the providers/imapx/ directory

 src/camel/Makefile.am                      |    2 +
 src/camel/camel-kolab-imapx-conn-manager.c |  201 ++++++++++++++++++++++++++++
 src/camel/camel-kolab-imapx-conn-manager.h |  108 +++++++++++++++
 3 files changed, 311 insertions(+), 0 deletions(-)
---
diff --git a/src/camel/Makefile.am b/src/camel/Makefile.am
index 29b696f..1e74950 100644
--- a/src/camel/Makefile.am
+++ b/src/camel/Makefile.am
@@ -5,6 +5,7 @@ camel_provider_DATA = libcamelkolab.urls
 #	libcamelkolab.la
 
 libcamelkolab_la_SOURCES =			\
+	camel-kolab-imapx-conn-manager.c	\
 	camel-kolab-imapx-folder.c		\
 	camel-kolab-imapx-metadata-db.c		\
 	camel-kolab-imapx-metadata.c		\
@@ -62,6 +63,7 @@ AM_CFLAGS =					\
 	$(KOLAB_INCLUDE)
 
 noinst_HEADERS =				\
+	camel-kolab-imapx-conn-manager.h	\
 	camel-kolab-imapx-folder.h		\
 	camel-kolab-imapx-metadata-db.h		\
 	camel-kolab-imapx-metadata.h		\
diff --git a/src/camel/camel-kolab-imapx-conn-manager.c b/src/camel/camel-kolab-imapx-conn-manager.c
new file mode 100644
index 0000000..aac095a
--- /dev/null
+++ b/src/camel/camel-kolab-imapx-conn-manager.c
@@ -0,0 +1,201 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/***************************************************************************
+ *            camel-kolab-imapx-conn-manager.c
+ *
+ *  2012-01-10, 17:07:28
+ *  Copyright 2012, Christian Hilberg
+ *  <hilberg unix-ag org>
+ ****************************************************************************/
+
+/*
+ * This program is free software; you can redistribute it and/or
+ * 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 main.c; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+
+/*----------------------------------------------------------------------------*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "camel-kolab-imapx-conn-manager.h"
+
+/*----------------------------------------------------------------------------*/
+
+/* dupe of enum in providers/imapx/camel-imapx-conn-manager.c */
+enum {
+	PROP_0,
+	PROP_STORE
+};
+
+G_DEFINE_TYPE (CamelKolabIMAPXConnManager, camel_kolab_imapx_conn_manager, CAMEL_TYPE_IMAPX_EXTD_CONN_MANAGER)
+
+/*----------------------------------------------------------------------------*/
+/* object/class init */
+
+static void
+camel_kolab_imapx_conn_manager_init (CamelKolabIMAPXConnManager *self)
+{
+	g_assert (CAMEL_IS_KOLAB_IMAPX_CONN_MANAGER (self));
+}
+
+static void
+camel_kolab_imapx_conn_manager_dispose (GObject *object)
+{
+	g_assert (CAMEL_IS_KOLAB_IMAPX_CONN_MANAGER (object));
+
+	G_OBJECT_CLASS (camel_kolab_imapx_conn_manager_parent_class)->dispose (object);
+}
+
+static void
+camel_kolab_imapx_conn_manager_finalize (GObject *object)
+{
+	g_assert (CAMEL_IS_KOLAB_IMAPX_CONN_MANAGER (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;
+}
+
+CamelStore*
+camel_kolab_imapx_conn_manager_get_store (CamelKolabIMAPXConnManager *self)
+{
+	CamelStore *store = NULL;
+	CamelIMAPXExtdConnManager *con_man = NULL;
+
+	g_return_val_if_fail (CAMEL_IS_KOLAB_IMAPX_CONN_MANAGER (self), NULL);
+
+	con_man = CAMEL_IMAPX_EXTD_CONN_MANAGER (self);
+	store = camel_imapx_extd_conn_manager_get_store (con_man);
+
+	return store;
+}
+
+CamelKolabIMAPXServer*
+camel_kolab_imapx_conn_manager_get_connection (CamelKolabIMAPXConnManager *self,
+                                               const gchar *foldername,
+                                               GCancellable *cancellable,
+                                               GError **err)
+{
+	CamelIMAPXServer *es = NULL;
+	CamelKolabIMAPXServer *ks = NULL;
+	CamelIMAPXExtdConnManager *con_man = NULL;
+	GError *tmp_err = NULL;
+
+	g_assert (CAMEL_IS_KOLAB_IMAPX_CONN_MANAGER (self));
+	g_assert (foldername != NULL);
+	/* 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);
+		return NULL;
+	}
+
+	ks = CAMEL_KOLAB_IMAPX_SERVER (es);
+
+	return ks;
+}
+
+void
+camel_kolab_imapx_conn_manager_close_connections (CamelKolabIMAPXConnManager *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);
+}
+
+GList*
+camel_kolab_imapx_conn_manager_get_connections (CamelKolabIMAPXConnManager *self)
+{
+	GList *cn = NULL;
+	CamelIMAPXExtdConnManager *con_man = NULL;
+
+	g_assert (CAMEL_IS_KOLAB_CONN_MANAGER (self));
+
+	con_man = CAMEL_IMAPX_EXTD_CONN_MANAGER (self);
+	cn = camel_imapx_extd_conn_manager_get_connections (con_man);
+
+	return cn;
+}
+
+void
+camel_kolab_imapx_conn_manager_update_con_info (CamelKolabIMAPXConnManager *self,
+                                                CamelKolabIMAPXServer *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 (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,
+	                                               foldername);
+}
+
+/*----------------------------------------------------------------------------*/
diff --git a/src/camel/camel-kolab-imapx-conn-manager.h b/src/camel/camel-kolab-imapx-conn-manager.h
new file mode 100644
index 0000000..158bc91
--- /dev/null
+++ b/src/camel/camel-kolab-imapx-conn-manager.h
@@ -0,0 +1,108 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/***************************************************************************
+ *            camel-kolab-imapx-conn-manager.h
+ *
+ *  2012-01-10, 17:32:18
+ *  Copyright 2012, Christian Hilberg
+ *  <hilberg unix-ag org>
+ ****************************************************************************/
+
+/*
+ * This program is free software; you can redistribute it and/or
+ * 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 main.c; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+
+/*----------------------------------------------------------------------------*/
+
+#ifndef _CAMEL_KOLAB_IMAPX_CONN_MANAGER_H_
+#define _CAMEL_KOLAB_IMAPX_CONN_MANAGER_H_
+
+/*----------------------------------------------------------------------------*/
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gio/gio.h>
+
+#include <camel/providers/imapx/camel-imapx-extd-conn-manager.h>
+
+#include "camel-kolab-imapx-server.h"
+#include "camel-kolab-imapx-store.h"
+
+/*----------------------------------------------------------------------------*/
+/* Standard GObject macros */
+
+#define CAMEL_TYPE_KOLAB_IMAPX_CONN_MANAGER	  \
+	(camel_kolab_imapx_conn_manager_get_type ())
+#define CAMEL_KOLAB_IMAPX_CONN_MANAGER(obj)	  \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	 ((obj), CAMEL_TYPE_KOLAB_IMAPX_CONN_MANAGER, CamelKolabIMAPXConnManager))
+#define CAMEL_KOLAB_IMAPX_CONN_MANAGER_CLASS(klass)	  \
+	(G_TYPE_CHECK_CLASS_CAST \
+	 ((klass), CAMEL_TYPE_KOLAB_IMAPX_CONN_MANAGER, CamelKolabIMAPXConnManagerClass))
+#define CAMEL_IS_KOLAB_IMAPX_CONN_MANAGER(obj)	  \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	 ((obj), CAMEL_TYPE_KOLAB_IMAPX_CONN_MANAGER))
+#define CAMEL_IS_KOLAB_IMAPX_CONN_MANAGER_CLASS(klass)	  \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	 ((klass), CAMEL_TYPE_KOLAB_IMAPX_CONN_MANAGER))
+#define CAMEL_KOLAB_IMAPX_CONN_MANAGER_GET_CLASS(obj)	  \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	 ((obj), CAMEL_TYPE_KOLAB_IMAPX_CONN_MANAGER, CamelKolabIMAPXConnManagerClass))
+
+G_BEGIN_DECLS
+
+typedef struct _CamelKolabIMAPXConnManager CamelKolabIMAPXConnManager;
+typedef struct _CamelKolabIMAPXConnManagerClass CamelKolabIMAPXConnManagerClass;
+
+struct _CamelKolabIMAPXConnManager {
+	CamelIMAPXExtdConnManager parent;
+};
+
+struct _CamelKolabIMAPXConnManagerClass {
+	CamelIMAPXExtdConnManagerClass parent_class;
+};
+
+GType
+camel_kolab_imapx_conn_manager_get_type (void);
+
+CamelKolabIMAPXConnManager*
+camel_kolab_imapx_conn_manager_new (CamelKolabIMAPXStore *store);
+
+CamelStore*
+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_imapx_extd_conn_manager_get_connections (CamelIMAPXExtdConnManager *self);
+
+void
+camel_kolab_imapx_conn_manager_update_con_info (CamelKolabIMAPXConnManager *self,
+                                                CamelKolabIMAPXServer *server,
+                                                const gchar *foldername);
+
+G_END_DECLS
+
+/*----------------------------------------------------------------------------*/
+
+#endif /* _CAMEL_KOLAB_IMAPX_CONN_MANAGER_H_ */
+
+/*----------------------------------------------------------------------------*/



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