]> saetta.ns0.it Git - zakbookmarks/libzakbookmarks/commitdiff
First build.
authorAndrea Zagli <azagli@libero.it>
Sun, 21 Jul 2019 07:08:10 +0000 (09:08 +0200)
committerAndrea Zagli <azagli@libero.it>
Sun, 21 Jul 2019 07:08:10 +0000 (09:08 +0200)
ChangeLog [new file with mode: 0644]
plugins/db/plgdb.c
plugins/db/plgdb.h
src/bks.c
src/bkspluggable.c
src/bkspluggable.h
src/libzakbookmarks.h

diff --git a/ChangeLog b/ChangeLog
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1 @@
+
index 88611261761731d8f55d102444fa7238e0bfb2ba..a09db52f07e0b50eb54bcec7af65a6182560c42c 100644 (file)
@@ -19,7 +19,7 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-#ifdef HAVE_CONFIG_H
+#ifdef HAVE_BKSG_H
 #include <config.h>
 #endif
 
 
 #include <libgdaex/libgdaex.h>
 
-#include "../../src/libzakconfi.h"
-#include "../../src/confipluggable.h"
+#include "../../src/libzakbookmarks.h"
+#include "../../src/bkspluggable.h"
 
 #include "plgdb.h"
 
-static void zak_confi_pluggable_iface_init (ZakConfiPluggableInterface *iface);
+static void zak_bks_pluggable_iface_init (ZakBksPluggableInterface *iface);
 
-static gboolean zak_confi_db_plugin_initialize (ZakConfiPluggable *pluggable, const gchar *cnc_string);
+static gboolean zak_bks_db_plugin_initialize (ZakBksPluggable *pluggable, const gchar *cnc_string);
 
-static GdaDataModel *zak_confi_db_plugin_path_get_data_model (ZakConfiPluggable *pluggable, const gchar *path);
-static gchar *zak_confi_db_plugin_path_get_value_from_db (ZakConfiPluggable *pluggable, const gchar *path);
-static void zak_confi_db_plugin_get_children (ZakConfiPluggable *pluggable, GNode *parentNode, gint idParent, gchar *path);
+static GdaDataModel *zak_bks_db_plugin_path_get_data_model (ZakBksPluggable *pluggable, const gchar *path);
+static gchar *zak_bks_db_plugin_path_get_value_from_db (ZakBksPluggable *pluggable, const gchar *path);
+static void zak_bks_db_plugin_get_children (ZakBksPluggable *pluggable, GNode *parentNode, gint idParent, gchar *path);
 
-#define ZAK_CONFI_DB_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_CONFI_TYPE_DB_PLUGIN, ZakConfiDBPluginPrivate))
+#define ZAK_BKS_DB_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_BKS_TYPE_DB_PLUGIN, ZakBksDBPluginPrivate))
 
-typedef struct _ZakConfiDBPluginPrivate ZakConfiDBPluginPrivate;
-struct _ZakConfiDBPluginPrivate
+typedef struct _ZakBksDBPluginPrivate ZakBksDBPluginPrivate;
+struct _ZakBksDBPluginPrivate
        {
                gchar *cnc_string;
 
                GdaEx *gdaex;
 
-               gint id_config;
+               gint id_bksg;
                gchar *name;
                gchar *description;
                gchar *root;
@@ -63,46 +63,33 @@ struct _ZakConfiDBPluginPrivate
                gchar chrquot;
        };
 
-G_DEFINE_DYNAMIC_TYPE_EXTENDED (ZakConfiDBPlugin,
-                                zak_confi_db_plugin,
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (ZakBksDBPlugin,
+                                zak_bks_db_plugin,
                                 PEAS_TYPE_EXTENSION_BASE,
                                 0,
-                                G_IMPLEMENT_INTERFACE_DYNAMIC (ZAK_CONFI_TYPE_PLUGGABLE,
-                                                               zak_confi_pluggable_iface_init))
+                                G_IMPLEMENT_INTERFACE_DYNAMIC (ZAK_BKS_TYPE_PLUGGABLE,
+                                                               zak_bks_pluggable_iface_init))
 
 enum {
        PROP_0,
        PROP_CNC_STRING,
-       PROP_NAME,
-       PROP_DESCRIPTION,
-       PROP_ROOT
 };
 
 static void
-zak_confi_db_plugin_set_property (GObject      *object,
+zak_bks_db_plugin_set_property (GObject      *object,
                               guint         prop_id,
                               const GValue *value,
                               GParamSpec   *pspec)
 {
        gchar *sql;
 
-       ZakConfiDBPlugin *plugin = ZAK_CONFI_DB_PLUGIN (object);
-       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (plugin);
+       ZakBksDBPlugin *plugin = ZAK_BKS_DB_PLUGIN (object);
+       ZakBksDBPluginPrivate *priv = ZAK_BKS_DB_PLUGIN_GET_PRIVATE (plugin);
 
        switch (prop_id)
                {
                        case PROP_CNC_STRING:
-                               zak_confi_db_plugin_initialize ((ZakConfiPluggable *)plugin, g_value_get_string (value));
-                               break;
-
-                       case PROP_NAME:
-                               break;
-
-                       case PROP_DESCRIPTION:
-                               break;
-
-                       case PROP_ROOT:
-                               priv->root = zak_confi_normalize_root (g_value_get_string (value));
+                               zak_bks_db_plugin_initialize ((ZakBksPluggable *)plugin, g_value_get_string (value));
                                break;
 
                        default:
@@ -112,13 +99,13 @@ zak_confi_db_plugin_set_property (GObject      *object,
 }
 
 static void
-zak_confi_db_plugin_get_property (GObject    *object,
+zak_bks_db_plugin_get_property (GObject    *object,
                               guint       prop_id,
                               GValue     *value,
                               GParamSpec *pspec)
 {
-       ZakConfiDBPlugin *plugin = ZAK_CONFI_DB_PLUGIN (object);
-       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (plugin);
+       ZakBksDBPlugin *plugin = ZAK_BKS_DB_PLUGIN (object);
+       ZakBksDBPluginPrivate *priv = ZAK_BKS_DB_PLUGIN_GET_PRIVATE (plugin);
 
        switch (prop_id)
                {
@@ -126,18 +113,6 @@ zak_confi_db_plugin_get_property (GObject    *object,
                                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;
@@ -145,29 +120,27 @@ zak_confi_db_plugin_get_property (GObject    *object,
 }
 
 static void
-zak_confi_db_plugin_init (ZakConfiDBPlugin *plugin)
+zak_bks_db_plugin_init (ZakBksDBPlugin *plugin)
 {
-       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (plugin);
+       ZakBksDBPluginPrivate *priv = ZAK_BKS_DB_PLUGIN_GET_PRIVATE (plugin);
 
        priv->cnc_string = NULL;
        priv->gdaex = NULL;
-       priv->name = NULL;
-       priv->description = NULL;
 }
 
 static void
-zak_confi_db_plugin_finalize (GObject *object)
+zak_bks_db_plugin_finalize (GObject *object)
 {
-       ZakConfiDBPlugin *plugin = ZAK_CONFI_DB_PLUGIN (object);
+       ZakBksDBPlugin *plugin = ZAK_BKS_DB_PLUGIN (object);
 
-       G_OBJECT_CLASS (zak_confi_db_plugin_parent_class)->finalize (object);
+       G_OBJECT_CLASS (zak_bks_db_plugin_parent_class)->finalize (object);
 }
 
 static gboolean
-zak_confi_db_plugin_initialize (ZakConfiPluggable *pluggable, const gchar *cnc_string)
+zak_bks_db_plugin_initialize (ZakBksPluggable *pluggable, const gchar *cnc_string)
 {
-       ZakConfiDBPlugin *plugin = ZAK_CONFI_DB_PLUGIN (pluggable);
-       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (plugin);
+       ZakBksDBPlugin *plugin = ZAK_BKS_DB_PLUGIN (pluggable);
+       ZakBksDBPluginPrivate *priv = ZAK_BKS_DB_PLUGIN_GET_PRIVATE (plugin);
 
        GString *gstr_cnc_string;
        gchar **strs;
@@ -188,9 +161,9 @@ zak_confi_db_plugin_initialize (ZakConfiPluggable *pluggable, const gchar *cnc_s
        l = g_strv_length (strs);
        for (i = 0; i < l; i++)
                {
-                       if (g_str_has_prefix (strs[i], "CONFI_NAME="))
+                       if (g_str_has_prefix (strs[i], "BKS_NAME="))
                                {
-                                       priv->name = g_strdup (strs[i] + strlen ("CONFI_NAME="));
+                                       priv->name = g_strdup (strs[i] + strlen ("BKS_NAME="));
                                        if (priv->name[strlen (priv->name)] == ';')
                                                {
                                                        priv->name[strlen (priv->name)] = '\0';
@@ -219,16 +192,16 @@ zak_confi_db_plugin_initialize (ZakConfiPluggable *pluggable, const gchar *cnc_s
        priv->gdaex = gdaex_new_from_string (priv->cnc_string);
        priv->chrquot = gdaex_get_chr_quoting (priv->gdaex);
 
-       /* check if config exists */
+       /* check if bksg exists */
        sql = g_strdup_printf ("SELECT id, name"
-                              " FROM configs"
+                              " FROM bksgs"
                               " WHERE name = '%s'",
                               gdaex_strescape (priv->name, NULL));
        dm = gdaex_query (priv->gdaex, sql);
        g_free (sql);
        if (dm != NULL || gda_data_model_get_n_rows (dm) > 0)
                {
-                       priv->id_config = gdaex_data_model_get_value_integer_at (dm, 0, 0);
+                       priv->id_bksg = gdaex_data_model_get_value_integer_at (dm, 0, 0);
                }
        if (dm != NULL)
                {
@@ -239,7 +212,7 @@ zak_confi_db_plugin_initialize (ZakConfiPluggable *pluggable, const gchar *cnc_s
 }
 
 static GdaDataModel
-*zak_confi_db_plugin_path_get_data_model (ZakConfiPluggable *pluggable, const gchar *path)
+*zak_bks_db_plugin_path_get_data_model (ZakBksPluggable *pluggable, const gchar *path)
 {
        gchar **tokens;
        gchar *sql;
@@ -248,7 +221,7 @@ static GdaDataModel
        guint id_parent;
        GdaDataModel *dm;
 
-       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakBksDBPluginPrivate *priv = ZAK_BKS_DB_PLUGIN_GET_PRIVATE (pluggable);
 
        if (path == NULL) return NULL;
 
@@ -266,11 +239,11 @@ static GdaDataModel
                                {
                                        sql = g_strdup_printf ("SELECT *"
                                                               " FROM %cvalues%c"
-                                                              " WHERE id_configs = %d"
+                                                              " WHERE id_bksgs = %d"
                                                               " AND id_parent = %d"
                                                               " AND %ckey%c = '%s'",
                                                               priv->chrquot, priv->chrquot,
-                                                              priv->id_config,
+                                                              priv->id_bksg,
                                                               id_parent,
                                                               priv->chrquot, priv->chrquot,
                                                               gdaex_strescape (token, NULL));
@@ -299,14 +272,14 @@ static GdaDataModel
 }
 
 static gchar
-*zak_confi_db_plugin_path_get_value_from_db (ZakConfiPluggable *pluggable, const gchar *path)
+*zak_bks_db_plugin_path_get_value_from_db (ZakBksPluggable *pluggable, const gchar *path)
 {
        gchar *ret;
        GdaDataModel *dm;
 
        ret = NULL;
 
-       dm = zak_confi_db_plugin_path_get_data_model (pluggable, path);
+       dm = zak_bks_db_plugin_path_get_data_model (pluggable, path);
        if (dm != NULL)
                {
                        ret = gdaex_data_model_get_field_value_stringify_at (dm, 0, "value");
@@ -317,19 +290,19 @@ static gchar
 }
 
 static void
-zak_confi_db_plugin_get_children (ZakConfiPluggable *pluggable, GNode *parentNode, gint idParent, gchar *path)
+zak_bks_db_plugin_get_children (ZakBksPluggable *pluggable, GNode *parentNode, gint idParent, gchar *path)
 {
        gchar *sql;
        GdaDataModel *dm;
 
-       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakBksDBPluginPrivate *priv = ZAK_BKS_DB_PLUGIN_GET_PRIVATE (pluggable);
 
        sql = g_strdup_printf ("SELECT *"
                               " FROM %cvalues%c"
-                              " WHERE id_configs = %d"
+                              " WHERE id_bksgs = %d"
                               " AND id_parent = %d",
                               priv->chrquot, priv->chrquot,
-                              priv->id_config,
+                              priv->id_bksg,
                               idParent);
 
        dm = gdaex_query (priv->gdaex, sql);
@@ -343,32 +316,32 @@ zak_confi_db_plugin_get_children (ZakConfiPluggable *pluggable, GNode *parentNod
                        for (i = 0; i < rows; i++)
                                {
                                        GNode *newNode;
-                                       ZakConfiKey *ck = g_new0 (ZakConfiKey, 1);
+                                       /* ZakBksKey *ck = g_new0 (ZakBksKey, 1); */
 
-                                       ck->config = g_strdup (priv->name);
-                                       ck->key = g_strdup (gdaex_data_model_get_field_value_stringify_at (dm, i, "key"));
-                                       ck->value = g_strdup (gdaex_data_model_get_field_value_stringify_at (dm, i, "value"));
-                                       ck->description = g_strdup (gdaex_data_model_get_field_value_stringify_at (dm, i, "description"));
-                                       ck->path = g_strdup (path);
+                                       /* ck->bksg = g_strdup (priv->name); */
+                                       /* ck->key = g_strdup (gdaex_data_model_get_field_value_stringify_at (dm, i, "key")); */
+                                       /* ck->value = g_strdup (gdaex_data_model_get_field_value_stringify_at (dm, i, "value")); */
+                                       /* ck->description = g_strdup (gdaex_data_model_get_field_value_stringify_at (dm, i, "description")); */
+                                       /* ck->path = g_strdup (path); */
 
-                                       newNode = g_node_append_data (parentNode, ck);
+                                       /* newNode = g_node_append_data (parentNode, ck); */
 
-                                       zak_confi_db_plugin_get_children (pluggable,
-                                                                                                         newNode,
-                                                                                                         gdaex_data_model_get_field_value_integer_at (dm, i, "id"),
-                                                                                                         g_strconcat (path, (g_strcmp0 (path, "") == 0 ? "" : "/"), ck->key, NULL));
+                                       /* zak_bks_db_plugin_get_children (pluggable, */
+                                       /*                                 newNode, */
+                                       /*                                 gdaex_data_model_get_field_value_integer_at (dm, i, "id"), */
+                                       /*                                 g_strconcat (path, (g_strcmp0 (path, "") == 0 ? "" : "/"), ck->key, NULL)); */
                                }
                        g_object_unref (dm);
                }
 }
 
 static GList
-*zak_confi_db_plugin_get_configs_list (ZakConfiPluggable *pluggable,
+*zak_bks_db_plugin_get_bksgs_list (ZakBksPluggable *pluggable,
                                    const gchar *filter)
 {
        GList *lst;
 
-       GdaDataModel *dmZakConfigs;
+       GdaDataModel *dmZakBksgs;
 
        gchar *sql;
        gchar *where;
@@ -376,7 +349,7 @@ static GList
        guint row;
        guint rows;
 
-       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakBksDBPluginPrivate *priv = ZAK_BKS_DB_PLUGIN_GET_PRIVATE (pluggable);
 
        lst = NULL;
 
@@ -394,23 +367,23 @@ static GList
                        where = g_strdup ("");
                }
 
-       sql = g_strdup_printf ("SELECT * FROM configs%s", where);
+       sql = g_strdup_printf ("SELECT * FROM bksgs%s", where);
        g_free (where);
 
-       dmZakConfigs = gdaex_query (priv->gdaex, sql);
+       dmZakBksgs = gdaex_query (priv->gdaex, sql);
        g_free (sql);
-       if (dmZakConfigs != NULL)
+       if (dmZakBksgs != NULL)
                {
-                       rows = gda_data_model_get_n_rows (dmZakConfigs);
+                       rows = gda_data_model_get_n_rows (dmZakBksgs);
                        if (rows > 0)
                                {
                                        for (row = 0; row < rows; row++)
                                                {
-                                                       ZakConfiConfi *confi;
-                                                       confi = g_new0 (ZakConfiConfi, 1);
-                                                       confi->name = gdaex_data_model_get_field_value_stringify_at (dmZakConfigs, row, "name");
-                                                       confi->description = gdaex_data_model_get_field_value_stringify_at (dmZakConfigs, row, "description");
-                                                       lst = g_list_append (lst, confi);
+                                                       /* ZakBksBks *bks; */
+                                                       /* bks = g_new0 (ZakBksBks, 1); */
+                                                       /* bks->name = gdaex_data_model_get_field_value_stringify_at (dmZakBksgs, row, "name"); */
+                                                       /* bks->description = gdaex_data_model_get_field_value_stringify_at (dmZakBksgs, row, "description"); */
+                                                       /* lst = g_list_append (lst, bks); */
                                                }
                                }
                        else
@@ -423,47 +396,46 @@ static GList
 }
 
 static gchar
-*zak_confi_db_plugin_path_get_value (ZakConfiPluggable *pluggable, const gchar *path)
+*zak_bks_db_plugin_path_get_value (ZakBksPluggable *pluggable, const gchar *path)
 {
        gchar *ret;
        gchar *path_;
 
-       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakBksDBPluginPrivate *priv = ZAK_BKS_DB_PLUGIN_GET_PRIVATE (pluggable);
 
        ret = NULL;
 
-       path_ = zak_confi_path_normalize (pluggable, path);
        if (path_ == NULL)
                {
                        return NULL;
                }
 
-       ret = zak_confi_db_plugin_path_get_value_from_db (pluggable, path_);
+       ret = zak_bks_db_plugin_path_get_value_from_db (pluggable, path_);
 
        return ret;
 }
 
 static gboolean
-zak_confi_db_plugin_path_set_value (ZakConfiPluggable *pluggable, const gchar *path, const gchar *value)
+zak_bks_db_plugin_path_set_value (ZakBksPluggable *pluggable, const gchar *path, const gchar *value)
 {
        GdaDataModel *dm;
        gchar *sql;
        gboolean ret;
 
-       dm = zak_confi_db_plugin_path_get_data_model (pluggable, zak_confi_path_normalize (pluggable, path));
+       dm = zak_bks_db_plugin_path_get_data_model (pluggable, path);
 
-       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakBksDBPluginPrivate *priv = ZAK_BKS_DB_PLUGIN_GET_PRIVATE (pluggable);
 
        ret = FALSE;
        if (dm != NULL && gda_data_model_get_n_rows (dm) > 0)
                {
                        sql = g_strdup_printf ("UPDATE %cvalues%c"
                                               " SET value = '%s'"
-                                              " WHERE id_configs = %d"
+                                              " WHERE id_bksgs = %d"
                                               " AND id = %d",
                                               priv->chrquot, priv->chrquot,
                                               gdaex_strescape (value, NULL),
-                                              priv->id_config,
+                                              priv->id_bksg,
                                               gdaex_data_model_get_field_value_integer_at (dm, 0, "id"));
                        ret = (gdaex_execute (priv->gdaex, sql) >= 0);
                        g_free (sql);
@@ -481,54 +453,54 @@ zak_confi_db_plugin_path_set_value (ZakConfiPluggable *pluggable, const gchar *p
 }
 
 GNode
-*zak_confi_db_plugin_get_tree (ZakConfiPluggable *pluggable)
+*zak_bks_db_plugin_get_tree (ZakBksPluggable *pluggable)
 {
        gchar *path;
        GNode *node;
 
-       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakBksDBPluginPrivate *priv = ZAK_BKS_DB_PLUGIN_GET_PRIVATE (pluggable);
 
        path = g_strdup ("");
 
-       ZakConfiKey *ck = g_new0 (ZakConfiKey, 1);
+       /* ZakBksKey *ck = g_new0 (ZakBksKey, 1); */
 
-       ck->config = g_strdup (priv->name);
-       ck->path = "";
-       ck->key = g_strdup ("/");
-       ck->value = "";
-       ck->description = "";
+       /* ck->bksg = g_strdup (priv->name); */
+       /* ck->path = ""; */
+       /* ck->key = g_strdup ("/"); */
+       /* ck->value = ""; */
+       /* ck->description = ""; */
 
-       node = g_node_new (ck);
+       /* node = g_node_new (ck); */
 
-       zak_confi_db_plugin_get_children (pluggable, node, 0, path);
+       zak_bks_db_plugin_get_children (pluggable, node, 0, path);
 
        return node;
 }
 
-static ZakConfiConfi
-*zak_confi_db_plugin_add_config (ZakConfiPluggable *pluggable, const gchar *name, const gchar *description)
+static ZakBksBks
+*zak_bks_db_plugin_add_bksg (ZakBksPluggable *pluggable, const gchar *name, const gchar *description)
 {
-       ZakConfiConfi *cc;
+       ZakBksBks *cc;
 
        gchar *sql;
        gint id;
 
-       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakBksDBPluginPrivate *priv = ZAK_BKS_DB_PLUGIN_GET_PRIVATE (pluggable);
 
        cc = NULL;
 
-       id = gdaex_get_new_id (priv->gdaex, "configs", "id", NULL);
+       id = gdaex_get_new_id (priv->gdaex, "bksgs", "id", NULL);
 
-       sql = g_strdup_printf ("INSERT INTO configs"
-                                                  " VALUES (%d, '%s', '%s')",
-                                                  id,
-                                                  gdaex_strescape (name, NULL),
-                                                  gdaex_strescape (description, NULL));
+       sql = g_strdup_printf ("INSERT INTO bksgs"
+                              " VALUES (%d, '%s', '%s')",
+                              id,
+                              gdaex_strescape (name, NULL),
+                              gdaex_strescape (description, NULL));
        if (gdaex_execute (priv->gdaex, sql) > 0)
                {
-                       cc = g_new0 (ZakConfiConfi, 1);
-                       cc->name = g_strdup (name);
-                       cc->description = g_strdup (description);
+                       /* cc = g_new0 (ZakBksBks, 1); */
+                       /* cc->name = g_strdup (name); */
+                       /* cc->description = g_strdup (description); */
                }
 
        g_free (sql);
@@ -537,24 +509,24 @@ static ZakConfiConfi
 }
 
 static gboolean
-zak_confi_db_plugin_set_config (ZakConfiPluggable *pluggable,
+zak_bks_db_plugin_set_bksg (ZakBksPluggable *pluggable,
                                    const gchar *name,
                                    const gchar *description)
 {
        gboolean ret;
        gchar *sql;
 
-       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakBksDBPluginPrivate *priv = ZAK_BKS_DB_PLUGIN_GET_PRIVATE (pluggable);
 
        g_return_val_if_fail (name != NULL, FALSE);
 
        ret = TRUE;
 
-       sql = g_strdup_printf ("UPDATE configs"
-                                                  " SET name = '%s'"
-                                                  " WHERE id = %d",
-                                                  gdaex_strescape (name, NULL),
-                                                  priv->id_config);
+       sql = g_strdup_printf ("UPDATE bksgs"
+                              " SET name = '%s'"
+                              " WHERE id = %d",
+                              gdaex_strescape (name, NULL),
+                              priv->id_bksg);
        if (gdaex_execute (priv->gdaex, sql) < 1)
                {
                        ret = FALSE;
@@ -564,11 +536,11 @@ zak_confi_db_plugin_set_config (ZakConfiPluggable *pluggable,
 
        if (description != NULL)
                {
-                       sql = g_strdup_printf ("UPDATE configs"
-                                                                  " SET description = '%s'"
-                                                                  " WHERE id = %d",
-                                                                  gdaex_strescape (description, NULL),
-                                                                  priv->id_config);
+                       sql = g_strdup_printf ("UPDATE bksgs"
+                                              " SET description = '%s'"
+                                              " WHERE id = %d",
+                                              gdaex_strescape (description, NULL),
+                                              priv->id_bksg);
                        if (gdaex_execute (priv->gdaex, sql) < 1)
                                {
                                        ret = FALSE;
@@ -580,239 +552,19 @@ zak_confi_db_plugin_set_config (ZakConfiPluggable *pluggable,
        return ret;
 }
 
-static ZakConfiKey
-*zak_confi_db_plugin_add_key (ZakConfiPluggable *pluggable, const gchar *parent, const gchar *key, const gchar *value)
-{
-       ZakConfiKey *ck;
-       GdaDataModel *dmParent;
-
-       gchar *sql;
-       gint id;
-       GdaDataModel *dm;
-
-       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
-
-       gint id_parent;
-       gchar *parent_;
-       gchar *key_;
-
-       gchar *path;
-
-       ck = NULL;
-       if (parent == NULL)
-               {
-                       id_parent = 0;
-               }
-       else
-               {
-                       parent_ = g_strstrip (g_strdup (parent));
-                       if (strcmp (parent_, "") == 0)
-                               {
-                                       id_parent = 0;
-                               }
-                       else
-                               {
-                                       dmParent = zak_confi_db_plugin_path_get_data_model (pluggable, zak_confi_path_normalize (pluggable, parent_));
-                                       if (dmParent == NULL)
-                                               {
-                                                       id_parent = -1;
-                                               }
-                                       else
-                                               {
-                                                       id_parent = gdaex_data_model_get_field_value_integer_at (dmParent, 0, "id");
-                                               }
-                               }
-               }
-
-       if (id_parent > -1)
-               {
-                       key_ = g_strdup (key);
-                       g_strstrip (key_);
-
-                       /* find if key exists */
-                       sql = g_strdup_printf ("SELECT id"
-                                              " FROM %cvalues%c"
-                                              " WHERE id_configs = %d"
-                                                                  " AND id_parent = %d"
-                                              " AND key = '%s'",
-                                              priv->chrquot, priv->chrquot,
-                                              priv->id_config,
-                                                                  id_parent,
-                                              gdaex_strescape (key_, NULL));
-                       dm = gdaex_query (priv->gdaex, sql);
-                       g_free (sql);
-                       if (dm == NULL
-                               || gda_data_model_get_n_rows (dm) < 1)
-                               {
-                                       id = 0;
-
-                                       /* find new id */
-                                       sql = g_strdup_printf ("SELECT MAX(id)"
-                                                              " FROM %cvalues%c"
-                                                              " WHERE id_configs = %d",
-                                                              priv->chrquot, priv->chrquot,
-                                                              priv->id_config);
-                                       dm = gdaex_query (priv->gdaex, sql);
-                                       g_free (sql);
-                                       if (dm != NULL)
-                                               {
-                                                       id = gdaex_data_model_get_value_integer_at (dm, 0, 0);
-                                                       g_object_unref (dm);
-                                               }
-                                       id++;
-
-                                       sql = g_strdup_printf ("INSERT INTO %cvalues%c"
-                                                              " (id_configs, id, id_parent, %ckey%c, value)"
-                                                              " VALUES (%d, %d, %d, '%s', '%s')",
-                                                              priv->chrquot, priv->chrquot,
-                                                              priv->chrquot, priv->chrquot,
-                                                              priv->id_config,
-                                                              id,
-                                                              id_parent,
-                                                              gdaex_strescape (key_, NULL),
-                                                              "");
-                                       if (gdaex_execute (priv->gdaex, sql) == -1)
-                                               {
-                                                       /* TO DO */
-                                                       g_free (sql);
-                                                       return NULL;
-                                               }
-                                       g_free (sql);
-                               }
-
-                       ck = g_new0 (ZakConfiKey, 1);
-                       ck->config = g_strdup (priv->name);
-                       if (id_parent == 0)
-                               {
-                                       ck->path = g_strdup ("");
-                               }
-                       else
-                               {
-                                       ck->path = g_strdup (parent_);
-                               }
-                       ck->key = g_strdup (key_);
-                       ck->value = g_strdup ("");
-                       ck->description = g_strdup ("");
-
-                       g_free (key_);
-               }
-       g_free (parent_);
-
-       if (ck != NULL)
-               {
-                       if (g_strcmp0 (ck->path, "") != 0)
-                               {
-                                       path = g_strconcat (ck->path, "/", key, NULL);
-                               }
-                       else
-                               {
-                                       path = g_strdup (ck->key);
-                               }
-
-                       if (!zak_confi_db_plugin_path_set_value (pluggable, path, value))
-                               {
-                                       ck = NULL;
-                               }
-                       else
-                               {
-                                       ck->value = g_strdup (value);
-                               }
-                       g_free (path);
-               }
-
-       return ck;
-}
-
 static gboolean
-zak_confi_db_plugin_key_set_key (ZakConfiPluggable *pluggable,
-                             ZakConfiKey *ck)
+zak_bks_db_plugin_delete_id_from_db_values (ZakBksPluggable *pluggable, gint id)
 {
        gboolean ret;
        gchar *sql;
 
-       GdaDataModel *dm;
-
-       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
-
-       dm = zak_confi_db_plugin_path_get_data_model (pluggable, g_strdup_printf ("%s/%s", ck->path, ck->key));
-       if (dm == NULL)
-               {
-                       return FALSE;
-               }
-
-       sql = g_strdup_printf ("UPDATE %cvalues%c"
-                              " SET %ckey%c = '%s',"
-                              " value = '%s',"
-                              " description = '%s'"
-                              " WHERE id_configs = %d"
-                              " AND id = %d",
-                              priv->chrquot, priv->chrquot,
-                              priv->chrquot, priv->chrquot,
-                              gdaex_strescape (ck->key, NULL),
-                              gdaex_strescape (ck->value, NULL),
-                              gdaex_strescape (ck->description, NULL),
-                              priv->id_config,
-                              gdaex_data_model_get_field_value_integer_at (dm, 0, "id"));
-
-       ret = (gdaex_execute (priv->gdaex, sql) >= 0);
-       g_free (sql);
-
-       return ret;
-}
-
-static ZakConfiKey
-*zak_confi_db_plugin_path_get_confi_key (ZakConfiPluggable *pluggable, const gchar *path)
-{
-       GdaDataModel *dm;
-       gchar *path_;
-       ZakConfiKey *ck;
-
-       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
-
-       path_ = zak_confi_path_normalize (pluggable, path);
-       if (path_ == NULL)
-               {
-                       return NULL;
-               }
-
-       dm = zak_confi_db_plugin_path_get_data_model (pluggable, path_);
-       if (dm == NULL || gda_data_model_get_n_rows (dm) <= 0)
-               {
-                       if (dm != NULL)
-                               {
-                                       g_object_unref (dm);
-                               }
-                       return NULL;
-               }
-
-       ck = g_new0 (ZakConfiKey, 1);
-       ck->config = g_strdup (priv->name);
-       ck->path = g_strdup (path_);
-       ck->key = gdaex_data_model_get_field_value_stringify_at (dm, 0, "key");
-       ck->value = gdaex_data_model_get_field_value_stringify_at (dm, 0, "value");
-       ck->description = gdaex_data_model_get_field_value_stringify_at (dm, 0, "description");
-
-       if (dm != NULL)
-               {
-                       g_object_unref (dm);
-               }
-
-       return ck;
-}
-
-static gboolean
-zak_confi_db_plugin_delete_id_from_db_values (ZakConfiPluggable *pluggable, gint id)
-{
-       gboolean ret;
-       gchar *sql;
-
-       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakBksDBPluginPrivate *priv = ZAK_BKS_DB_PLUGIN_GET_PRIVATE (pluggable);
 
        sql = g_strdup_printf ("DELETE FROM %cvalues%c"
-                              " WHERE id_configs = %d"
+                              " WHERE id_bksgs = %d"
                               " AND id = %d",
                               priv->chrquot, priv->chrquot,
-                              priv->id_config,
+                              priv->id_bksg,
                               id);
 
        if (gdaex_execute (priv->gdaex, sql) >= 0)
@@ -829,31 +581,14 @@ zak_confi_db_plugin_delete_id_from_db_values (ZakConfiPluggable *pluggable, gint
 }
 
 static gboolean
-zak_confi_db_plugin_remove_path_traverse_func (GNode *node, gpointer data)
-{
-       GdaDataModel *dm;
-       ZakConfiPluggable* pluggable;
-
-       pluggable = (ZakConfiPluggable *)data;
-       ZakConfiKey *ck = (ZakConfiKey *)node->data;
-       if (g_strcmp0 (ck->value, "") != 0)
-               {
-                       dm = zak_confi_db_plugin_path_get_data_model (pluggable, g_strdup_printf ("%s/%s", ck->path, ck->key));
-                       zak_confi_db_plugin_delete_id_from_db_values (pluggable, gdaex_data_model_get_field_value_integer_at (dm, 0, "id"));
-               }
-
-       return FALSE;
-}
-
-static gboolean
-zak_confi_db_plugin_remove_path (ZakConfiPluggable *pluggable, const gchar *path)
+zak_bks_db_plugin_remove_path (ZakBksPluggable *pluggable, const gchar *path)
 {
        gboolean ret = FALSE;
        GdaDataModel *dm;
 
-       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakBksDBPluginPrivate *priv = ZAK_BKS_DB_PLUGIN_GET_PRIVATE (pluggable);
 
-       dm = zak_confi_db_plugin_path_get_data_model (pluggable, zak_confi_path_normalize (pluggable, path));
+       dm = zak_bks_db_plugin_path_get_data_model (pluggable, path);
 
        if (dm != NULL && gda_data_model_get_n_rows (dm) > 0)
                {
@@ -863,21 +598,21 @@ zak_confi_db_plugin_remove_path (ZakConfiPluggable *pluggable, const gchar *path
                        GNode *node;
                        gint id = gdaex_data_model_get_field_value_integer_at (dm, 0, "id");
 
-                       ZakConfiKey *ck = g_new0 (ZakConfiKey, 1);
+                       /* ZakBksKey *ck = g_new0 (ZakBksKey, 1); */
 
-                       ck->config = g_strdup (priv->name);
-                       ck->path = path_;
-                       ck->key = gdaex_data_model_get_field_value_stringify_at (dm, 0, "key");
-                       ck->value = "";
-                       ck->description = "";
+                       /* ck->bksg = g_strdup (priv->name); */
+                       /* ck->path = path_; */
+                       /* ck->key = gdaex_data_model_get_field_value_stringify_at (dm, 0, "key"); */
+                       /* ck->value = ""; */
+                       /* ck->description = ""; */
 
-                       node = g_node_new (ck);
-                       zak_confi_db_plugin_get_children (pluggable, node, id, path_);
+                       /* node = g_node_new (ck); */
+                       zak_bks_db_plugin_get_children (pluggable, node, id, path_);
 
-                       g_node_traverse (node, G_POST_ORDER, G_TRAVERSE_ALL, -1, zak_confi_db_plugin_remove_path_traverse_func, (gpointer)pluggable);
+                       /* g_node_traverse (node, G_POST_ORDER, G_TRAVERSE_ALL, -1, zak_bks_db_plugin_remove_path_traverse_func, (gpointer)pluggable); */
 
                        /* removing the path */
-                       ret = zak_confi_db_plugin_delete_id_from_db_values (pluggable, id);
+                       ret = zak_bks_db_plugin_delete_id_from_db_values (pluggable, id);
                }
        else
                {
@@ -892,18 +627,18 @@ zak_confi_db_plugin_remove_path (ZakConfiPluggable *pluggable, const gchar *path
 }
 
 static gboolean
-zak_confi_db_plugin_remove (ZakConfiPluggable *pluggable)
+zak_bks_db_plugin_remove (ZakBksPluggable *pluggable)
 {
        gboolean ret;
        gchar *sql;
 
-       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakBksDBPluginPrivate *priv = ZAK_BKS_DB_PLUGIN_GET_PRIVATE (pluggable);
 
        ret = TRUE;
-       sql = g_strdup_printf ("DELETE FROM %cvalues%c WHERE id_configs = %d",
+       sql = g_strdup_printf ("DELETE FROM %cvalues%c WHERE id_bksgs = %d",
                            priv->chrquot,
                            priv->chrquot,
-                           priv->id_config);
+                           priv->id_bksg);
        if (gdaex_execute (priv->gdaex, sql) == -1)
                {
                        g_free (sql);
@@ -912,8 +647,8 @@ zak_confi_db_plugin_remove (ZakConfiPluggable *pluggable)
        else
                {
                        g_free (sql);
-                       sql = g_strdup_printf ("DELETE FROM configs WHERE id = %d",
-                                              priv->id_config);
+                       sql = g_strdup_printf ("DELETE FROM bksgs WHERE id = %d",
+                                              priv->id_bksg);
                        if (gdaex_execute (priv->gdaex, sql) == -1)
                                {
                                        ret = FALSE;
@@ -925,50 +660,36 @@ zak_confi_db_plugin_remove (ZakConfiPluggable *pluggable)
 }
 
 static void
-zak_confi_db_plugin_class_init (ZakConfiDBPluginClass *klass)
+zak_bks_db_plugin_class_init (ZakBksDBPluginClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-       g_type_class_add_private (object_class, sizeof (ZakConfiDBPluginPrivate));
+       g_type_class_add_private (object_class, sizeof (ZakBksDBPluginPrivate));
 
-       object_class->set_property = zak_confi_db_plugin_set_property;
-       object_class->get_property = zak_confi_db_plugin_get_property;
-       object_class->finalize = zak_confi_db_plugin_finalize;
+       object_class->set_property = zak_bks_db_plugin_set_property;
+       object_class->get_property = zak_bks_db_plugin_get_property;
+       object_class->finalize = zak_bks_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
-zak_confi_pluggable_iface_init (ZakConfiPluggableInterface *iface)
+zak_bks_pluggable_iface_init (ZakBksPluggableInterface *iface)
 {
-       iface->initialize = zak_confi_db_plugin_initialize;
-       iface->get_configs_list = zak_confi_db_plugin_get_configs_list;
-       iface->path_get_value = zak_confi_db_plugin_path_get_value;
-       iface->path_set_value = zak_confi_db_plugin_path_set_value;
-       iface->get_tree = zak_confi_db_plugin_get_tree;
-       iface->add_config = zak_confi_db_plugin_add_config;
-       iface->set_config = zak_confi_db_plugin_set_config;
-       iface->add_key = zak_confi_db_plugin_add_key;
-       iface->key_set_key = zak_confi_db_plugin_key_set_key;
-       iface->path_get_confi_key = zak_confi_db_plugin_path_get_confi_key;
-       iface->remove_path = zak_confi_db_plugin_remove_path;
-       iface->remove = zak_confi_db_plugin_remove;
+       iface->initialize = zak_bks_db_plugin_initialize;
 }
 
 static void
-zak_confi_db_plugin_class_finalize (ZakConfiDBPluginClass *klass)
+zak_bks_db_plugin_class_finalize (ZakBksDBPluginClass *klass)
 {
 }
 
 G_MODULE_EXPORT void
 peas_register_types (PeasObjectModule *module)
 {
-       zak_confi_db_plugin_register_type (G_TYPE_MODULE (module));
+       zak_bks_db_plugin_register_type (G_TYPE_MODULE (module));
 
        peas_object_module_register_extension_type (module,
-                                                   ZAK_CONFI_TYPE_PLUGGABLE,
-                                                   ZAK_CONFI_TYPE_DB_PLUGIN);
+                                                   ZAK_BKS_TYPE_PLUGGABLE,
+                                                   ZAK_BKS_TYPE_DB_PLUGIN);
 }
index 1593c933f2384b59d50112fe12691353b248c711..abea817742242d0e6dd5df1a8f8c8dc398ca61b2 100644 (file)
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-#ifndef __ZAK_CONFI_DB_PLUGIN_H__
-#define __ZAK_CONFI_DB_PLUGIN_H__
+#ifndef __ZAK_BKS_DB_PLUGIN_H__
+#define __ZAK_BKS_DB_PLUGIN_H__
 
 #include <libpeas/peas.h>
 
 G_BEGIN_DECLS
 
-#define ZAK_CONFI_TYPE_DB_PLUGIN         (zak_confi_db_plugin_get_type ())
-#define ZAK_CONFI_DB_PLUGIN(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), ZAK_CONFI_TYPE_DB_PLUGIN, ZakConfiDBPlugin))
-#define ZAK_CONFI_DB_PLUGIN_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), ZAK_CONFI_TYPE_DB_PLUGIN, ZakConfiDBPlugin))
-#define ZAK_CONFI_IS_DB_PLUGIN(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZAK_CONFI_TYPE_DB_PLUGIN))
-#define ZAK_CONFI_IS_DB_PLUGIN_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), ZAK_CONFI_TYPE_DB_PLUGIN))
-#define ZAK_CONFI_DB_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZAK_CONFI_TYPE_DB_PLUGIN, ZakConfiDBPluginClass))
+#define ZAK_BKS_TYPE_DB_PLUGIN         (zak_bks_db_plugin_get_type ())
+#define ZAK_BKS_DB_PLUGIN(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), ZAK_BKS_TYPE_DB_PLUGIN, ZakBksDBPlugin))
+#define ZAK_BKS_DB_PLUGIN_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), ZAK_BKS_TYPE_DB_PLUGIN, ZakBksDBPlugin))
+#define ZAK_BKS_IS_DB_PLUGIN(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZAK_BKS_TYPE_DB_PLUGIN))
+#define ZAK_BKS_IS_DB_PLUGIN_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), ZAK_BKS_TYPE_DB_PLUGIN))
+#define ZAK_BKS_DB_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZAK_BKS_TYPE_DB_PLUGIN, ZakBksDBPluginClass))
 
-typedef struct _ZakConfiDBPlugin       ZakConfiDBPlugin;
-typedef struct _ZakConfiDBPluginClass  ZakConfiDBPluginClass;
+typedef struct _ZakBksDBPlugin       ZakBksDBPlugin;
+typedef struct _ZakBksDBPluginClass  ZakBksDBPluginClass;
 
-struct _ZakConfiDBPlugin {
+struct _ZakBksDBPlugin {
        PeasExtensionBase parent_instance;
 };
 
-struct _ZakConfiDBPluginClass {
+struct _ZakBksDBPluginClass {
        PeasExtensionBaseClass parent_class;
 };
 
-GType                 zak_confi_db_plugin_get_type        (void) G_GNUC_CONST;
+GType                 zak_bks_db_plugin_get_type        (void) G_GNUC_CONST;
 G_MODULE_EXPORT void  peas_register_types                         (PeasObjectModule *module);
 
 G_END_DECLS
 
-#endif /* __ZAK_CONFI_DB_PLUGIN_H__ */
+#endif /* __ZAK_BKS_DB_PLUGIN_H__ */
index 7a9ce88c64eebabbc76443e0890b58b101cfe777..2a7fc3acb7c49ec9f8da451496d45cfe5526b851 100644 (file)
--- a/src/bks.c
+++ b/src/bks.c
@@ -17,7 +17,7 @@
  */
 
 #ifdef HAVE_BKSG_H
-       #include <bksg.h>
+       #include <config.h>
 #endif
 
 #include <string.h>
 
 static gchar *pluginsdir;
 
-enum
-{
-       PROP_0,
-       PROP_ID_BKSG,
-       PROP_NAME,
-       PROP_DESCRIPTION,
-       PROP_ROOT
-};
-
-static void zak_bks_class_init (ZakBksClass *klass);
-static void zak_bks_init (ZakBks *bks);
+static void zak_bks_bks_class_init (ZakBksBksClass *klass);
+static void zak_bks_bks_init (ZakBksBks *bks);
 
-static void zak_bks_set_property (GObject *object,
+static void zak_bks_bks_set_property (GObject *object,
                                 guint property_id,
                                 const GValue *value,
                                 GParamSpec *pspec);
-static void zak_bks_get_property (GObject *object,
+static void zak_bks_bks_get_property (GObject *object,
                                 guint property_id,
                                 GValue *value,
                                 GParamSpec *pspec);
 
-static ZakBksPluggable *zak_bks_get_bks_pluggable_from_cnc_string (const gchar *cnc_string);
-
-#define ZAK_BKS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_TYPE_BKS, ZakBksPrivate))
-
-typedef struct _ZakBksPrivate ZakBksPrivate;
-struct _ZakBksPrivate
+struct _ZakBksBks
        {
-               gint id_bksg;
-               gchar *name;
-               gchar *description;
-               gchar *root;
-               GHashTable *values;
+               GObject parent_instance;
 
                ZakBksPluggable *pluggable;
        };
 
-G_DEFINE_TYPE (ZakBks, zak_bks, G_TYPE_OBJECT)
+G_DEFINE_TYPE (ZakBksBks, zak_bks_bks, G_TYPE_OBJECT)
 
 #ifdef G_OS_WIN32
 static HMODULE backend_dll = NULL;
@@ -97,22 +79,17 @@ DllMain (HINSTANCE hinstDLL,
 #endif
 
 static void
-zak_bks_class_init (ZakBksClass *klass)
+zak_bks_bks_class_init (ZakBksBksClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-       g_type_class_add_private (object_class, sizeof (ZakBksPrivate));
-
-       object_class->set_property = zak_bks_set_property;
-       object_class->get_property = zak_bks_get_property;
+       object_class->set_property = zak_bks_bks_set_property;
+       object_class->get_property = zak_bks_bks_get_property;
 }
 
 static void
-zak_bks_init (ZakBks *bks)
+zak_bks_bks_init (ZakBksBks *bks)
 {
-       ZakBksPrivate *priv = ZAK_BKS_GET_PRIVATE (bks);
-
-       priv->pluggable = NULL;
 }
 
 static ZakBksPluggable
@@ -169,16 +146,15 @@ static ZakBksPluggable
 }
 
 /**
- * zak_bks_new:
+ * zak_bks_bks_new:
  * @cnc_string: the connection string.
  *
  * Returns: (transfer none): the newly created #ZakBks object, or NULL if it fails.
  */
-ZakBks
-*zak_bks_new (const gchar *cnc_string)
+ZakBksBks
+*zak_bks_bks_new (const gchar *cnc_string)
 {
-       ZakBks *bks;
-       ZakBksPrivate *priv;
+       ZakBksBks *bks;
        ZakBksPluggable *pluggable;
 
        g_return_val_if_fail (cnc_string != NULL, NULL);
@@ -215,574 +191,50 @@ ZakBks
        pluggable = zak_bks_get_bks_pluggable_from_cnc_string (cnc_string);
        if (pluggable != NULL)
                {
-                       bks = ZAK_BKS (g_object_new (zak_bks_get_type (), NULL));
-                       priv = ZAK_BKS_GET_PRIVATE (bks);
-                       priv->pluggable = pluggable;
+                       bks = ZAK_BKS_BKS (g_object_new (zak_bks_bks_get_type (), NULL));
+                       bks->pluggable = pluggable;
                }
 
        return bks;
 }
 
 PeasPluginInfo
-*zak_bks_get_plugin_info (ZakBks *bks)
+*zak_bks_bks_get_plugin_info (ZakBksBks *bks)
 {
        PeasPluginInfo *ppinfo;
 
-       ZakBksPrivate *priv = ZAK_BKS_GET_PRIVATE (bks);
-
-       if (priv->pluggable == NULL)
+       if (bks->pluggable == NULL)
                {
                        g_warning ("Not initialized.");
                        ppinfo = NULL;
                }
        else
                {
-                       ppinfo = peas_extension_base_get_plugin_info ((PeasExtensionBase *)priv->pluggable);
+                       ppinfo = peas_extension_base_get_plugin_info ((PeasExtensionBase *)bks->pluggable);
                }
 
        return ppinfo;
 }
 
 /**
- * zak_bks_get_bksgs_list:
- * @cnc_string: the connection string to use to connect to database that
- * contains bksguration.
- * @filter: (nullable):
- *
- * Returns: (element-type ZakBksBks) (transfer container):  a #GList of #ZakBksBks. If there's no bksgurations, returns a valid
- * #GList but with a unique NULL element.
- */
-GList
-*zak_bks_get_bksgs_list (const gchar *cnc_string,
-                                                        const gchar *filter)
-{
-       ZakBksPluggable *pluggable;
-       GList *lst;
-
-       pluggable = zak_bks_get_bks_pluggable_from_cnc_string (cnc_string);
-
-       if (pluggable == NULL)
-               {
-                       g_warning ("Not initialized.");
-                       lst = NULL;
-               }
-       else
-               {
-                       lst = zak_bks_pluggable_get_bksgs_list (pluggable, filter);
-               }
-
-       return lst;
-}
-
-/**
- * zak_bks_get_bks_bks:
- * @bks:
- *
- * Returns: a #ZakBksBks struct.
- */
-ZakBksBks
-*zak_bks_get_bks_bks (ZakBks *bks)
-{
-       ZakBksBks *cc;
-
-       ZakBksPrivate *priv = ZAK_BKS_GET_PRIVATE (bks);
-
-       cc = g_new0 (ZakBksBks, 1);
-       cc->name = g_strdup (priv->name);
-       cc->description = g_strdup (priv->description);
-
-       return cc;
-}
-
-/**
- * zak_bks_add_bksg:
- * @cnc_string:
- * @name:
- * @description:
+ * zak_bks_bks_destroy:
+ * @bks: a #ZakBksBks object.
  *
- * Returns: a #ZakBksBks struct just rceated.
- */
-ZakBksBks
-*zak_bks_add_bksg (const gchar *cnc_string,
-                                          const gchar *name,
-                                          const gchar *description)
-{
-       ZakBksPluggable *pluggable;
-       ZakBksBks *cc;
-
-       pluggable = zak_bks_get_bks_pluggable_from_cnc_string (cnc_string);
-
-       if (pluggable == NULL)
-               {
-                       g_warning ("Not initialized.");
-                       cc = NULL;
-               }
-       else
-               {
-                       cc = zak_bks_pluggable_add_bksg (pluggable, name, description);
-               }
-
-       return cc;
-}
-
-static gboolean
-add_traverse_func (GNode *node,
-               gpointer data)
-{
-       ZakBksKey *ck = (ZakBksKey *)node->data;
-
-       if (g_strcmp0 (ck->key, "") != 0
-               && g_strcmp0 (ck->key, "/") != 0)
-               {
-                       zak_bks_add_key ((ZakBks *)data, ck->path, ck->key, ck->value);
-               }
-
-       return FALSE;
-}
-
-/**
- * zak_bks_add_bksg_from_bks:
- * @bks_source:
- * @cnc_string:
- * @name_new:
- * @description_new:
- *
- * Returns: a #ZakBksBks struct just created.
- */
-ZakBksBks
-*zak_bks_add_bksg_from_bks (ZakBks *bks_source,
-                                                                 const gchar *cnc_string,
-                                                                 const gchar *name_new,
-                                                                 const gchar *description_new)
-{
-       ZakBks *bks;
-       ZakBksBks *cc;
-
-       GNode *tree;
-
-       gchar *bks_name;
-
-       cc = zak_bks_add_bksg (cnc_string, name_new, description_new);
-       if (cc != NULL)
-               {
-                       tree = zak_bks_get_tree (bks_source);
-                       if (tree != NULL)
-                               {
-                                       bks_name = g_strdup_printf ("%s;BKS_NAME=%s", cnc_string, cc->name);
-
-                                       bks = zak_bks_new (bks_name);
-
-                                       if (bks != NULL)
-                                               {
-                                                       g_node_traverse (tree, G_PRE_ORDER, G_TRAVERSE_ALL, -1, add_traverse_func, (gpointer)bks);
-                                               }
-
-                                       g_free (bks_name);
-                               }
-                       else
-                               {
-                                       g_warning ("ZakBks source is empty.");
-                               }
-               }
-
-       return cc;
-}
-
-/**
- * zak_bks_get_tree:
- * @bks: a #ZakBks object.
- *
- * Returns: a #GNode.
- */
-GNode
-*zak_bks_get_tree (ZakBks *bks)
-{
-       ZakBksPrivate *priv = ZAK_BKS_GET_PRIVATE (bks);
-
-       if (priv->pluggable != NULL)
-               {
-                       return zak_bks_pluggable_get_tree (priv->pluggable);
-               }
-       else
-               {
-                       return NULL;
-               }
-}
-
-/**
- * zak_bks_normalize_set_root:
- * @bks: a #ZakBks object.
- * @root: the root.
- *
- * Returns: a correct value for root property.
- */
-gchar
-*zak_bks_normalize_root (const gchar *root)
-{
-       GString *root_;
-       gchar *strret;
-
-       if (root == NULL)
-               {
-                       root_ = g_string_new ("/");
-               }
-       else
-               {
-                       root_ = g_string_new (root);
-                       g_strstrip (root_->str);
-                       if (g_strcmp0 (root_->str, "") == 0)
-                               {
-                                       g_string_printf (root_, "/");
-                               }
-                       else
-                               {
-                                       if (root_->str[0] != '/')
-                                               {
-                                                       g_string_prepend (root_, "/");
-                                               }
-                                       if (root_->str[root_->len - 1] != '/')
-                                               {
-                                                       g_string_append (root_, "/");
-                                               }
-                               }
-               }
-
-       strret = g_strdup (root_->str);
-       g_string_free (root_, TRUE);
-
-       return strret;
-}
-
-/**
- * zak_bks_set_root:
- * @bks: a #ZakBks object.
- * @root: the root.
- *
- */
-gboolean
-zak_bks_set_root (ZakBks *bks, const gchar *root)
-{
-       gboolean ret;
-
-       ZakBksPrivate *priv = ZAK_BKS_GET_PRIVATE (bks);
-
-       if (priv->pluggable == NULL)
-               {
-                       g_warning ("Not initialized.");
-                       ret = FALSE;
-               }
-       else
-               {
-                       g_object_set (priv->pluggable, "root", root, NULL);
-                       ret = TRUE;
-               }
-
-       return ret;
-}
-
-/**
- * zak_bks_set_bksg:
- * @bks: a #ZakBks object.
- * @name:
- * @description:
- *
- * Returns:
- */
-gboolean
-zak_bks_set_bksg (ZakBks *bks,
-                                         const gchar *name,
-                                         const gchar *description)
-{
-       ZakBksPrivate *priv = ZAK_BKS_GET_PRIVATE (bks);
-
-       if (priv->pluggable == NULL)
-               {
-                       g_warning ("Not initialized.");
-                       return FALSE;
-               }
-       else
-               {
-                       return zak_bks_pluggable_set_bksg (priv->pluggable,
-                                                                                                  name,
-                                                                                                  description);
-               }
-}
-
-/**
- * zak_bks_add_key:
- * @bks: a #ZakBks object.
- * @parent: the path where add the key.
- * @key: the key's name.
- * @value: the key's value.
- *
- * Returns: a #ZakBksgKey struct filled with data from the key just added.
- */
-ZakBksKey
-*zak_bks_add_key (ZakBks *bks, const gchar *parent, const gchar *key, const gchar *value)
-{
-       ZakBksKey *ck;
-
-       ZakBksPrivate *priv = ZAK_BKS_GET_PRIVATE (bks);
-
-       if (priv->pluggable == NULL)
-               {
-                       g_warning ("Not initialized.");
-                       ck = NULL;
-               }
-       else
-               {
-                       ck = zak_bks_pluggable_add_key (priv->pluggable, parent, key, value);
-               }
-
-       return ck;
-}
-
-/**
- * zak_bks_key_set_key:
- * @bks: a #ZakBks object.
- * @ck: a #ZakBksKey struct.
- *
- */
-gboolean
-zak_bks_key_set_key (ZakBks *bks,
-                   ZakBksKey *ck)
-{
-       gboolean ret;
-
-       ZakBksPrivate *priv = ZAK_BKS_GET_PRIVATE (bks);
-
-       if (priv->pluggable == NULL)
-               {
-                       g_warning ("Not initialized.");
-                       ret = FALSE;
-               }
-       else
-               {
-                       ret = zak_bks_pluggable_key_set_key (priv->pluggable, ck);
-               }
-
-       return ret;
-}
-
-/**
- * zak_bks_remove_path:
- * @bks: a #ZakBks object.
- * @path: the path to remove.
- *
- * Removes @path and every child key.
- */
-gboolean
-zak_bks_remove_path (ZakBks *bks, const gchar *path)
-{
-       gboolean ret;
-       ZakBksPrivate *priv = ZAK_BKS_GET_PRIVATE (bks);
-
-       if (priv->pluggable == NULL)
-               {
-                       g_warning ("Not initialized.");
-                       ret = FALSE;
-               }
-       else
-               {
-                       ret = zak_bks_pluggable_remove_path (priv->pluggable, path);
-               }
-
-       return ret;
-}
-
-/**
- * zak_bks_path_get_value:
- * @bks: a #ZakBks object.
- * @path: the path from which retrieving the value.
- *
- * Returns: the bksguration's value as a string.
- */
-gchar
-*zak_bks_path_get_value (ZakBks *bks, const gchar *path)
-{
-       gchar *ret;
-
-       ZakBksPrivate *priv = ZAK_BKS_GET_PRIVATE (bks);
-
-       if (priv->pluggable == NULL)
-               {
-                       g_warning ("Not initialized.");
-                       ret = NULL;
-               }
-       else
-               {
-                       ret = zak_bks_pluggable_path_get_value (priv->pluggable, path);
-               }
-
-       return ret;
-}
-
-/**
- * zak_bks_path_set_value:
- * @bks: a #ZakBks object.
- * @path: the key's path.
- * @value: the value to set.
- *
- */
-gboolean
-zak_bks_path_set_value (ZakBks *bks, const gchar *path, const gchar *value)
-{
-       gboolean ret;
-
-       ZakBksPrivate *priv = ZAK_BKS_GET_PRIVATE (bks);
-
-       if (priv->pluggable == NULL)
-               {
-                       g_warning ("Not initialized.");
-                       ret = FALSE;
-               }
-       else
-               {
-                       ret = zak_bks_pluggable_path_set_value (priv->pluggable, path, value);
-               }
-
-       return ret;
-}
-
-/**
- * zak_bks_path_get_bks_key:
- * @bks: a #ZakBks object.
- * @path: the key's path to get.
- *
- * Returns: (transfer full): a #ZakBksKey from @path
- */
-ZakBksKey
-*zak_bks_path_get_bks_key (ZakBks *bks, const gchar *path)
-{
-       ZakBksKey *ck;
-
-       ZakBksPrivate *priv = ZAK_BKS_GET_PRIVATE (bks);
-
-       if (priv->pluggable == NULL)
-               {
-                       g_warning ("Not initialized.");
-                       ck = NULL;
-               }
-       else
-               {
-                       ck = zak_bks_pluggable_path_get_bks_key (priv->pluggable, path);
-               }
-
-       return ck;
-}
-
-/**
- * zak_bks_remove:
- * @bks: a #ZakBks object.
- *
- * Remove a bksguration from databases and destroy the relative object.
- */
-gboolean
-zak_bks_remove (ZakBks *bks)
-{
-       gboolean ret;
-
-       ZakBksPrivate *priv = ZAK_BKS_GET_PRIVATE (bks);
-
-       if (priv->pluggable == NULL)
-               {
-                       g_warning ("Not initialized.");
-                       ret = FALSE;
-               }
-       else
-               {
-                       ret = zak_bks_pluggable_remove (priv->pluggable);
-               }
-
-       if (ret)
-               {
-                       zak_bks_destroy (bks);
-               }
-
-       return ret;
-}
-
-/**
- * zak_bks_destroy:
- * @bks: a #ZakBks object.
- *
- * Destroy the #ZakBks object, freeing memory.
+ * Destroy the #ZakBksBks object, freeing memory.
  */
 void
-zak_bks_destroy (ZakBks *bks)
-{
-       ZakBksPrivate *priv = ZAK_BKS_GET_PRIVATE (bks);
-
-       g_free (priv->name);
-       g_free (priv->description);
-       g_free (priv->root);
-       g_object_unref (priv->pluggable);
-}
-
-/**
- * zak_bks_path_normalize:
- * @pluggable: a #ZakBksPluggable object.
- *
- * Returns: a normalize path (with root).
- */
-gchar
-*zak_bks_path_normalize (ZakBksPluggable *pluggable, const gchar *path)
+zak_bks_bks_destroy (ZakBksBks *bks)
 {
-       GString *ret;
-       gchar *strret;
-
-       guint lead;
-
-       gchar *root;
-
-       if (path == NULL)
-               {
-                       return NULL;
-               }
-
-       ret = g_string_new (path);
-       g_strstrip (ret->str);
-       if (g_strcmp0 (ret->str, "") == 0)
-               {
-                       return NULL;
-               }
-       else if (ret->str[strlen (ret->str) - 1] == '/')
-               {
-                       return NULL;
-               }
-
-       /* removing leading '/' */
-       lead = 0;
-       for (lead = 0; lead < ret->len; lead++)
-               {
-                       if (ret->str[lead] != '/')
-                               {
-                                       break;
-                               }
-               }
-
-       if (lead < ret->len)
-               {
-                       g_string_erase (ret, 0, lead++);
-               }
-
-       g_object_get (pluggable, "root", &root, NULL);
-       g_string_prepend (ret, root);
-
-       strret = g_strdup (ret->str);
-       g_string_free (ret, TRUE);
-
-       return strret;
+       g_object_unref (bks->pluggable);
 }
 
 /* PRIVATE */
 static void
-zak_bks_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
+zak_bks_bks_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
 {
        gchar *sql;
 
-       ZakBks *bks = ZAK_BKS (object);
-       ZakBksPrivate *priv = ZAK_BKS_GET_PRIVATE (bks);
+       ZakBksBks *bks = ZAK_BKS_BKS (object);
 
        switch (property_id)
                {
@@ -793,10 +245,9 @@ zak_bks_set_property (GObject *object, guint property_id, const GValue *value, G
 }
 
 static void
-zak_bks_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+zak_bks_bks_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
 {
-       ZakBks *bks = ZAK_BKS (object);
-       ZakBksPrivate *priv = ZAK_BKS_GET_PRIVATE (bks);
+       ZakBksBks *bks = ZAK_BKS_BKS (object);
 
        switch (property_id)
                {
index d9792583ac0b80aa75d6377938f6b5187a1d6aa8..f7065e84293344dc5e8fd9682aa61a4f76626dd9 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * confipluggable.c
- * This file is part of libzakconfi
+ * bkspluggable.c
+ * This file is part of libzakbookmarks
  *
- * Copyright (C) 2014-2016 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2019 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
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-#ifdef HAVE_CONFIG_H
+#ifdef HAVE_BKSG_H
 #include <config.h>
 #endif
 
-#include "confipluggable.h"
+#include "bkspluggable.h"
 
 /**
- * SECTION:confipluggable
+ * SECTION:bkspluggable
  * @short_description: Interface for pluggable plugins.
  * @see_also: #PeasExtensionSet
  *
  **/
 
-G_DEFINE_INTERFACE(ZakConfiPluggable, zak_confi_pluggable, G_TYPE_OBJECT)
+G_DEFINE_INTERFACE(ZakBksPluggable, zak_bks_pluggable, G_TYPE_OBJECT)
 
 void
-zak_confi_pluggable_default_init (ZakConfiPluggableInterface *iface)
+zak_bks_pluggable_default_init (ZakBksPluggableInterface *iface)
 {
        static gboolean initialized = FALSE;
 
        if (!initialized)
                {
                        /**
-                       * ZakConfiPluggable:cnc_string:
+                       * ZakBksPluggable:cnc_string:
                        *
                        */
                        g_object_interface_install_property (iface,
@@ -52,46 +52,13 @@ zak_confi_pluggable_default_init (ZakConfiPluggableInterface *iface)
                                                                                  "",
                                                                                  G_PARAM_READWRITE));
 
-                       /**
-                       * ZakConfiPluggable:name:
-                       *
-                       */
-                       g_object_interface_install_property (iface,
-                                                            g_param_spec_string ("name",
-                                                                                 "Configuraton Name",
-                                                                                 "The configuration name",
-                                                                                 "",
-                                                                                 G_PARAM_READABLE));
-
-                       /**
-                       * ZakConfiPluggable:description:
-                       *
-                       */
-                       g_object_interface_install_property (iface,
-                                                            g_param_spec_string ("description",
-                                                                                 "Configuraton Description",
-                                                                                 "The configuration description",
-                                                                                 "",
-                                                                                 G_PARAM_READABLE));
-
-                       /**
-                       * ZakConfiPluggable:root:
-                       *
-                       */
-                       g_object_interface_install_property (iface,
-                                                            g_param_spec_string ("root",
-                                                                                 "Configuraton Root",
-                                                                                 "The configuration root",
-                                                                                 "/",
-                                                                                 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
                        initialized = TRUE;
                }
 }
 
 /**
- * zak_confi_pluggable_initialize:
- * @pluggable: A #ZakConfiPluggable.
+ * zak_bks_pluggable_initialize:
+ * @pluggable: A #ZakBksPluggable.
  * @cnc_string: The connection string.
  *
  * Initialize the backend.
@@ -99,237 +66,14 @@ zak_confi_pluggable_default_init (ZakConfiPluggableInterface *iface)
  * Returns: #TRUE if success.
  */
 gboolean
-zak_confi_pluggable_initialize (ZakConfiPluggable *pluggable, const gchar *cnc_string)
+zak_bks_pluggable_initialize (ZakBksPluggable *pluggable, const gchar *cnc_string)
 {
-       ZakConfiPluggableInterface *iface;
+       ZakBksPluggableInterface *iface;
 
-       g_return_val_if_fail (ZAK_CONFI_IS_PLUGGABLE (pluggable), FALSE);
+       g_return_val_if_fail (ZAK_BKS_IS_PLUGGABLE (pluggable), FALSE);
 
-       iface = ZAK_CONFI_PLUGGABLE_GET_IFACE (pluggable);
+       iface = ZAK_BKS_PLUGGABLE_GET_IFACE (pluggable);
        g_return_val_if_fail (iface->initialize != NULL, FALSE);
 
        return iface->initialize (pluggable, cnc_string);
 }
-
-/**
- * zak_confi_pluggable_get_configs_list:
- * @pluggable: A #ZakConfiPluggable.
- * @filter: (nullable):
- *
- * Returns: (element-type ZakConfi) (transfer container): a #GList of #ZakConfi. If there's no configurations, returns a valid
- * #GList but with a unique NULL element.
-*/
-GList
-*zak_confi_pluggable_get_configs_list (ZakConfiPluggable *pluggable, const gchar *filter)
-{
-       ZakConfiPluggableInterface *iface;
-
-       g_return_val_if_fail (ZAK_CONFI_IS_PLUGGABLE (pluggable), FALSE);
-
-       iface = ZAK_CONFI_PLUGGABLE_GET_IFACE (pluggable);
-       g_return_val_if_fail (iface->get_configs_list != NULL, FALSE);
-
-       return iface->get_configs_list (pluggable, filter);
-}
-
-/**
- * zak_confi_pluggable_path_get_value:
- * @pluggable: A #ZakConfiPluggable.
- * @path:
- *
- * Returns: the value of the @path.
-*/
-gchar
-*zak_confi_pluggable_path_get_value (ZakConfiPluggable *pluggable, const gchar *path)
-{
-       ZakConfiPluggableInterface *iface;
-
-       g_return_val_if_fail (ZAK_CONFI_IS_PLUGGABLE (pluggable), FALSE);
-
-       iface = ZAK_CONFI_PLUGGABLE_GET_IFACE (pluggable);
-       g_return_val_if_fail (iface->path_get_value != NULL, FALSE);
-
-       return iface->path_get_value (pluggable, path);
-}
-
-/**
- * zak_confi_pluggable_path_set_value:
- * @pluggable: a #ZakConfiPluggable object.
- * @path: the key's path.
- * @value: the value to set.
- *
- */
-gboolean
-zak_confi_pluggable_path_set_value (ZakConfiPluggable *pluggable, const gchar *path, const gchar *value)
-{
-       ZakConfiPluggableInterface *iface;
-
-       g_return_val_if_fail (ZAK_CONFI_IS_PLUGGABLE (pluggable), FALSE);
-
-       iface = ZAK_CONFI_PLUGGABLE_GET_IFACE (pluggable);
-       g_return_val_if_fail (iface->path_set_value != NULL, FALSE);
-
-       return iface->path_set_value (pluggable, path, value);
-}
-
-/**
- * zak_confi_pluggable_get_tree:
- * @pluggable: a #ZakConfiPluggable object.
- *
- * Returns: a #GNode with the entire tree of configurations.
- */
-GNode
-*zak_confi_pluggable_get_tree (ZakConfiPluggable *pluggable)
-{
-       ZakConfiPluggableInterface *iface;
-
-       g_return_val_if_fail (ZAK_CONFI_IS_PLUGGABLE (pluggable), FALSE);
-
-       iface = ZAK_CONFI_PLUGGABLE_GET_IFACE (pluggable);
-       g_return_val_if_fail (iface->get_tree != NULL, FALSE);
-
-       return iface->get_tree (pluggable);
-}
-
-/**
- * zak_confi_pluggable_add_config:
- * @pluggable: a #ZakConfiPluggable object.
- * @name: the name of the config..
- * @description: the config's description.
- *
- * Returns: a #ZakConfiConfi struct filled with data from the key just added.
- */
-ZakConfiConfi
-*zak_confi_pluggable_add_config (ZakConfiPluggable *pluggable, const gchar *name, const gchar *description)
-{
-       ZakConfiPluggableInterface *iface;
-
-       g_return_val_if_fail (ZAK_CONFI_IS_PLUGGABLE (pluggable), FALSE);
-
-       iface = ZAK_CONFI_PLUGGABLE_GET_IFACE (pluggable);
-       g_return_val_if_fail (iface->add_config != NULL, FALSE);
-
-       return iface->add_config (pluggable, name, description);
-}
-
-/**
- * zak_confi_pluggable_set_config:
- * @pluggable: a #ZakConfiPluggable object.
- * @name: the name of the config..
- * @description: the config's description.
- *
- * Returns:
- */
-gboolean
-zak_confi_pluggable_set_config (ZakConfiPluggable *pluggable, const gchar *name, const gchar *description)
-{
-       ZakConfiPluggableInterface *iface;
-
-       g_return_val_if_fail (ZAK_CONFI_IS_PLUGGABLE (pluggable), FALSE);
-
-       iface = ZAK_CONFI_PLUGGABLE_GET_IFACE (pluggable);
-       g_return_val_if_fail (iface->set_config != NULL, FALSE);
-
-       return iface->set_config (pluggable, name, description);
-}
-
-/**
- * zak_confi_pluggable_add_key:
- * @pluggable: a #ZakConfiPluggable object.
- * @parent: the path where add the key.
- * @key: the key's name.
- * @value: the key's value.
- *
- * Returns: a #ZakConfiKey struct filled with data from the key just added.
- */
-ZakConfiKey
-*zak_confi_pluggable_add_key (ZakConfiPluggable *pluggable, const gchar *parent, const gchar *key, const gchar *value)
-{
-       ZakConfiPluggableInterface *iface;
-
-       g_return_val_if_fail (ZAK_CONFI_IS_PLUGGABLE (pluggable), FALSE);
-
-       iface = ZAK_CONFI_PLUGGABLE_GET_IFACE (pluggable);
-       g_return_val_if_fail (iface->add_key != NULL, FALSE);
-
-       return iface->add_key (pluggable, parent, key, value);
-}
-
-/**
- * zak_confi_pluggable_key_set_key:
- * @pluggable: a #ZakConfiPluggable object.
- * @ck: a #ZakConfiKey struct.
- *
- */
-gboolean
-zak_confi_pluggable_key_set_key (ZakConfiPluggable *pluggable,
-                   ZakConfiKey *ck)
-{
-       ZakConfiPluggableInterface *iface;
-
-       g_return_val_if_fail (ZAK_CONFI_IS_PLUGGABLE (pluggable), FALSE);
-
-       iface = ZAK_CONFI_PLUGGABLE_GET_IFACE (pluggable);
-       g_return_val_if_fail (iface->key_set_key != NULL, FALSE);
-
-       return iface->key_set_key (pluggable, ck);
-}
-
-/**
- * zak_confi_pluggable_path_get_confi_key:
- * @pluggable: a #ZakConfiPluggable object.
- * @path: the key's path to get.
- *
- * Returns: (transfer full): a #ZakConfiKey from @path
- */
-ZakConfiKey
-*zak_confi_pluggable_path_get_confi_key (ZakConfiPluggable *pluggable, const gchar *path)
-{
-       ZakConfiPluggableInterface *iface;
-
-       g_return_val_if_fail (ZAK_CONFI_IS_PLUGGABLE (pluggable), FALSE);
-
-       iface = ZAK_CONFI_PLUGGABLE_GET_IFACE (pluggable);
-       g_return_val_if_fail (iface->path_get_confi_key != NULL, FALSE);
-
-       return iface->path_get_confi_key (pluggable, path);
-}
-
-/**
- * zak_confi_pluggable_remove_path:
- * @pluggable: a #ZakConfiPluggable object.
- * @path: the path to remove.
- *
- * Removes @path and every child key.
- */
-gboolean
-zak_confi_pluggable_remove_path (ZakConfiPluggable *pluggable, const gchar *path)
-{
-       ZakConfiPluggableInterface *iface;
-
-       g_return_val_if_fail (ZAK_CONFI_IS_PLUGGABLE (pluggable), FALSE);
-
-       iface = ZAK_CONFI_PLUGGABLE_GET_IFACE (pluggable);
-       g_return_val_if_fail (iface->remove_path != NULL, FALSE);
-
-       return iface->remove_path (pluggable, path);
-}
-
-/**
- * zak_confi_pluggable_remove:
- * @pluggable: a #ZakConfiPluggable object.
- *
- * Remove a configuration from databases and destroy the relative object.
- */
-gboolean
-zak_confi_pluggable_remove (ZakConfiPluggable *pluggable)
-{
-       ZakConfiPluggableInterface *iface;
-
-       g_return_val_if_fail (ZAK_CONFI_IS_PLUGGABLE (pluggable), FALSE);
-
-       iface = ZAK_CONFI_PLUGGABLE_GET_IFACE (pluggable);
-       g_return_val_if_fail (iface->remove != NULL, FALSE);
-
-       return iface->remove (pluggable);
-}
index 269964c4140dbc20aaa4a2789d9ad262234e263a..77b6cf2869103e026c36550b1c408cac59b39f36 100644 (file)
@@ -19,7 +19,7 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-#ifndef __ZAK_BOOKMAKRS_PLUGGABLE_H__
+#ifndef __ZAK_BOOKMARKS_PLUGGABLE_H__
 #define __ZAK_BOOKMARKS_PLUGGABLE_H__
 
 #include <glib-object.h>
@@ -57,29 +57,6 @@ struct _ZakBksPluggableInterface {
 
        /* Virtual public methods */
        gboolean (*initialize) (ZakBksPluggable *pluggable, const gchar *cnc_string);
-       GList *(*get_bksgs_list) (ZakBksPluggable *pluggable,
-                                   const gchar *filter);
-       gchar *(*path_get_value) (ZakBksPluggable *pluggable, const gchar *path);
-       gboolean (*path_set_value) (ZakBksPluggable *pluggable,
-                                   const gchar *path,
-                                   const gchar *value);
-       GNode *(*get_tree) (ZakBksPluggable *pluggable);
-       ZakBksBks *(*add_bksg) (ZakBksPluggable *pluggable,
-                             const gchar *name,
-                             const gchar *description);
-       gboolean (*set_bksg) (ZakBksPluggable *pluggable,
-                             const gchar *name,
-                             const gchar *description);
-       ZakBksKey *(*add_key) (ZakBksPluggable *pluggable,
-                             const gchar *parent,
-                             const gchar *key,
-                             const gchar *value);
-       ZakBksKey *(*path_get_bks_key) (ZakBksPluggable *pluggable, const gchar *path);
-       gboolean (*remove_path) (ZakBksPluggable *pluggable,
-                                const gchar *path);
-       gboolean (*remove) (ZakBksPluggable *pluggable);
-       gboolean (*key_set_key) (ZakBksPluggable *pluggable,
-                                ZakBksKey *ck);
 };
 
 /*
@@ -88,34 +65,9 @@ struct _ZakBksPluggableInterface {
 GType zak_bks_pluggable_get_type (void) G_GNUC_CONST;
 
 gboolean zak_bks_pluggable_initialize (ZakBksPluggable *pluggable,
-                                     const gchar *cnc_string);
-
-GList *zak_bks_pluggable_get_bksgs_list (ZakBksPluggable *pluggable,
-                                         const gchar *filter);
-gchar *zak_bks_pluggable_path_get_value (ZakBksPluggable *pluggable,
-                                       const gchar *path);
-gboolean zak_bks_pluggable_path_set_value (ZakBksPluggable *pluggable,
-                               const gchar *path,
-                               const gchar *value);
-GNode *zak_bks_pluggable_get_tree (ZakBksPluggable *pluggable);
-ZakBksBks *zak_bks_pluggable_add_bksg (ZakBksPluggable *pluggable,
-                                   const gchar *name,
-                                   const gchar *description);
-gboolean zak_bks_pluggable_set_bksg (ZakBksPluggable *pluggable,
-                                   const gchar *name,
-                                   const gchar *description);
-ZakBksKey *zak_bks_pluggable_add_key (ZakBksPluggable *pluggable,
-                                   const gchar *parent,
-                                   const gchar *key,
-                                   const gchar *value);
-gboolean zak_bks_pluggable_key_set_key (ZakBksPluggable *pluggable,
-                   ZakBksKey *ck);
-ZakBksKey *zak_bks_pluggable_path_get_bks_key (ZakBksPluggable *pluggable, const gchar *path);
-gboolean zak_bks_pluggable_remove_path (ZakBksPluggable *pluggable, const gchar *path);
-gboolean zak_bks_pluggable_remove (ZakBksPluggable *pluggable);
+                                       const gchar *cnc_string);
 
 
 G_END_DECLS
 
-#endif /* __ZAK_BOOKMAKRS_PLUGGABLE_H__ */
-<
+#endif /* __ZAK_BOOKMARKS_PLUGGABLE_H__ */
index 36b12b40a3840b5d5a3d7ea66821abda2c8ab482..f317f019a2bda1cfb8ffd38d736d7edcd22cdf58 100644 (file)
 G_BEGIN_DECLS
 
 
-#define ZAK_TYPE_BKS                 (zak_bks_get_type ())
-#define ZAK_BKS(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), ZAK_TYPE_BKS, ZakBks))
-#define ZAK_BKS_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), ZAK_TYPE_BKS, ZakBksClass))
-#define ZAK_IS_BKS(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ZAK_TYPE_BKS))
-#define ZAK_IS_BKS_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), ZAK_TYPE_BKS))
-#define ZAK_BKS_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), ZAK_TYPE_BKS, ZakBksClass))
+#define ZAK_BKS_TYPE_BKS zak_bks_bks_get_type ()
+G_DECLARE_FINAL_TYPE (ZakBksBks, zak_bks_bks, ZAK_BKS, BKS, GObject)
 
+ZakBksBks *zak_bks_new (const gchar *cnc_string);
 
-typedef struct _ZakBks ZakBks;
-typedef struct _ZakBksClass ZakBksClass;
+PeasPluginInfo *zak_bks_get_plugin_info (ZakBksBks *bks);
 
-struct _ZakBks
-       {
-               GObject parent;
-       };
-
-struct _ZakBksClass
-       {
-               GObjectClass parent_class;
-       };
-
-GType zak_bks_get_type (void);
-
-ZakBks *zak_bks_new (const gchar *cnc_string);
-
-PeasPluginInfo *zak_bks_get_plugin_info (ZakBks *bks);
-
-void zak_bks_destroy (ZakBks *bks);
+void zak_bks_destroy (ZakBksBks *bks);
 
 
 G_END_DECLS