[evolution-kolab/ek-wip-gui: 2/16] EPlugin: restructuring (single file for eplug entry points)



commit 01fac003b7a342ee5c07eceac0e8b151993c2a4c
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Wed Feb 8 18:14:29 2012 +0100

    EPlugin: restructuring (single file for eplug entry points)
    
    * added a new header/impl files pair where all
      functions referred to in the *.eplug(.xml)
      description will live
    * moved public API from the old account setup
      files there (just eplug entry functions)
    * changed function names to a common naming
      scheme

 src/eplugin/Makefile.am               |    2 +
 src/eplugin/e-kolab-account-setup.h   |   29 ++----
 src/eplugin/e-kolab-plugin.c          |  183 +++++++++++++++++++++++++++++++++
 src/eplugin/e-kolab-plugin.h          |   86 +++++++++++++++
 src/eplugin/org-gnome-kolab.eplug.xml |   48 +++++----
 5 files changed, 306 insertions(+), 42 deletions(-)
---
diff --git a/src/eplugin/Makefile.am b/src/eplugin/Makefile.am
index 30f7e5a..89a5570 100644
--- a/src/eplugin/Makefile.am
+++ b/src/eplugin/Makefile.am
@@ -16,6 +16,7 @@ noinst_HEADERS =		\
 @EVO_PLUGIN_RULE@
 
 plugin_DATA = org-gnome-kolab.eplug
+	e-kolab-plugin.c
 
 plugin_LTLIBRARIES = liborg-gnome-kolab.la
 
@@ -32,6 +33,7 @@ liborg_gnome_kolab_la_LIBADD =		\
 	$(EVOLUTION_LIBS)		\
 	$(KOLAB_LIB_EKOLABBACKEND)
 
+	e-kolab-plugin.h
 EXTRA_DIST =				\
 	org-gnome-kolab.eplug.xml	\
 	$(noinst_HEADERS)
diff --git a/src/eplugin/e-kolab-account-setup.h b/src/eplugin/e-kolab-account-setup.h
index ca64a4a..5853e2d 100644
--- a/src/eplugin/e-kolab-account-setup.h
+++ b/src/eplugin/e-kolab-account-setup.h
@@ -25,8 +25,8 @@
 
 /*----------------------------------------------------------------------------*/
 
-#ifndef _KOLAB_ACCOUNT_SETUP_H_
-#define _KOLAB_ACCOUNT_SETUP_H_
+#ifndef _E_KOLAB_ACCOUNT_SETUP_H_
+#define _E_KOLAB_ACCOUNT_SETUP_H_
 
 /*----------------------------------------------------------------------------*/
 
@@ -45,32 +45,19 @@ typedef enum {
 
 /*----------------------------------------------------------------------------*/
 
-gint
-e_plugin_lib_enable (EPlugin*, gint);
+void
+e_kolab_account_setup_ensure_calendar_source_groups (void);
 
-GtkWidget*
-org_gnome_kolab_account_setup (EPlugin *epl,
-                               EConfigHookItemFactoryData *data);
-
-gboolean
-org_gnome_kolab_check_options(EPlugin *epl,
-                              EConfigHookPageCheckData *data);
+void
+e_kolab_account_setup_ensure_contacts_source_group (void);
 
 GtkWidget*
-e_kolab_account_setup_create_backend (EPlugin *epl,
+e_kolab_account_setup_backend_create (EPlugin *epl,
                                       EConfigHookItemFactoryData *data,
                                       KolabWidgetType widget_type);
 
-GtkWidget*
-e_kolab_account_setup_create_calendar (EPlugin *epl,
-                                       EConfigHookItemFactoryData *data);
-
-GtkWidget*
-e_kolab_account_setup_create_addressbook (EPlugin *epl,
-                                          EConfigHookItemFactoryData *data);
-
 /*----------------------------------------------------------------------------*/
 
-#endif /* _KOLAB_ACCOUNT_SETUP_H_ */
+#endif /* _E_KOLAB_ACCOUNT_SETUP_H_ */
 
 /*----------------------------------------------------------------------------*/
diff --git a/src/eplugin/e-kolab-plugin.c b/src/eplugin/e-kolab-plugin.c
new file mode 100644
index 0000000..ba0f3c2
--- /dev/null
+++ b/src/eplugin/e-kolab-plugin.c
@@ -0,0 +1,183 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/***************************************************************************
+ *            e-kolab-plugin.c
+ *
+ *  Wed Feb 08 16:22:05 2012
+ *  Copyright  2012  Christian Hilberg
+ *  <hilberg kernelconcepts de>
+ *
+ ****************************************************************************/
+
+/*
+ * 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 <config.h>
+
+#include "e-kolab-account-setup.h"
+#include "e-kolab-plugin.h"
+
+/*----------------------------------------------------------------------------*/
+/* plugin */
+
+gint
+e_plugin_lib_enable (EPlugin *epl,
+                     gint enable)
+{
+	/* api demo */
+	g_assert (E_IS_PLUGIN (epl));
+	if (enable) {
+		/* init stuff, call some libekolab/ init function here */
+		/*
+		  bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
+		  bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+		*/
+		/* TODO error propagation? */
+		e_kolab_account_setup_ensure_calendar_source_groups ();
+		e_kolab_account_setup_ensure_contacts_source_group ();
+		g_debug ("%s(): Kolab plugin enabled", __func__);
+	} else {
+		g_debug ("%s(): Kolab plugin disabled", __func__);
+	}
+	return 0;
+}
+
+/*----------------------------------------------------------------------------*/
+/* calendar */
+
+gboolean
+e_kolab_plugin_calendar_check (EPlugin *epl,
+                               EConfigHookPageCheckData *data)
+{
+	g_assert (E_IS_PLUGIN (epl));
+	g_assert (data != NULL);
+
+	/* FIXME implement me */
+	g_warning ("%s: FIXME implement me", __func__);
+
+	return TRUE;
+}
+
+void
+e_kolab_plugin_calendar_commit (EPlugin *epl,
+                                EConfigTarget *target)
+{
+	g_assert (E_IS_PLUGIN (epl));
+	g_assert (target != NULL);
+
+	/* FIXME implement me */
+	g_warning ("%s: FIXME implement me", __func__);
+}
+
+GtkWidget*
+e_kolab_plugin_calendar_create (EPlugin *epl,
+                                EConfigHookItemFactoryData *data)
+{
+	g_assert (E_IS_PLUGIN (epl));
+	g_assert (data != NULL);
+
+	e_kolab_account_setup_backend_create (epl,
+	                                      data,
+	                                      KOLAB_CALENDAR_WIDGET);
+	return NULL;
+}
+
+/*----------------------------------------------------------------------------*/
+/* address book */
+
+gboolean
+e_kolab_plugin_addressbook_check (EPlugin *epl,
+                                  EConfigHookPageCheckData *data)
+{
+	g_assert (E_IS_PLUGIN (epl));
+	g_assert (data != NULL);
+
+	/* FIXME implement me */
+	g_warning ("%s: FIXME implement me", __func__);
+
+	return TRUE;
+}
+
+void
+e_kolab_plugin_addressbook_commit (EPlugin *epl,
+                                   EConfigTarget *target)
+{
+	g_assert (E_IS_PLUGIN (epl));
+	g_assert (target != NULL);
+
+	/* FIXME implement me */
+	g_warning ("%s: FIXME implement me", __func__);
+}
+
+GtkWidget*
+e_kolab_plugin_addressbook_create (EPlugin *epl,
+                                   EConfigHookItemFactoryData *data)
+{
+	g_assert (E_IS_PLUGIN (epl));
+	g_assert (data != NULL);
+
+	e_kolab_account_setup_backend_create (epl,
+	                                      data,
+	                                      KOLAB_CONTACT_WIDGET);
+	return NULL;
+}
+
+/*----------------------------------------------------------------------------*/
+/* mail */
+
+gboolean
+e_kolab_plugin_mail_account_check (EPlugin *epl,
+                                   EConfigHookPageCheckData *data)
+{
+	g_assert (E_IS_PLUGIN (epl));
+	g_assert (data != NULL);
+
+	/* FIXME implement me */
+	g_warning ("%s: FIXME implement me", __func__);
+
+	return TRUE;
+}
+
+void
+e_kolab_plugin_mail_account_commit (EPlugin *epl,
+                                    EConfigTarget *target)
+{
+	g_assert (E_IS_PLUGIN (epl));
+	g_assert (target != NULL);
+
+	/* FIXME implement me */
+	g_warning ("%s: FIXME implement me", __func__);
+}
+
+GtkWidget*
+e_kolab_plugin_mail_account_setup (EPlugin *epl,
+                                   EConfigHookItemFactoryData *data)
+{
+	g_assert (E_IS_PLUGIN (epl));
+
+	g_debug ("%s() called.\n", __func__);
+	g_debug (" + epl: %p", (void*)epl);
+	g_debug (" + data: %p", (void*)data);
+
+	/* is NULL on New Account creation, add more stuff here */
+	return NULL;
+
+	/* more here to be stolen from e-mapi-account-setup.c */
+	/* ... */
+}
+
+/*----------------------------------------------------------------------------*/
diff --git a/src/eplugin/e-kolab-plugin.h b/src/eplugin/e-kolab-plugin.h
new file mode 100644
index 0000000..59f97e9
--- /dev/null
+++ b/src/eplugin/e-kolab-plugin.h
@@ -0,0 +1,86 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/***************************************************************************
+ *            e-kolab-plugin.h
+ *
+ *  Wed Feb 08 16:24:05 2012
+ *  Copyright  2012  Christian Hilberg
+ *  <hilberg kernelconcepts de>
+ *
+ ****************************************************************************/
+
+/*
+ * 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_PLUGIN_H_
+#define _E_KOLAB_PLUGIN_H_
+
+/*----------------------------------------------------------------------------*/
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include <e-util/e-config.h>
+#include <e-util/e-plugin.h>
+
+/*----------------------------------------------------------------------------*/
+
+gint
+e_plugin_lib_enable (EPlugin *epl,
+                     gint enable);
+
+gboolean
+e_kolab_plugin_calendar_check (EPlugin *epl,
+                               EConfigHookPageCheckData *data);
+
+void
+e_kolab_plugin_calendar_commit (EPlugin *epl,
+                                EConfigTarget *target);
+
+GtkWidget*
+e_kolab_plugin_calendar_create (EPlugin *epl,
+                                EConfigHookItemFactoryData *data);
+
+gboolean
+e_kolab_plugin_addressbook_check (EPlugin *epl,
+                                  EConfigHookPageCheckData *data);
+
+void
+e_kolab_plugin_addressbook_commit (EPlugin *epl,
+                                   EConfigTarget *target);
+
+GtkWidget*
+e_kolab_plugin_addressbook_create (EPlugin *epl,
+                                   EConfigHookItemFactoryData *data);
+
+gboolean
+e_kolab_plugin_mail_account_check (EPlugin *epl,
+                                   EConfigHookPageCheckData *data);
+
+void
+e_kolab_plugin_mail_account_commit (EPlugin *epl,
+                                    EConfigTarget *target);
+
+GtkWidget*
+e_kolab_plugin_mail_account_setup (EPlugin *epl,
+                                   EConfigHookItemFactoryData *data);
+
+/*----------------------------------------------------------------------------*/
+
+#endif /* _E_KOLAB_PLUGIN_H_ */
+
+/*----------------------------------------------------------------------------*/
diff --git a/src/eplugin/org-gnome-kolab.eplug.xml b/src/eplugin/org-gnome-kolab.eplug.xml
index 5802080..6b7aff5 100644
--- a/src/eplugin/org-gnome-kolab.eplug.xml
+++ b/src/eplugin/org-gnome-kolab.eplug.xml
@@ -13,26 +13,29 @@
 		<description>Kolab2 Plugin</description>
 
 		<hook class="org.gnome.evolution.addressbook.config:1.0">
-			<group target="source"
-			       id="com.novell.evolution.addressbook.config.accountEditor"
-			       check="org_gnome_kolab_check_options">
-				<item type="item"
-				      path="00.general/10.display/50.createcontacts"
-				      factory="e_kolab_account_setup_create_addressbook">
-				</item>
+			<group
+				target="source"
+				id="com.novell.evolution.addressbook.config.accountEditor"
+				check="e_kolab_plugin_addressbook_check"
+				commit="e_kolab_plugin_addressbook_commit">
+				<item
+					type="item"
+					path="00.general/10.display/50.createcontacts"
+					factory="e_kolab_plugin_addressbook_create"/>
 			</group>
 		</hook>
 		<hook class="org.gnome.evolution.calendar.config:1.0">
-			<group target="source"
-			       id="org.gnome.evolution.calendar.calendarProperties"
-			       check="org_gnome_kolab_check_options">
-				<item type="item_table"
-				      path="00.general/00.source/99.kolabcalendar"
-				      factory="e_kolab_account_setup_create_calendar">
-				</item>
+			<group
+				target="source"
+				id="org.gnome.evolution.calendar.calendarProperties"
+				check="e_kolab_plugin_calendar_check"
+				commit="e_kolab_plugin_calendar_commit">
+				<item
+					type="item_table"
+					path="00.general/10.source/40.pcalendar"
+					factory="e_kolab_plugin_calendar_create"/>
 			</group>
 		</hook>
-		<!-- TODO need at least one (dummy) hook? -->
 
 		<!--
 
@@ -40,33 +43,36 @@
 			<group
 				target="account"
 				id="org.gnome.evolution.mail.config.accountWizard"
-				check="org_gnome_kolab_check_options">
+				check="e_kolab_plugin_mail_account_check">
+				commit="e_kolab_plugin_mail_account_commit">
 				<item
 					type="item_table"
 					path="10.receive/20.config/30.kolab"
-					factory="org_gnome_kolab_account_setup"/>
+					factory="e_kolab_plugin_mail_account_setup"/>
 			</group>
 		</hook>
 		<hook class="org.gnome.evolution.mail.config:1.0">
 			<group
 				target="account"
 				id="org.gnome.evolution.mail.config.accountAssistant"
-				check="org_gnome_kolab_check_options">
+				check="e_kolab_plugin_mail_account_check">
+				commit="e_kolab_plugin_mail_account_commit">
 				<item
 					type="item_table"
 					path="10.receive/20.config/30.kolab"
-					factory="org_gnome_kolab_account_setup"/>
+					factory="e_kolab_plugin_mail_account_setup"/>
 			</group>
 		</hook>
 		<hook class="org.gnome.evolution.mail.config:1.0">
 			<group
 				target="account"
 				id="org.gnome.evolution.mail.config.accountEditor"
-				check="org_gnome_kolab_check_options">
+				check="e_kolab_plugin_mail_account_check">
+				commit="e_kolab_plugin_mail_account_commit">
 				<item
 					type="item_table"
 					path="10.receive/20.config/30.kolab"
-					factory="org_gnome_kolab_account_setup"/>
+					factory="e_kolab_plugin_mail_account_setup"/>
 			</group>
 		</hook>
 



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