[evolution-couchdb] Added plugin for CouchDB source configuration



commit 5619adbbaa031c5eb822aa826e68b2847e4ae056
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Thu Jun 18 13:51:51 2009 +0200

    Added plugin for CouchDB source configuration

 Makefile.am                                        |    2 +-
 configure.ac                                       |    5 +
 plugins/Makefile.am                                |   10 ++-
 plugins/couchdb-contacts-source.c                  |   85 ++++++++++++++++++++
 plugins/couchdb-contacts-source.h                  |    8 ++
 ...ml => org-gnome-evolution-couchdb.eplug.xml.in} |    2 +-
 6 files changed, 106 insertions(+), 6 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index e838fdf..5f7bf72 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1 +1 @@
-SUBDIRS = addressbook po
+SUBDIRS = addressbook plugins po
diff --git a/configure.ac b/configure.ac
index 228f243..25bc849 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,6 +38,10 @@ PKG_CHECK_MODULES(EVOLUTION, glib-2.0 couchdb-glib-1.0 >= 0.2 libebook-1.2 libed
 AC_SUBST(EVOLUTION_CFLAGS)
 AC_SUBST(EVOLUTION_LIBS)
 
+PKG_CHECK_MODULES(EPLUGIN, gtk+-2.0 evolution-plugin)
+AC_SUBST(EPLUGIN_CFLAGS)
+AC_SUBST(EPLUGIN_LIBS)
+
 EDS_API_VERSION=1.2
 EDS_EXTENSION_DIR=`$PKG_CONFIG --variable=extensiondir evolution-data-server-1.2`
 AC_SUBST(EDS_API_VERSION)
@@ -52,5 +56,6 @@ Makefile
 addressbook/Makefile
 addressbook/GNOME_Evolution_CouchDB.server
 plugins/Makefile
+plugins/org-gnome-evolution-couchdb.eplug.xml
 po/Makefile.in
 ])
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index a4ac887..512ac00 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -1,8 +1,10 @@
-INCLUDES = 						\
-	-I$(top_srcdir)	                                \
-	$(EVOLUTION_CFLAGS)
+INCLUDES = 			\
+	-I$(top_srcdir)	        \
+	$(EVOLUTION_CFLAGS)	\
+	$(EPLUGIN_CFLAGS)
 
- EVO_PLUGIN_RULE@
+%.eplug: %.eplug.xml
+	cp $< $@
 
 plugindir = $(EVOLUTION_PLUGINS_DIR)
 plugin_DATA = org-gnome-evolution-couchdb.eplug
diff --git a/plugins/couchdb-contacts-source.c b/plugins/couchdb-contacts-source.c
index 9d4e5aa..32efee3 100644
--- a/plugins/couchdb-contacts-source.c
+++ b/plugins/couchdb-contacts-source.c
@@ -20,3 +20,88 @@
  *
  * Authors: Rodrigo Moya <rodrigo moya canonical com>
  */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <e-util/e-config.h>
+#include <e-util/e-plugin.h>
+#include <addressbook/gui/widgets/eab-config.h>
+#include <libedataserver/e-source.h>
+#include <libedataserver/e-source-list.h>
+#include <libedataserver/e-url.h>
+#include <libedataserver/e-account-list.h>
+
+#define COUCHDB_BASE_URI "couchdb://"
+
+static void
+ensure_couchdb_contacts_source_group (void)
+{
+	ESourceList *source_list;
+
+	source_list = e_source_list_new_for_gconf_default("/apps/evolution/addressbook/sources");
+	if (source_list) {
+		e_source_list_ensure_group (source_list, _("CouchDB"), COUCHDB_BASE_URI, FALSE);
+
+		g_object_unref (G_OBJECT (source_list));
+	}
+}
+
+static void
+remove_couchdb_contacts_source_group (void)
+{
+	ESourceList *source_list;
+
+	source_list = e_source_list_new_for_gconf_default("/apps/evolution/addressbook/sources");
+	if (source_list) {
+		ESourceGroup *group;
+
+		group = e_source_list_peek_group_by_base_uri (source_list, COUCHDB_BASE_URI);
+		if (group) {
+			GSList *sources;
+
+			sources = e_source_group_peek_sources (group);
+			if (sources == NULL) {
+				e_source_list_remove_group (source_list, group);
+				e_source_list_sync (source_list, NULL);
+			}
+		}
+
+		g_object_unref (G_OBJECT (source_list));
+	}
+}
+
+GtkWidget *
+plugin_couchdb_contacts (EPlugin *epl, EConfigHookItemFactoryData *data)
+{
+	ESource *source;
+        ESourceGroup *group;
+	const gchar *base_uri;
+	EABConfigTargetSource *t = (EABConfigTargetSource *) data->target;
+
+	source = t->source;
+        group  = e_source_peek_group (source);
+
+        base_uri = e_source_group_peek_base_uri (group);
+
+        g_object_set_data (G_OBJECT (epl), "wwidget", NULL);
+
+	if (strcmp(base_uri, COUCHDB_BASE_URI) != 0)
+                return NULL;
+
+	return NULL;
+}
+
+gint
+e_plugin_lib_enable (EPluginLib *ep, gint enable)
+{
+	if (enable)
+		ensure_couchdb_contacts_source_group ();
+	else
+		remove_couchdb_contacts_source_group ();
+
+	return 0;
+}
diff --git a/plugins/couchdb-contacts-source.h b/plugins/couchdb-contacts-source.h
index 9d4e5aa..345c8ac 100644
--- a/plugins/couchdb-contacts-source.h
+++ b/plugins/couchdb-contacts-source.h
@@ -20,3 +20,11 @@
  *
  * Authors: Rodrigo Moya <rodrigo moya canonical com>
  */
+
+#ifndef __COUCHDB_CONTACTS_SOURCE_H__
+#define __COUCHDB_CONTACTS_SOURCE_H__
+
+GtkWidget *plugin_couchdb_contacts (EPlugin                    *epl,
+				    EConfigHookItemFactoryData *data);
+
+#endif
diff --git a/plugins/org-gnome-evolution-couchdb.eplug.xml b/plugins/org-gnome-evolution-couchdb.eplug.xml.in
similarity index 79%
rename from plugins/org-gnome-evolution-couchdb.eplug.xml
rename to plugins/org-gnome-evolution-couchdb.eplug.xml.in
index 9ed2ddf..d242db1 100644
--- a/plugins/org-gnome-evolution-couchdb.eplug.xml
+++ b/plugins/org-gnome-evolution-couchdb.eplug.xml.in
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <e-plugin-list>
   <e-plugin id="org.gnome.evolution.couchdb" type="shlib" _name="CouchDB sources"
-    location="@PLUGINDIR@/liborg-gnome-evolution-couchdb SOEXT@" load-on-startup="false" localedir = "@LOCALEDIR@" system_plugin="true">
+    location="@EVOLUTION_PLUGINS_DIR@/liborg-gnome-evolution-couchdb.so" load-on-startup="false" localedir = "@LOCALEDIR@" system_plugin="true">
     <author name="Rodrigo Moya" email="rodrigo moya canonical com"/>
     <_description>A plugin to setup CouchDB Contacts.</_description>
 



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