changeset 313:5a20f229ece6 trunk

[svn] Revert changes; this plugin is hard to convert to configdb. Leave it for now.
author chainsaw
date Sat, 17 Dec 2005 13:51:17 -0800
parents 69a59bfeac07
children 31725d73a697
files Plugins/Visualization/libvisual-proxy/lv_bmp_config.c
diffstat 1 files changed, 40 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/Visualization/libvisual-proxy/lv_bmp_config.c	Sat Dec 17 13:14:46 2005 -0800
+++ b/Plugins/Visualization/libvisual-proxy/lv_bmp_config.c	Sat Dec 17 13:51:17 2005 -0800
@@ -1,7 +1,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <gtk/gtk.h>
-#include <libaudacious/configdb.h>
+#include <libaudacious/configfile.h>
 #include <audacious/util.h>
 #include <libvisual/libvisual.h>
 #include <glib/gi18n.h>
@@ -128,18 +128,19 @@
 int lv_bmp_config_load_prefs ()
 {
 	gchar *vstr;
-	ConfigDb *db;
+	ConfigFile *f;
 	gboolean errors;
 	gboolean must_create_entry;
 	gboolean must_update;
 	GtkWidget *msg;
 
-	db = bmp_cfg_db_open();
+	if ((f = xmms_cfg_open_default_file ()) == NULL)
+		return -1;
 
 	errors = FALSE;
 	must_create_entry = FALSE;
 	must_update = FALSE;
-	if (bmp_cfg_db_get_string(db, "libvisual_bmp", "version", &vstr)) {
+	if (xmms_cfg_read_string (f, "libvisual_bmp", "version", &vstr)) {
 		if (strcmp (vstr, VERSION) == 0) {
 			errors = read_config_file (f);
 			if (errors)
@@ -157,7 +158,7 @@
 
 	load_actor_plugin_enable_table (f);
 
-	bmp_cfg_db_close(db);
+	xmms_cfg_free (f);
 
 	/*
 	 * Set our local copies
@@ -227,42 +228,45 @@
 		visual_log (VISUAL_LOG_DEBUG, "enable == NULL for %s", actor->info->plugname);
 		return;
 	}
-	bmp_cfg_db_set_bool(db, "libvisual_bmp", actor->info->plugname, *enable);
+	xmms_cfg_write_boolean (f, "libvisual_bmp", actor->info->plugname, *enable);
 }
 
 int lv_bmp_config_save_prefs ()
 {
-	ConfigDb *db;
+	ConfigFile *f;
 
-	db = bmp_cfg_db_open();
+	if((f = xmms_cfg_open_default_file ()) == NULL)
+		f = xmms_cfg_new ();
+	if (f == NULL)
+		return -1;
 
-	bmp_cfg_db_set_string(db, "libvisual_bmp", "version", VERSION);
+	xmms_cfg_write_string (f, "libvisual_bmp", "version", VERSION);
 
 	if (options.last_plugin != NULL && (strlen(options.last_plugin) > 0))
-		bmp_cfg_db_set_string(db, "libvisual_bmp", "last_plugin", options.last_plugin);
+		xmms_cfg_write_string (f, "libvisual_bmp", "last_plugin", options.last_plugin);
 	else
-		bmp_cfg_db_set_string(db, "libvisual_bmp", "last_plugin", CONFIG_DEFAULT_ACTOR_PLUGIN);
+		xmms_cfg_write_string (f, "libvisual_bmp", "last_plugin", CONFIG_DEFAULT_ACTOR_PLUGIN);
 
 	if (options.morph_plugin != NULL && (strlen(options.morph_plugin) > 0))
-		bmp_cfg_db_set_string(db, "libvisual_bmp", "morph_plugin", options.morph_plugin);
+		xmms_cfg_write_string (f, "libvisual_bmp", "morph_plugin", options.morph_plugin);
 	else
-		bmp_cfg_db_set_string(db, "libvisual_bmp", "morph_plugin", CONFIG_DEFAULT_MORPH_PLUGIN);
-	bmp_cfg_db_set_bool(db, "libvisual_bmp", "random_morph", options.random_morph);
+		xmms_cfg_write_string (f, "libvisual_bmp", "morph_plugin", CONFIG_DEFAULT_MORPH_PLUGIN);
+	xmms_cfg_write_boolean (f, "libvisual_bmp", "random_morph", options.random_morph);
 		
 	if (options.icon_file != NULL && (strlen(options.icon_file) > 0))
-		bmp_cfg_db_set_string(db, "libvisual_bmp", "icon", options.icon_file);
+		xmms_cfg_write_string (f, "libvisual_bmp", "icon", options.icon_file);
 
-	bmp_cfg_db_set_int(db, "libvisual_bmp", "width", options.width);
-	bmp_cfg_db_set_int(db, "libvisual_bmp", "height", options.height);
-	bmp_cfg_db_set_int(db, "libvisual_bmp", "color_depth", options.depth);
-	bmp_cfg_db_set_int(db, "libvisual_bmp", "fps", options.fps);
-	bmp_cfg_db_set_bool(db, "libvisual_bmp", "fullscreen", options.fullscreen);
+	xmms_cfg_write_int (f, "libvisual_bmp", "width", options.width);
+	xmms_cfg_write_int (f, "libvisual_bmp", "height", options.height);
+	xmms_cfg_write_int (f, "libvisual_bmp", "color_depth", options.depth);
+	xmms_cfg_write_int (f, "libvisual_bmp", "fps", options.fps);
+	xmms_cfg_write_boolean (f, "libvisual_bmp", "fullscreen", options.fullscreen);
 	if (options.gl_plugins_only)
-		bmp_cfg_db_set_string(db, "libvisual_bmp", "enabled_plugins", "gl_only");
+		xmms_cfg_write_string (f, "libvisual_bmp", "enabled_plugins", "gl_only");
 	else if (options.non_gl_plugins_only)
-		bmp_cfg_db_set_string(db, "libvisual_bmp", "enabled_plugins", "non_gl_only");
+		xmms_cfg_write_string (f, "libvisual_bmp", "enabled_plugins", "non_gl_only");
 	else if (options.all_plugins_enabled)
-		bmp_cfg_db_set_string(db, "libvisual_bmp", "enabled_plugins", "all");
+		xmms_cfg_write_string (f, "libvisual_bmp", "enabled_plugins", "all");
 	else
 		g_warning ("Inconsistency on config module");
 
@@ -271,7 +275,8 @@
 	g_slist_foreach (actor_plugins_gl, save_actor_enable_state, f);
 	g_slist_foreach (actor_plugins_nongl, save_actor_enable_state, f);
 
-	bmp_cfg_db_close(db);
+	xmms_cfg_write_default_file (f);
+	xmms_cfg_free (f);
 
 	return 0;
 }
@@ -1060,19 +1065,19 @@
 {
 }
 
-static gboolean read_config_file (ConfigDb *db)
+static gboolean read_config_file (ConfigFile *f)
 {
 	gchar *enabled_plugins;
 	gboolean errors = FALSE;
 
-	if (!bmp_cfg_db_get_string(db, "libvisual_bmp", "last_plugin", &actor_plugin_buffer)
+	if (!xmms_cfg_read_string (f, "libvisual_bmp", "last_plugin", &actor_plugin_buffer)
  		|| (strlen (actor_plugin_buffer) <= 0)) {
 		visual_log (VISUAL_LOG_DEBUG, "Error on last_plugin option");
 		strcpy (actor_plugin_buffer, CONFIG_DEFAULT_ACTOR_PLUGIN);
 		errors = TRUE;
 	}
 	options.last_plugin = actor_plugin_buffer;
-	if (!bmp_cfg_db_get_string(db, "libvisual_bmp", "morph_plugin", &morph_plugin_buffer)
+	if (!xmms_cfg_read_string (f, "libvisual_bmp", "morph_plugin", &morph_plugin_buffer)
 		|| (strlen (morph_plugin_buffer) <= 0)) {
 		visual_log (VISUAL_LOG_DEBUG, "Error on morph_plugin option");
 		strcpy (morph_plugin_buffer, CONFIG_DEFAULT_MORPH_PLUGIN);
@@ -1080,43 +1085,43 @@
 	}
 	morph_plugin = morph_plugin_buffer;
 	options.morph_plugin = morph_plugin;
-	if (!bmp_cfg_db_get_bool(db, "libvisual_bmp", "random_morph", &options.random_morph)) {
+	if (!xmms_cfg_read_boolean (f, "libvisual_bmp", "random_morph", &options.random_morph)) {
 		visual_log (VISUAL_LOG_DEBUG, "Error on random_morph option");
 		options.random_morph = default_options.random_morph;
 		errors = TRUE;
 	}
-	if (!bmp_cfg_db_get_string(db, "libvisual_bmp", "icon", &options.icon_file)
+	if (!xmms_cfg_read_string (f, "libvisual_bmp", "icon", &options.icon_file)
 		|| (strlen (options.icon_file) <= 0)) {
 		visual_log (VISUAL_LOG_DEBUG, "Error on icon option");
 		errors = TRUE;
 	}
-	if (!bmp_cfg_db_get_int(db, "libvisual_bmp", "width", &options.width) || options.width <= 0) {
+	if (!xmms_cfg_read_int (f, "libvisual_bmp", "width", &options.width) || options.width <= 0) {
 		visual_log (VISUAL_LOG_DEBUG, "Error on width option");
 		options.width = default_options.width;
 		errors = TRUE;
 	}
-	if (!bmp_cfg_db_get_int(db, "libvisual_bmp", "height", &options.height)	|| options.height <= 0) {
+	if (!xmms_cfg_read_int (f, "libvisual_bmp", "height", &options.height)	|| options.height <= 0) {
 		visual_log (VISUAL_LOG_DEBUG, "Error on height option");
 		options.height = default_options.height;
 		errors = TRUE;
 	}
-	if (!bmp_cfg_db_get_int(db, "libvisual_bmp", "fps", &options.fps) || options.fps <= 0) {
+	if (!xmms_cfg_read_int (f, "libvisual_bmp", "fps", &options.fps) || options.fps <= 0) {
 		visual_log (VISUAL_LOG_DEBUG, "Error on fps option");
 		options.fps = default_options.fps;
 		errors = TRUE;
 	}
-	if (!bmp_cfg_db_get_int(db, "libvisual_bmp", "color_depth", &options.depth) || options.depth <= 0) {
+	if (!xmms_cfg_read_int (f, "libvisual_bmp", "color_depth", &options.depth) || options.depth <= 0) {
 		visual_log (VISUAL_LOG_DEBUG, "Error on color_depth option");
 		options.depth = default_options.depth;
 		errors = TRUE;
 	}
-	if (!bmp_cfg_db_get_bool(db, "libvisual_bmp", "fullscreen", &options.fullscreen)) {
+	if (!xmms_cfg_read_boolean (f, "libvisual_bmp", "fullscreen", &options.fullscreen)) {
 		visual_log (VISUAL_LOG_DEBUG, "Error on fullscreen option");
 		options.fullscreen = default_options.fullscreen;
 		errors = TRUE;
 	}
 	enabled_plugins = g_malloc0 (OPTIONS_MAX_NAME_LEN);
-	if (!bmp_cfg_db_get_string(db, "libvisual_bmp", "enabled_plugins", &enabled_plugins)
+	if (!xmms_cfg_read_string (f, "libvisual_bmp", "enabled_plugins", &enabled_plugins)
 		|| (strlen (enabled_plugins) <= 0)) {
 		visual_log (VISUAL_LOG_DEBUG, "Error on enabled_plugins option: %s", enabled_plugins);
 		options.gl_plugins_only = default_options.gl_plugins_only;