[evolution-kolab/ek-wip-porting] IMAPX: initial subclassing of CamelIMAPXConnManager
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/ek-wip-porting] IMAPX: initial subclassing of CamelIMAPXConnManager
- Date: Tue, 20 Dec 2011 20:00:52 +0000 (UTC)
commit 55595001318ac8ac915987c135f08a4316cde004
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Tue Dec 20 20:54:35 2011 +0100
IMAPX: initial subclassing of CamelIMAPXConnManager
* added CamelIMAPXExtdConnManager GObject
* this serves mainly to ensure that we're
dealing with CamelIMAPXExtd* classes in
the places where we need it (Store, Server)
src/camel/providers/imapx/Makefile.am | 2 +
.../imapx/camel-imapx-extd-conn-manager.c | 210 ++++++++++++++++++++
.../imapx/camel-imapx-extd-conn-manager.h | 108 ++++++++++
3 files changed, 320 insertions(+), 0 deletions(-)
---
diff --git a/src/camel/providers/imapx/Makefile.am b/src/camel/providers/imapx/Makefile.am
index 4be7947..69d28ba 100644
--- a/src/camel/providers/imapx/Makefile.am
+++ b/src/camel/providers/imapx/Makefile.am
@@ -22,6 +22,7 @@ libcamelimapx_la_CFLAGS = \
libcamelimapx_la_SOURCES = \
camel-imapx-conn-manager.c \
+ camel-imapx-extd-conn-manager.c \
camel-imapx-folder.c \
camel-imapx-extd-folder.c \
camel-imapx-metadata.c \
@@ -38,6 +39,7 @@ libcamelimapx_la_SOURCES = \
noinst_HEADERS = \
camel-imapx-conn-manager.h \
+ camel-imapx-extd-conn-manager.h \
camel-imapx-folder.h \
camel-imapx-extd-folder.h \
camel-imapx-metadata.h \
diff --git a/src/camel/providers/imapx/camel-imapx-extd-conn-manager.c b/src/camel/providers/imapx/camel-imapx-extd-conn-manager.c
new file mode 100644
index 0000000..3ec4fa5
--- /dev/null
+++ b/src/camel/providers/imapx/camel-imapx-extd-conn-manager.c
@@ -0,0 +1,210 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/***************************************************************************
+ * camel-imapx-extd-conn-manager.c
+ *
+ * 2011-12-20, 16:04:28
+ * Copyright 2011, 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-imapx-extd-conn-manager.h"
+
+/*----------------------------------------------------------------------------*/
+
+/* dupe of enum in camel-imapx-conn-manager.c */
+enum {
+ PROP_0,
+ PROP_STORE
+};
+
+/* dupe of _CamelIMAPXConnManagerPrivate */
+struct _CamelIMAPXExtdConnManagerPrivate {
+ GList *connections;
+ gpointer store; /* weak pointer */
+ GStaticRecMutex con_man_lock;
+ gboolean clearing_connections;
+};
+
+G_DEFINE_TYPE (CamelIMAPXExtdConnManager, camel_imapx_extd_conn_manager, CAMEL_TYPE_IMAPX_CONN_MANAGER)
+
+/*----------------------------------------------------------------------------*/
+/* object/class init */
+
+static void
+camel_imapx_extd_conn_manager_init (CamelIMAPXExtdConnManager *self)
+{
+ g_assert (CAMEL_IS_IMAPX_EXTD_CONN_MANAGER (self));
+}
+
+static void
+camel_imapx_extd_conn_manager_dispose (GObject *object)
+{
+ g_assert (CAMEL_IS_IMAPX_EXTD_CONN_MANAGER (object));
+
+ G_OBJECT_CLASS (camel_imapx_extd_conn_manager_parent_class)->dispose (object);
+}
+
+static void
+camel_imapx_extd_conn_manager_finalize (GObject *object)
+{
+ g_assert (CAMEL_IS_IMAPX_EXTD_CONN_MANAGER (object));
+
+ G_OBJECT_CLASS (camel_imapx_extd_conn_manager_parent_class)->finalize (object);
+}
+
+static void
+camel_imapx_extd_conn_manager_class_init (CamelIMAPXExtdConnManagerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *gobj_p_class = NULL;
+
+ g_type_class_add_private (klass, sizeof (CamelIMAPXExtdConnManagerPrivate));
+
+ gobj_p_class = G_OBJECT_CLASS (camel_imapx_extd_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_imapx_extd_conn_manager_dispose;
+ object_class->finalize = camel_imapx_extd_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 */
+
+CamelIMAPXExtdConnManager*
+camel_imapx_extd_conn_manager_new (CamelStore *store)
+{
+ CamelIMAPXExtdConnManager *self = NULL;
+
+ g_return_val_if_fail (CAMEL_IS_STORE (store), NULL);
+
+ self = g_object_new (CAMEL_TYPE_IMAPX_EXTD_CONN_MANAGER,
+ "store", store, NULL);
+
+ return self;
+}
+
+CamelStore*
+camel_imapx_extd_conn_manager_get_store (CamelIMAPXExtdConnManager *self)
+{
+ CamelStore *store = NULL;
+ CamelIMAPXConnManager *con_man = NULL;
+
+ g_return_val_if_fail (CAMEL_IS_IMAPX_EXTD_CONN_MANAGER (self), NULL);
+
+ con_man = CAMEL_IMAPX_CONN_MANAGER (self);
+ store = camel_imapx_conn_manager_get_store (con_man);
+
+ return store;
+}
+
+CamelIMAPXExtdServer*
+camel_imapx_extd_conn_manager_get_connection (CamelIMAPXExtdConnManager *self,
+ const gchar *foldername,
+ GCancellable *cancellable,
+ GError **err)
+{
+ CamelIMAPXServer *is = NULL;
+ CamelIMAPXExtdServer *es = NULL;
+ CamelIMAPXConnManager *con_man = NULL;
+ GError *tmp_err = NULL;
+
+ g_assert (CAMEL_IS_IMAPX_EXTD_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_CONN_MANAGER (self);
+ is = camel_imapx_conn_manager_get_connection (con_man,
+ foldername,
+ cancellable,
+ &tmp_err);
+ if (is == NULL) {
+ g_propagate_error (err, tmp_err);
+ return NULL;
+ }
+
+ es = CAMEL_IMAPX_EXTD_SERVER (is);
+
+ return es;
+}
+
+void
+camel_imapx_extd_conn_manager_close_connections (CamelIMAPXExtdConnManager *self)
+{
+ CamelIMAPXConnManager *con_man = NULL;
+
+ g_assert (CAMEL_IS_IMAPX_EXTD_CONN_MANAGER (self));
+
+ con_man = CAMEL_IMAPX_CONN_MANAGER (self);
+ camel_imapx_conn_manager_close_connections (con_man);
+}
+
+GList*
+camel_imapx_extd_conn_manager_get_connections (CamelIMAPXExtdConnManager *self)
+{
+ GList *cn = NULL;
+ CamelIMAPXConnManager *con_man = NULL;
+
+ g_assert (CAMEL_IS_IMAPX_EXTD_CONN_MANAGER (self));
+
+ con_man = CAMEL_IMAPX_CONN_MANAGER (self);
+ cn = camel_imapx_conn_manager_get_connections (con_man);
+
+ return cn;
+}
+
+void
+camel_imapx_extd_conn_manager_update_con_info (CamelIMAPXExtdConnManager *self,
+ CamelIMAPXExtdServer *server,
+ const gchar *foldername)
+{
+ CamelIMAPXConnManager *con_man = NULL;
+ CamelIMAPXServer *is = NULL;
+
+ g_assert (CAMEL_IS_IMAPX_EXTD_CONN_MANAGER (con_man));
+ g_assert (CAMEL_IS_IMAPX_EXTD_SERVER (server));
+ g_assert (foldername != NULL);
+
+ con_man = CAMEL_IMAPX_CONN_MANAGER (self);
+ is = CAMEL_IMAPX_SERVER (server);
+
+ camel_imapx_conn_manager_update_con_info (con_man,
+ is,
+ foldername);
+}
+
+/*----------------------------------------------------------------------------*/
diff --git a/src/camel/providers/imapx/camel-imapx-extd-conn-manager.h b/src/camel/providers/imapx/camel-imapx-extd-conn-manager.h
new file mode 100644
index 0000000..302da82
--- /dev/null
+++ b/src/camel/providers/imapx/camel-imapx-extd-conn-manager.h
@@ -0,0 +1,108 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/***************************************************************************
+ * camel-imapx-extd-conn-manager.h
+ *
+ * 2011-12-20, 15:59:18
+ * Copyright 2011, 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_IMAPX_EXTD_CONN_MANAGER_H_
+#define _CAMEL_IMAPX_EXTD_CONN_MANAGER_H_
+
+/*----------------------------------------------------------------------------*/
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gio/gio.h>
+
+#include "camel-imapx-conn-manager.h"
+#include "camel-imapx-extd-server.h"
+
+/*----------------------------------------------------------------------------*/
+/* Standard GObject macros */
+
+#define CAMEL_TYPE_IMAPX_EXTD_CONN_MANAGER \
+ (camel_imapx_extd_conn_manager_get_type ())
+#define CAMEL_IMAPX_EXTD_CONN_MANAGER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), CAMEL_TYPE_IMAPX_EXTD_CONN_MANAGER, CamelIMAPXExtdConnManager))
+#define CAMEL_IMAPX_EXTD_CONN_MANAGER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((klass), CAMEL_TYPE_IMAPX_EXTD_CONN_MANAGER, CamelIMAPXExtdConnManagerClass))
+#define CAMEL_IS_IMAPX_EXTD_CONN_MANAGER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), CAMEL_TYPE_IMAPX_EXTD_CONN_MANAGER))
+#define CAMEL_IS_IMAPX_EXTD_CONN_MANAGER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((klass), CAMEL_TYPE_IMAPX_EXTD_CONN_MANAGER))
+#define CAMEL_IMAPX_EXTD_CONN_MANAGER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), CAMEL_TYPE_IMAPX_EXTD_CONN_MANAGER, CamelIMAPXExtdConnManagerClass))
+
+G_BEGIN_DECLS
+
+typedef struct _CamelIMAPXExtdConnManager CamelIMAPXExtdConnManager;
+typedef struct _CamelIMAPXExtdConnManagerClass CamelIMAPXExtdConnManagerClass;
+typedef struct _CamelIMAPXExtdConnManagerPrivate CamelIMAPXExtdConnManagerPrivate;
+
+struct _CamelIMAPXExtdConnManager {
+ CamelIMAPXConnManager parent;
+ CamelIMAPXExtdConnManagerPrivate *priv;
+};
+
+struct _CamelIMAPXExtdConnManagerClass {
+ CamelIMAPXConnManagerClass parent_class;
+};
+
+GType
+camel_imapx_extd_conn_manager_get_type (void);
+
+CamelIMAPXExtdConnManager*
+camel_imapx_extd_conn_manager_new (CamelStore *store);
+
+CamelStore*
+camel_imapx_extd_conn_manager_get_store (CamelIMAPXExtdConnManager *self);
+
+CamelIMAPXExtdServer*
+camel_imapx_extd_conn_manager_get_connection (CamelIMAPXExtdConnManager *self,
+ const gchar *foldername,
+ GCancellable *cancellable,
+ GError **err);
+
+void
+camel_imapx_extd_conn_manager_close_connections (CamelIMAPXExtdConnManager *self);
+
+GList*
+camel_imapx_extd_conn_manager_get_connections (CamelIMAPXExtdConnManager *self);
+
+void
+camel_imapx_extd_conn_manager_update_con_info (CamelIMAPXExtdConnManager *self,
+ CamelIMAPXExtdServer *server,
+ const gchar *foldername);
+
+G_END_DECLS
+
+/*----------------------------------------------------------------------------*/
+
+#endif /* _CAMEL_IMAPX_EXTD_CONN_MANAGER_H_ */
+
+/*----------------------------------------------------------------------------*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]