diff src/xs_fileinfo.c @ 622:d7389ea52113

Move SLDB and STIL utility functions to xs_slsup.[ch] and amend some changes between XMMS-SID and Aud-SID via a macro mess.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 03 Sep 2007 00:22:04 +0000
parents 8fe2e757fa4a
children 547f4d35f56a
line wrap: on
line diff
--- a/src/xs_fileinfo.c	Mon Sep 03 00:21:05 2007 +0000
+++ b/src/xs_fileinfo.c	Mon Sep 03 00:22:04 2007 +0000
@@ -26,14 +26,11 @@
 #include "xs_fileinfo.h"
 #include "xs_player.h"
 #include "xs_support.h"
-#include "xs_stil.h"
 #include "xs_config.h"
 #include "xs_interface.h"
 #include "xs_glade.h"
-
+#include "xs_slsup.h"
 
-static t_xs_stildb *xs_stildb_db = NULL;
-XS_MUTEX(xs_stildb_db);
 
 static GtkWidget *xs_fileinfowin = NULL;
 static t_xs_stil_node *xs_fileinfostil = NULL;
@@ -42,101 +39,7 @@
 #define LUW(x)	lookup_widget(xs_fileinfowin, x)
 
 
-/* STIL-database handling
- */
-gint xs_stil_init(void)
-{
-	XS_MUTEX_LOCK(xs_cfg);
-
-	if (!xs_cfg.stilDBPath) {
-		XS_MUTEX_UNLOCK(xs_cfg);
-		return -1;
-	}
-
-	XS_MUTEX_LOCK(xs_stildb_db);
-
-	/* Check if already initialized */
-	if (xs_stildb_db)
-		xs_stildb_free(xs_stildb_db);
-
-	/* Allocate database */
-	xs_stildb_db = (t_xs_stildb *) g_malloc0(sizeof(t_xs_stildb));
-	if (!xs_stildb_db) {
-		XS_MUTEX_UNLOCK(xs_cfg);
-		XS_MUTEX_UNLOCK(xs_stildb_db);
-		return -2;
-	}
-
-	/* Read the database */
-	if (xs_stildb_read(xs_stildb_db, xs_cfg.stilDBPath) != 0) {
-		xs_stildb_free(xs_stildb_db);
-		xs_stildb_db = NULL;
-		XS_MUTEX_UNLOCK(xs_cfg);
-		XS_MUTEX_UNLOCK(xs_stildb_db);
-		return -3;
-	}
-
-	/* Create index */
-	if (xs_stildb_index(xs_stildb_db) != 0) {
-		xs_stildb_free(xs_stildb_db);
-		xs_stildb_db = NULL;
-		XS_MUTEX_UNLOCK(xs_cfg);
-		XS_MUTEX_UNLOCK(xs_stildb_db);
-		return -4;
-	}
-
-	XS_MUTEX_UNLOCK(xs_cfg);
-	XS_MUTEX_UNLOCK(xs_stildb_db);
-	return 0;
-}
-
-
-void xs_stil_close(void)
-{
-	XS_MUTEX_LOCK(xs_stildb_db);
-	xs_stildb_free(xs_stildb_db);
-	xs_stildb_db = NULL;
-	XS_MUTEX_UNLOCK(xs_stildb_db);
-}
-
-
-t_xs_stil_node *xs_stil_get(gchar *pcFilename)
-{
-	t_xs_stil_node *pResult;
-	gchar *tmpFilename;
-
-	XS_MUTEX_LOCK(xs_stildb_db);
-	XS_MUTEX_LOCK(xs_cfg);
-
-	if (xs_cfg.stilDBEnable && xs_stildb_db) {
-		if (xs_cfg.hvscPath) {
-			/* Remove postfixed directory separator from HVSC-path */
-			tmpFilename = xs_strrchr(xs_cfg.hvscPath, '/');
-			if (tmpFilename && (tmpFilename[1] == 0))
-				tmpFilename[0] = 0;
-
-			/* Remove HVSC location-prefix from filename */
-			tmpFilename = strstr(pcFilename, xs_cfg.hvscPath);
-			if (tmpFilename)
-				tmpFilename += strlen(xs_cfg.hvscPath);
-			else
-				tmpFilename = pcFilename;
-		} else
-			tmpFilename = pcFilename;
-
-XSDEBUG("xs_stil_get('%s') = '%s'\n", pcFilename, tmpFilename);
-		
-		pResult = xs_stildb_get_node(xs_stildb_db, tmpFilename);
-	} else
-		pResult = NULL;
-
-	XS_MUTEX_UNLOCK(xs_stildb_db);
-	XS_MUTEX_UNLOCK(xs_cfg);
-
-	return pResult;
-}
-
-
+#ifndef AUDACIOUS_PLUGIN
 void xs_fileinfo_update(void)
 {
 	XS_MUTEX_LOCK(xs_status);
@@ -189,6 +92,7 @@
 	XS_MUTEX_UNLOCK(xs_fileinfowin);
 	XS_MUTEX_UNLOCK(xs_status);
 }
+#endif /* AUDACIOUS_PLUGIN */
 
 
 void xs_fileinfo_ok(void)
@@ -354,5 +258,7 @@
 
 	XS_MUTEX_UNLOCK(xs_fileinfowin);
 
+#ifndef AUDACIOUS_PLUGIN
 	xs_fileinfo_update();
+#endif
 }