changeset 4433:a6a2e84e2b2e

Use mcs_handle_t directly instead of ConfigDb struct to remove the useless wrapper. A compatibility #define alias for ConfigDb added in plugin.h, at least for now.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 09 Apr 2008 15:50:37 +0300
parents b9587e67eb02
children 35d5b1b8aa1e 7d57fb61f2e4
files src/audacious/audconfig.c src/audacious/configdb.c src/audacious/configdb.h src/audacious/plugin.h src/audacious/ui_preferences.c
diffstat 5 files changed, 66 insertions(+), 85 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/audconfig.c	Wed Apr 09 12:41:25 2008 +0300
+++ b/src/audacious/audconfig.c	Wed Apr 09 15:50:37 2008 +0300
@@ -487,7 +487,7 @@
 void
 aud_config_load(void)
 {
-    ConfigDb *db;
+    mcs_handle_t *db;
     gint i, length;
 
     memcpy(&cfg, &aud_default_config, sizeof(AudConfig));
@@ -610,7 +610,7 @@
     GList *node;
     gchar *str;
     gint i, cur_pb_time, vol_l, vol_r;
-    ConfigDb *db;
+    mcs_handle_t *db;
     GList *saved;
     Playlist *playlist = playlist_get_active();
 
--- a/src/audacious/configdb.c	Wed Apr 09 12:41:25 2008 +0300
+++ b/src/audacious/configdb.c	Wed Apr 09 15:50:37 2008 +0300
@@ -19,50 +19,36 @@
 #endif
 
 #include "configdb.h"
-
+#include <libmcs/mcs.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 *
+mcs_handle_t *
 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;
+    return mcs_new(RCFILE_DEFAULT_SECTION_NAME);
 }
 
 void
-cfg_db_close(ConfigDb * db)
+cfg_db_close(mcs_handle_t * db)
 {
-    mcs_destroy(db->handle);
-    g_free(db);
+    mcs_destroy(db);
 }
 
 gboolean
-cfg_db_get_string(ConfigDb * db,
+cfg_db_get_string(mcs_handle_t * db,
                       const gchar * section,
                       const gchar * key,
                       gchar ** value)
@@ -70,21 +56,21 @@
     if (!section)
         section = RCFILE_DEFAULT_SECTION_NAME;
 
-    return mcs_get_string(db->handle, section, key, value);
+    return mcs_get_string(db, section, key, value);
 }
 
 gboolean
-cfg_db_get_int(ConfigDb * db,
+cfg_db_get_int(mcs_handle_t * 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);
+    return mcs_get_int(db, section, key, value);
 }
 
 gboolean
-cfg_db_get_bool(ConfigDb * db,
+cfg_db_get_bool(mcs_handle_t * db,
                     const gchar * section,
                     const gchar * key,
                     gboolean * value)
@@ -92,11 +78,11 @@
     if (!section)
         section = RCFILE_DEFAULT_SECTION_NAME;
 
-    return mcs_get_bool(db->handle, section, key, value);
+    return mcs_get_bool(db, section, key, value);
 }
 
 gboolean
-cfg_db_get_float(ConfigDb * db,
+cfg_db_get_float(mcs_handle_t * db,
                      const gchar * section,
                      const gchar * key,
                      gfloat * value)
@@ -104,11 +90,11 @@
     if (!section)
         section = RCFILE_DEFAULT_SECTION_NAME;
 
-    return mcs_get_float(db->handle, section, key, value);
+    return mcs_get_float(db, section, key, value);
 }
 
 gboolean
-cfg_db_get_double(ConfigDb * db,
+cfg_db_get_double(mcs_handle_t * db,
                       const gchar * section,
                       const gchar * key,
                       gdouble * value)
@@ -116,11 +102,11 @@
     if (!section)
         section = RCFILE_DEFAULT_SECTION_NAME;
 
-    return mcs_get_double(db->handle, section, key, value);
+    return mcs_get_double(db, section, key, value);
 }
 
 void
-cfg_db_set_string(ConfigDb * db,
+cfg_db_set_string(mcs_handle_t * db,
                       const gchar * section,
                       const gchar * key,
                       const gchar * value)
@@ -128,11 +114,11 @@
     if (!section)
         section = RCFILE_DEFAULT_SECTION_NAME;
 
-    mcs_set_string(db->handle, section, key, value);
+    mcs_set_string(db, section, key, value);
 }
 
 void
-cfg_db_set_int(ConfigDb * db,
+cfg_db_set_int(mcs_handle_t * db,
                    const gchar * section,
                    const gchar * key,
                    gint value)
@@ -140,11 +126,11 @@
     if (!section)
         section = RCFILE_DEFAULT_SECTION_NAME;
 
-    mcs_set_int(db->handle, section, key, value);
+    mcs_set_int(db, section, key, value);
 }
 
 void
-cfg_db_set_bool(ConfigDb * db,
+cfg_db_set_bool(mcs_handle_t * db,
                     const gchar * section,
                     const gchar * key,
                     gboolean value)
@@ -152,11 +138,11 @@
     if (!section)
         section = RCFILE_DEFAULT_SECTION_NAME;
 
-    mcs_set_bool(db->handle, section, key, value);
+    mcs_set_bool(db, section, key, value);
 }
 
 void
-cfg_db_set_float(ConfigDb * db,
+cfg_db_set_float(mcs_handle_t * db,
                      const gchar * section,
                      const gchar * key,
                      gfloat value)
@@ -164,11 +150,11 @@
     if (!section)
         section = RCFILE_DEFAULT_SECTION_NAME;
 
-    mcs_set_float(db->handle, section, key, value);
+    mcs_set_float(db, section, key, value);
 }
 
 void
-cfg_db_set_double(ConfigDb * db,
+cfg_db_set_double(mcs_handle_t * db,
                       const gchar * section,
                       const gchar * key,
                       gdouble value)
@@ -176,11 +162,11 @@
     if (!section)
         section = RCFILE_DEFAULT_SECTION_NAME;
 
-    mcs_set_double(db->handle, section, key, value);
+    mcs_set_double(db, section, key, value);
 }
 
 void
-cfg_db_unset_key(ConfigDb * db,
+cfg_db_unset_key(mcs_handle_t * db,
                      const gchar * section,
                      const gchar * key)
 {
@@ -190,5 +176,5 @@
     if (!section)
         section = RCFILE_DEFAULT_SECTION_NAME;
 
-    mcs_unset_key(db->handle, section, key);
+    mcs_unset_key(db, section, key);
 }
--- a/src/audacious/configdb.h	Wed Apr 09 12:41:25 2008 +0300
+++ b/src/audacious/configdb.h	Wed Apr 09 15:50:37 2008 +0300
@@ -3,13 +3,7 @@
 
 #include <glib.h>
 
-/**
- * ConfigDb:
- *
- * A configuration database handle, opened with cfg_db_open().
- **/
-typedef struct _ConfigDb ConfigDb;
-
+typedef struct mcs_handle_ mcs_handle_t;
 
 G_BEGIN_DECLS
 
@@ -20,7 +14,7 @@
      *
      * Return value: A configuration database handle.
      **/
-    ConfigDb *cfg_db_open();
+    mcs_handle_t *cfg_db_open();
 
     /**
      * cfg_db_close:
@@ -28,7 +22,7 @@
      *
      * Closes the configuration database.
      **/
-    void cfg_db_close(ConfigDb *db);
+    void cfg_db_close(mcs_handle_t *db);
 
     /**
      * cfg_db_get_string:
@@ -41,7 +35,7 @@
      *
      * Return value: TRUE if successful, FALSE otherwise.
      **/
-    gboolean cfg_db_get_string(ConfigDb *db,
+    gboolean cfg_db_get_string(mcs_handle_t *db,
                                    const gchar *section,
                                    const gchar *key,
                                    gchar **value);
@@ -57,7 +51,7 @@
      *
      * Return value: TRUE if successful, FALSE otherwise.
      **/
-    gboolean cfg_db_get_int(ConfigDb *db,
+    gboolean cfg_db_get_int(mcs_handle_t *db,
                                 const gchar *section,
                                 const gchar *key,
                                 gint *value);
@@ -73,7 +67,7 @@
      *
      * Return value: TRUE if successful, FALSE otherwise.
      **/
-    gboolean cfg_db_get_bool(ConfigDb *db,
+    gboolean cfg_db_get_bool(mcs_handle_t *db,
                                  const gchar *section,
                                  const gchar *key,
                                  gboolean *value);
@@ -89,7 +83,7 @@
      *
      * Return value: TRUE if successful, FALSE otherwise.
      **/
-    gboolean cfg_db_get_float(ConfigDb *db,
+    gboolean cfg_db_get_float(mcs_handle_t *db,
                                   const gchar *section,
                                   const gchar *key,
                                   gfloat *value);
@@ -105,7 +99,7 @@
      *
      * Return value: TRUE if successful, FALSE otherwise.
      **/
-    gboolean cfg_db_get_double(ConfigDb *db,
+    gboolean cfg_db_get_double(mcs_handle_t *db,
                                    const gchar *section,
                                    const gchar *key,
                                    gdouble *value);
@@ -119,7 +113,7 @@
      *
      * Sets a value in the configuration database.
      **/
-    void cfg_db_set_string(ConfigDb *db,
+    void cfg_db_set_string(mcs_handle_t *db,
                                const gchar *section,
                                const gchar *key,
                                const gchar *value);
@@ -133,7 +127,7 @@
      *
      * Sets a value in the configuration database.
      **/
-    void cfg_db_set_int(ConfigDb *db,
+    void cfg_db_set_int(mcs_handle_t *db,
                             const gchar *section,
                             const gchar *key,
                             gint value);
@@ -147,7 +141,7 @@
      *
      * Sets a value in the configuration database.
      **/
-    void cfg_db_set_bool(ConfigDb *db,
+    void cfg_db_set_bool(mcs_handle_t *db,
                              const gchar *section,
                              const gchar *key,
                              gboolean value);
@@ -161,7 +155,7 @@
      *
      * Sets a value in the configuration database.
      **/
-    void cfg_db_set_float(ConfigDb *db,
+    void cfg_db_set_float(mcs_handle_t *db,
                               const gchar *section,
                               const gchar *key,
                               gfloat value);
@@ -175,7 +169,7 @@
      *
      * Sets a value in the configuration database.
      **/
-    void cfg_db_set_double(ConfigDb *db,
+    void cfg_db_set_double(mcs_handle_t *db,
                                const gchar *section,
                                const gchar *key,
                                gdouble value);
@@ -188,7 +182,7 @@
      *
      * Removes a value from the configuration database.
      **/
-    void cfg_db_unset_key(ConfigDb *db,
+    void cfg_db_unset_key(mcs_handle_t *db,
                               const gchar *section,
                               const gchar *key);
 
--- a/src/audacious/plugin.h	Wed Apr 09 12:41:25 2008 +0300
+++ b/src/audacious/plugin.h	Wed Apr 09 15:50:37 2008 +0300
@@ -250,52 +250,52 @@
     VFSFile *(*vfs_buffered_file_release_live_fd)(VFSFile *fd);
 
     /* ConfigDb */
-    ConfigDb *(*cfg_db_open)(void);
-    void (*cfg_db_close)(ConfigDb *db);
+    mcs_handle_t *(*cfg_db_open)(void);
+    void (*cfg_db_close)(mcs_handle_t *db);
 
-    gboolean (*cfg_db_get_string)(ConfigDb *db,
+    gboolean (*cfg_db_get_string)(mcs_handle_t *db,
                                   const gchar *section,
                                   const gchar *key,
                                   gchar **value);
-    gboolean (*cfg_db_get_int)(ConfigDb *db,
+    gboolean (*cfg_db_get_int)(mcs_handle_t *db,
                                const gchar *section,
                                const gchar *key,
                                gint *value);
-    gboolean (*cfg_db_get_bool)(ConfigDb *db,
+    gboolean (*cfg_db_get_bool)(mcs_handle_t *db,
                                 const gchar *section,
                                 const gchar *key,
                                 gboolean *value);
-    gboolean (*cfg_db_get_float)(ConfigDb *db,
+    gboolean (*cfg_db_get_float)(mcs_handle_t *db,
                                  const gchar *section,
                                  const gchar *key,
                                  gfloat *value);
-    gboolean (*cfg_db_get_double)(ConfigDb *db,
+    gboolean (*cfg_db_get_double)(mcs_handle_t *db,
                                   const gchar *section,
                                   const gchar *key,
                                   gdouble *value);
 
-    void (*cfg_db_set_string)(ConfigDb *db,
+    void (*cfg_db_set_string)(mcs_handle_t *db,
                               const gchar *section,
                               const gchar *key,
                               const gchar *value);
-    void (*cfg_db_set_int)(ConfigDb *db,
+    void (*cfg_db_set_int)(mcs_handle_t *db,
                            const gchar *section,
                            const gchar *key,
                            gint value);
-    void (*cfg_db_set_bool)(ConfigDb *db,
+    void (*cfg_db_set_bool)(mcs_handle_t *db,
                             const gchar *section,
                             const gchar *key,
                             gboolean value);
-    void (*cfg_db_set_float)(ConfigDb *db,
+    void (*cfg_db_set_float)(mcs_handle_t *db,
                              const gchar *section,
                              const gchar *key,
                              gfloat value);
-    void (*cfg_db_set_double)(ConfigDb *db,
+    void (*cfg_db_set_double)(mcs_handle_t *db,
                               const gchar *section,
                               const gchar *key,
                               gdouble value);
 
-    void (*cfg_db_unset_key)(ConfigDb *db,
+    void (*cfg_db_unset_key)(mcs_handle_t *db,
                              const gchar *section,
                              const gchar *key);
 
@@ -691,6 +691,7 @@
 #define aud_vfs_fget_be64		_audvt->vfs_fget_be64
 
 /* XXX: deprecation warnings */
+#define ConfigDb mcs_handle_t		/* Alias for compatibility -- ccr */
 #define aud_cfg_db_open			_audvt->cfg_db_open
 #define aud_cfg_db_close		_audvt->cfg_db_close
 #define aud_cfg_db_set_string		_audvt->cfg_db_set_string
--- a/src/audacious/ui_preferences.c	Wed Apr 09 12:41:25 2008 +0300
+++ b/src/audacious/ui_preferences.c	Wed Apr 09 15:50:37 2008 +0300
@@ -688,7 +688,7 @@
 {
     g_return_if_fail(cfg != NULL);
 
-    ConfigDb *db;
+    mcs_handle_t *db;
     gboolean ret;
 
     db = cfg_db_open();
@@ -704,7 +704,7 @@
 {
     g_return_if_fail(cfg != NULL);
 
-    ConfigDb *db;
+    mcs_handle_t *db;
     gboolean ret = gtk_toggle_button_get_active(button);
 
     db = cfg_db_open();
@@ -717,7 +717,7 @@
 {
     g_return_if_fail(cfg != NULL);
 
-    ConfigDb *db;
+    mcs_handle_t *db;
     gchar *ret = g_strdup(gtk_entry_get_text(entry));
 
     db = cfg_db_open();
@@ -732,7 +732,7 @@
 {
     g_return_if_fail(cfg != NULL);
 
-    ConfigDb *db;
+    mcs_handle_t *db;
     gchar *ret;
 
     db = cfg_db_open();
@@ -1026,7 +1026,7 @@
                                 guint info, guint time,
                                 gpointer user_data) 
 {
-    ConfigDb *db;
+    mcs_handle_t *db;
     gchar *path;
 
     if (!selection_data->data) {
@@ -1063,7 +1063,7 @@
 static void
 on_chardet_detector_cbox_changed(GtkComboBox * combobox, gpointer data)
 {
-    ConfigDb *db;
+    mcs_handle_t *db;
     gint position = 0;
 
     position = gtk_combo_box_get_active(GTK_COMBO_BOX(combobox));
@@ -1079,7 +1079,7 @@
 static void
 on_chardet_detector_cbox_realize(GtkComboBox *combobox, gpointer data)
 {
-    ConfigDb *db;
+    mcs_handle_t *db;
     gchar *ret=NULL;
     guint i=0,index=0;
 
@@ -1117,7 +1117,7 @@
 static void
 on_chardet_fallback_realize(GtkEntry *entry, gpointer data)
 {
-    ConfigDb *db;
+    mcs_handle_t *db;
     gchar *ret = NULL;
 
     db = cfg_db_open();
@@ -1140,7 +1140,7 @@
 static void
 on_chardet_fallback_changed(GtkEntry *entry, gpointer data)
 {
-    ConfigDb *db;
+    mcs_handle_t *db;
     gchar *ret = NULL;
 
     if(cfg.chardet_fallback)