changeset 533:9ca430524698

Audacious-related cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 20 Feb 2007 23:38:03 +0000
parents bc548249464a
children 6817f2a03b21
files src/xmms-sid.h src/xs_config.c
diffstat 2 files changed, 52 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- a/src/xmms-sid.h	Tue Feb 20 22:03:01 2007 +0000
+++ b/src/xmms-sid.h	Tue Feb 20 23:38:03 2007 +0000
@@ -109,7 +109,6 @@
 
 
 #define XS_CONFIG_IDENT		"XMMS-SID"	/* Configuration file identifier */
-#define XS_CONFIG_FILE		"/.xmms/xmms-sid"	/* Use this configfile if autocyrpe fails */
 
 #define XS_MIN_OVERSAMPLE	(2)		/* Minimum oversampling factor */
 #define XS_MAX_OVERSAMPLE	(8)		/* Maximum oversampling factor */
--- a/src/xs_config.c	Tue Feb 20 22:03:01 2007 +0000
+++ b/src/xs_config.c	Tue Feb 20 23:38:03 2007 +0000
@@ -21,7 +21,38 @@
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 #include "xs_config.h"
+
+#ifdef AUDACIOUS_PLUGIN
+#include <audacious/configdb.h>
+#define XS_CONFIG_FILE		ConfigDb
+#define XS_CONFIG_OPEN		bmp_cfg_db_open
+#define XS_CONFIG_FREE		bmp_cfg_db_close
+#define XS_CONFIG_WRITE
+
+#define XS_CFG_SET_STRING	bmp_cfg_db_set_string
+#define XS_CFG_SET_FLOAT	bmp_cfg_db_set_float
+#define XS_CFG_SET_INT		bmp_cfg_db_set_int
+#define XS_CFG_SET_BOOL		bmp_cfg_db_set_bool
+#define XS_CFG_GET_STRING	bmp_cfg_db_get_string
+#define XS_CFG_GET_FLOAT	bmp_cfg_db_get_float
+#define XS_CFG_GET_INT		bmp_cfg_db_get_int
+#define XS_CFG_GET_BOOL		bmp_cfg_db_get_bool
+#else
 #include <xmms/configfile.h>
+#define XS_CONFIG_FILE		ConfigFile
+#define XS_CONFIG_OPEN		xmms_cfg_open_default_file
+#define XS_CONFIG_FREE		xmms_cfg_free
+#define XS_CONFIG_WRITE		xmms_cfg_write_default_file
+
+#define XS_CFG_SET_STRING	xmms_cfg_write_string
+#define XS_CFG_SET_FLOAT	xmms_cfg_write_float
+#define XS_CFG_SET_INT		xmms_cfg_write_int
+#define XS_CFG_SET_BOOL		xmms_cfg_write_boolean
+#define XS_CFG_GET_STRING	xmms_cfg_read_string
+#define XS_CFG_GET_FLOAT	xmms_cfg_read_float
+#define XS_CFG_GET_INT		xmms_cfg_read_int
+#define XS_CFG_GET_BOOL		xmms_cfg_read_boolean
+#endif
 #include <stdio.h>
 #include "xs_glade.h"
 #include "xs_interface.h"
@@ -254,27 +285,18 @@
  */
 void xs_read_configuration(void)
 {
-#ifdef HAVE_NODEFAULTCFG
-	gchar *cfgFilename;
-#endif
+	XS_CONFIG_FILE *cfg;
+	gint i;
 	gchar *tmpStr;
-	ConfigFile *cfgFile;
-	gint i;
 
 	/* Try to open the XMMS configuration file  */
 	XS_MUTEX_LOCK(xs_cfg);
 	XSDEBUG("loading from config-file ...\n");
 
-#ifdef HAVE_NODEFAULTCFG
-	cfgFilename = g_strconcat(g_get_home_dir(), XS_CONFIG_FILE, NULL);
-	cfgFile = xmms_cfg_open_file(cfgFilename);
-	g_free(cfgFilename);
-#else
-	cfgFile = xmms_cfg_open_default_file();
-#endif
+	cfg = XS_CONFIG_OPEN();
 
-	if (cfgFile == NULL) {
-		XSDEBUG("could not open configuration file, trying to write defaults...\n");
+	if (cfg == NULL) {
+		XSDEBUG("Could not open configuration, trying to write defaults...\n");
 		xs_write_configuration();
 		return;
 	}
@@ -283,27 +305,26 @@
 	for (i = 0; i < xs_cfgtable_max; i++) {
 		switch (xs_cfgtable[i].itemType) {
 		case CTYPE_INT:
-			xmms_cfg_read_int(cfgFile, XS_CONFIG_IDENT,
+			XS_CFG_GET_INT(cfg, XS_CONFIG_IDENT,
 				xs_cfgtable[i].itemName,
 				(gint *) xs_cfgtable[i].itemData);
 			break;
 
 		case CTYPE_BOOL:
-			xmms_cfg_read_boolean(cfgFile, XS_CONFIG_IDENT,
+			XS_CFG_GET_BOOL(cfg, XS_CONFIG_IDENT,
 				xs_cfgtable[i].itemName,
 				(gboolean *) xs_cfgtable[i].itemData);
 			break;
 
 		case CTYPE_FLOAT:
-			xmms_cfg_read_float(cfgFile, XS_CONFIG_IDENT,
+			XS_CFG_GET_FLOAT(cfg, XS_CONFIG_IDENT,
 				xs_cfgtable[i].itemName,
 				(gfloat *) xs_cfgtable[i].itemData);
 			break;
 		
 		case CTYPE_STR:
-			if (xmms_cfg_read_string(cfgFile, XS_CONFIG_IDENT,
+			if (XS_CFG_GET_STRING(cfg, XS_CONFIG_IDENT,
 				xs_cfgtable[i].itemName, (gchar **) &tmpStr)) {
-				/* Read was successfull */
 				xs_pstrcpy((gchar **) xs_cfgtable[i].itemData, tmpStr);
 				g_free(tmpStr);
 			}
@@ -311,9 +332,7 @@
 		}
 	}
 
-
-	/* Free the config file */
-	xmms_cfg_free(cfgFile);
+	XS_CONFIG_FREE(cfg);
 
 	XS_MUTEX_UNLOCK(xs_cfg);
 	XSDEBUG("OK\n");
@@ -326,65 +345,50 @@
  */
 gint xs_write_configuration(void)
 {
-#ifdef HAVE_NODEFAULTCFG
-	gchar *cfgFilename;
-#endif
-	ConfigFile *cfgFile;
+	XS_CONFIG_FILE *cfg;
 	gint i;
 
 	XSDEBUG("writing configuration ...\n");
 	XS_MUTEX_LOCK(xs_cfg);
 
 	/* Try to open the XMMS configuration file  */
-#ifdef HAVE_NODEFAULTCFG
-	cfgFilename = g_strconcat(g_get_home_dir(), XS_CONFIG_FILE, NULL);
-	cfgFile = xmms_cfg_open_file(cfgFilename);
-#else
-	cfgFile = xmms_cfg_open_default_file();
+	cfg = XS_CONFIG_OPEN();
+
+#ifndef AUDACIOUS_PLUGIN
+	if (!cfg) cfg = xmms_cfg_new();
 #endif
 
-	if (!cfgFile)
-		cfgFile = xmms_cfg_new();
-
 	/* Write the new settings to XMMS configuration file */
 	for (i = 0; i < xs_cfgtable_max; i++) {
 		switch (xs_cfgtable[i].itemType) {
 		case CTYPE_INT:
-			xmms_cfg_write_int(cfgFile, XS_CONFIG_IDENT,
+			XS_CFG_SET_INT(cfg, XS_CONFIG_IDENT,
 				xs_cfgtable[i].itemName,
 				*(gint *) xs_cfgtable[i].itemData);
 			break;
 
 		case CTYPE_BOOL:
-			xmms_cfg_write_boolean(cfgFile, XS_CONFIG_IDENT,
+			XS_CFG_SET_BOOL(cfg, XS_CONFIG_IDENT,
 				xs_cfgtable[i].itemName,
 				*(gboolean *) xs_cfgtable[i].itemData);
 			break;
 
 		case CTYPE_FLOAT:
-			xmms_cfg_write_float(cfgFile, XS_CONFIG_IDENT,
+			XS_CFG_SET_FLOAT(cfg, XS_CONFIG_IDENT,
 				xs_cfgtable[i].itemName,
 				*(gfloat *) xs_cfgtable[i].itemData);
 			break;
 
 		case CTYPE_STR:
-			xmms_cfg_write_string(cfgFile, XS_CONFIG_IDENT,
+			XS_CFG_SET_STRING(cfg, XS_CONFIG_IDENT,
 				xs_cfgtable[i].itemName,
 				*(gchar **) xs_cfgtable[i].itemData);
 			break;
 		}
 	}
 
-	/* Flush the file */
-#ifdef HAVE_NODEFAULTCFG
-	xmms_cfg_write_file(cfgFile, cfgFilename);
-	g_free(cfgFilename);
-#else
-	xmms_cfg_write_default_file(cfgFile);
-#endif
-
-	/* Free the memory areas */
-	xmms_cfg_free(cfgFile);
+	XS_CONFIG_WRITE(cfg);
+	XS_CONFIG_FREE(cfg);
 
 	XS_MUTEX_UNLOCK(xs_cfg);