SOURCES: gmpc-xspf.patch (NEW) Fix XSPF support

wiget wiget at pld-linux.org
Sun Mar 29 20:01:20 CEST 2009


Author: wiget                        Date: Sun Mar 29 18:01:20 2009 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
Fix XSPF support

---- Files affected:
SOURCES:
   gmpc-xspf.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/gmpc-xspf.patch
diff -u /dev/null SOURCES/gmpc-xspf.patch:1.1
--- /dev/null	Sun Mar 29 20:01:21 2009
+++ SOURCES/gmpc-xspf.patch	Sun Mar 29 20:01:15 2009
@@ -0,0 +1,240 @@
+--- gmpc-0.18.0/configure.ac.wiget	2009-03-09 17:23:10.000000000 +0100
++++ gmpc-0.18.0/configure.ac	2009-03-29 19:28:50.000000000 +0200
+@@ -63,34 +63,30 @@ then
+  AC_MSG_ERROR([GMPC plugin requires zlib])
+ fi
+ 
++PKG_PROG_PKG_CONFIG
+ 
+-libspiff=0;
++libxspf=0;
+ 
+-AC_ARG_ENABLE(libspiff,
+-    [   --enable-libspiff      Use libspiff to parse spiff playlists.],
++AC_ARG_ENABLE(libxspf,
++    [  --enable-libxspf        Use libxspf to parse XSPF playlists.],
+     [ case "${enableval}" in
+-        yes)    enable_libspiff=yes;;
+-         no)    enable_libspiff=no;;
+-          *)    AC_MSG_ERROR([bad value ${enableval} for --enable-libspiff]);;
++        yes)    enable_libxspf=yes;;
++         no)    enable_libxspf=no;;
++          *)    AC_MSG_ERROR([bad value ${enableval} for --enable-libxspf]);;
+      esac],
+-     [enable_libspiff=auto])
++     [enable_libxspf=auto])
+ 
+-if test "x${enable_libspiff}" != xno; then 
+-    AC_CHECK_HEADER(spiff/spiff_c.h, AC_CHECK_LIB(spiff, spiff_parse,libspiff=1,libspiff=0),libspiff=0)
+-    if test "x${libspiff}" == "x1";
+-    then
+-        AC_DEFINE(SPIFF,1,["Use or don't use libspiff"])
+-        SPIFF_LIBS=-lspiff
+-        AC_SUBST(SPIFF_LIBS)
+-    else 
+-        if test "x${enable_libspiff}" == "xyes"; then
+-            AC_MSG_ERROR([libspiff not found])
+-        fi
+-    fi
++if test "x${enable_libxspf}" != xno; then 
++    PKG_CHECK_MODULES([xspf], [xspf], [
++		       AC_DEFINE(XSPF,1,["Use or don't use libxspf"])
++		       libxspf=1
++		       ], [
++		       if test "x${enable_libxspf}" = "xyes"; then
++			       AC_MSG_ERROR([libxspf not found])
++		       fi])
+ fi
+-
+-PKG_PROG_PKG_CONFIG
+-
++AC_SUBST(xspf_LIBS) 
++AC_SUBST(xspf_CFLAGS)
+ 
+ # Checks for header files.
+ AC_HEADER_STDC
+@@ -475,10 +471,10 @@ if test "x$macige" = "xyes"; then 
+ else
+ 	echo "Use mac integration library:      disabled"
+ fi
+-if test "x$libspiff" = "x1"; then
+-	echo "Use libspiff library:             enabled"
++if test "x$libxspf" = "x1"; then
++	echo "Use libxspf library:              enabled"
+ else
+-	echo "Use libspiff library:             disabled"
++	echo "Use libxspf library:              disabled"
+ fi
+ echo "";
+ echo "Now type make to build"
+--- gmpc-0.18.0/src/url_fetcher.c.wiget	2009-03-09 17:23:05.000000000 +0100
++++ gmpc-0.18.0/src/url_fetcher.c	2009-03-29 19:27:26.000000000 +0200
+@@ -25,8 +25,8 @@
+ #include "playlist3.h"
+ #include "gmpc_easy_download.h"
+ 
+-#ifdef SPIFF
+-#include <spiff/spiff_c.h>
++#ifdef XSPF
++#include <xspf_c.h>
+ #endif
+ /** in gmpc */
+ void pl3_option_menu_activate();
+@@ -89,73 +89,57 @@ static void url_parse_extm3u_file(const 
+ 	}
+ }
+ /***
+- * parse spiff file 
++ * parse XSPF file 
+  */
+-static void url_parse_spiff_file(const char *data, int size)
++static void url_parse_xspf_file(const char *data, int size, const char *uri)
+ {
+-#ifdef SPIFF
++#ifdef XSPF
+     int songs= 0;
+-    const gchar *tempdir = g_get_tmp_dir();
+-    gchar *filename = g_build_filename(tempdir, "gmpc-temp-spiff-file",NULL);
+-    if(filename)
+-    {
+-        GError *error = NULL;
+-        int has_http = FALSE, has_file = FALSE;
+-        char **handlers = mpd_server_get_url_handlers(connection);
+-        int i = 0;
+-        for (i = 0; handlers && handlers[i]; i++) {
+-            if (strcmp(handlers[i], "http://") == 0) {
+-                has_http = TRUE;
+-            } else if (strcmp(handlers[i], "file://") == 0) {
+-                has_file = TRUE;
+-            }
+-        }
+-        if (handlers)
+-            g_strfreev(handlers);
+-
+-        g_file_set_contents(filename, data,(gssize)size, &error);
+-        if(!error)
+-        {
+-            struct spiff_track *strack;
+-            struct spiff_mvalue *sloc;
+-            struct spiff_list *slist = spiff_parse(filename);
+-            if (slist != NULL)
+-            {
+-                SPIFF_LIST_FOREACH_TRACK(slist, strack) {
+-                    SPIFF_TRACK_FOREACH_LOCATION(strack, sloc) {
+-                        char *scheme = g_uri_parse_scheme(sloc->value);
+-                        if(scheme)
+-                        {
+-                            debug_printf(DEBUG_INFO, "Trying to add url: %s", sloc->value);
+-                            if(strcmp(scheme, "http") == 0 && has_http) 
+-                            {
+-                                mpd_playlist_add(connection, sloc->value);
+-                                songs++;
+-                            }
+-                            else if(strcmp(scheme, "file") == 0 && has_file)
+-                            {
+-                                mpd_playlist_add(connection, sloc->value);
+-                                songs++;
+-                            }
+-                            g_free(scheme);
+-                        }
+-                        else{
+-                            debug_printf(DEBUG_ERROR, "Failed to parse scheme: %s",sloc->value);
+-                        }
+-                    }
+-                }
+-                spiff_free(slist);
+-            }
+-            g_unlink(filename);
+-        }
+-        else 
+-        {
+-            debug_printf(DEBUG_ERROR, "Error message: %s", error->message);
+-            g_error_free(error);
+-        }
++	GError *error = NULL;
++	int has_http = FALSE, has_file = FALSE;
++	char **handlers = mpd_server_get_url_handlers(connection);
++	int i = 0;
++	for (i = 0; handlers && handlers[i]; i++) {
++		if (strcmp(handlers[i], "http://") == 0) {
++			has_http = TRUE;
++		} else if (strcmp(handlers[i], "file://") == 0) {
++			has_file = TRUE;
++		}
++	}
++	if (handlers)
++		g_strfreev(handlers);
++
++	struct xspf_track *strack;
++	struct xspf_mvalue *sloc;
++	struct xspf_list *slist = xspf_parse_memory(data, (int)size, uri);
++	if (slist != NULL)
++	{
++		XSPF_LIST_FOREACH_TRACK(slist, strack) {
++			XSPF_TRACK_FOREACH_LOCATION(strack, sloc) {
++				char *scheme = g_uri_parse_scheme(sloc->value);
++				if(scheme)
++				{
++					debug_printf(DEBUG_INFO, "Trying to add url: %s", sloc->value);
++					if(strcmp(scheme, "http") == 0 && has_http) 
++					{
++						mpd_playlist_add(connection, sloc->value);
++						songs++;
++					}
++					else if(strcmp(scheme, "file") == 0 && has_file)
++					{
++						mpd_playlist_add(connection, sloc->value);
++						songs++;
++					}
++					g_free(scheme);
++				}
++				else{
++					debug_printf(DEBUG_ERROR, "Failed to parse scheme: %s",sloc->value);
++				}
++			}
++		}
++		xspf_free(slist);
++	}
+ 
+-        g_free(filename);
+-    }
+     if (songs) {
+         char *string = g_strdup_printf(_("Added %i %s"), songs, ngettext("stream", "streams", songs));
+         pl3_push_statusbar_message(string);
+@@ -164,7 +148,7 @@ static void url_parse_spiff_file(const c
+ 
+ 
+ #else
+-    debug_printf(DEBUG_ERROR, "Spiff not supported, install libspiff");
++    debug_printf(DEBUG_ERROR, "XSPF playlist not supported, install libxspf");
+ #endif
+ }
+ 
+@@ -220,7 +204,7 @@ static void parse_data(const char *data,
+     else if (!strncasecmp(data, "<?xml", 5)) {
+         debug_printf(DEBUG_INFO,  "Detected a xml file, might be xspf");
+         /* This might just be a xspf file */
+-        url_parse_spiff_file(data, size);
++        url_parse_xspf_file(data, size, text);
+     }
+ 	/** pls file: */
+ 	else if (!strncasecmp(data, "[playlist]", 10)) {
+--- gmpc-0.18.0/src/Makefile.am.wiget	2009-03-09 17:23:05.000000000 +0100
++++ gmpc-0.18.0/src/Makefile.am	2009-03-29 19:27:26.000000000 +0200
+@@ -97,7 +97,7 @@ LIBS= \
+ 	@libglade_LIBS@\
+ 	@gthread_LIBS@\
+ 	@libsoup_LIBS@\
+-	@SPIFF_LIBS@\
++	@xspf_LIBS@\
+ 	@sm_LIBS@ 
+ 
+ if USE_SYSTEM_LIBSEXY
+@@ -126,6 +126,7 @@ AM_CFLAGS = @CFLAGS@\
+ 	@gthread_CFLAGS@\
+ 	@sm_CFLAGS@\
+ 	@libsoup_CFLAGS@\
++	@xspf_CFLAGS@\
+ 	@EXTRA_CFLAGS@\
+ 	-DPACKAGE_LIB_DIR=\""$(pkglibdir)"\"\
+ 	-DPACKAGE_DATA_DIR=\""$(datarootdir)"\"
================================================================


More information about the pld-cvs-commit mailing list