Mercurial > audlegacy
changeset 2536:b06d60a5cb15 trunk
[svn] - relocate configdb to audacious core
author | nenolod |
---|---|
date | Sat, 17 Feb 2007 01:02:11 -0800 |
parents | 97a305e550cf |
children | 7aac1b5ef85d |
files | ChangeLog src/audacious/Makefile src/audacious/build_stamp.c src/audacious/configdb.c src/audacious/configdb.h src/libaudacious/Makefile src/libaudacious/configdb.c src/libaudacious/configdb.h |
diffstat | 8 files changed, 411 insertions(+), 395 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sat Feb 17 00:59:50 2007 -0800 +++ b/ChangeLog Sat Feb 17 01:02:11 2007 -0800 @@ -1,3 +1,21 @@ +2007-02-17 08:59:50 +0000 William Pitcock <nenolod@sacredspiral.co.uk> + revision [4080] + - make libmcs a forced requirement + - remove legacy configdb engines + - remove RcFile class (use g_keyfile instead) + + trunk/configure.ac | 22 - + trunk/mk/rules.mk.in | 1 + trunk/src/libaudacious/Makefile | 5 + trunk/src/libaudacious/configdb.c | 193 ++++++++++ + trunk/src/libaudacious/configdb_gconf.c | 276 --------------- + trunk/src/libaudacious/configdb_libmcs.c | 193 ---------- + trunk/src/libaudacious/configdb_rcfile.c | 227 ------------ + trunk/src/libaudacious/rcfile.c | 565 ------------------------------- + trunk/src/libaudacious/rcfile.h | 94 ----- + 9 files changed, 201 insertions(+), 1375 deletions(-) + + 2007-02-17 02:28:07 +0000 William Pitcock <nenolod@sacredspiral.co.uk> revision [4078] - fix a typo
--- a/src/audacious/Makefile Sat Feb 17 00:59:50 2007 -0800 +++ b/src/audacious/Makefile Sat Feb 17 01:02:11 2007 -0800 @@ -49,6 +49,7 @@ SOURCES = \ build_stamp.c \ controlsocket.c \ + configdb.c \ dnd.c \ dock.c \ effect.c \
--- a/src/audacious/build_stamp.c Sat Feb 17 00:59:50 2007 -0800 +++ b/src/audacious/build_stamp.c Sat Feb 17 01:02:11 2007 -0800 @@ -1,2 +1,2 @@ #include <glib.h> -const gchar *svn_stamp = "20070217-4078"; +const gchar *svn_stamp = "20070217-4080";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/audacious/configdb.c Sat Feb 17 01:02:11 2007 -0800 @@ -0,0 +1,193 @@ +/* This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "configdb.h" + +#include <stdlib.h> +#include <string.h> + +#include <libmcs/mcs.h> + + +#define RCFILE_DEFAULT_SECTION_NAME "audacious" + +static gboolean mcs_initted = FALSE; + +struct _ConfigDb +{ + mcs_handle_t *handle; +}; + + +ConfigDb * +bmp_cfg_db_open() +{ + ConfigDb *db; + + db = g_new(ConfigDb, 1); + + if (!mcs_initted) + { + mcs_init(); + mcs_initted = TRUE; + } + + db->handle = mcs_new(RCFILE_DEFAULT_SECTION_NAME); + + return db; +} + +void +bmp_cfg_db_close(ConfigDb * db) +{ + mcs_destroy(db->handle); + g_free(db); +} + +gboolean +bmp_cfg_db_get_string(ConfigDb * db, + const gchar * section, + const gchar * key, + gchar ** value) +{ + if (!section) + section = RCFILE_DEFAULT_SECTION_NAME; + + return mcs_get_string(db->handle, section, key, value); +} + +gboolean +bmp_cfg_db_get_int(ConfigDb * db, + const gchar * section, const gchar * key, gint * value) +{ + if (!section) + section = RCFILE_DEFAULT_SECTION_NAME; + + return mcs_get_int(db->handle, section, key, value); +} + +gboolean +bmp_cfg_db_get_bool(ConfigDb * db, + const gchar * section, + const gchar * key, + gboolean * value) +{ + if (!section) + section = RCFILE_DEFAULT_SECTION_NAME; + + return mcs_get_bool(db->handle, section, key, value); +} + +gboolean +bmp_cfg_db_get_float(ConfigDb * db, + const gchar * section, + const gchar * key, + gfloat * value) +{ + if (!section) + section = RCFILE_DEFAULT_SECTION_NAME; + + return mcs_get_float(db->handle, section, key, value); +} + +gboolean +bmp_cfg_db_get_double(ConfigDb * db, + const gchar * section, + const gchar * key, + gdouble * value) +{ + if (!section) + section = RCFILE_DEFAULT_SECTION_NAME; + + return mcs_get_double(db->handle, section, key, value); +} + +void +bmp_cfg_db_set_string(ConfigDb * db, + const gchar * section, + const gchar * key, + const gchar * value) +{ + if (!section) + section = RCFILE_DEFAULT_SECTION_NAME; + + mcs_set_string(db->handle, section, key, value); +} + +void +bmp_cfg_db_set_int(ConfigDb * db, + const gchar * section, + const gchar * key, + gint value) +{ + if (!section) + section = RCFILE_DEFAULT_SECTION_NAME; + + mcs_set_int(db->handle, section, key, value); +} + +void +bmp_cfg_db_set_bool(ConfigDb * db, + const gchar * section, + const gchar * key, + gboolean value) +{ + if (!section) + section = RCFILE_DEFAULT_SECTION_NAME; + + mcs_set_bool(db->handle, section, key, value); +} + +void +bmp_cfg_db_set_float(ConfigDb * db, + const gchar * section, + const gchar * key, + gfloat value) +{ + if (!section) + section = RCFILE_DEFAULT_SECTION_NAME; + + mcs_set_float(db->handle, section, key, value); +} + +void +bmp_cfg_db_set_double(ConfigDb * db, + const gchar * section, + const gchar * key, + gdouble value) +{ + if (!section) + section = RCFILE_DEFAULT_SECTION_NAME; + + mcs_set_double(db->handle, section, key, value); +} + +void +bmp_cfg_db_unset_key(ConfigDb * db, + const gchar * section, + const gchar * key) +{ + g_return_if_fail(db != NULL); + g_return_if_fail(key != NULL); + + if (!section) + section = RCFILE_DEFAULT_SECTION_NAME; + + mcs_unset_key(db->handle, section, key); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/audacious/configdb.h Sat Feb 17 01:02:11 2007 -0800 @@ -0,0 +1,198 @@ +#ifndef CONFIGDB_H +#define CONFIGDB_H + +#include <glib.h> + +/** + * ConfigDb: + * + * A configuration database handle, opened with bmp_cfg_db_open(). + **/ +typedef struct _ConfigDb ConfigDb; + + +G_BEGIN_DECLS + + /** + * bmp_cfg_db_open: + * + * Opens the configuration database. + * + * Return value: A configuration database handle. + **/ + ConfigDb *bmp_cfg_db_open(); + + /** + * bmp_cfg_db_close: + * @db: A configuration database handle. + * + * Closes the configuration database. + **/ + void bmp_cfg_db_close(ConfigDb *db); + + /** + * bmp_cfg_db_get_string: + * @db: A configuration database handle. + * @section: The section of the configuration database to search. + * @key: The name of the field in the configuration database to look up. + * @value: Pointer to a buffer to put the data in. + * + * Searches the configuration database for a value. + * + * Return value: TRUE if successful, FALSE otherwise. + **/ + gboolean bmp_cfg_db_get_string(ConfigDb *db, + const gchar *section, + const gchar *key, + gchar **value); + + /** + * bmp_cfg_db_get_int: + * @db: A configuration database handle. + * @section: The section of the configuration database to search. + * @key: The name of the field in the configuration database to look up. + * @value: Pointer to an integer to put the data in. + * + * Searches the configuration database for a value. + * + * Return value: TRUE if successful, FALSE otherwise. + **/ + gboolean bmp_cfg_db_get_int(ConfigDb *db, + const gchar *section, + const gchar *key, + gint *value); + + /** + * bmp_cfg_db_get_bool: + * @db: A configuration database handle. + * @section: The section of the configuration database to search. + * @key: The name of the field in the configuration database to look up. + * @value: Pointer to a boolean to put the data in. + * + * Searches the configuration database for a value. + * + * Return value: TRUE if successful, FALSE otherwise. + **/ + gboolean bmp_cfg_db_get_bool(ConfigDb *db, + const gchar *section, + const gchar *key, + gboolean *value); + + /** + * bmp_cfg_db_get_float: + * @db: A configuration database handle. + * @section: The section of the configuration database to search. + * @key: The name of the field in the configuration database to look up. + * @value: Pointer to a floating point integer to put the data in. + * + * Searches the configuration database for a value. + * + * Return value: TRUE if successful, FALSE otherwise. + **/ + gboolean bmp_cfg_db_get_float(ConfigDb *db, + const gchar *section, + const gchar *key, + gfloat *value); + + /** + * bmp_cfg_db_get_double: + * @db: A configuration database handle. + * @section: The section of the configuration database to search. + * @key: The name of the field in the configuration database to look up. + * @value: Pointer to a double-precision floating point integer to put the data in. + * + * Searches the configuration database for a value. + * + * Return value: TRUE if successful, FALSE otherwise. + **/ + gboolean bmp_cfg_db_get_double(ConfigDb *db, + const gchar *section, + const gchar *key, + gdouble *value); + + /** + * bmp_cfg_db_set_string: + * @db: A configuration database handle. + * @section: The section of the configuration database to search. + * @key: The name of the field in the configuration database to set. + * @value: Pointer to a buffer containing the data. + * + * Sets a value in the configuration database. + **/ + void bmp_cfg_db_set_string(ConfigDb *db, + const gchar *section, + const gchar *key, + const gchar *value); + + /** + * bmp_cfg_db_set_int: + * @db: A configuration database handle. + * @section: The section of the configuration database to search. + * @key: The name of the field in the configuration database to set. + * @value: Pointer to an integer containing the data. + * + * Sets a value in the configuration database. + **/ + void bmp_cfg_db_set_int(ConfigDb *db, + const gchar *section, + const gchar *key, + gint value); + + /** + * bmp_cfg_db_set_bool: + * @db: A configuration database handle. + * @section: The section of the configuration database to search. + * @key: The name of the field in the configuration database to set. + * @value: Pointer to a boolean containing the data. + * + * Sets a value in the configuration database. + **/ + void bmp_cfg_db_set_bool(ConfigDb *db, + const gchar *section, + const gchar *key, + gboolean value); + + /** + * bmp_cfg_db_set_float: + * @db: A configuration database handle. + * @section: The section of the configuration database to search. + * @key: The name of the field in the configuration database to set. + * @value: Pointer to a floating point integer containing the data. + * + * Sets a value in the configuration database. + **/ + void bmp_cfg_db_set_float(ConfigDb *db, + const gchar *section, + const gchar *key, + gfloat value); + + /** + * bmp_cfg_db_set_double: + * @db: A configuration database handle. + * @section: The section of the configuration database to search. + * @key: The name of the field in the configuration database to set. + * @value: Pointer to a double precision floating point integer containing the data. + * + * Sets a value in the configuration database. + **/ + void bmp_cfg_db_set_double(ConfigDb *db, + const gchar *section, + const gchar *key, + gdouble value); + + /** + * bmp_cfg_db_unset_key: + * @db: A configuration database handle. + * @section: The section of the configuration database to search. + * @key: The name of the field in the configuration database to set. + * + * Removes a value from the configuration database. + **/ + void bmp_cfg_db_unset_key(ConfigDb *db, + const gchar *section, + const gchar *key); + +G_END_DECLS + +#endif /* CONFIGDB_H */ +
--- a/src/libaudacious/Makefile Sat Feb 17 00:59:50 2007 -0800 +++ b/src/libaudacious/Makefile Sat Feb 17 01:02:11 2007 -0800 @@ -20,14 +20,11 @@ -I../intl SOURCES = \ - configdb.c \ beepctrl.c OBJECTS = ${SOURCES:.c=.o} HEADERS = \ - rcfile.h \ - configdb.h \ beepctrl.h include ../../mk/objective.mk
--- a/src/libaudacious/configdb.c Sat Feb 17 00:59:50 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,193 +0,0 @@ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "configdb.h" - -#include <stdlib.h> -#include <string.h> - -#include <libmcs/mcs.h> - - -#define RCFILE_DEFAULT_SECTION_NAME "audacious" - -static gboolean mcs_initted = FALSE; - -struct _ConfigDb -{ - mcs_handle_t *handle; -}; - - -ConfigDb * -bmp_cfg_db_open() -{ - ConfigDb *db; - - db = g_new(ConfigDb, 1); - - if (!mcs_initted) - { - mcs_init(); - mcs_initted = TRUE; - } - - db->handle = mcs_new(RCFILE_DEFAULT_SECTION_NAME); - - return db; -} - -void -bmp_cfg_db_close(ConfigDb * db) -{ - mcs_destroy(db->handle); - g_free(db); -} - -gboolean -bmp_cfg_db_get_string(ConfigDb * db, - const gchar * section, - const gchar * key, - gchar ** value) -{ - if (!section) - section = RCFILE_DEFAULT_SECTION_NAME; - - return mcs_get_string(db->handle, section, key, value); -} - -gboolean -bmp_cfg_db_get_int(ConfigDb * db, - const gchar * section, const gchar * key, gint * value) -{ - if (!section) - section = RCFILE_DEFAULT_SECTION_NAME; - - return mcs_get_int(db->handle, section, key, value); -} - -gboolean -bmp_cfg_db_get_bool(ConfigDb * db, - const gchar * section, - const gchar * key, - gboolean * value) -{ - if (!section) - section = RCFILE_DEFAULT_SECTION_NAME; - - return mcs_get_bool(db->handle, section, key, value); -} - -gboolean -bmp_cfg_db_get_float(ConfigDb * db, - const gchar * section, - const gchar * key, - gfloat * value) -{ - if (!section) - section = RCFILE_DEFAULT_SECTION_NAME; - - return mcs_get_float(db->handle, section, key, value); -} - -gboolean -bmp_cfg_db_get_double(ConfigDb * db, - const gchar * section, - const gchar * key, - gdouble * value) -{ - if (!section) - section = RCFILE_DEFAULT_SECTION_NAME; - - return mcs_get_double(db->handle, section, key, value); -} - -void -bmp_cfg_db_set_string(ConfigDb * db, - const gchar * section, - const gchar * key, - const gchar * value) -{ - if (!section) - section = RCFILE_DEFAULT_SECTION_NAME; - - mcs_set_string(db->handle, section, key, value); -} - -void -bmp_cfg_db_set_int(ConfigDb * db, - const gchar * section, - const gchar * key, - gint value) -{ - if (!section) - section = RCFILE_DEFAULT_SECTION_NAME; - - mcs_set_int(db->handle, section, key, value); -} - -void -bmp_cfg_db_set_bool(ConfigDb * db, - const gchar * section, - const gchar * key, - gboolean value) -{ - if (!section) - section = RCFILE_DEFAULT_SECTION_NAME; - - mcs_set_bool(db->handle, section, key, value); -} - -void -bmp_cfg_db_set_float(ConfigDb * db, - const gchar * section, - const gchar * key, - gfloat value) -{ - if (!section) - section = RCFILE_DEFAULT_SECTION_NAME; - - mcs_set_float(db->handle, section, key, value); -} - -void -bmp_cfg_db_set_double(ConfigDb * db, - const gchar * section, - const gchar * key, - gdouble value) -{ - if (!section) - section = RCFILE_DEFAULT_SECTION_NAME; - - mcs_set_double(db->handle, section, key, value); -} - -void -bmp_cfg_db_unset_key(ConfigDb * db, - const gchar * section, - const gchar * key) -{ - g_return_if_fail(db != NULL); - g_return_if_fail(key != NULL); - - if (!section) - section = RCFILE_DEFAULT_SECTION_NAME; - - mcs_unset_key(db->handle, section, key); -}
--- a/src/libaudacious/configdb.h Sat Feb 17 00:59:50 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,198 +0,0 @@ -#ifndef CONFIGDB_H -#define CONFIGDB_H - -#include <glib.h> - -/** - * ConfigDb: - * - * A configuration database handle, opened with bmp_cfg_db_open(). - **/ -typedef struct _ConfigDb ConfigDb; - - -G_BEGIN_DECLS - - /** - * bmp_cfg_db_open: - * - * Opens the configuration database. - * - * Return value: A configuration database handle. - **/ - ConfigDb *bmp_cfg_db_open(); - - /** - * bmp_cfg_db_close: - * @db: A configuration database handle. - * - * Closes the configuration database. - **/ - void bmp_cfg_db_close(ConfigDb *db); - - /** - * bmp_cfg_db_get_string: - * @db: A configuration database handle. - * @section: The section of the configuration database to search. - * @key: The name of the field in the configuration database to look up. - * @value: Pointer to a buffer to put the data in. - * - * Searches the configuration database for a value. - * - * Return value: TRUE if successful, FALSE otherwise. - **/ - gboolean bmp_cfg_db_get_string(ConfigDb *db, - const gchar *section, - const gchar *key, - gchar **value); - - /** - * bmp_cfg_db_get_int: - * @db: A configuration database handle. - * @section: The section of the configuration database to search. - * @key: The name of the field in the configuration database to look up. - * @value: Pointer to an integer to put the data in. - * - * Searches the configuration database for a value. - * - * Return value: TRUE if successful, FALSE otherwise. - **/ - gboolean bmp_cfg_db_get_int(ConfigDb *db, - const gchar *section, - const gchar *key, - gint *value); - - /** - * bmp_cfg_db_get_bool: - * @db: A configuration database handle. - * @section: The section of the configuration database to search. - * @key: The name of the field in the configuration database to look up. - * @value: Pointer to a boolean to put the data in. - * - * Searches the configuration database for a value. - * - * Return value: TRUE if successful, FALSE otherwise. - **/ - gboolean bmp_cfg_db_get_bool(ConfigDb *db, - const gchar *section, - const gchar *key, - gboolean *value); - - /** - * bmp_cfg_db_get_float: - * @db: A configuration database handle. - * @section: The section of the configuration database to search. - * @key: The name of the field in the configuration database to look up. - * @value: Pointer to a floating point integer to put the data in. - * - * Searches the configuration database for a value. - * - * Return value: TRUE if successful, FALSE otherwise. - **/ - gboolean bmp_cfg_db_get_float(ConfigDb *db, - const gchar *section, - const gchar *key, - gfloat *value); - - /** - * bmp_cfg_db_get_double: - * @db: A configuration database handle. - * @section: The section of the configuration database to search. - * @key: The name of the field in the configuration database to look up. - * @value: Pointer to a double-precision floating point integer to put the data in. - * - * Searches the configuration database for a value. - * - * Return value: TRUE if successful, FALSE otherwise. - **/ - gboolean bmp_cfg_db_get_double(ConfigDb *db, - const gchar *section, - const gchar *key, - gdouble *value); - - /** - * bmp_cfg_db_set_string: - * @db: A configuration database handle. - * @section: The section of the configuration database to search. - * @key: The name of the field in the configuration database to set. - * @value: Pointer to a buffer containing the data. - * - * Sets a value in the configuration database. - **/ - void bmp_cfg_db_set_string(ConfigDb *db, - const gchar *section, - const gchar *key, - const gchar *value); - - /** - * bmp_cfg_db_set_int: - * @db: A configuration database handle. - * @section: The section of the configuration database to search. - * @key: The name of the field in the configuration database to set. - * @value: Pointer to an integer containing the data. - * - * Sets a value in the configuration database. - **/ - void bmp_cfg_db_set_int(ConfigDb *db, - const gchar *section, - const gchar *key, - gint value); - - /** - * bmp_cfg_db_set_bool: - * @db: A configuration database handle. - * @section: The section of the configuration database to search. - * @key: The name of the field in the configuration database to set. - * @value: Pointer to a boolean containing the data. - * - * Sets a value in the configuration database. - **/ - void bmp_cfg_db_set_bool(ConfigDb *db, - const gchar *section, - const gchar *key, - gboolean value); - - /** - * bmp_cfg_db_set_float: - * @db: A configuration database handle. - * @section: The section of the configuration database to search. - * @key: The name of the field in the configuration database to set. - * @value: Pointer to a floating point integer containing the data. - * - * Sets a value in the configuration database. - **/ - void bmp_cfg_db_set_float(ConfigDb *db, - const gchar *section, - const gchar *key, - gfloat value); - - /** - * bmp_cfg_db_set_double: - * @db: A configuration database handle. - * @section: The section of the configuration database to search. - * @key: The name of the field in the configuration database to set. - * @value: Pointer to a double precision floating point integer containing the data. - * - * Sets a value in the configuration database. - **/ - void bmp_cfg_db_set_double(ConfigDb *db, - const gchar *section, - const gchar *key, - gdouble value); - - /** - * bmp_cfg_db_unset_key: - * @db: A configuration database handle. - * @section: The section of the configuration database to search. - * @key: The name of the field in the configuration database to set. - * - * Removes a value from the configuration database. - **/ - void bmp_cfg_db_unset_key(ConfigDb *db, - const gchar *section, - const gchar *key); - -G_END_DECLS - -#endif /* CONFIGDB_H */ -