[evolution-kolab] Stub in a collection backend.



commit 4e16c69ab3796684ab6febc6cea4fa00a86bae99
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed Jul 4 10:19:53 2012 -0400

    Stub in a collection backend.
    
    This runs in the evolution-source-registry process.  It doesn't do
    anything yet, but something needs to be registered or the server will
    simply swallow Kolab collections and not export them to clients.

 configure.ac                             |    4 +
 src/Makefile.am                          |    1 +
 src/collection/Makefile.am               |   29 ++++++++
 src/collection/e-kolab-backend-factory.c |   99 +++++++++++++++++++++++++
 src/collection/e-kolab-backend-factory.h |   64 +++++++++++++++++
 src/collection/e-kolab-backend.c         |  115 ++++++++++++++++++++++++++++++
 src/collection/e-kolab-backend.h         |   62 ++++++++++++++++
 src/collection/module-kolab-backend.c    |   35 +++++++++
 8 files changed, 409 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 248899e..a1672f7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -179,6 +179,9 @@ dnl *******************
 dnl Special directories
 dnl *******************
 
+eds_moduledir=`$PKG_CONFIG --variable=moduledir libebackend-1.2`
+AC_SUBST(eds_moduledir)
+
 evo_moduledir=`$PKG_CONFIG --variable=moduledir evolution-shell-3.0`
 AC_SUBST(evo_moduledir)
 
@@ -250,6 +253,7 @@ src/Makefile
 src/addressbook/Makefile
 src/calendar/Makefile
 src/camel/Makefile
+src/collection/Makefile
 src/configuration/Makefile
 src/libekolab/Makefile
 src/libekolabconv/Makefile
diff --git a/src/Makefile.am b/src/Makefile.am
index 4d6934f..ffcadf0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,6 +7,7 @@ SUBDIRS =		\
 	camel		\
 	addressbook	\
 	calendar	\
+	collection	\
 	configuration	\
 	tests
 
diff --git a/src/collection/Makefile.am b/src/collection/Makefile.am
new file mode 100644
index 0000000..d3c04e6
--- /dev/null
+++ b/src/collection/Makefile.am
@@ -0,0 +1,29 @@
+NULL =
+
+eds_module_LTLIBRARIES = module-kolab-backend.la
+
+module_kolab_backend_la_CPPFLAGS = \
+	$(AM_CPPFLAGS) \
+	-I$(top_srcdir) \
+	-I$(top_srcdir)/src \
+	$(EDS_CFLAGS) \
+	$(NULL)
+
+module_kolab_backend_la_SOURCES = \
+	module-kolab-backend.c \
+	e-kolab-backend.c \
+	e-kolab-backend.h \
+	e-kolab-backend-factory.c \
+	e-kolab-backend-factory.h \
+	$(NULL)
+
+module_kolab_backend_la_LIBADD = \
+	$(KOLAB_LIB_EKOLABBACKEND) \
+	$(EDS_LIBS) \
+	$(NULL)
+
+module_kolab_backend_la_LDFLAGS = \
+	-module -avoid-version $(NO_UNDEFINED) \
+	$(NULL)
+
+-include $(top_srcdir)/git.mk
diff --git a/src/collection/e-kolab-backend-factory.c b/src/collection/e-kolab-backend-factory.c
new file mode 100644
index 0000000..fbdfeea
--- /dev/null
+++ b/src/collection/e-kolab-backend-factory.c
@@ -0,0 +1,99 @@
+/*
+ * 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+
+#include "e-kolab-backend-factory.h"
+
+#include "e-kolab-backend.h"
+
+G_DEFINE_DYNAMIC_TYPE (
+	EKolabBackendFactory,
+	e_kolab_backend_factory,
+	E_TYPE_COLLECTION_BACKEND_FACTORY)
+
+static void
+kolab_backend_prepare_mail_account_source (ESource *source)
+{
+	ESourceBackend *extension;
+	const gchar *extension_name;
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+	extension = e_source_get_extension (source, extension_name);
+	e_source_backend_set_backend_name (extension, "kolab");
+}
+
+static void
+kolab_backend_prepare_mail_transport_source (ESource *source)
+{
+	ESourceBackend *extension;
+	const gchar *extension_name;
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_TRANSPORT;
+	extension = e_source_get_extension (source, extension_name);
+	e_source_backend_set_backend_name (extension, "kolab");
+}
+
+static void
+kolab_backend_factory_prepare_mail (ECollectionBackendFactory *factory,
+                                    ESource *mail_account_source,
+                                    ESource *mail_identity_source,
+                                    ESource *mail_transport_source)
+{
+	ECollectionBackendFactoryClass *parent_class;
+
+	/* Chain up to parent's prepare_mail() method. */
+	parent_class =
+		E_COLLECTION_BACKEND_FACTORY_CLASS (
+		e_kolab_backend_factory_parent_class);
+	parent_class->prepare_mail (
+		factory,
+		mail_account_source,
+		mail_identity_source,
+		mail_transport_source);
+
+	kolab_backend_prepare_mail_account_source (mail_account_source);
+	kolab_backend_prepare_mail_transport_source (mail_transport_source);
+}
+
+static void
+e_kolab_backend_factory_class_init (EKolabBackendFactoryClass *class)
+{
+	ECollectionBackendFactoryClass *factory_class;
+
+	factory_class = E_COLLECTION_BACKEND_FACTORY_CLASS (class);
+	factory_class->factory_name = "kolab";
+	factory_class->backend_type = E_TYPE_KOLAB_BACKEND;
+	factory_class->prepare_mail = kolab_backend_factory_prepare_mail;
+}
+
+static void
+e_kolab_backend_factory_class_finalize (EKolabBackendFactoryClass *class)
+{
+}
+
+static void
+e_kolab_backend_factory_init (EKolabBackendFactory *factory)
+{
+}
+
+void
+e_kolab_backend_factory_type_register (GTypeModule *type_module)
+{
+	/* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
+	 *     function, so we have to wrap it with a public function in
+	 *     order to register types from a separate compilation unit. */
+	e_kolab_backend_factory_register_type (type_module);
+}
+
diff --git a/src/collection/e-kolab-backend-factory.h b/src/collection/e-kolab-backend-factory.h
new file mode 100644
index 0000000..3d1eed5
--- /dev/null
+++ b/src/collection/e-kolab-backend-factory.h
@@ -0,0 +1,64 @@
+/*
+ * 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+
+#ifndef E_KOLAB_BACKEND_FACTORY_H
+#define E_KOLAB_BACKEND_FACTORY_H
+
+#include <libebackend/libebackend.h>
+
+/* Standard GObject macros */
+#define E_TYPE_KOLAB_BACKEND_FACTORY \
+	(e_kolab_backend_get_type ())
+#define E_KOLAB_BACKEND_FACTORY(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_KOLAB_BACKEND_FACTORY, EKolabBackendFactory))
+#define E_KOLAB_BACKEND_FACTORY_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_KOLAB_BACKEND_FACTORY, EKolabBackendFactoryClass))
+#define E_IS_KOLAB_BACKEND_FACTORY(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_KOLAB_BACKEND_FACTORY))
+#define E_IS_KOLAB_BACKEND_FACTORY_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_KOLAB_BACKEND_FACTORY))
+#define E_KOLAB_BACKEND_FACTORY_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_KOLAB_BACKEND_FACTORY, EKolabBackendFactoryClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EKolabBackendFactory EKolabBackendFactory;
+typedef struct _EKolabBackendFactoryClass EKolabBackendFactoryClass;
+typedef struct _EKolabBackendFactoryPrivate EKolabBackendFactoryPrivate;
+
+struct _EKolabBackendFactory {
+	ECollectionBackendFactory parent;
+	EKolabBackendFactoryPrivate *priv;
+};
+
+struct _EKolabBackendFactoryClass {
+	ECollectionBackendFactoryClass parent_class;
+};
+
+GType		e_kolab_backend_factory_get_type
+						(void) G_GNUC_CONST;
+void		e_kolab_backend_factory_type_register
+						(GTypeModule *type_module);
+
+G_END_DECLS
+
+#endif /* E_KOLAB_BACKEND_FACTORY_H */
+
diff --git a/src/collection/e-kolab-backend.c b/src/collection/e-kolab-backend.c
new file mode 100644
index 0000000..34373c3
--- /dev/null
+++ b/src/collection/e-kolab-backend.c
@@ -0,0 +1,115 @@
+/*
+ * 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+
+#include "e-kolab-backend.h"
+
+#include <libekolab/e-source-kolab-folder.h>
+#include <libekolab/camel-kolab-imapx-settings.h>
+
+#define E_KOLAB_BACKEND_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_KOLAB_BACKEND, EKolabBackendPrivate))
+
+struct _EKolabBackendPrivate {
+	gint placeholder;   /* remove when there's something else to add */
+};
+
+G_DEFINE_DYNAMIC_TYPE (
+	EKolabBackend,
+	e_kolab_backend,
+	E_TYPE_COLLECTION_BACKEND)
+
+static void
+kolab_backend_populate (ECollectionBackend *backend)
+{
+	/* FIXME At this point the backend should query the Kolab server
+	 *       for all available non-mail folders such as address books
+	 *       and calendars, and create ESources for them.
+	 *
+	 *       Upstream authors are still fleshing out the details of
+	 *       how this should work.  Query Matthew Barnes when you're
+	 *       ready to implement this.
+	 */
+}
+
+static gchar *
+kolab_backend_dup_resource_id (ECollectionBackend *backend,
+                               ESource *child_source)
+{
+	ESourceResource *extension;
+	const gchar *extension_name;
+
+	extension_name = E_SOURCE_EXTENSION_KOLAB_FOLDER;
+	extension = e_source_get_extension (child_source, extension_name);
+
+	return e_source_resource_dup_identity (extension);
+}
+
+static void
+kolab_backend_child_added (ECollectionBackend *backend,
+                           ESource *child_source)
+{
+	/* Chain up to parent's child_added() method. */
+	E_COLLECTION_BACKEND_CLASS (e_kolab_backend_parent_class)->
+		child_added (backend, child_source);
+}
+
+static void
+kolab_backend_child_removed (ECollectionBackend *backend,
+                             ESource *child_source)
+{
+	/* Chain up to parent's child_removed() method. */
+	E_COLLECTION_BACKEND_CLASS (e_kolab_backend_parent_class)->
+		child_removed (backend, child_source);
+}
+
+static void
+e_kolab_backend_class_init (EKolabBackendClass *class)
+{
+	ECollectionBackendClass *backend_class;
+
+	g_type_class_add_private (class, sizeof (EKolabBackendPrivate));
+
+	backend_class = E_COLLECTION_BACKEND_CLASS (class);
+	backend_class->populate = kolab_backend_populate;
+	backend_class->dup_resource_id = kolab_backend_dup_resource_id;
+	backend_class->child_added = kolab_backend_child_added;
+	backend_class->child_removed = kolab_backend_child_removed;
+
+	/* This generates an ESourceCamel subtype for CamelKolabIMAPXSettings. */
+	e_source_camel_generate_subtype ("kolab", CAMEL_TYPE_KOLAB_IMAPX_SETTINGS);
+}
+
+static void
+e_kolab_backend_class_finalize (EKolabBackendClass *class)
+{
+}
+
+static void
+e_kolab_backend_init (EKolabBackend *backend)
+{
+	backend->priv = E_KOLAB_BACKEND_GET_PRIVATE (backend);
+}
+
+void
+e_kolab_backend_type_register (GTypeModule *type_module)
+{
+	/* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
+	 *     function, so we have to wrap it with a public function in
+	 *     order to register types from a separate compilation unit. */
+	e_kolab_backend_register_type (type_module);
+}
+
diff --git a/src/collection/e-kolab-backend.h b/src/collection/e-kolab-backend.h
new file mode 100644
index 0000000..ab581e2
--- /dev/null
+++ b/src/collection/e-kolab-backend.h
@@ -0,0 +1,62 @@
+/*
+ * 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+
+#ifndef E_KOLAB_BACKEND_H
+#define E_KOLAB_BACKEND_H
+
+#include <libebackend/libebackend.h>
+
+/* Standard GObject macros */
+#define E_TYPE_KOLAB_BACKEND \
+	(e_kolab_backend_get_type ())
+#define E_KOLAB_BACKEND(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_KOLAB_BACKEND, EKolabBackend))
+#define E_KOLAB_BACKEND_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_KOLAB_BACKEND, EKolabBackendClass))
+#define E_IS_KOLAB_BACKEND(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_KOLAB_BACKEND))
+#define E_IS_KOLAB_BACKEND_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_KOLAB_BACKEND))
+#define E_KOLAB_BACKEND_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_KOLAB_BACKEND, EKolabBackendClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EKolabBackend EKolabBackend;
+typedef struct _EKolabBackendClass EKolabBackendClass;
+typedef struct _EKolabBackendPrivate EKolabBackendPrivate;
+
+struct _EKolabBackend {
+	ECollectionBackend parent;
+	EKolabBackendPrivate *priv;
+};
+
+struct _EKolabBackendClass {
+	ECollectionBackendClass parent_class;
+};
+
+GType		e_kolab_backend_get_type	(void) G_GNUC_CONST;
+void		e_kolab_backend_type_register	(GTypeModule *type_module);
+
+G_END_DECLS
+
+#endif /* E_KOLAB_BACKEND_H */
+
diff --git a/src/collection/module-kolab-backend.c b/src/collection/module-kolab-backend.c
new file mode 100644
index 0000000..bc77053
--- /dev/null
+++ b/src/collection/module-kolab-backend.c
@@ -0,0 +1,35 @@
+/*
+ * 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+
+#include "e-kolab-backend.h"
+#include "e-kolab-backend-factory.h"
+
+/* Module Entry Points */
+void e_module_load (GTypeModule *type_module);
+void e_module_unload (GTypeModule *type_module);
+
+G_MODULE_EXPORT void
+e_module_load (GTypeModule *type_module)
+{
+	e_kolab_backend_type_register (type_module);
+	e_kolab_backend_factory_type_register (type_module);
+}
+
+G_MODULE_EXPORT void
+e_module_unload (GTypeModule *type_module)
+{
+}
+



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