From 63e252153f465536953d644520319d80195222fb Mon Sep 17 00:00:00 2001
From: Andrea Zagli <azagli@libero.it>
Date: Thu, 1 Sep 2016 17:30:16 +0200
Subject: [PATCH] Migration to libpeas.

---
 configure.ac         |   4 +-
 libzakauthe.pc.in    |   1 +
 src/Makefile.am      |  11 +++-
 src/aute.c           | 145 +++++++++++++++++++------------------------
 src/authe.h          |  66 ++++++++++++++++++++
 src/authepluggable.c | 130 ++++++++++++++++++++++++++++++++++++++
 src/authepluggable.h |  85 +++++++++++++++++++++++++
 src/libzakauthe.h    |  49 ++-------------
 8 files changed, 360 insertions(+), 131 deletions(-)
 create mode 100644 src/authe.h
 create mode 100644 src/authepluggable.c
 create mode 100644 src/authepluggable.h

diff --git a/configure.ac b/configure.ac
index b440d21..9e25ee1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,8 +25,8 @@ GTK_DOC_CHECK
 # Checks for libraries.
 have_libconfi=no
 
-PKG_CHECK_MODULES(LIBZAKAUTHE, [gmodule-2.0 >= 2.10.0
-							   gtk+-3.0 >= 3.0.0])
+PKG_CHECK_MODULES(LIBZAKAUTHE, [gtk+-3.0 >= 3.0.0
+                                libpeas-1.0 >= 1.12.0])
 
 AC_SUBST(LIBZAKAUTHE_CFLAGS)
 AC_SUBST(LIBZAKAUTHE_LIBS)
diff --git a/libzakauthe.pc.in b/libzakauthe.pc.in
index e761b75..c1ecf42 100644
--- a/libzakauthe.pc.in
+++ b/libzakauthe.pc.in
@@ -2,6 +2,7 @@ prefix=@prefix@
 exec_prefix=@exec_prefix@
 libdir=@libdir@
 includedir=@includedir@
+pluginsdir=@libdir@/@PACKAGE@/plugins
 
 Name: @PACKAGE_NAME@
 Description: Library to manage authentication through plugins
diff --git a/src/Makefile.am b/src/Makefile.am
index 47a3454..c92dc0a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,14 +1,19 @@
 AM_CPPFLAGS = $(LIBZAKAUTHE_CFLAGS) \
               $(LIBZAKCONFI_CFLAGS) \
-              -DLIB_ZAK_AUTHE_PLUGINS_DIR=\""$(libdir)/libzakauthe/plugins"\"
+              -DLIB_ZAK_AUTHE_PLUGINS_DIR=\""$(libdir)/$(PACKAGE)/plugins"\"
 
 LIBS = $(LIBZAKAUTHE_LIBS) \
        $(LIBZAKCONFI_LIBS)
 
 lib_LTLIBRARIES = libzakauthe.la
 
-libzakauthe_la_SOURCES = aute.c
+libzakauthe_la_SOURCES = aute.c \
+                         authepluggable.c
 
 libzakauthe_la_LDFLAGS = -no-undefined
 
-include_HEADERS = libzakauthe.h
+libzakauthe_includedir = $(includedir)/$(PACKAGE)
+
+libzakauthe_include_HEADERS = libzakauthe.h \
+                              authe.h \
+                              authepluggable.h
diff --git a/src/aute.c b/src/aute.c
index 0cd9964..bd5a966 100644
--- a/src/aute.c
+++ b/src/aute.c
@@ -23,6 +23,8 @@
 #include <stdio.h>
 #include <glib/gprintf.h>
 
+#include <libpeas/peas.h>
+
 #ifdef HAVE_LIBZAKCONFI
 	#include <libzakconfi/libzakconfi.h>
 #endif
@@ -42,14 +44,16 @@ static void zak_authe_get_property (GObject *object,
                                GParamSpec *pspec);
 static void zak_authe_finalize (GObject *object);
 
-static gchar *zak_authe_get_module_from_confi (ZakAuthe *aute);
+#ifdef HAVE_LIBZAKCONFI
+static gchar *zak_authe_get_pluggable_from_confi (ZakAuthe *authe);
+#endif
 
 #define ZAK_AUTHE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_TYPE_AUTHE, ZakAuthePrivate))
 
 typedef struct _ZakAuthePrivate ZakAuthePrivate;
 struct _ZakAuthePrivate
 	{
-		GModule *module;
+		ZakAuthePluggable *pluggable;
 
 		GSList *parameters;
 
@@ -77,7 +81,7 @@ zak_authe_init (ZakAuthe *form)
 {
 	ZakAuthePrivate *priv = ZAK_AUTHE_GET_PRIVATE (form);
 
-	priv->module = NULL;
+	priv->pluggable = NULL;
 	priv->parameters = NULL;
 
 #ifdef HAVE_LIBZAKCONFI
@@ -105,8 +109,14 @@ ZakAuthe
 gboolean
 zak_authe_set_config (ZakAuthe *aute, GSList *parameters)
 {
+	gboolean ret;
+
+	PeasEngine *peas_engine;
+
 	gchar *module_name;
 
+	const GList *lst_plugins;
+
 	ZakAuthePrivate *priv = ZAK_AUTHE_GET_PRIVATE (aute);
 
 	g_return_val_if_fail (parameters != NULL && parameters->data != NULL, FALSE);
@@ -122,7 +132,7 @@ zak_authe_set_config (ZakAuthe *aute, GSList *parameters)
 			if (ZAK_IS_CONFI ((ZakConfi *)g_slist_nth_data (priv->parameters, 1)))
 				{
 					priv->confi = ZAK_CONFI ((ZakConfi *)g_slist_nth_data (priv->parameters, 1));
-					module_name = zak_authe_get_module_from_confi (aute);
+					module_name = zak_authe_get_pluggable_from_confi (aute);
 				}
 		}
 #endif
@@ -139,18 +149,47 @@ zak_authe_set_config (ZakAuthe *aute, GSList *parameters)
 			return FALSE;
 		}
 
-	/* loading library */
-	priv->module = g_module_open (module_name, G_MODULE_BIND_LAZY);
-	if (!priv->module)
+	peas_engine = peas_engine_get_default ();
+	if (peas_engine == NULL)
 		{
-			/* TO DO */
-			g_warning ("Error g_module_open.");
 			return FALSE;
 		}
 
+	ret = TRUE;
+
+	peas_engine_add_search_path (peas_engine, LIB_ZAK_AUTHE_PLUGINS_DIR, NULL);
+
+	lst_plugins = peas_engine_get_plugin_list (peas_engine);
+	while (lst_plugins)
+		{
+			PeasPluginInfo *ppinfo;
+
+			ppinfo = (PeasPluginInfo *)lst_plugins->data;
+
+			if (g_strcmp0 (module_name, peas_plugin_info_get_module_name (ppinfo)) == 0)
+				{
+					if (peas_engine_load_plugin (peas_engine, ppinfo))
+						{
+							PeasExtension *ext;
+							ext = peas_engine_create_extension (peas_engine, ppinfo, ZAK_AUTHE_TYPE_PLUGGABLE,
+							                                    NULL);
+							priv->pluggable = (ZakAuthePluggable *)ext;
+							break;
+						}
+				}
+
+			lst_plugins = g_list_next (lst_plugins);
+		}
+
+	if (priv->pluggable == NULL)
+		{
+			g_warning ("No plugin found with name \"%s\".", module_name);
+			ret = FALSE;
+		}
+
 	g_free (module_name);
 
-	return TRUE;
+	return ret;
 }
 
 /**
@@ -163,25 +202,16 @@ zak_authe_set_config (ZakAuthe *aute, GSList *parameters)
 gchar
 *zak_authe_authe (ZakAuthe *aute)
 {
-	gchar *(*autentica) (GSList *parameters);
 	gchar *ret;
 
 	ZakAuthePrivate *priv = ZAK_AUTHE_GET_PRIVATE (aute);
 
-	g_return_val_if_fail (priv->module != NULL, NULL);
+	g_return_val_if_fail (priv->pluggable != NULL, NULL);
 
 	ret = NULL;
 
-	/* loading the function */
-	if (!g_module_symbol (priv->module, "zak_authe_plg_authe", (gpointer *)&autentica))
-		{
-			/* TO DO */
-			g_warning ("Error g_module_symbol\n");
-			return NULL;
-		}
-
 	/* calling plugin's function */
-	ret = (*autentica) (priv->parameters);
+	ret = zak_authe_pluggable_authe (priv->pluggable, priv->parameters);
 
 	return ret;
 }
@@ -198,29 +228,16 @@ gchar
 gchar
 *zak_authe_get_password (ZakAuthe *aute, gchar **password)
 {
-	gchar *(*zak_authe_plg_get_password) (GSList *parameters, gchar **password);
 	gchar *ret;
 
 	ZakAuthePrivate *priv = ZAK_AUTHE_GET_PRIVATE (aute);
 
-	g_return_val_if_fail (priv->module != NULL, NULL);
+	g_return_val_if_fail (priv->pluggable != NULL, NULL);
 
 	ret = NULL;
 
-	/* loading the function */
-	if (!g_module_symbol (priv->module, "zak_authe_plg_get_password", (gpointer *)&zak_authe_plg_get_password))
-		{
-			/* TO DO */
-			g_warning ("Error g_module_symbol: zak_authe_plg_get_password.\n");
-
-			/* try zak_authe_authe */
-			ret = zak_authe_authe (aute);
-		}
-	else
-		{
-			/* calling plugin's function */
-			ret = (*zak_authe_plg_get_password) (priv->parameters, password);
-		}
+	/* calling plugin's function */
+	ret = zak_authe_pluggable_authe_get_password (priv->pluggable, priv->parameters, password);
 
 	return ret;
 }
@@ -239,25 +256,12 @@ zak_authe_authe_nogui (ZakAuthe *zakauthe, const gchar *username, const gchar *p
 {
 	gboolean ret;
 
-	gboolean (*zak_authe_plg_authe_nogui) (GSList *parameters, const gchar *username, const gchar *password, const gchar *new_password);
-
 	ZakAuthePrivate *priv = ZAK_AUTHE_GET_PRIVATE (zakauthe);
 
-	g_return_val_if_fail (priv->module != NULL, FALSE);
+	g_return_val_if_fail (priv->pluggable != NULL, FALSE);
 
-	/* loading the function */
-	if (!g_module_symbol (priv->module, "zak_authe_plg_authe_nogui", (gpointer *)&zak_authe_plg_authe_nogui))
-		{
-			/* TO DO */
-			g_warning ("Error g_module_symbol: zak_authe_plg_authe_nogui.\n");
-
-			ret = FALSE;
-		}
-	else
-		{
-			/* calling plugin's function */
-			ret = (*zak_authe_plg_authe_nogui) (priv->parameters, username, password, new_password);
-		}
+	/* calling plugin's function */
+	ret = zak_authe_pluggable_authe_nogui (priv->pluggable, priv->parameters, username, password, new_password);
 
 	return ret;
 }
@@ -270,28 +274,18 @@ zak_authe_authe_nogui (ZakAuthe *zakauthe, const gchar *username, const gchar *p
 GtkWidget
 *zak_authe_get_management_gui (ZakAuthe *aute)
 {
-	GtkWidget *(*get_management_gui) (GSList *parameters);
 	GtkWidget *ret;
 
 	ZakAuthePrivate *priv = ZAK_AUTHE_GET_PRIVATE (aute);
 
-	g_return_val_if_fail (priv->module != NULL, NULL);
+	g_return_val_if_fail (priv->pluggable != NULL, NULL);
 
 	ret = NULL;
 
-	/* loading the function */
-	if (!g_module_symbol (priv->module, "zak_authe_plg_get_management_gui", (gpointer *)&get_management_gui))
-		{
-			/* TO DO */
-			g_warning ("Error g_module_symbol: zak_authe_plg_get_management_gui.\n");
-			return NULL;
-		}
-
 	/* calling plugin's function */
-	ret = (*get_management_gui) (priv->parameters);
+	ret = zak_authe_pluggable_get_management_gui (priv->pluggable, priv->parameters);
 
 	return ret;
-
 }
 
 /* PRIVATE */
@@ -338,36 +332,23 @@ zak_authe_finalize (GObject *object)
 
 	ZakAuthePrivate *priv = ZAK_AUTHE_GET_PRIVATE (aute);
 
-	/* closing the library */
-	if (priv->module != NULL)
-		{
-			if (!g_module_close (priv->module))
-				{
-					g_fprintf (stderr, "Error g_module_close\n");
-				}
-			else
-				{
-					priv->module = NULL;
-				}
-		}
-
 	/* Chain up to the parent class */
 	G_OBJECT_CLASS (zak_authe_parent_class)->finalize (object);
 }
 
 #ifdef HAVE_LIBZAKCONFI
 /**
- * zak_authe_get_plugin_module:
- * @aute: a #ZakAuthe object.
+ * zak_authe_get_pluggable_from_confi:
+ * @authe: a #ZakAuthe object.
  *
  * Returns: plugin path.
  */
 static gchar
-*zak_authe_get_module_from_confi (ZakAuthe *aute)
+*zak_authe_get_pluggable_from_confi (ZakAuthe *authe)
 {
 	gchar *libname;
 
-	ZakAuthePrivate *priv = ZAK_AUTHE_GET_PRIVATE (aute);
+	ZakAuthePrivate *priv = ZAK_AUTHE_GET_PRIVATE (authe);
 
 	g_return_val_if_fail (ZAK_IS_CONFI (priv->confi), NULL);
 
diff --git a/src/authe.h b/src/authe.h
new file mode 100644
index 0000000..db9c41e
--- /dev/null
+++ b/src/authe.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2005-2016 Andrea Zagli <azagli@libero.it>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __ZAKAUTHE_H__
+#define __ZAKAUTHE_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gmodule.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define ZAK_TYPE_AUTHE                 (zak_authe_get_type ())
+#define ZAK_AUTHE(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), ZAK_TYPE_AUTHE, ZakAuthe))
+#define ZAK_AUTHE_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), ZAK_TYPE_AUTHE, ZakAutheClass))
+#define ZAK_IS_AUTHE(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ZAK_TYPE_AUTHE))
+#define ZAK_IS_AUTHE_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), ZAK_TYPE_AUTHE))
+#define ZAKAUTHE_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), ZAK_TYPE_AUTHE, ZakAutheClass))
+
+
+typedef struct _ZakAuthe ZakAuthe;
+typedef struct _ZakAutheClass ZakAutheClass;
+
+struct _ZakAuthe
+	{
+		GObject parent;
+	};
+
+struct _ZakAutheClass
+	{
+		GObjectClass parent_class;
+	};
+
+GType zak_authe_get_type (void) G_GNUC_CONST;
+
+ZakAuthe *zak_authe_new (void);
+
+gboolean zak_authe_set_config (ZakAuthe *zakauthe, GSList *parameters);
+
+gchar *zak_authe_authe (ZakAuthe *zakauthe);
+gchar *zak_authe_get_password (ZakAuthe *zakauthe, gchar **password);
+gboolean zak_authe_authe_nogui (ZakAuthe *zakauthe, const gchar *username, const gchar *password, const gchar *new_password);
+
+GtkWidget *zak_authe_get_management_gui (ZakAuthe *zakauthe);
+
+
+G_END_DECLS
+
+
+#endif /* __ZAKAUTHE_H__ */
diff --git a/src/authepluggable.c b/src/authepluggable.c
new file mode 100644
index 0000000..42a311d
--- /dev/null
+++ b/src/authepluggable.c
@@ -0,0 +1,130 @@
+/*
+ * authepluggable.c
+ * This file is part of libzakauthe
+ *
+ * Copyright (C) 2016 Andrea Zagli <azagli@libero.it>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Library General Public License as published by
+ *  the Free Software Foundation; either version 2 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 Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "authepluggable.h"
+
+/**
+ * SECTION:authepluggable
+ * @short_description: Interface for pluggable plugins.
+ * @see_also: #PeasExtensionSet
+ *
+ **/
+
+G_DEFINE_INTERFACE(ZakAuthePluggable, zak_authe_pluggable, G_TYPE_OBJECT)
+
+void
+zak_authe_pluggable_default_init (ZakAuthePluggableInterface *iface)
+{
+	static gboolean initialized = FALSE;
+
+	if (!initialized)
+		{
+			initialized = TRUE;
+		}
+}
+
+/**
+ * zak_authe_pluggable_authe:
+ * @pluggable: A #ZakAuthePluggable.
+ * @parameters:
+ *
+ * Returns:
+ */
+gchar
+*zak_authe_pluggable_authe (ZakAuthePluggable *pluggable, GSList *parameters)
+{
+	ZakAuthePluggableInterface *iface;
+
+	g_return_val_if_fail (ZAK_AUTHE_IS_PLUGGABLE (pluggable), FALSE);
+
+	iface = ZAK_AUTHE_PLUGGABLE_GET_IFACE (pluggable);
+	g_return_val_if_fail (iface->authe != NULL, FALSE);
+
+	return iface->authe (pluggable, parameters);
+}
+
+/**
+ * zak_authe_pluggable_authe_get_password:
+ * @pluggable: A #ZakAuthePluggable.
+ * @parameters:
+ * @password:
+ *
+ * Returns:
+*/
+gchar
+*zak_authe_pluggable_authe_get_password (ZakAuthePluggable *pluggable, GSList *parameters, gchar **password)
+{
+	ZakAuthePluggableInterface *iface;
+
+	g_return_val_if_fail (ZAK_AUTHE_IS_PLUGGABLE (pluggable), FALSE);
+
+	iface = ZAK_AUTHE_PLUGGABLE_GET_IFACE (pluggable);
+	g_return_val_if_fail (iface->authe_get_password != NULL, FALSE);
+
+	return iface->authe_get_password (pluggable, parameters, password);
+}
+
+/**
+ * zak_authe_pluggable_authe_nogui:
+ * @pluggable: A #ZakAuthePluggable.
+ * @parameters:
+ * @username:
+ * @password:
+ * @new_password:
+ *
+ * Returns:
+*/
+gboolean
+zak_authe_pluggable_authe_nogui (ZakAuthePluggable *pluggable, GSList *parameters, const gchar *username, const gchar *password, const gchar *new_password)
+{
+	ZakAuthePluggableInterface *iface;
+
+	g_return_val_if_fail (ZAK_AUTHE_IS_PLUGGABLE (pluggable), FALSE);
+
+	iface = ZAK_AUTHE_PLUGGABLE_GET_IFACE (pluggable);
+	g_return_val_if_fail (iface->authe_nogui != NULL, FALSE);
+
+	return iface->authe_nogui (pluggable, parameters, username, password, new_password);
+}
+
+/**
+ * zak_authe_pluggable_get_management_gui:
+ * @pluggable: a #ZakAuthePluggable object.
+ * @parameters:
+ *
+ * Returns:
+ */
+GtkWidget
+*zak_authe_pluggable_get_management_gui (ZakAuthePluggable *pluggable, GSList *parameters)
+{
+	ZakAuthePluggableInterface *iface;
+
+	g_return_val_if_fail (ZAK_AUTHE_IS_PLUGGABLE (pluggable), FALSE);
+
+	iface = ZAK_AUTHE_PLUGGABLE_GET_IFACE (pluggable);
+	g_return_val_if_fail (iface->get_management_gui != NULL, FALSE);
+
+	return iface->get_management_gui (pluggable, parameters);
+}
diff --git a/src/authepluggable.h b/src/authepluggable.h
new file mode 100644
index 0000000..ee5c7de
--- /dev/null
+++ b/src/authepluggable.h
@@ -0,0 +1,85 @@
+/*
+ * authepluggable.h
+ * This file is part of libzakauthe
+ *
+ * Copyright (C) 2016 - Andrea Zagli <azagli@libero.it>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Library General Public License as published by
+ *  the Free Software Foundation; either version 2 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 Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library 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 __ZAK_AUTHE_PLUGGABLE_H__
+#define __ZAK_AUTHE_PLUGGABLE_H__
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+/*
+ * Type checking and casting macros
+ */
+#define ZAK_AUTHE_TYPE_PLUGGABLE             (zak_authe_pluggable_get_type ())
+#define ZAK_AUTHE_PLUGGABLE(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), ZAK_AUTHE_TYPE_PLUGGABLE, ZakAuthePluggable))
+#define ZAK_AUTHE_PLUGGABLE_IFACE(obj)       (G_TYPE_CHECK_CLASS_CAST ((obj), ZAK_AUTHE_TYPE_PLUGGABLE, ZakAuthePluggableInterface))
+#define ZAK_AUTHE_IS_PLUGGABLE(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ZAK_AUTHE_TYPE_PLUGGABLE))
+#define ZAK_AUTHE_PLUGGABLE_GET_IFACE(obj)   (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ZAK_AUTHE_TYPE_PLUGGABLE, ZakAuthePluggableInterface))
+
+/**
+ * ZakAuthePluggable:
+ *
+ * Interface for pluggable plugins.
+ */
+typedef struct _ZakAuthePluggable           ZakAuthePluggable; /* dummy typedef */
+typedef struct _ZakAuthePluggableInterface  ZakAuthePluggableInterface;
+
+/**
+ * ZakAuthePluggableInterface:
+ * @g_iface: The parent interface.
+ * @initialize: Construct the plugin.
+ *
+ * Provides an interface for pluggable plugins.
+ */
+struct _ZakAuthePluggableInterface {
+	GTypeInterface g_iface;
+
+	/* Virtual public methods */
+	gchar *(*authe) (ZakAuthePluggable *pluggable, GSList *parameters);
+	gchar *(*authe_get_password) (ZakAuthePluggable *pluggable, GSList *parameters, gchar **password);
+	gboolean (*authe_nogui) (ZakAuthePluggable *pluggable, GSList *parameters, const gchar *username, const gchar *password, const gchar *new_password);
+	GtkWidget *(*get_management_gui) (ZakAuthePluggable *pluggable, GSList *parameters);
+};
+
+/*
+ * Public methods
+ */
+GType zak_authe_pluggable_get_type (void) G_GNUC_CONST;
+
+gchar *zak_authe_pluggable_authe (ZakAuthePluggable *pluggable,
+								  GSList *parameters);
+gchar *zak_authe_pluggable_authe_get_password (ZakAuthePluggable *pluggable,
+											   GSList *parameters,
+											   gchar **password);
+gboolean zak_authe_pluggable_authe_nogui (ZakAuthePluggable *pluggable,
+										  GSList *parameters,
+										  const gchar *username,
+										  const gchar *password,
+										  const gchar *new_password);
+GtkWidget *zak_authe_pluggable_get_management_gui (ZakAuthePluggable *pluggable,
+												   GSList *parameters);
+
+
+G_END_DECLS
+
+#endif /* __ZAK_AUTHE_PLUGGABLE_H__ */
diff --git a/src/libzakauthe.h b/src/libzakauthe.h
index db9c41e..46f90b7 100644
--- a/src/libzakauthe.h
+++ b/src/libzakauthe.h
@@ -16,51 +16,12 @@
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-#ifndef __ZAKAUTHE_H__
-#define __ZAKAUTHE_H__
+#ifndef __LIBZAKAUTHE_H__
+#define __LIBZAKAUTHE_H__
 
-#include <glib.h>
-#include <glib-object.h>
-#include <gmodule.h>
-#include <gtk/gtk.h>
 
-G_BEGIN_DECLS
+#include "authe.h"
+#include "authepluggable.h"
 
-#define ZAK_TYPE_AUTHE                 (zak_authe_get_type ())
-#define ZAK_AUTHE(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), ZAK_TYPE_AUTHE, ZakAuthe))
-#define ZAK_AUTHE_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), ZAK_TYPE_AUTHE, ZakAutheClass))
-#define ZAK_IS_AUTHE(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ZAK_TYPE_AUTHE))
-#define ZAK_IS_AUTHE_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), ZAK_TYPE_AUTHE))
-#define ZAKAUTHE_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), ZAK_TYPE_AUTHE, ZakAutheClass))
 
-
-typedef struct _ZakAuthe ZakAuthe;
-typedef struct _ZakAutheClass ZakAutheClass;
-
-struct _ZakAuthe
-	{
-		GObject parent;
-	};
-
-struct _ZakAutheClass
-	{
-		GObjectClass parent_class;
-	};
-
-GType zak_authe_get_type (void) G_GNUC_CONST;
-
-ZakAuthe *zak_authe_new (void);
-
-gboolean zak_authe_set_config (ZakAuthe *zakauthe, GSList *parameters);
-
-gchar *zak_authe_authe (ZakAuthe *zakauthe);
-gchar *zak_authe_get_password (ZakAuthe *zakauthe, gchar **password);
-gboolean zak_authe_authe_nogui (ZakAuthe *zakauthe, const gchar *username, const gchar *password, const gchar *new_password);
-
-GtkWidget *zak_authe_get_management_gui (ZakAuthe *zakauthe);
-
-
-G_END_DECLS
-
-
-#endif /* __ZAKAUTHE_H__ */
+#endif /* __LIBZAKAUTHE_H__ */
-- 
2.49.0