return ret;
}
+gboolean
+confi_db_plugin_path_set_value (ConfiPluggable *pluggable, const gchar *path, const gchar *value)
+{
+ GdaDataModel *dm;
+ gchar *sql;
+ gboolean ret;
+
+ dm = confi_db_plugin_path_get_data_model (pluggable, confi_path_normalize (pluggable, path));
+
+ ConfiDBPluginPrivate *priv = CONFI_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 "
+ "AND id = %d ",
+ priv->chrquot, priv->chrquot,
+ gdaex_strescape (value, 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);
+ }
+ else
+ {
+ g_warning ("Path %s doesn't exists.", path);
+ }
+ if (dm != NULL)
+ {
+ g_object_unref (dm);
+ }
+
+ return ret;
+}
+
static void
confi_db_plugin_class_init (ConfiDBPluginClass *klass)
{
iface->initialize = confi_db_plugin_initialize;
iface->get_configs_list = confi_db_plugin_get_configs_list;
iface->path_get_value = confi_db_plugin_path_get_value;
+ iface->path_set_value = confi_db_plugin_path_set_value;
}
static void
return iface->path_get_value (pluggable, path);
}
+/**
+ * confi_pluggable_path_set_value:
+ * @pluggable: a #ConfiPluggable object.
+ * @path: the key's path.
+ * @value: the value to set.
+ *
+ */
+gboolean
+confi_pluggable_path_set_value (ConfiPluggable *pluggable, const gchar *path, const gchar *value)
+{
+ ConfiPluggableInterface *iface;
+
+ g_return_val_if_fail (CONFI_IS_PLUGGABLE (pluggable), FALSE);
+
+ iface = CONFI_PLUGGABLE_GET_IFACE (pluggable);
+ g_return_val_if_fail (iface->path_set_value != NULL, FALSE);
+
+ return iface->path_set_value (pluggable, path, value);
+}
GList *(*get_configs_list) (ConfiPluggable *pluggable,
const gchar *filter);
gchar *(*path_get_value) (ConfiPluggable *pluggable, const gchar *path);
+ gboolean (*path_set_value) (ConfiPluggable *pluggable,
+ const gchar *path,
+ const gchar *value);
};
/*
GList *confi_pluggable_get_configs_list (ConfiPluggable *pluggable,
const gchar *filter);
gchar *confi_pluggable_path_get_value (ConfiPluggable *pluggable, const gchar *path);
+gboolean confi_pluggable_path_set_value (ConfiPluggable *pluggable,
+ const gchar *path,
+ const gchar *value);
G_END_DECLS
gboolean
confi_path_set_value (Confi *confi, const gchar *path, const gchar *value)
{
- GdaDataModel *dm;
- gchar *sql;
gboolean ret;
- //dm = path_get_data_model (confi, path_normalize (confi, path));
-
ConfiPrivate *priv = CONFI_GET_PRIVATE (confi);
- ret = FALSE;
- if (dm != NULL && gda_data_model_get_n_rows (dm) > 0)
+ if (priv->pluggable == NULL)
{
- sql = g_strdup_printf ("UPDATE %cvalues%c SET value = '%s' "
- "WHERE id_configs = %d "
- "AND id = %d ",
- priv->chrquot, priv->chrquot,
- gdaex_strescape (value, 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);
+ g_warning ("Not initialized.");
+ ret = FALSE;
}
else
{
- g_warning ("Path %s doesn't exists.", path);
- }
- if (dm != NULL)
- {
- g_object_unref (dm);
+ ret = confi_pluggable_path_set_value (priv->pluggable, path, value);
}
return ret;
return 0;
}
+ gchar *val = confi_path_get_value (confi, "folder/key1/key1_2");
+ g_printf ("Value from key \"folder/key1/key1_2\"\n%s\n\n", val);
+ confi_path_set_value (confi, "folder/key1/key1_2", "new value programmatically setted");
g_printf ("Value from key \"folder/key1/key1_2\"\n%s\n\n", confi_path_get_value (confi, "folder/key1/key1_2"));
+ confi_path_set_value (confi, "folder/key1/key1_2", val);
/*g_printf ("Traversing the entire tree\n");
tree = confi_get_tree (confi);