</tool>\r
<tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.autogen.392743236" name="autogen.sh" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.autogen"/>\r
<tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc.1618546228" name="GCC C Compiler" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc">\r
- <option id="gnu.c.compiler.option.include.paths.1467657593" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">\r
+ <option id="gnu.c.compiler.option.include.paths.1467657593" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">\r
<listOptionValue builtIn="false" value=""C:\msys32\mingw32\include""/>\r
<listOptionValue builtIn="false" value=""C:\msys32\mingw32\include\glib-2.0""/>\r
<listOptionValue builtIn="false" value=""C:\msys32\mingw32\include\libxml2""/>\r
+ <listOptionValue builtIn="false" value=""C:\msys32\mingw32\include\libpeas-1.0""/>\r
+ <listOptionValue builtIn="false" value=""C:\msys32\mingw32\include\libgda-5.0""/>\r
</option>\r
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1742788074" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>\r
</tool>\r
DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --enable-introspection
-SUBDIRS = src tests data docs
+SUBDIRS = src plugins tests data docs
EXTRA_DIST = libconfi.pc.in
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
-AC_INIT([libconfi], [0.5.0], [azagli@libero.it])
+AC_INIT([libconfi], [0.10.0], [azagli@libero.it])
AC_CONFIG_SRCDIR([src/libconfi.c])
AC_CONFIG_HEADER([config.h])
GOBJECT_INTROSPECTION_CHECK([1.30.0])
# Checks for libraries.
-PKG_CHECK_MODULES(LIBCONFI, [libgdaex >= 0.5.0])
+PKG_CHECK_MODULES(LIBCONFI, [libgdaex >= 0.5.0
+ libpeas-1.0 >= 1.12.0])
AC_SUBST(LIBCONFI_CFLAGS)
AC_SUBST(LIBCONFI_LIBS)
# Checks for library functions.
+PLUGIN_LIBTOOL_FLAGS="-module -avoid-version -no-undefined"
+AC_SUBST(PLUGIN_LIBTOOL_FLAGS)
+
AC_CONFIG_FILES([
libconfi.pc
Makefile
src/Makefile
+ plugins/Makefile
+ plugins/db/Makefile
+ plugins/file/Makefile
tests/Makefile
data/Makefile
docs/Makefile
--- /dev/null
+SUBDIRS = db file
\ No newline at end of file
--- /dev/null
+plugindir = $(libdir)/plugins/db
+
+AM_CPPFLAGS = \
+ -I$(top_srcdir) \
+ $(LIBCONFI_CFLAGS)
+
+plugin_LTLIBRARIES = libdb.la
+
+libdb_la_SOURCES = \
+ plgdb.h \
+ plgdb.c
+
+libdb_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS)
+libdb_la_LIBADD = \
+ $(top_builddir)/src/libconfi.la \
+ $(LIBCONFI_LIBS)
+
+plugin_DATA = db.plugin
+
+EXTRA_DIST = $(plugin_DATA)
--- /dev/null
+[Plugin]
+Module=db
+Name=DB
+Description=Inserts a box containing "Hello World" in every windows.
+Authors=Andrea Zagli <azagli@libero.it>
+Copyright=Copyright © 2014 Andrea Zagli
+Website=http://saetta.ns0.it/
+Help=http://saetta.ns0.it/
--- /dev/null
+/*
+ * plgdb.c
+ * This file is part of confi
+ *
+ * Copyright (C) 2014 Andrea Zagli
+ *
+ * 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 <string.h>
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gmodule.h>
+
+#include <libpeas/peas.h>
+
+#include <libgdaex/libgdaex.h>
+
+#include "../../src/libconfi.h"
+#include "../../src/confipluggable.h"
+
+#include "plgdb.h"
+
+static void confi_pluggable_iface_init (ConfiPluggableInterface *iface);
+
+#define CONFI_DB_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CONFI_TYPE_DB_PLUGIN, ConfiDBPluginPrivate))
+
+typedef struct _ConfiDBPluginPrivate ConfiDBPluginPrivate;
+struct _ConfiDBPluginPrivate
+ {
+ gchar *cnc_string;
+
+ GdaEx *gdaex;
+
+ gint id_config;
+ gchar *name;
+ gchar *description;
+ gchar *root;
+ GHashTable *values;
+
+ gchar chrquot;
+ };
+
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (ConfiDBPlugin,
+ confi_db_plugin,
+ PEAS_TYPE_EXTENSION_BASE,
+ 0,
+ G_IMPLEMENT_INTERFACE_DYNAMIC (CONFI_TYPE_PLUGGABLE,
+ confi_pluggable_iface_init))
+
+enum {
+ PROP_0,
+ PROP_CNC_STRING,
+ PROP_NAME,
+ PROP_DESCRIPTION,
+ PROP_ROOT
+};
+
+static void
+confi_db_plugin_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ ConfiDBPlugin *plugin = CONFI_DB_PLUGIN (object);
+ ConfiDBPluginPrivate *priv = CONFI_DB_PLUGIN_GET_PRIVATE (plugin);
+
+ switch (prop_id)
+ {
+ case PROP_CNC_STRING:
+ confi_db_plugin_initialize ((ConfiPluggable *)plugin, g_value_get_string (value));
+ break;
+
+ case PROP_NAME:
+ break;
+
+ case PROP_DESCRIPTION:
+ break;
+
+ case PROP_ROOT:
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+confi_db_plugin_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ ConfiDBPlugin *plugin = CONFI_DB_PLUGIN (object);
+ ConfiDBPluginPrivate *priv = CONFI_DB_PLUGIN_GET_PRIVATE (plugin);
+
+ switch (prop_id)
+ {
+ case PROP_CNC_STRING:
+ g_value_set_string (value, priv->cnc_string);
+ break;
+
+ case PROP_NAME:
+ g_value_set_string (value, priv->name);
+ break;
+
+ case PROP_DESCRIPTION:
+ g_value_set_string (value, priv->description);
+ break;
+
+ case PROP_ROOT:
+ g_value_set_string (value, priv->root);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+confi_db_plugin_init (ConfiDBPlugin *plugin)
+{
+}
+
+static void
+confi_db_plugin_finalize (GObject *object)
+{
+ ConfiDBPlugin *plugin = CONFI_DB_PLUGIN (object);
+
+ G_OBJECT_CLASS (confi_db_plugin_parent_class)->finalize (object);
+}
+
+gboolean
+confi_db_plugin_initialize (ConfiPluggable *pluggable, const gchar *cnc_string)
+{
+ ConfiDBPlugin *plugin = CONFI_DB_PLUGIN (pluggable);
+ ConfiDBPluginPrivate *priv = CONFI_DB_PLUGIN_GET_PRIVATE (plugin);
+
+ GString *gstr_cnc_string;
+ gchar **strs;
+ guint i;
+ guint l;
+
+ strs = g_strsplit (cnc_string, ";", -1);
+
+ gstr_cnc_string = g_string_new ("");
+
+ l = g_strv_length (strs);
+ for (i = 0; i < l; i++)
+ {
+ if (g_str_has_prefix (strs[i], "CONFI_NAME="))
+ {
+ priv->name = g_strdup (strs[i] + strlen ("CONFI_NAME="));
+ if (priv->name[strlen (priv->name)] == ';')
+ {
+ priv->name[strlen (priv->name)] = '\0';
+ }
+ }
+ else
+ {
+ g_string_append (gstr_cnc_string, strs[i]);
+ g_string_append (gstr_cnc_string, ";");
+ }
+ }
+ if (priv->cnc_string != NULL)
+ {
+ g_free (priv->cnc_string);
+ }
+ priv->cnc_string = g_strdup (gstr_cnc_string->str);
+
+ g_string_free (gstr_cnc_string, TRUE);
+ g_strfreev (strs);
+
+ priv->gdaex = gdaex_new_from_string (priv->cnc_string);
+
+ return (priv->gdaex != NULL ? TRUE : FALSE);
+}
+
+static GList
+*confi_db_plugin_get_configs_list (ConfiPluggable *pluggable,
+ const gchar *filter)
+{
+ GList *lst;
+
+ gchar *sql;
+ gchar *where = "";
+
+ ConfiDBPluginPrivate *priv = CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+
+ lst = NULL;
+
+ if (priv->gdaex == NULL)
+ {
+ return NULL;
+ }
+
+ if (filter != NULL && strcmp (g_strstrip (g_strdup (filter)), "") != 0)
+ {
+ where = g_strdup_printf (" WHERE name LIKE '%s'", filter);
+ }
+
+ sql = g_strdup_printf ("SELECT * FROM configs%s", where);
+
+ GdaDataModel *dmConfigs = gdaex_query (priv->gdaex, sql);
+ if (dmConfigs != NULL)
+ {
+ guint row;
+ guint id;
+ guint rows;
+
+ rows = gda_data_model_get_n_rows (dmConfigs);
+ if (rows > 0)
+ {
+ for (row = 0; row < rows; row++)
+ {
+ ConfiConfi *confi;
+ confi = g_new0 (ConfiConfi, 1);
+ confi->name = gdaex_data_model_get_field_value_stringify_at (dmConfigs, row, "name");
+ confi->description = gdaex_data_model_get_field_value_stringify_at (dmConfigs, row, "description");
+ lst = g_list_append (lst, confi);
+ }
+ }
+ else
+ {
+ lst = g_list_append (lst, NULL);
+ }
+ }
+
+ return lst;
+}
+
+static void
+confi_db_plugin_class_init (ConfiDBPluginClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (object_class, sizeof (ConfiDBPluginPrivate));
+
+ object_class->set_property = confi_db_plugin_set_property;
+ object_class->get_property = confi_db_plugin_get_property;
+ object_class->finalize = confi_db_plugin_finalize;
+
+ g_object_class_override_property (object_class, PROP_CNC_STRING, "cnc_string");
+ g_object_class_override_property (object_class, PROP_NAME, "name");
+ g_object_class_override_property (object_class, PROP_DESCRIPTION, "description");
+ g_object_class_override_property (object_class, PROP_ROOT, "root");
+}
+
+static void
+confi_pluggable_iface_init (ConfiPluggableInterface *iface)
+{
+ iface->initialize = confi_db_plugin_initialize;
+ iface->get_configs_list = confi_db_plugin_get_configs_list;
+}
+
+static void
+confi_db_plugin_class_finalize (ConfiDBPluginClass *klass)
+{
+}
+
+G_MODULE_EXPORT void
+peas_register_types (PeasObjectModule *module)
+{
+ confi_db_plugin_register_type (G_TYPE_MODULE (module));
+
+ peas_object_module_register_extension_type (module,
+ CONFI_TYPE_PLUGGABLE,
+ CONFI_TYPE_DB_PLUGIN);
+}
--- /dev/null
+/*
+ * plgdb.h
+ * This file is part of confi
+ *
+ * Copyright (C) 2014 Andrea Zagli
+ *
+ * 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 __CONFI_DB_PLUGIN_H__
+#define __CONFI_DB_PLUGIN_H__
+
+#include <libpeas/peas.h>
+
+G_BEGIN_DECLS
+
+#define CONFI_TYPE_DB_PLUGIN (confi_db_plugin_get_type ())
+#define CONFI_DB_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CONFI_TYPE_DB_PLUGIN, ConfiDBPlugin))
+#define CONFI_DB_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CONFI_TYPE_DB_PLUGIN, ConfiDBPlugin))
+#define CONFI_IS_DB_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CONFI_TYPE_DB_PLUGIN))
+#define CONFI_IS_DB_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CONFI_TYPE_DB_PLUGIN))
+#define CONFI_DB_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CONFI_TYPE_DB_PLUGIN, ConfiDBPluginClass))
+
+typedef struct _ConfiDBPlugin ConfiDBPlugin;
+typedef struct _ConfiDBPluginClass ConfiDBPluginClass;
+
+struct _ConfiDBPlugin {
+ PeasExtensionBase parent_instance;
+};
+
+struct _ConfiDBPluginClass {
+ PeasExtensionBaseClass parent_class;
+};
+
+GType confi_db_plugin_get_type (void) G_GNUC_CONST;
+G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);
+
+G_END_DECLS
+
+#endif /* __CONFI_DB_PLUGIN_H__ */
if (!initialized)
{
+ /**
+ * ConfiPluggable:cnc_string:
+ *
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_string ("cnc_string",
+ "Connection string",
+ "Connection string",
+ "",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
/**
* ConfiPluggable:name:
*
}
/**
- * confi_pluggable_activate:
+ * confi_pluggable_initialize:
* @pluggable: A #ConfiPluggable.
* @cnc_string: The connection string.
*
return iface->initialize (pluggable, cnc_string);
}
+
+/**
+ * confi_pluggable_get_configs_list:
+ * @pluggable: A #ConfiPluggable.
+ * @filter: (nullable):
+ *
+ * Returns: (element-type ConfiConfi) (transfer container): a #GList of #ConfiConfi. If there's no configurations, returns a valid
+ * #GList but with a unique NULL element.
+*/
+GList
+*confi_pluggable_get_configs_list (ConfiPluggable *pluggable, const gchar *filter)
+{
+ ConfiPluggableInterface *iface;
+
+ g_return_val_if_fail (CONFI_IS_PLUGGABLE (pluggable), FALSE);
+
+ iface = CONFI_PLUGGABLE_GET_IFACE (pluggable);
+ g_return_val_if_fail (iface->get_configs_list != NULL, FALSE);
+
+ return iface->get_configs_list (pluggable, filter);
+}
/* Virtual public methods */
gboolean (*initialize) (ConfiPluggable *pluggable, const gchar *cnc_string);
+ GList *(*get_configs_list) (ConfiPluggable *pluggable,
+ const gchar *filter);
};
/*
gboolean confi_pluggable_initialize (ConfiPluggable *pluggable, const gchar *cnc_string);
+GList *confi_pluggable_get_configs_list (ConfiPluggable *pluggable,
+ const gchar *filter);
+
G_END_DECLS
#endif /* __CONFI_PLUGGABLE_H__ */
#include <string.h>
#include <libgdaex/libgdaex.h>
+#include <libpeas/peas.h>
#include "libconfi.h"
+#include "confipluggable.h"
+ConfiConfi
+*confi_confi_copy (ConfiConfi *confi)
+{
+ ConfiConfi *b;
+
+ b = g_slice_new (ConfiConfi);
+ b->name = g_strdup (confi->name);
+ b->description = g_strdup (confi->description);
+
+ return b;
+}
+
+void
+confi_confi_free (ConfiConfi *confi)
+{
+ g_free (confi->name);
+ g_free (confi->description);
+ g_slice_free (ConfiConfi, confi);
+}
+
+G_DEFINE_BOXED_TYPE (ConfiConfi, confi_confi, confi_confi_copy, confi_confi_free)
+
ConfiKey
*confi_key_copy (ConfiKey *key)
{
GHashTable *values;
gchar chrquot;
+
+ PeasPluginInfo *ppinfo;
+ ConfiPluggable *pluggable;
};
G_DEFINE_TYPE (Confi, confi, G_TYPE_OBJECT)
{
}
-/**
- * confi_new:
- * @cnc_string: the connection string to use to connect to database that
- * contains configuration.
- * @name: configuration's name.
- * @root: (nullable):
- * @create: whether create a config into database if @name doesn't exists.
- *
- * Returns: (transfer none): the newly created #Confi object, or NULL if it fails.
- */
-Confi
-*confi_new (const gchar *cnc_string,
- const gchar *name,
- const gchar *root,
- gboolean create)
+ConfiPluggable
+*confi_get_confi_pluggable_from_cnc_string (const gchar *cnc_string)
{
- if (name == NULL) return NULL;
+ ConfiPluggable *pluggable;
- GdaDataModel *dm;
- gchar *sql;
- gint id = 0;
+ const GList *lst_plugins;
- Confi *confi = CONFI (g_object_new (confi_get_type (), NULL));
+ pluggable = NULL;
- ConfiPrivate *priv = CONFI_GET_PRIVATE (confi);
+ PeasEngine *peas_engine;
- priv->gdaex = gdaex_new_from_string (cnc_string);
- if (priv->gdaex == NULL)
+ peas_engine = peas_engine_get_default ();
+ if (peas_engine == NULL)
{
- /* TO DO */
return NULL;
}
- priv->chrquot = gdaex_get_chr_quoting (priv->gdaex);
-
- /* check if config exists */
- sql = g_strdup_printf ("SELECT id, name FROM configs WHERE name = '%s'",
- gdaex_strescape (name, NULL));
- dm = gdaex_query (priv->gdaex, sql);
- if (dm == NULL || gda_data_model_get_n_rows (dm) == 0)
+ lst_plugins = peas_engine_get_plugin_list (peas_engine);
+ while (lst_plugins)
{
- if (create)
- {
- /* saving a new config into database */
- if (dm != NULL)
- {
- g_object_unref (dm);
- }
-
- dm = gdaex_query (priv->gdaex, "SELECT MAX(id) FROM configs");
- if (dm != NULL)
- {
- id = gdaex_data_model_get_value_integer_at (dm, 0, 0);
- }
- id++;
-
- if (gdaex_execute (priv->gdaex, g_strdup_printf ("INSERT INTO configs "
- "(id, name, description) "
- "VALUES (%d, '%s', '')",
- id, gdaex_strescape (name, NULL))) == -1)
- {
- return NULL;
- }
- }
- else
+ PeasPluginInfo *ppinfo;
+ gchar *uri;
+
+ ppinfo = (PeasPluginInfo *)lst_plugins->data;
+
+ uri = g_strdup_printf ("%s://", peas_plugin_info_get_module_name (ppinfo));
+ if (g_str_has_prefix (cnc_string, uri))
{
- /* TO DO */
- return NULL;
+ if (peas_engine_load_plugin (peas_engine, ppinfo))
+ {
+ PeasExtension *ext;
+ ext = peas_engine_create_extension (peas_engine, ppinfo, CONFI_TYPE_PLUGGABLE,
+ "cnc_string", cnc_string + strlen (uri),
+ NULL);
+ pluggable = (ConfiPluggable *)ext;
+ break;
+ }
}
+ g_free (uri);
+
+ lst_plugins = g_list_next (lst_plugins);
}
- else
+
+ if (pluggable == NULL)
{
- id = gdaex_data_model_get_value_integer_at (dm, 0, 0);
+ g_warning ("No plugin found for connection string \"%s\".", cnc_string);
}
- g_object_set (G_OBJECT (confi),
- "name", name,
- "root", root,
- NULL);
- priv->id_config = id;
- priv->values = g_hash_table_new (g_str_hash, g_str_equal);
+ return pluggable;
+}
- if (dm != NULL)
+/**
+ * confi_new:
+ * @cnc_string: the connection string.
+ *
+ * Returns: (transfer none): the newly created #Confi object, or NULL if it fails.
+ */
+Confi
+*confi_new (const gchar *cnc_string)
+{
+ Confi *confi;
+ ConfiPrivate *priv;
+ ConfiPluggable *pluggable;
+
+ g_return_val_if_fail (cnc_string != NULL, NULL);
+
+ confi = NULL;
+
+ pluggable = confi_get_confi_pluggable_from_cnc_string (cnc_string);
+ if (pluggable != NULL)
{
- g_object_unref (dm);
+ confi = CONFI (g_object_new (confi_get_type (), NULL));
+ priv = CONFI_GET_PRIVATE (confi);
+ priv->pluggable = pluggable;
}
return confi;
*confi_get_configs_list (const gchar *cnc_string,
const gchar *filter)
{
- GList *lst = NULL;
- gchar *sql;
- gchar *where = "";
-
- GdaEx *gdaex = gdaex_new_from_string (cnc_string);
-
- if (gdaex == NULL)
- {
- return NULL;
- }
+ ConfiPluggable *pluggable;
+ GList *lst;
- if (filter != NULL && strcmp (g_strstrip (g_strdup (filter)), "") != 0)
- {
- where = g_strdup_printf (" WHERE name LIKE '%s'", filter);
- }
+ lst = NULL;
- sql = g_strdup_printf ("SELECT * FROM configs%s", where);
+ pluggable = confi_get_confi_pluggable_from_cnc_string (cnc_string);
- GdaDataModel *dmConfigs = gdaex_query (gdaex, sql);
- if (dmConfigs != NULL)
+ if (pluggable != NULL)
{
- gint row, id,
- rows = gda_data_model_get_n_rows (dmConfigs);
- Confi *confi;
- ConfiPrivate *priv;
-
- if (rows > 0)
- {
- for (row = 0; row < rows; row++)
- {
- confi = confi_new (cnc_string,
- gdaex_data_model_get_field_value_stringify_at (dmConfigs, row, "name"),
- NULL, FALSE);
-
- priv = CONFI_GET_PRIVATE (confi);
- priv->id_config = gdaex_data_model_get_field_value_integer_at (dmConfigs, row, "id");
-
- g_object_set (G_OBJECT (confi),
- "description", gdaex_data_model_get_field_value_stringify_at (dmConfigs, row, "description"),
- NULL);
-
- lst = g_list_append (lst, confi);
- }
- }
- else
- {
- lst = g_list_append (lst, NULL);
- }
+ lst = confi_pluggable_get_configs_list (pluggable, filter);
}
- gdaex_free (gdaex);
-
return lst;
}
G_BEGIN_DECLS
+#define CONFI_TYPE_CONFI (confi_confi_get_type ())
+
+GType confi_confi_get_type ();
+
+typedef struct _ConfiConfi ConfiConfi;
+struct _ConfiConfi
+ {
+ gchar *name;
+ gchar *description;
+ };
+
+ConfiConfi *confi_confi_copy (ConfiConfi *confi);
+void confi_confi_free (ConfiConfi *confi);
+
#define CONFI_TYPE_KEY (confi_key_get_type ())
GType confi_key_get_type ();
GType confi_get_type (void);
-Confi *confi_new (const gchar *cnc_string,
- const gchar *name,
- const gchar *root,
- gboolean create);
+Confi *confi_new (const gchar *cnc_string);
GList *confi_get_configs_list (const gchar *cnc_string,
const gchar *filter);
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#include <libpeas/peas.h>
#include <libconfi.h>
gboolean
int
main (int argc, char **argv)
{
+ PeasEngine *engine;
Confi *confi;
+ GList *confis;
GNode *tree;
gda_init ();
return 0;
}
- confi = confi_new (argv[1], "Default", NULL, FALSE);
+ engine = peas_engine_get_default ();
+ peas_engine_add_search_path (engine, "./plugins", NULL);
+
+ confis = confi_get_configs_list (argv[1], NULL);
+ while (confis)
+ {
+ ConfiConfi *confi = (ConfiConfi *)confis->data;
+
+ if (confi == NULL) break;
+
+ g_printf ("NAME: %s\nDESCRIPTION: %s\n\n",
+ confi->name,
+ confi->description);
+ confis = g_list_next (confis);
+ }
+
+ /*confi = confi_new (argv[1], "Default", NULL, FALSE);
if (confi == NULL)
{
g_error ("Error on configuration initialization.");
confi_set_root (confi, "key2");
g_printf ("Value from key \"key2-1\" %s\n", confi_path_get_value (confi, "key2-1"));
- confi_destroy (confi);
+ confi_destroy (confi);*/
return 0;
}