diff options
51 files changed, 39 insertions, 9234 deletions
@@ -1,3 +1,23 @@ +2007-12-03 Bastien Nocera <hadess@hadess.net> + + * plparse/*: + * totem-plparser-uninstalled.pc.in: + * totem-plparser.pc.in: Move to totem-pl-parser module + + * Makefile.am: + * bindings/python/totem.override: + * browser-plugin/Makefile.am: + * configure.in: + * lib/Makefile.am: + * src/Makefile.am: + * src/backend/bacon-video-widget.h: + * src/totem-playlist.h: + * src/totem.c: + * src/totem.h: Update includes and configure to use the external + totem-pl-parser + + (Closes: #462153) + 2007-12-03 Mathias Hasselmann <mathias@openismus.com> Small improvements to the publish plugin. diff --git a/Makefile.am b/Makefile.am index 9c8f8793e..fce687c70 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = lib plparse bindings po data src help +SUBDIRS = lib bindings po data src help if ENABLE_BROWSER_PLUGINS SUBDIRS += browser-plugin @@ -14,16 +14,12 @@ EXTRA_DIST = \ totem.spec.in \ totem.spec \ omf.make \ - totem-plparser.pc.in \ xmldocs.make \ gnome-doc-utils.make -CLEANFILES = totem.spec totem-plparser.pc +CLEANFILES = totem.spec DISTCLEANFILES = intltool-extract intltool-merge intltool-update \ gnome-doc-utils.make -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = totem-plparser.pc - DISTCHECK_CONFIGURE_FLAGS = --disable-scrollkeeper diff --git a/bindings/python/totem.override b/bindings/python/totem.override index 0c321083e..6762a72ac 100644 --- a/bindings/python/totem.override +++ b/bindings/python/totem.override @@ -10,7 +10,7 @@ headers #include "override_common.h" #include "totem.h" #include "totem-cell-renderer-video.h" -#include "plparse/totem-disc.h" +#include "totem-disc.h" #include "plugins/totem-plugin.h" void pytotem_register_classes (PyObject *d); diff --git a/browser-plugin/Makefile.am b/browser-plugin/Makefile.am index 05a10efe0..018ab1ed4 100644 --- a/browser-plugin/Makefile.am +++ b/browser-plugin/Makefile.am @@ -89,10 +89,8 @@ totem_plugin_viewer_CPPFLAGS = \ -I$(top_srcdir) \ -I$(top_srcdir)/lib \ -I$(top_srcdir)/src \ - -I$(top_srcdir)/plparse \ -I$(top_srcdir)/src/backend \ -I$(top_builddir)/src \ - -I$(top_builddir)/plparse \ -I$(top_builddir)/src/backend \ -DGNOMELOCALEDIR="\"$(datadir)/locale\"" \ -DGCONF_PREFIX="\"/apps/totem\"" \ @@ -114,7 +112,6 @@ totem_plugin_viewer_CFLAGS = \ totem_plugin_viewer_LDADD = \ $(top_builddir)/src/backend/libbaconvideowidget.la \ $(top_builddir)/src/libtotem_player.la \ - $(top_builddir)/plparse/libtotem-plparser.la \ $(top_builddir)/lib/libtotemscrsaver.la \ libtotempluginviewer_helper.la \ $(EXTRA_GNOME_LIBS) \ @@ -154,10 +151,8 @@ libtotem_basic_plugin_la_SOURCES = \ libtotem_basic_plugin_la_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/backend \ - -I$(top_srcdir)/plparse \ -I$(top_builddir)/src \ -I$(top_builddir)/src/backend \ - -I$(top_builddir)/plparse \ -Iidl \ $(addprefix -I$(MOZILLA_INCLUDE_ROOT)/,$(gecko_include_subdirs)) \ -DTOTEM_BASIC_PLUGIN \ @@ -182,7 +177,6 @@ libtotem_basic_plugin_la_CXXFLAGS = \ $(AM_CXXFLAGS) libtotem_basic_plugin_la_LIBADD = \ - $(top_builddir)/plparse/libtotem-plparser-mini.la \ libtotempluginviewer_helper.la \ $(DBUS_LIBS) \ $(MOZILLA_LIBS) \ @@ -223,10 +217,8 @@ libtotem_gmp_plugin_la_SOURCES = \ libtotem_gmp_plugin_la_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/backend \ - -I$(top_srcdir)/plparse \ -I$(top_builddir)/src \ -I$(top_builddir)/src/backend \ - -I$(top_builddir)/plparse \ -Iidl \ $(addprefix -I$(MOZILLA_INCLUDE_ROOT)/,$(gecko_include_subdirs)) \ -DTOTEM_GMP_PLUGIN \ @@ -251,7 +243,6 @@ libtotem_gmp_plugin_la_CXXFLAGS = \ $(AM_CXXFLAGS) libtotem_gmp_plugin_la_LIBADD = \ - $(top_builddir)/plparse/libtotem-plparser-mini.la \ libtotempluginviewer_helper.la \ $(DBUS_LIBS) \ $(MOZILLA_LIBS) \ @@ -286,10 +277,8 @@ libtotem_complex_plugin_la_SOURCES = \ libtotem_complex_plugin_la_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/backend \ - -I$(top_srcdir)/plparse \ -I$(top_builddir)/src \ -I$(top_builddir)/src/backend \ - -I$(top_builddir)/plparse \ -Iidl \ $(addprefix -I$(MOZILLA_INCLUDE_ROOT)/,$(gecko_include_subdirs)) \ -DTOTEM_COMPLEX_PLUGIN \ @@ -314,7 +303,6 @@ libtotem_complex_plugin_la_CXXFLAGS = \ $(AM_CXXFLAGS) libtotem_complex_plugin_la_LIBADD = \ - $(top_builddir)/plparse/libtotem-plparser-mini.la \ libtotempluginviewer_helper.la \ $(DBUS_LIBS) \ $(MOZILLA_LIBS) \ @@ -349,10 +337,8 @@ libtotem_narrowspace_plugin_la_SOURCES = \ libtotem_narrowspace_plugin_la_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/backend \ - -I$(top_srcdir)/plparse \ -I$(top_builddir)/src \ -I$(top_builddir)/src/backend \ - -I$(top_builddir)/plparse \ -Iidl \ $(addprefix -I$(MOZILLA_INCLUDE_ROOT)/,$(gecko_include_subdirs)) \ -DTOTEM_NARROWSPACE_PLUGIN \ @@ -377,7 +363,6 @@ libtotem_narrowspace_plugin_la_CXXFLAGS = \ $(AM_CXXFLAGS) libtotem_narrowspace_plugin_la_LIBADD = \ - $(top_builddir)/plparse/libtotem-plparser-mini.la \ libtotempluginviewer_helper.la \ $(DBUS_LIBS) \ $(MOZILLA_LIBS) \ @@ -412,10 +397,8 @@ libtotem_mully_plugin_la_SOURCES = \ libtotem_mully_plugin_la_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/backend \ - -I$(top_srcdir)/plparse \ -I$(top_builddir)/src \ -I$(top_builddir)/src/backend \ - -I$(top_builddir)/plparse \ -Iidl \ $(addprefix -I$(MOZILLA_INCLUDE_ROOT)/,$(gecko_include_subdirs)) \ -DTOTEM_MULLY_PLUGIN \ @@ -440,7 +423,6 @@ libtotem_mully_plugin_la_CXXFLAGS = \ $(AM_CXXFLAGS) libtotem_mully_plugin_la_LIBADD = \ - $(top_builddir)/plparse/libtotem-plparser-mini.la \ libtotempluginviewer_helper.la \ $(DBUS_LIBS) \ $(MOZILLA_LIBS) \ @@ -475,10 +457,8 @@ libtotem_cone_plugin_la_SOURCES = \ libtotem_cone_plugin_la_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/backend \ - -I$(top_srcdir)/plparse \ -I$(top_builddir)/src \ -I$(top_builddir)/src/backend \ - -I$(top_builddir)/plparse \ -Iidl \ $(addprefix -I$(MOZILLA_INCLUDE_ROOT)/,$(gecko_include_subdirs)) \ -DTOTEM_CONE_PLUGIN \ @@ -503,7 +483,6 @@ libtotem_cone_plugin_la_CXXFLAGS = \ $(AM_CXXFLAGS) libtotem_cone_plugin_la_LIBADD = \ - $(top_builddir)/plparse/libtotem-plparser-mini.la \ libtotempluginviewer_helper.la \ $(DBUS_LIBS) \ $(MOZILLA_LIBS) \ diff --git a/configure.in b/configure.in index bb06c1e45..630cb4de6 100644 --- a/configure.in +++ b/configure.in @@ -27,11 +27,6 @@ AM_PROG_CC_C_O AC_PROG_LIBTOOL() PKG_PROG_PKG_CONFIG -dnl Use local version of asprintf when not on the current system. -AC_CHECK_FUNCS(asprintf) -AC_CONFIG_LIBOBJ_DIR([lib]) -AC_REPLACE_FUNCS([asprintf]) - AC_PATH_PROG([GLIB_GENMARSHAL],[glib-genmarshal]) AC_PATH_PROG([GLIB_MKENUMS],[glib-mkenums]) @@ -39,34 +34,19 @@ AC_PATH_PROG([GLIB_MKENUMS],[glib-mkenums]) GLIB_REQS=2.13.4 GTK_REQS=2.11.6 GNOMEVFS_REQS=2.16.0 +TOTEM_PLPARSER_REQS=2.21.3 GNOMEUI_REQS=2.3.3 LIBGNOME_REQS=2.14.0 GNOMEICON_REQS=2.15.90 DBUS_REQS=0.61 VALA_REQS=0.0.8 -# Before making a release, the PLPARSER_LT_VERSION string should be modified. -# The string is of the form C:R:A. -# - If interfaces have been changed or added, but binary compatibility has -# been preserved, change to C+1:0:A+1 -# - If binary compatibility has been broken (eg removed or changed interfaces) -# change to C+1:0:0 -# - If the interface is the same as the previous version, change to C:R+1:A -PLPARSER_LT_VERSION=10:1:0 -AC_SUBST(PLPARSER_LT_VERSION) - TOTEM_VERSION_MAJOR=totem_version_major TOTEM_VERSION_MINOR=totem_version_minor TOTEM_VERSION_MICRO=totem_version_micro AC_SUBST(TOTEM_VERSION_MAJOR) AC_SUBST(TOTEM_VERSION_MINOR) AC_SUBST(TOTEM_VERSION_MICRO) -TOTEM_PL_PARSER_VERSION_MAJOR=totem_version_major -TOTEM_PL_PARSER_VERSION_MINOR=totem_version_minor -TOTEM_PL_PARSER_VERSION_MICRO=totem_version_micro -AC_SUBST(TOTEM_PL_PARSER_VERSION_MAJOR) -AC_SUBST(TOTEM_PL_PARSER_VERSION_MINOR) -AC_SUBST(TOTEM_PL_PARSER_VERSION_MICRO) # The full list of plugins allowed_plugins="screensaver ontop galago gromit lirc media-player-keys mythtv properties sidebar-test skipto sample-python sample-vala bemused youtube publish tracker" @@ -254,11 +234,11 @@ dnl Seems that the order matters because libtool blows dnl Also check if we're going to be using GTK+ only if test x$ENABLE_GTK = "xno" ; then # FIXME: use gmodule-no-export instead! - PKG_CHECK_MODULES(EXTRA_GNOME, glib-2.0 >= $GLIB_REQS gtk+-2.0 >= $GTK_REQS libgnomeui-2.0 >= $GNOMEUI_REQS gnome-vfs-2.0 >= $GNOMEVFS_REQS gnome-vfs-module-2.0 >= $GNOMEVFS_REQS libgnome-2.0 >= $LIBGNOME_REQS gnome-desktop-2.0 >= 2.1.5 gnome-icon-theme >= $GNOMEICON_REQS gmodule-2.0 $ISO_CODES $MM) + PKG_CHECK_MODULES(EXTRA_GNOME, glib-2.0 >= $GLIB_REQS gtk+-2.0 >= $GTK_REQS libgnomeui-2.0 >= $GNOMEUI_REQS gnome-vfs-2.0 >= $GNOMEVFS_REQS gnome-vfs-module-2.0 >= $GNOMEVFS_REQS libgnome-2.0 >= $LIBGNOME_REQS gnome-desktop-2.0 >= 2.1.5 gnome-icon-theme >= $GNOMEICON_REQS gmodule-2.0 totem-plparser > $TOTEM_PLPARSER_REQS $ISO_CODES $MM) HAVE_GNOME=yes else # FIXME: use gmodule-no-export instead! - PKG_CHECK_MODULES(EXTRA_GNOME, glib-2.0 >= $GLIB_REQS gtk+-2.0 >= $GTK_REQS gnome-vfs-2.0 >= $GNOMEVFS_REQS gnome-vfs-module-2.0 >= $GNOMEVFS_REQS gnome-icon-theme >= $GNOMEICON_REQS gmodule-2.0 $ISO_CODES $MM) + PKG_CHECK_MODULES(EXTRA_GNOME, glib-2.0 >= $GLIB_REQS gtk+-2.0 >= $GTK_REQS gnome-vfs-2.0 >= $GNOMEVFS_REQS gnome-vfs-module-2.0 >= $GNOMEVFS_REQS gnome-icon-theme >= $GNOMEICON_REQS gmodule-2.0 totem-plparser > $TOTEM_PLPARSER_REQS $ISO_CODES $MM) AC_DEFINE(USE_STABLE_LIBGNOMEUI, 1, [defined if we don't have GNOME]) AC_DEFINE(HAVE_GTK_ONLY, 1, [defined if GNOME isn't used]) HAVE_GNOME=no @@ -493,7 +473,8 @@ if test "$enable_browser_plugins" = "yes" ; then [glib-2.0 gnome-vfs-2.0 >= $GNOMEVFS_REQS gnome-vfs-module-2.0 >= $GNOMEVFS_REQS - gthread-2.0], + gthread-2.0 + totem-plparser-mini > $TOTEM_PLPARSER_REQS], [],[enable_browser_plugins=no]) BROWSER_PLUGIN_CFLAGS="$MOZILLA_NOT_LINKED_CFLAGS $BROWSER_PLUGIN_CFLAGS" @@ -826,13 +807,6 @@ fi AC_PATH_PROG(GCONFTOOL, gconftool-2) AM_GCONF_SOURCE_2 -dnl Check for packages for building libtotem-plparser.la -PKG_CHECK_MODULES(TOTEM_PLPARSER, [gtk+-2.0 libxml-2.0 gnome-vfs-2.0 - gnome-vfs-module-2.0]) - -PKG_CHECK_MODULES([TOTEM_PLPARSER_MINI], - [gnome-vfs-2.0 gnome-vfs-module-2.0]) - GNOME_COMMON_INIT GNOME_DEBUG_CHECK GNOME_COMPILE_WARNINGS([maximum]) @@ -958,7 +932,8 @@ if test "x$have_python" != "xno"; then PYGTK_REQUIRED=2.12.0 PKG_CHECK_MODULES([PYGTK], [ - pygtk-2.0 >= $PYGTK_REQUIRED], + pygtk-2.0 >= $PYGTK_REQUIRED + totem-plparser > $TOTEM_PLPARSER_REQS], [], [ have_python=no @@ -1041,11 +1016,7 @@ AM_CONDITIONAL(ENABLE_VALA, test "x$with_vala" = "xyes") AC_OUTPUT([ Makefile totem.spec -totem-plparser.pc -totem-plparser-uninstalled.pc lib/Makefile -plparse/Makefile -plparse/totem-pl-parser-features.h src/Makefile src/plugins/Makefile src/plugins/bemused/Makefile diff --git a/lib/Makefile.am b/lib/Makefile.am index 163e867e7..617f6300e 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,6 +1,5 @@ noinst_LTLIBRARIES = \ - libtotemscrsaver.la \ - libtotem_glibc.la + libtotemscrsaver.la common_defines = \ -D_REENTRANT \ @@ -31,10 +30,3 @@ libtotemscrsaver_la_LIBADD = \ $(DBUS_LIBS) \ $(XTEST_LIBS) -noinst_HEADERS = totem_internal.h - -libtotem_glibc_la_SOURCES = -libtotem_glibc_la_LIBADD = @LTLIBOBJS@ - -EXTRA_DIST = asprintf.c - diff --git a/plparse/Makefile.am b/plparse/Makefile.am deleted file mode 100644 index 187fc812c..000000000 --- a/plparse/Makefile.am +++ /dev/null @@ -1,197 +0,0 @@ -noinst_PROGRAMS = test-parser disc-test - -test_parser_SOURCES = test-parser.c - -test_parser_CPPFLAGS = \ - -I$(top_srcdir) \ - -I$(top_builddir)/src/plparser \ - -DGNOMELOCALEDIR=\""$(datadir)/locale"\"\ - $(DISABLE_DEPRECATED) \ - $(AM_CPPFLAGS) - -test_parser_CFLAGS = \ - $(EXTRA_GNOME_CFLAGS) \ - $(HAL_CFLAGS) \ - $(DBUS_CFLAGS) \ - $(WARN_CFLAGS) \ - $(AM_CFLAGS) - -test_parser_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - libtotem-plparser.la - -disc_test_SOURCES = \ - disc-test.c - -disc_test_CPPFLAGS = \ - $(common_defines) \ - $(AM_CPPFLAGS) - -disc_test_CFLAGS = \ - $(WARN_CFLAGS) \ - $(GTK_CFLAGS) \ - $(EXTRA_GNOME_CFLAGS) \ - $(AM_CFLAGS) - -disc_test_LDFLAGS = \ - $(AM_LDFLAGS) - -disc_test_LDADD = \ - libtotem-plparser.la \ - $(GTK_LIBS) \ - $(EXTRA_GNOME_LIBS) - -lib_LTLIBRARIES = libtotem-plparser.la -noinst_LTLIBRARIES = libtotem-plparser-mini.la - -MARSHALFILES = totemplparser-marshal.c totemplparser-marshal.h -BUILT_SOURCES = $(MARSHALFILES) - -totemplparser-marshal.c: totemplparser-marshal.h - ( $(GLIB_GENMARSHAL) --prefix=totemplparser_marshal $(srcdir)/totemplparser-marshal.list --header --body > totemplparser-marshal.c ) -totemplparser-marshal.h: totemplparser-marshal.list - ( $(GLIB_GENMARSHAL) --prefix=totemplparser_marshal $(srcdir)/totemplparser-marshal.list --header > totemplparser-marshal.h ) - -plparserincludedir = $(pkgincludedir)/1/plparser -plparserinclude_HEADERS = \ - totem-pl-parser-builtins.h \ - totem-pl-parser-features.h \ - totem-pl-parser.h \ - totem-disc.h - -libtotem_plparser_la_SOURCES = \ - totem-disc.c \ - totem-disc.h \ - totem-pl-parser-builtins.c \ - totem-pl-parser-builtins.h \ - totem-pl-parser.c \ - totem-pl-parser-features.h \ - totem-pl-parser.h \ - totem-pl-parser-lines.c \ - totem-pl-parser-lines.h \ - totemplparser-marshal.c \ - totemplparser-marshal.h \ - totem-pl-parser-media.c \ - totem-pl-parser-media.h \ - totem-pl-parser-misc.c \ - totem-pl-parser-misc.h \ - totem-pl-parser-pla.c \ - totem-pl-parser-pla.h \ - totem-pl-parser-pls.c \ - totem-pl-parser-pls.h \ - totem-pl-parser-podcast.c \ - totem-pl-parser-podcast.h \ - totem-pl-parser-private.h \ - totem-pl-parser-qt.c \ - totem-pl-parser-qt.h \ - totem-pl-parser-smil.c \ - totem-pl-parser-smil.h \ - totem-pl-parser-wm.c \ - totem-pl-parser-wm.h \ - totem-pl-parser-xspf.c \ - totem-pl-parser-xspf.h \ - xmlparser.h xmlparser.c \ - xmllexer.h xmllexer.c - -libtotem_plparser_la_CPPFLAGS = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/lib \ - -I$(top_builddir)/src/plparser \ - -DGNOMELOCALEDIR=\""$(datadir)/locale"\"\ - $(DISABLE_DEPRECATED) \ - $(AM_CPPFLAGS) - -libtotem_plparser_la_CFLAGS = \ - $(TOTEM_PLPARSER_CFLAGS) \ - $(HAL_CFLAGS) \ - $(DBUS_CFLAGS) \ - $(WARN_CFLAGS) \ - $(AM_CFLAGS) \ - -I$(top_srcdir)/lib \ - -D_GNU_SOURCE - -libtotem_plparser_la_LIBADD = \ - $(TOTEM_PLPARSER_LIBS) \ - $(top_builddir)/lib/libtotem_glibc.la \ - $(HAL_LIBS) - -libtotem_plparser_la_LDFLAGS = \ - -version-info $(PLPARSER_LT_VERSION) \ - -export-symbols $(srcdir)/plparser.symbols \ - -no-undefined \ - $(AM_LDFLAGS) - -libtotem_plparser_mini_la_SOURCES = \ - totem-pl-parser-mini.h \ - totem-pl-parser.c \ - totem-pl-parser-lines.c \ - totem-pl-parser-lines.h \ - totem-pl-parser-misc.c \ - totem-pl-parser-misc.h \ - totem-pl-parser-pls.c \ - totem-pl-parser-pls.h \ - totem-pl-parser-podcast.c \ - totem-pl-parser-podcast.h \ - totem-pl-parser-private.h \ - totem-pl-parser-qt.c \ - totem-pl-parser-qt.h \ - totem-pl-parser-smil.c \ - totem-pl-parser-smil.h \ - totem-pl-parser-wm.c \ - totem-pl-parser-wm.h \ - totem-pl-parser-xspf.c \ - totem-pl-parser-xspf.h - -libtotem_plparser_mini_la_CPPFLAGS = \ - -I$(top_srcdir) \ - -I$(top_builddir)/src/plparser \ - -DTOTEM_PL_PARSER_MINI \ - $(DISABLE_DEPRECATED) \ - $(AM_CPPFLAGS) - -libtotem_plparser_mini_la_CFLAGS = \ - $(TOTEM_PLPARSER_MINI_CFLAGS) \ - $(WARN_CFLAGS) \ - $(AM_CFLAGS) - -libtotem_plparser_mini_la_LIBADD = \ - $(TOTEM_PLPARSER_MINI_LIBS) - -libtotem_plparser_mini_la_LDFLAGS = \ - -no-undefined \ - $(AM_LDFLAGS) - -totem-pl-parser-builtins.h: stamp-totem-pl-parser-builtins.h - @true - -stamp-totem-pl-parser-builtins.h: totem-pl-parser.h Makefile - (cd $(srcdir) && $(GLIB_MKENUMS) \ - --fhead "#ifndef __TOTEM_PL_PARSER_BUILTINS_H__\n#define __TOTEM_PL_PARSER_BUILTINS_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \ - --fprod "/* enumerations from \"@filename@\" */\n" \ - --vhead "GType @enum_name@_get_type (void) G_GNUC_CONST;\n#define TOTEM_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n" \ - --ftail "G_END_DECLS\n\n#endif /* __TOTEM_PL_PARSER_BUILTINS_H__ */" totem-pl-parser.h) >> xgen-gtbh \ - && (cmp -s xgen-gtbh totem-pl-parser-builtins.h || cp xgen-gtbh totem-pl-parser-builtins.h ) \ - && rm -f xgen-gtbh \ - && echo timestamp > $(@F) - -totem-pl-parser-builtins.c: totem-pl-parser.h Makefile totem-pl-parser-builtins.h - (cd $(srcdir) && $(GLIB_MKENUMS) \ - --fhead "#include \"totem-pl-parser.h\"\n#include \"totem-pl-parser-builtins.h\"" \ - --fprod "\n/* enumerations from \"@filename@\" */" \ - --vhead "GType\n@enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G@Type@Value values[] = {" \ - --vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \ - --vtail " { 0, NULL, NULL }\n };\n etype = g_@type@_register_static (\"@EnumName@\", values);\n }\n return etype;\n}\n" \ - totem-pl-parser.h ) > xgen-gtbc \ - && cp xgen-gtbc totem-pl-parser-builtins.c \ - && rm -f xgen-gtbc - -CLEANFILES = \ - totem-pl-parser-builtins.h \ - totem-pl-parser-builtins.c \ - stamp-totem-pl-parser-builtins.h \ - $(BUILT_SOURCES) - -EXTRA_DIST = \ - totemplparser-marshal.list \ - totem-pl-parser-features.h.in \ - plparser.symbols diff --git a/plparse/disc-test.c b/plparse/disc-test.c deleted file mode 100644 index 79548736e..000000000 --- a/plparse/disc-test.c +++ /dev/null @@ -1,111 +0,0 @@ -/* Small test app for disc concent detection - * (c) 2004 Ronald Bultje <rbultje@ronald.bitfreak.net> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <glib.h> -#include <libgnomevfs/gnome-vfs.h> - -#include "totem-disc.h" - -gint -main (gint argc, - gchar *argv[]) -{ - TotemDiscMediaType type; - GError *error = NULL; - const char *type_s = NULL; - char *url = NULL; - gboolean is_dir = FALSE; - GList *or, *list; - GnomeVFSVolumeMonitor *mon; - - if (argc != 2) { - g_print ("Usage: %s <device>\n", argv[0]); - return -1; - } - - g_type_init (); - gnome_vfs_init (); - g_log_set_always_fatal (G_LOG_LEVEL_WARNING); - - if (g_file_test (argv[1], G_FILE_TEST_IS_DIR) != FALSE) { - type = totem_cd_detect_type_from_dir (argv[1], &url, &error); - is_dir = TRUE; - } else { - type = totem_cd_detect_type_with_url (argv[1], &url, &error); - } - - switch (type) { - case MEDIA_TYPE_ERROR: - mon = gnome_vfs_get_volume_monitor (); - g_print ("Error: %s\n", error ? error->message : "unknown reason"); - g_print ("\n"); - g_print ("List of connected drives:\n"); - for (or = list = gnome_vfs_volume_monitor_get_connected_drives (mon); - list != NULL; list = list->next) { - char *device; - device = gnome_vfs_drive_get_device_path ((GnomeVFSDrive *) list->data); - g_print ("%s\n", device); - g_free (device); - } - if (or == NULL) - g_print ("No connected drives!\n"); - - g_print ("List of mounted volumes:\n"); - for (or = list = gnome_vfs_volume_monitor_get_mounted_volumes (mon); - list != NULL; list = list->next) { - char *device; - - device = gnome_vfs_volume_get_device_path ((GnomeVFSVolume *) list->data); - g_print ("%s\n", device); - g_free (device); - } - if (or == NULL) - g_print ("No mounted volumes!\n"); - - return -1; - case MEDIA_TYPE_DATA: - type_s = "Data CD"; - break; - case MEDIA_TYPE_CDDA: - type_s = "Audio CD"; - break; - case MEDIA_TYPE_VCD: - type_s = "Video CD"; - break; - case MEDIA_TYPE_DVD: - type_s = "DVD"; - break; - default: - g_assert_not_reached (); - } - - g_print ("%s contains a %s\n", argv[1], type_s); - - if (url != NULL) { - g_print ("URL for directory is %s\n", url); - } - - g_free (url); - - return 0; -} diff --git a/plparse/plparser.symbols b/plparse/plparser.symbols deleted file mode 100644 index fbf08e60e..000000000 --- a/plparse/plparser.symbols +++ /dev/null @@ -1,24 +0,0 @@ -totem_pl_parser_error_quark -totem_pl_parser_get_type -totem_pl_parser_result_get_type -totem_pl_parser_error_get_type -totem_pl_parser_write -totem_pl_parser_write_with_title -totem_pl_parser_add_ignored_scheme -totem_pl_parser_add_ignored_mimetype -totem_pl_parser_parse -totem_pl_parser_parse_with_base -totem_pl_parser_new -totem_pl_parser_can_parse_from_data -totem_pl_parser_can_parse_from_filename -totem_pl_parser_type_get_type -totem_pl_parser_parse_duration -totem_pl_parser_parse_date -totem_cd_detect_type -totem_cd_detect_type_with_url -totem_cd_detect_type_from_dir -totem_cd_get_human_readable_name -totem_cd_mrl_from_type -totem_cd_has_medium -totemplparser_marshal_VOID__STRING_STRING_STRING -totem_pl_parser_resolve_url diff --git a/plparse/test-parser.c b/plparse/test-parser.c deleted file mode 100644 index 21bdd9b55..000000000 --- a/plparse/test-parser.c +++ /dev/null @@ -1,430 +0,0 @@ -#include "config.h" - -#include <locale.h> - -#include <glib.h> -#include <string.h> -#include <unistd.h> -#include <stdlib.h> -#include <libgnomevfs/gnome-vfs.h> - -#include "totem-pl-parser.h" -#include "totem-pl-parser-mini.h" -#include "totem-pl-parser-private.h" - -#define USE_DATA - -static GMainLoop *loop = NULL; -static gboolean option_no_recurse = FALSE; -static gboolean option_debug = FALSE; -static gboolean option_data = FALSE; -static gboolean option_force = FALSE; -static gboolean option_disable_unsafe = FALSE; -static gboolean option_duration = FALSE; -static gboolean g_fatal_warnings = FALSE; -static char *option_base_uri = NULL; -static char **files = NULL; - -static void -header (const char *message) -{ - g_print ("\n"); - g_print ("###################### %s ################\n", message); - g_print ("\n"); -} - -#define error(x...) { g_warning (x); exit(1); } - -#if 0 -static void -test_relative_real (const char *url, const char *output) -{ - char *base, *dos; - - g_print ("url: %s\n", url); - g_print ("output: %s\n", output); - base = totem_pl_parser_relative (url, output); - if (base) { - g_print ("relative path: %s\n", base); - } else { - g_print ("no relative path\n"); - } - dos = totem_pl_parser_url_to_dos (url, output); - g_print ("DOS path: %s\n", dos); - g_print ("\n"); - - g_free (base); - g_free (dos); -} - -static void -test_relative (void) -{ - header ("relative"); - - test_relative_real ("/home/hadess/test/test file.avi", - "/home/hadess/foobar.m3u"); - test_relative_real ("file:///home/hadess/test/test%20file.avi", - "/home/hadess/whatever.m3u"); - test_relative_real ("smb://server/share/file.mp3", - "/home/hadess/whatever again.m3u"); - test_relative_real ("smb://server/share/file.mp3", - "smb://server/share/file.m3u"); - test_relative_real ("/home/hadess/test.avi", - "/home/hadess/test/file.m3u"); - test_relative_real ("http://foobar.com/test.avi", - "/home/hadess/test/file.m3u"); -} -#endif - -static void -test_resolve_real (const char *base, const char *url, const char *expected) -{ - char *result; - - result = totem_pl_parser_resolve_url (base, url); - if (result == NULL) - error ("NULL output resolving '%s' with base '%s'", url, base); - if (strcmp (result, expected) != 0) - error ("Resolving '%s' with base '%s', different results than expected:\n'%s' instead of '%s'", - url, base, result, expected); - g_print ("Resolved: '%s' with base '%s' to '%s'\n", url, base, result); - g_free (result); -} - -static void -test_resolve (void) -{ - header ("Resolve URL"); - - test_resolve_real ("http://localhost:12345/foobar", "/leopard.mov", "http://localhost:12345/leopard.mov"); - test_resolve_real ("file:///home/hadess/Movies", "Movies/mymovie.mov", "file:///home/hadess/Movies/Movies/mymovie.mov"); - test_resolve_real ("http://localhost/video.dir/video.mpg?param1=foo¶m2=bar", "dir/image.jpg", "http://localhost/video.dir/dir/image.jpg"); - test_resolve_real ("http://movies.apple.com/movies/us/apple/ipoditunes/2007/touch/features/apple_ipodtouch_safari_r640-9cie.mov", "/movies/us/apple/ipoditunes/2007/touch/features/apple_ipodtouch_safari_i320x180.m4v", "http://movies.apple.com/movies/us/apple/ipoditunes/2007/touch/features/apple_ipodtouch_safari_i320x180.m4v"); -} - -static void -test_duration_real (const char *duration, gint64 expected) -{ - gint64 res; - - res = totem_pl_parser_parse_duration (duration, option_debug); - if (res != expected) - error ("Error parsing '%s' to %"G_GINT64_FORMAT" secs, got %"G_GINT64_FORMAT" secs", - duration ? duration : "(null)", expected, res); - g_print ("Parsed '%s' to %"G_GINT64_FORMAT" secs\n", duration ? duration : "(null)", res); -} - -static void -test_duration (void) -{ - header ("Duration string parsing"); - - test_duration_real ("500", 500); - test_duration_real ("01:01", 61); - test_duration_real ("00:00:00.01", 1); - test_duration_real ("01:00:01.01", 3601); - test_duration_real ("01:00.01", 60); -} - -#define MAX_DESCRIPTION_LEN 128 - -static void -entry_metadata_foreach (const char *key, - const char *value, - gpointer data) -{ - if (g_ascii_strcasecmp (key, TOTEM_PL_PARSER_FIELD_URL) == 0) - return; - if (g_ascii_strcasecmp (key, TOTEM_PL_PARSER_FIELD_DESCRIPTION) == 0 - && strlen (value) > MAX_DESCRIPTION_LEN) { - char *tmp = g_strndup (value, MAX_DESCRIPTION_LEN), *s; - for (s = tmp; s - tmp < MAX_DESCRIPTION_LEN; s++) - if (*s == '\n' || *s == '\r') { - *s = '\0'; - break; - } - g_print ("\t%s = '%s' (truncated)\n", key, tmp); - return; - } - g_print ("\t%s = '%s'\n", key, value); -} - -static void -entry_parsed (TotemPlParser *parser, const char *uri, - GHashTable *metadata, gpointer data) -{ - g_print ("added URI '%s'\n", uri); - g_hash_table_foreach (metadata, (GHFunc) entry_metadata_foreach, NULL); -} - -static void -test_parsing_real (TotemPlParser *pl, const char *url) -{ - TotemPlParserResult res; - - res = totem_pl_parser_parse_with_base (pl, url, option_base_uri, FALSE); - if (res != TOTEM_PL_PARSER_RESULT_SUCCESS) { - switch (res) { - case TOTEM_PL_PARSER_RESULT_UNHANDLED: - g_print ("url '%s' unhandled\n", url); - break; - case TOTEM_PL_PARSER_RESULT_ERROR: - g_print ("error handling url '%s'\n", url); - break; - case TOTEM_PL_PARSER_RESULT_IGNORED: - g_print ("ignored url '%s'\n", url); - break; - default: - g_assert_not_reached (); - ;; - } - } -} - -static gboolean -push_parser (gpointer data) -{ - TotemPlParser *pl = (TotemPlParser *)data; - - if (files != NULL) { - guint i; - - for (i = 0; files[i] != NULL; ++i) { - test_parsing_real (pl, files[i]); - } - } else { - //test_parsing_real (pl, "file:///mnt/cdrom"); - test_parsing_real (pl, "file:///home/hadess/Movies"); - /* Bugzilla 158052, 404 */ - test_parsing_real (pl, "http://live.hujjat.org:7860/main"); - /* Bugzilla 330120 */ - test_parsing_real (pl, "file:///tmp/file_doesnt_exist.wmv"); - /* Bugzilla 323683 */ - test_parsing_real (pl, "http://www.comedycentral.com/sitewide/media_player/videoswitcher.jhtml?showid=934&category=/shows/the_daily_show/videos/headlines&sec=videoId%3D36032%3BvideoFeatureId%3D%3BpoppedFrom%3D_shows_the_daily_show_index.jhtml%3BisIE%3Dfalse%3BisPC%3Dtrue%3Bpagename%3Dmedia_player%3Bzyg%3D%27%2Bif_nt_zyg%2B%27%3Bspan%3D%27%2Bif_nt_span%2B%27%3Bdemo%3D%27%2Bif_nt_demo%2B%27%3Bbps%3D%27%2Bif_nt_bandwidth%2B%27%3Bgateway%3Dshows%3Bsection_1%3Dthe_daily_show%3Bsection_2%3Dvideos%3Bsection_3%3Dheadlines%3Bzyg%3D%27%2Bif_nt_zyg%2B%27%3Bspan%3D%27%2Bif_nt_span%2B%27%3Bdemo%3D%27%2Bif_nt_demo%2B%27%3Bera%3D%27%2Bif_nt_era%2B%27%3Bbps%3D%27%2Bif_nt_bandwidth%2B%27%3Bfla%3D%27%2Bif_nt_Flash%2B%27&itemid=36032&clip=com/dailyshow/headlines/10156_headline.wmv&mswmext=.asx"); - } - g_main_loop_quit (loop); - return FALSE; -} - -#ifdef USE_DATA - -#define READ_CHUNK_SIZE 8192 -#define MIME_READ_CHUNK_SIZE 1024 - -static char * -test_data_get_data (const char *uri, guint *len) -{ - GnomeVFSResult result; - GnomeVFSHandle *handle; - char *buffer; - GnomeVFSFileSize total_bytes_read; - GnomeVFSFileSize bytes_read; - - *len = 0; - - /* Open the file. */ - result = gnome_vfs_open (&handle, uri, GNOME_VFS_OPEN_READ); - if (result != GNOME_VFS_OK) - return NULL; - - /* Read the whole thing, up to MIME_READ_CHUNK_SIZE */ - buffer = NULL; - total_bytes_read = 0; - do { - buffer = g_realloc (buffer, total_bytes_read - + MIME_READ_CHUNK_SIZE); - result = gnome_vfs_read (handle, - buffer + total_bytes_read, - MIME_READ_CHUNK_SIZE, - &bytes_read); - if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_EOF) { - g_free (buffer); - gnome_vfs_close (handle); - return NULL; - } - - /* Check for overflow. */ - if (total_bytes_read + bytes_read < total_bytes_read) { - g_free (buffer); - gnome_vfs_close (handle); - return NULL; - } - - total_bytes_read += bytes_read; - } while (result == GNOME_VFS_OK - && total_bytes_read < MIME_READ_CHUNK_SIZE); - - /* Close the file but don't overwrite the possible error */ - if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_EOF) - gnome_vfs_close (handle); - else - result = gnome_vfs_close (handle); - - if (result != GNOME_VFS_OK) { - g_message ("URL '%s' couldn't be read or closed in _get_mime_type_with_data: '%s'\n", uri, gnome_vfs_result_to_string (result)); - g_free (buffer); - return NULL; - } - - /* Return the file null-terminated. */ - buffer = g_realloc (buffer, total_bytes_read + 1); - buffer[total_bytes_read] = '\0'; - *len = total_bytes_read; - - return buffer; -} -#endif /* USE_DATA */ - -static void -test_data (void) -{ - guint i; - - for (i = 0; files[i] != NULL; ++i) { - char *filename = files[i]; - gboolean retval; -#ifdef USE_DATA - char *data; - guint len; - - data = test_data_get_data (filename, &len); - if (data == NULL) { - g_message ("Couldn't get data for %s", filename); - continue; - } - retval = totem_pl_parser_can_parse_from_data (data, len, TRUE); - g_free (data); -#else - retval = totem_pl_parser_can_parse_from_filename (filename, TRUE); -#endif /* USE_DATA */ - - if (retval != FALSE) { - g_message ("IS a playlist: %s", filename); - } else { - g_message ("ISNOT playlist: %s", filename); - } - } -} - -static void -playlist_started (TotemPlParser *parser, const char *uri, GHashTable *metadata) -{ - g_print ("Started playlist '%s'\n", uri); - g_hash_table_foreach (metadata, (GHFunc) entry_metadata_foreach, NULL); - g_print ("\n"); -} - -static void -playlist_ended (TotemPlParser *parser, const char *uri) -{ - g_print ("Playlist '%s' ended\n", uri); - g_print ("\n"); -} - -static void -test_parsing (void) -{ - TotemPlParser *pl = totem_pl_parser_new (); - - g_object_set (pl, "recurse", !option_no_recurse, - "debug", option_debug, - "force", option_force, - "disable-unsafe", option_disable_unsafe, - NULL); - g_signal_connect (G_OBJECT (pl), "entry-parsed", G_CALLBACK (entry_parsed), NULL); - g_signal_connect (G_OBJECT (pl), "playlist-started", G_CALLBACK (playlist_started), NULL); - g_signal_connect (G_OBJECT (pl), "playlist-ended", G_CALLBACK (playlist_ended), NULL); - - header ("parsing"); - g_idle_add (push_parser, pl); - loop = g_main_loop_new (NULL, FALSE); - g_main_loop_run (loop); -} - -int main (int argc, char **argv) -{ - GOptionEntry option_entries [] = - { - { "no-recurse", 'n', 0, G_OPTION_ARG_NONE, &option_no_recurse, "Disable recursion", NULL }, - { "debug", 'd', 0, G_OPTION_ARG_NONE, &option_debug, "Enable debug", NULL }, - { "data", 't', 0, G_OPTION_ARG_NONE, &option_data, "Use data instead of filename", NULL }, - { "force", 'f', 0, G_OPTION_ARG_NONE, &option_force, "Force parsing", NULL }, - { "disable-unsafe", 'u', 0, G_OPTION_ARG_NONE, &option_disable_unsafe, "Disabling unsafe playlist-types", NULL }, - { "base-uri", 'b', 0, G_OPTION_ARG_STRING, &option_base_uri, "Base URI to resolve relative items from", NULL }, - { "duration", 0, 0, G_OPTION_ARG_NONE, &option_duration, "Run duration test", NULL }, - { "g-fatal-warnings", 0, 0, G_OPTION_ARG_NONE, &g_fatal_warnings, "Make all warnings fatal", NULL }, - { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &files, NULL, "[URI...]" }, - { NULL } - }; - GOptionContext *context; - GError *error = NULL; - gboolean retval; - - setlocale (LC_ALL, ""); - - g_thread_init (NULL); - - context = g_option_context_new (NULL); - g_option_context_add_main_entries (context, option_entries, NULL); - - retval = g_option_context_parse (context, &argc, &argv, &error); - g_option_context_free (context); - - if (!retval) { - g_print ("Error parsing arguments: %s\n", error->message); - g_error_free (error); - - g_print ("Usage: %s <-n | --no-recurse> <-d | --debug> <-h | --help> <-t | --data > <-u | --disable-unsafe> <url>\n", argv[0]); - exit (1); - } - - gnome_vfs_init(); - - if (g_fatal_warnings) { - GLogLevelFlags fatal_mask; - - fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK); - fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL; - g_log_set_always_fatal (fatal_mask); - } - - if (option_data != FALSE && files == NULL) { - g_message ("Please pass specific files to check by data"); - return 1; - } - - if (option_duration != FALSE) { - if (files == NULL) { - test_duration (); - return 0; - } else { - guint i; - - for (i = 0; files[i] != NULL; i++) { - g_print ("Parsed '%s' to %"G_GINT64_FORMAT" secs\n", - files[i], - totem_pl_parser_parse_duration (files[i], option_debug)); - } - - return 0; - } - } - - if (files == NULL) { - test_duration (); - test_resolve (); -#if 0 - test_relative (); -#endif - test_parsing (); - } else { - if (option_data) { - test_data (); - } else { - test_parsing (); - } - } - - return 0; -} diff --git a/plparse/totem-disc.c b/plparse/totem-disc.c deleted file mode 100644 index 6a2c7fcfc..000000000 --- a/plparse/totem-disc.c +++ /dev/null @@ -1,878 +0,0 @@ -/* Totem Disc Content Detection - * Copyright (C) 2004 Ronald Bultje <rbultje@ronald.bitfreak.net> - * Copyright (C) 2004-2007 Bastien Nocera <hadess@hadess.net> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * The Totem project hereby grant permission for non-gpl compatible GStreamer - * plugins to be used and distributed together with GStreamer and Totem. This - * permission are above and beyond the permissions granted by the GPL license - * Totem is covered by. - * - * Monday 7th February 2005: Christian Schaller: Add exception clause. - * See license_change file for details. - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#include <errno.h> -#include <string.h> - -#include <sys/stat.h> - -#include <glib.h> -#include <glib/gi18n.h> -#include <libgnomevfs/gnome-vfs.h> - -#ifdef HAVE_HAL -#include <libhal.h> -#include <dbus/dbus.h> -#endif - -#include "totem-disc.h" - -typedef struct _CdCache { - /* device node and mountpoint */ - char *device, *mountpoint; - GnomeVFSDrive *drive; - -#ifdef HAVE_HAL - LibHalContext *ctx; - /* If the disc is a media, have the UDI available here */ - char *disc_udi; -#endif - - /* Whether we have a medium */ - guint has_medium : 1; - /* if we're checking a media, or a dir */ - guint is_media : 1; - - /* indicates if we mounted this mountpoint ourselves or if it - * was already mounted. */ - guint self_mounted : 1; - guint mounted : 1; -} CdCache; - -static char * -totem_resolve_symlink (const char *device, GError **error) -{ - char *dir, *link; - char *f; - char *f1; - - f = g_strdup (device); - while (g_file_test (f, G_FILE_TEST_IS_SYMLINK)) { - link = g_file_read_link (f, error); - if(link == NULL) { - g_free (f); - return NULL; - } - - dir = g_path_get_dirname (f); - f1 = g_build_filename (dir, link, NULL); - g_free (dir); - g_free (f); - f = f1; - } - - if (f != NULL) { - f1 = gnome_vfs_make_path_name_canonical (f); - g_free (f); - f = f1; - } - return f; -} - -static gboolean -cd_cache_get_dev_from_volumes (GnomeVFSVolumeMonitor *mon, const char *device, - char **mountpoint) -{ - gboolean found; - GnomeVFSVolume *volume = NULL; - GList *list, *or; - - found = FALSE; - - for (or = list = gnome_vfs_volume_monitor_get_mounted_volumes (mon); - list != NULL; list = list->next) { - char *pdev, *pdev2; - - volume = list->data; - if (!(pdev = gnome_vfs_volume_get_device_path (volume))) - continue; - pdev2 = totem_resolve_symlink (pdev, NULL); - if (!pdev2) { - g_free (pdev); - continue; - } - g_free (pdev); - - if (strcmp (pdev2, device) == 0) { - char *mnt; - - mnt = gnome_vfs_volume_get_activation_uri (volume); - if (mnt && strncmp (mnt, "file://", 7) == 0) { - g_free (pdev2); - *mountpoint = g_strdup (mnt + 7); - g_free (mnt); - found = TRUE; - break; - } else if (mnt && strncmp (mnt, "cdda://", 7) == 0) { - g_free (pdev2); - *mountpoint = NULL; - g_free (mnt); - found = TRUE; - break; - } - g_free (mnt); - } - g_free (pdev2); - } - g_list_foreach (or, (GFunc) gnome_vfs_volume_unref, NULL); - g_list_free (or); - - return found; -} - -static gboolean -cd_cache_get_dev_from_drives (GnomeVFSVolumeMonitor *mon, const char *device, - char **mountpoint, GnomeVFSDrive **d) -{ - gboolean found; - GnomeVFSDrive *drive = NULL; - GList *list, *or; - - found = FALSE; - - for (or = list = gnome_vfs_volume_monitor_get_connected_drives (mon); - list != NULL; list = list->next) { - char *pdev, *pdev2; - - drive = list->data; - if (!(pdev = gnome_vfs_drive_get_device_path (drive))) - continue; - pdev2 = totem_resolve_symlink (pdev, NULL); - if (!pdev2) { - g_free (pdev); - continue; - } - g_free (pdev); - - if (strcmp (pdev2, device) == 0) { - char *mnt; - - mnt = gnome_vfs_drive_get_activation_uri (drive); - if (mnt && strncmp (mnt, "file://", 7) == 0) { - *mountpoint = g_strdup (mnt + 7); - } else { - *mountpoint = NULL; - } - found = TRUE; - g_free (pdev2); - g_free (mnt); - gnome_vfs_drive_ref (drive); - break; - } - g_free (pdev2); - } - g_list_foreach (or, (GFunc) gnome_vfs_drive_unref, NULL); - g_list_free (or); - - *d = drive; - - return found; -} - -#ifdef HAVE_HAL -static LibHalContext * -cd_cache_new_hal_ctx (void) -{ - LibHalContext *ctx; - DBusConnection *conn; - DBusError error; - - ctx = libhal_ctx_new (); - if (ctx == NULL) - return NULL; - - dbus_error_init (&error); - conn = dbus_bus_get_private (DBUS_BUS_SYSTEM, &error); - - if (conn != NULL && !dbus_error_is_set (&error)) { - if (!libhal_ctx_set_dbus_connection (ctx, conn)) { - libhal_ctx_free (ctx); - return NULL; - } - if (libhal_ctx_init (ctx, &error)) - return ctx; - } - - if (dbus_error_is_set (&error)) { - g_warning ("Couldn't get the system D-Bus: %s", error.message); - dbus_error_free (&error); - } - - libhal_ctx_free (ctx); - if (conn != NULL) { - dbus_connection_close (conn); - dbus_connection_unref (conn); - } - - return NULL; -} -#endif - -static CdCache * -cd_cache_new (const char *dev, - GError **error) -{ - CdCache *cache; - char *mountpoint = NULL, *device, *local; - GnomeVFSVolumeMonitor *mon; - GnomeVFSDrive *drive = NULL; -#ifdef HAVE_HAL - LibHalContext *ctx = NULL; -#endif - gboolean found; - - if (g_str_has_prefix (dev, "file://") != FALSE) - local = g_filename_from_uri (dev, NULL, NULL); - else - local = g_strdup (dev); - - g_assert (local != NULL); - - if (g_file_test (local, G_FILE_TEST_IS_DIR) != FALSE) { - cache = g_new0 (CdCache, 1); - cache->mountpoint = local; - cache->is_media = FALSE; - - return cache; - } - - /* retrieve mountpoint from gnome-vfs volumes and drives */ - device = totem_resolve_symlink (local, error); - g_free (local); - if (!device) - return NULL; - mon = gnome_vfs_get_volume_monitor (); - found = cd_cache_get_dev_from_drives (mon, device, &mountpoint, &drive); - if (!found) { - drive = NULL; - found = cd_cache_get_dev_from_volumes (mon, device, &mountpoint); - } - - if (!found) { - g_set_error (error, 0, 0, - _("Failed to find mountpoint for device %s"), - device); - g_free (device); - return NULL; - } - -#ifdef HAVE_HAL - ctx = cd_cache_new_hal_ctx (); - if (!ctx) { - g_set_error (error, 0, 0, - _("Could not connect to the HAL daemon")); - g_free (device); - return NULL; - } -#endif - - /* create struture */ - cache = g_new0 (CdCache, 1); - cache->device = device; - cache->mountpoint = mountpoint; - cache->self_mounted = FALSE; - cache->drive = drive; - cache->is_media = TRUE; -#ifdef HAVE_HAL - cache->ctx = ctx; -#endif - - g_free (device); - - return cache; -} - -#ifndef HAVE_HAL -static gboolean -cd_cache_has_medium (CdCache *cache) -{ - return TRUE; -} -#endif - -#ifdef HAVE_HAL -static gboolean -cd_cache_has_medium (CdCache *cache) -{ - char **devices; - int num_devices; - char *udi; - gboolean retval = FALSE; - DBusError error; - - if (cache->drive == NULL) - return FALSE; - - udi = gnome_vfs_drive_get_hal_udi (cache->drive); - if (udi == NULL) - return FALSE; - - dbus_error_init (&error); - devices = libhal_manager_find_device_string_match (cache->ctx, - "info.parent", udi, &num_devices, &error); - if (devices != NULL && num_devices >= 1) - retval = TRUE; - - if (dbus_error_is_set (&error)) { - g_warning ("Error getting the children: %s", error.message); - dbus_error_free (&error); - g_free (udi); - return FALSE; - } - - if (retval == FALSE) { - dbus_bool_t volume; - - if (libhal_device_property_exists (cache->ctx, - udi, "volume.is_disc", NULL) == FALSE) { - g_free (udi); - return FALSE; - } - - volume = libhal_device_get_property_bool (cache->ctx, - udi, "volume.is_disc", &error); - if (dbus_error_is_set (&error)) { - g_warning ("Error checking whether the volume is a disc: %s", - error.message); - dbus_error_free (&error); - g_free (udi); - return FALSE; - } - retval = TRUE; - cache->disc_udi = udi; - } else { - g_free (udi); - } - - if (devices != NULL) - libhal_free_string_array (devices); - - return retval; -} -#endif - -static gboolean -cd_cache_open_device (CdCache *cache, - GError **error) -{ - /* not a medium? */ - if (cache->is_media == FALSE || cache->has_medium != FALSE) { - return TRUE; - } - - if (cd_cache_has_medium (cache) == FALSE) { - g_set_error (error, 0, 0, - _("Please check that a disc is present in the drive.")); - return FALSE; - } - cache->has_medium = TRUE; - - return TRUE; -} - -typedef struct _CdCacheCallbackData { - CdCache *cache; - gboolean called; -} CdCacheCallbackData; - -static void -cb_mount_done (gboolean success, char * error, - char * detail, CdCacheCallbackData * data) -{ - data->called = TRUE; - data->cache->mounted = success != FALSE; -} - -static gboolean -cd_cache_open_mountpoint (CdCache *cache, - GError **error) -{ - CdCacheCallbackData data; - - /* already opened? */ - if (cache->mounted || cache->is_media == FALSE) - return TRUE; - - /* check for mounting - assume we'll mount ourselves */ - if (cache->drive == NULL) - return TRUE; - cache->self_mounted = !gnome_vfs_drive_is_mounted (cache->drive); - - /* mount if we have to */ - if (cache->self_mounted) { - /* mount - wait for callback */ - data.called = FALSE; - data.cache = cache; - gnome_vfs_drive_mount (cache->drive, - (GnomeVFSVolumeOpCallback) cb_mount_done, &data); - while (!data.called) g_main_context_iteration (NULL, TRUE); - - if (!cache->mounted) { - g_set_error (error, 0, 0, - _("Failed to mount %s"), cache->device); - return FALSE; - } - } - - if (!cache->mountpoint) { - GList *vol, *item; - - for (vol = item = gnome_vfs_drive_get_mounted_volumes (cache->drive); - item != NULL; item = item->next) { - char *mnt = gnome_vfs_volume_get_activation_uri (item->data); - - if (mnt && strncmp (mnt, "file://", 7) == 0) { - cache->mountpoint = g_strdup (mnt + 7); - g_free (mnt); - break; - } - g_free (mnt); - } - g_list_foreach (vol, (GFunc) gnome_vfs_volume_unref, NULL); - g_list_free (vol); - - if (!cache->mountpoint) { - g_set_error (error, 0, 0, - _("Failed to find mountpoint for %s"), cache->device); - return FALSE; - } - } - - return TRUE; -} - -static void -cd_cache_free (CdCache *cache) -{ -#ifdef HAVE_HAL - if (cache->ctx != NULL) { - DBusConnection *conn; - - conn = libhal_ctx_get_dbus_connection (cache->ctx); - libhal_ctx_shutdown (cache->ctx, NULL); - libhal_ctx_free(cache->ctx); - /* Close the connection before doing the last unref */ - dbus_connection_close (conn); - dbus_connection_unref (conn); - - g_free (cache->disc_udi); - } -#endif /* HAVE_HAL */ - - /* free mem */ - if (cache->drive) - gnome_vfs_drive_unref (cache->drive); - g_free (cache->mountpoint); - g_free (cache->device); - g_free (cache); -} - -static TotemDiscMediaType -cd_cache_disc_is_cdda (CdCache *cache, - GError **error) -{ - TotemDiscMediaType type; - - /* We can't have audio CDs on disc, yet */ - if (cache->is_media == FALSE) - return MEDIA_TYPE_DATA; - if (!cd_cache_open_device (cache, error)) - return MEDIA_TYPE_ERROR; - -#ifdef HAVE_HAL - { - DBusError error; - dbus_bool_t is_cdda; - - dbus_error_init (&error); - - is_cdda = libhal_device_get_property_bool (cache->ctx, - cache->disc_udi, "volume.disc.has_audio", &error); - type = is_cdda ? MEDIA_TYPE_CDDA : MEDIA_TYPE_DATA; - - if (dbus_error_is_set (&error)) { - g_warning ("Error checking whether the volume is an audio CD: %s", - error.message); - dbus_error_free (&error); - return MEDIA_TYPE_ERROR; - } - return type; - } -#else - { - GList *vol, *item; - - type = MEDIA_TYPE_DATA; - - for (vol = item = gnome_vfs_drive_get_mounted_volumes (cache->drive); - item != NULL; item = item->next) { - char *mnt = gnome_vfs_volume_get_activation_uri (item->data); - if (mnt && strncmp (mnt, "cdda://", 7) == 0) { - g_free (mnt); - type = MEDIA_TYPE_CDDA; - break; - } - g_free (mnt); - } - g_list_foreach (vol, (GFunc) gnome_vfs_volume_unref, NULL); - g_list_free (vol); - } - - return type; -#endif -} - -static gboolean -cd_cache_file_exists (CdCache *cache, const char *subdir, const char *filename) -{ - char *path, *dir; - gboolean ret; - - dir = NULL; - - /* Check whether the directory exists, for a start */ - path = g_build_filename (cache->mountpoint, subdir, NULL); - ret = g_file_test (path, G_FILE_TEST_IS_DIR); - if (ret == FALSE) { - char *subdir_low; - - g_free (path); - subdir_low = g_ascii_strdown (subdir, -1); - path = g_build_filename (cache->mountpoint, subdir_low, NULL); - ret = g_file_test (path, G_FILE_TEST_IS_DIR); - g_free (path); - if (ret) { - dir = subdir_low; - } else { - g_free (subdir_low); - return FALSE; - } - } else { - g_free (path); - dir = g_strdup (subdir); - } - - /* And now the file */ - path = g_build_filename (cache->mountpoint, dir, filename, NULL); - ret = g_file_test (path, G_FILE_TEST_IS_REGULAR); - if (ret == FALSE) { - char *fname_low; - - g_free (path); - fname_low = g_ascii_strdown (filename, -1); - path = g_build_filename (cache->mountpoint, dir, fname_low, NULL); - ret = g_file_test (path, G_FILE_TEST_IS_REGULAR); - g_free (fname_low); - } - - g_free (dir); - g_free (path); - - return ret; -} - -static TotemDiscMediaType -cd_cache_disc_is_vcd (CdCache *cache, - GError **error) -{ - /* open disc and open mount */ - if (!cd_cache_open_device (cache, error)) - return MEDIA_TYPE_ERROR; - if (!cd_cache_open_mountpoint (cache, error)) - return MEDIA_TYPE_ERROR; - if (!cache->mountpoint) - return MEDIA_TYPE_ERROR; -#ifdef HAVE_HAL - if (cache->is_media != FALSE) { - DBusError error; - dbus_bool_t is_vcd; - - dbus_error_init (&error); - - is_vcd = libhal_device_get_property_bool (cache->ctx, - cache->disc_udi, "volume.disc.is_vcd", &error); - - if (dbus_error_is_set (&error)) { - g_warning ("Error checking whether the volume is a VCD: %s", - error.message); - dbus_error_free (&error); - return MEDIA_TYPE_ERROR; - } - if (is_vcd != FALSE) - return MEDIA_TYPE_VCD; - is_vcd = libhal_device_get_property_bool (cache->ctx, - cache->disc_udi, "volume.disc.is_svcd", &error); - - if (dbus_error_is_set (&error)) { - g_warning ("Error checking whether the volume is an SVCD: %s", - error.message); - dbus_error_free (&error); - return MEDIA_TYPE_ERROR; - } - return is_vcd ? MEDIA_TYPE_VCD : MEDIA_TYPE_DATA; - } -#endif - /* first is VCD, second is SVCD */ - if (cd_cache_file_exists (cache, "MPEGAV", "AVSEQ01.DAT") || - cd_cache_file_exists (cache, "MPEG2", "AVSEQ01.MPG")) - return MEDIA_TYPE_VCD; - - return MEDIA_TYPE_DATA; -} - -static TotemDiscMediaType -cd_cache_disc_is_dvd (CdCache *cache, - GError **error) -{ - /* open disc, check capabilities and open mount */ - if (!cd_cache_open_device (cache, error)) - return MEDIA_TYPE_ERROR; - if (!cd_cache_open_mountpoint (cache, error)) - return MEDIA_TYPE_ERROR; - if (!cache->mountpoint) - return MEDIA_TYPE_ERROR; -#ifdef HAVE_HAL - if (cache->is_media != FALSE) { - DBusError error; - dbus_bool_t is_dvd; - - dbus_error_init (&error); - - is_dvd = libhal_device_get_property_bool (cache->ctx, - cache->disc_udi, "volume.disc.is_videodvd", &error); - - if (dbus_error_is_set (&error)) { - g_warning ("Error checking whether the volume is a DVD: %s", - error.message); - dbus_error_free (&error); - return MEDIA_TYPE_ERROR; - } - return is_dvd ? MEDIA_TYPE_DVD : MEDIA_TYPE_DATA; - } -#endif - if (cd_cache_file_exists (cache, "VIDEO_TS", "VIDEO_TS.IFO")) - return MEDIA_TYPE_DVD; - - return MEDIA_TYPE_DATA; -} - -char * -totem_cd_mrl_from_type (const char *scheme, const char *dir) -{ - char *retval; - - if (g_str_has_prefix (dir, "file://") != FALSE) { - char *local; - local = g_filename_from_uri (dir, NULL, NULL); - retval = g_strdup_printf ("%s://%s", scheme, local); - g_free (local); - } else { - retval = g_strdup_printf ("%s://%s", scheme, dir); - } - return retval; -} - -static char * -totem_cd_dir_get_parent (const char *dir) -{ - GnomeVFSURI *uri, *parent_uri; - char *parent; - - uri = gnome_vfs_uri_new (dir); - if (uri == NULL) - return NULL; - parent_uri = gnome_vfs_uri_get_parent (uri); - gnome_vfs_uri_unref (uri); - if (parent_uri == NULL) - return NULL; - parent = gnome_vfs_uri_to_string (parent_uri, GNOME_VFS_URI_HIDE_NONE); - gnome_vfs_uri_unref (parent_uri); - - return parent; -} - -TotemDiscMediaType -totem_cd_detect_type_from_dir (const char *dir, char **url, GError **error) -{ - CdCache *cache; - TotemDiscMediaType type; - - g_return_val_if_fail (dir != NULL, MEDIA_TYPE_ERROR); - - if (dir[0] != '/' && g_str_has_prefix (dir, "file://") == FALSE) - return MEDIA_TYPE_ERROR; - - if (!(cache = cd_cache_new (dir, error))) - return MEDIA_TYPE_ERROR; - if ((type = cd_cache_disc_is_vcd (cache, error)) == MEDIA_TYPE_DATA && - (type = cd_cache_disc_is_dvd (cache, error)) == MEDIA_TYPE_DATA) { - /* is it the directory itself? */ - char *parent; - - cd_cache_free (cache); - parent = totem_cd_dir_get_parent (dir); - if (!parent) - return type; - - cache = cd_cache_new (parent, error); - g_free (parent); - if (!cache) - return MEDIA_TYPE_ERROR; - if ((type = cd_cache_disc_is_vcd (cache, error)) == MEDIA_TYPE_DATA && - (type = cd_cache_disc_is_dvd (cache, error)) == MEDIA_TYPE_DATA) { - /* crap, nothing found */ - cd_cache_free (cache); - return type; - } - } - - if (url == NULL) { - cd_cache_free (cache); - return type; - } - - if (type == MEDIA_TYPE_DVD) { - *url = totem_cd_mrl_from_type ("dvd", cache->mountpoint); - } else if (type == MEDIA_TYPE_VCD) { - *url = totem_cd_mrl_from_type ("vcd", cache->mountpoint); - } - - cd_cache_free (cache); - - return type; -} - -TotemDiscMediaType -totem_cd_detect_type_with_url (const char *device, - char **url, - GError **error) -{ - CdCache *cache; - TotemDiscMediaType type; - - if (url != NULL) - *url = NULL; - - if (!(cache = cd_cache_new (device, error))) - return MEDIA_TYPE_ERROR; - - type = cd_cache_disc_is_cdda (cache, error); - if (type == MEDIA_TYPE_ERROR && *error != NULL) { - cd_cache_free (cache); - return type; - } - - if ((type == MEDIA_TYPE_DATA || type == MEDIA_TYPE_ERROR) && - (type = cd_cache_disc_is_vcd (cache, error)) == MEDIA_TYPE_DATA && - (type = cd_cache_disc_is_dvd (cache, error)) == MEDIA_TYPE_DATA) { - /* crap, nothing found */ - } - - if (url == NULL) { - cd_cache_free (cache); - return type; - } - - switch (type) { - case MEDIA_TYPE_DVD: - *url = totem_cd_mrl_from_type ("dvd", cache->mountpoint ? - cache->mountpoint : device); - break; - case MEDIA_TYPE_VCD: - *url = totem_cd_mrl_from_type ("vcd", cache->mountpoint ? - cache->mountpoint : device); - break; - case MEDIA_TYPE_CDDA: - *url = totem_cd_mrl_from_type ("cdda", cache->device ? - cache->device : device); - break; - case MEDIA_TYPE_DATA: - *url = g_strdup (cache->mountpoint); - break; - default: - break; - } - - cd_cache_free (cache); - - return type; -} - -TotemDiscMediaType -totem_cd_detect_type (const char *device, - GError **error) -{ - return totem_cd_detect_type_with_url (device, NULL, error); -} - -gboolean -totem_cd_has_medium (const char *device) -{ - CdCache *cache; - gboolean retval = TRUE; - - if (!(cache = cd_cache_new (device, NULL))) - return TRUE; - - retval = cd_cache_has_medium (cache); - cd_cache_free (cache); - - return retval; -} - -const char * -totem_cd_get_human_readable_name (TotemDiscMediaType type) -{ - switch (type) - { - case MEDIA_TYPE_CDDA: - return N_("Audio CD"); - case MEDIA_TYPE_VCD: - return N_("Video CD"); - case MEDIA_TYPE_DVD: - return N_("DVD"); - case MEDIA_TYPE_DVB: - return N_("Digital Television"); - default: - g_assert_not_reached (); - } - - return NULL; -} - -/* - * vim: sw=2 ts=8 cindent noai bs=2 - */ diff --git a/plparse/totem-disc.h b/plparse/totem-disc.h deleted file mode 100644 index 7efb67250..000000000 --- a/plparse/totem-disc.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Totem Disc Content Detection - * (c) 2004 Ronald Bultje <rbultje@ronald.bitfreak.net> - * - * totem-disc.h: media content detection - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef TOTEM_DISC_H -#define TOTEM_DISC_H - -#include <glib.h> - -G_BEGIN_DECLS - -typedef enum { - MEDIA_TYPE_ERROR = -1, /* error */ - MEDIA_TYPE_DATA = 1, - MEDIA_TYPE_CDDA, - MEDIA_TYPE_VCD, - MEDIA_TYPE_DVD, - MEDIA_TYPE_DVB, - MEDIA_TYPE_NUM_TYPES -} TotemDiscMediaType; - -#define MediaType TotemDiscMediaType - -TotemDiscMediaType totem_cd_detect_type (const char *device, - GError **error); -TotemDiscMediaType totem_cd_detect_type_with_url (const char *device, - char **url, - GError **error); -TotemDiscMediaType totem_cd_detect_type_from_dir (const char *dir, - char **url, - GError **error); -const char * totem_cd_get_human_readable_name (TotemDiscMediaType type); -char * totem_cd_mrl_from_type (const char *scheme, const char *dir); -gboolean totem_cd_has_medium (const char *device); - -G_END_DECLS - -#endif /* TOTEM_DISC_H */ diff --git a/plparse/totem-pl-parser-features.h.in b/plparse/totem-pl-parser-features.h.in deleted file mode 100644 index c739765f1..000000000 --- a/plparse/totem-pl-parser-features.h.in +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- - * - * Copyright (C) 2006 William Jon McCann <mccann@jhu.edu> - * - * 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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - */ - -#ifndef __TOTEM_PL_PARSER_VERSION_H__ -#define __TOTEM_PL_PARSER_VERSION_H__ - -/* compile time version - */ -#define TOTEM_PL_PARSER_VERSION_MAJOR (@TOTEM_PL_PARSER_VERSION_MAJOR@) -#define TOTEM_PL_PARSER_VERSION_MINOR (@TOTEM_PL_PARSER_VERSION_MINOR@) -#define TOTEM_PL_PARSER_VERSION_MICRO (@TOTEM_PL_PARSER_VERSION_MICRO@) - -/* check whether a version equal to or greater than - * major.minor.micro is present. - */ -#define TOTEM_PL_PARSER_CHECK_VERSION(major,minor,micro) \ - (TOTEM_PL_PARSER_VERSION_MAJOR > (major) || \ - (TOTEM_PL_PARSER_VERSION_MAJOR == (major) && TOTEM_PL_PARSER_VERSION_MINOR > (minor)) || \ - (TOTEM_PL_PARSER_VERSION_MAJOR == (major) && TOTEM_PL_PARSER_VERSION_MINOR == (minor) && \ - TOTEM_PL_PARSER_VERSION_MICRO >= (micro))) - - -#endif /* __TOTEM_PL_PARSER_VERSION_H__ */ - diff --git a/plparse/totem-pl-parser-lines.c b/plparse/totem-pl-parser-lines.c deleted file mode 100644 index 14a543619..000000000 --- a/plparse/totem-pl-parser-lines.c +++ /dev/null @@ -1,526 +0,0 @@ -/* - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Bastien Nocera - Copyright (C) 2003, 2004 Colin Walters <walters@rhythmbox.org> - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera <hadess@hadess.net> - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include <string.h> -#include <glib.h> - -#ifndef TOTEM_PL_PARSER_MINI -#include <glib/gi18n-lib.h> -#include <gtk/gtk.h> -#include <libgnomevfs/gnome-vfs.h> -#include "totem-pl-parser.h" -#include "totemplparser-marshal.h" -#include "totem-pl-parser-pls.h" -#endif /* !TOTEM_PL_PARSER_MINI */ - -#include "totem-pl-parser-mini.h" -#include "totem-pl-parser-lines.h" -#include "totem-pl-parser-private.h" - -#ifndef TOTEM_PL_PARSER_MINI - -#define EXTINF "#EXTINF:" - -static char * -totem_pl_parser_url_to_dos (const char *url, const char *output) -{ - char *retval, *i; - - retval = totem_pl_parser_relative (url, output); - - if (retval == NULL) - retval = g_strdup (url); - - /* Don't change URIs, but change smb:// */ - if (g_str_has_prefix (retval, "smb://") != FALSE) - { - char *tmp; - tmp = g_strdup (retval + strlen ("smb:")); - g_free (retval); - retval = tmp; - } - - if (strstr (retval, "://") != NULL) - return retval; - - i = retval; - while (*i != '\0') - { - if (*i == '/') - *i = '\\'; - i++; - } - - return retval; -} - -gboolean -totem_pl_parser_write_m3u (TotemPlParser *parser, GtkTreeModel *model, - TotemPlParserIterFunc func, const char *output, - gboolean dos_compatible, gpointer user_data, GError **error) -{ - GnomeVFSHandle *handle; - GnomeVFSResult res; - int num_entries_total, i; - gboolean success; - char *buf; - char *cr; - - res = gnome_vfs_open (&handle, output, GNOME_VFS_OPEN_WRITE); - if (res == GNOME_VFS_ERROR_NOT_FOUND) { - res = gnome_vfs_create (&handle, output, - GNOME_VFS_OPEN_WRITE, FALSE, - GNOME_VFS_PERM_USER_WRITE - | GNOME_VFS_PERM_USER_READ - | GNOME_VFS_PERM_GROUP_READ); - } - - if (res != GNOME_VFS_OK) { - g_set_error(error, - TOTEM_PL_PARSER_ERROR, - TOTEM_PL_PARSER_ERROR_VFS_OPEN, - _("Couldn't open file '%s': %s"), - output, gnome_vfs_result_to_string (res)); - return FALSE; - } - - cr = dos_compatible ? "\r\n" : "\n"; - num_entries_total = gtk_tree_model_iter_n_children (model, NULL); - if (num_entries_total == 0) - return TRUE; - - for (i = 1; i <= num_entries_total; i++) { - GtkTreeIter iter; - char *url, *title, *path2; - gboolean custom_title; - - if (gtk_tree_model_iter_nth_child (model, &iter, NULL, i - 1) == FALSE) - continue; - - func (model, &iter, &url, &title, &custom_title, user_data); - - if (totem_pl_parser_scheme_is_ignored (parser, url) != FALSE) - { - g_free (url); - g_free (title); - continue; - } - - if (custom_title != FALSE) { - buf = g_strdup_printf (EXTINF",%s%s", title, cr); - success = totem_pl_parser_write_string (handle, buf, error); - g_free (buf); - if (success == FALSE) { - g_free (title); - g_free (url); - gnome_vfs_close (handle); - return FALSE; - } - } - g_free (title); - - if (dos_compatible == FALSE) { - char *tmp; - tmp = totem_pl_parser_relative (url, output); - if (tmp == NULL && g_str_has_prefix (url, "file:")) { - path2 = g_filename_from_uri (url, NULL, NULL); - } else { - path2 = tmp; - } - } else { - path2 = totem_pl_parser_url_to_dos (url, output); - } - - buf = g_strdup_printf ("%s%s", path2 ? path2 : url, cr); - g_free (path2); - g_free (url); - - success = totem_pl_parser_write_string (handle, buf, error); - g_free (buf); - - if (success == FALSE) - { - gnome_vfs_close (handle); - return FALSE; - } - } - - gnome_vfs_close (handle); - - return TRUE; -} - -static void -totem_pl_parser_parse_ram_url (TotemPlParser *parser, const char *url) -{ - char *mark, **params; - GString *str; - guint i, num_params; - char *title, *author, *copyright, *abstract, *screensize, *mode, *start, *end; - - if (g_str_has_prefix (url, "rtsp://") == FALSE - && g_str_has_prefix (url, "pnm://") == FALSE) { - totem_pl_parser_add_one_url (parser, url, NULL); - return; - } - - /* Look for "?" */ - mark = strstr (url, "?"); - if (mark == NULL) { - totem_pl_parser_add_one_url (parser, url, NULL); - return; - } - - if (mark[1] == '\0') { - char *new_url; - - new_url = g_strndup (url, mark + 1 - url); - totem_pl_parser_add_one_url (parser, new_url, NULL); - g_free (new_url); - return; - } - - title = author = copyright = abstract = screensize = mode = end = start = NULL; - num_params = 0; - - str = g_string_new_len (url, mark - url); - params = g_strsplit (mark + 1, "&", -1); - for (i = 0; params[i] != NULL; i++) { - if (g_str_has_prefix (params[i], "title=") != FALSE) { - title = params[i] + strlen ("title="); - } else if (g_str_has_prefix (params[i], "author=") != FALSE) { - author = params[i] + strlen ("author="); - } else if (g_str_has_prefix (params[i], "copyright=") != FALSE) { - copyright = params[i] + strlen ("copyright="); - } else if (g_str_has_prefix (params[i], "abstract=") != FALSE) { - abstract = params[i] + strlen ("abstract="); - } else if (g_str_has_prefix (params[i], "screensize=") != FALSE) { - screensize = params[i] + strlen ("screensize="); - } else if (g_str_has_prefix (params[i], "mode=") != FALSE) { - mode = params[i] + strlen ("mode="); - } else if (g_str_has_prefix (params[i], "end=") != FALSE) { - end = params[i] + strlen ("end="); - } else if (g_str_has_prefix (params[i], "start=") != FALSE) { - start = params[i] + strlen ("start="); - } else { - if (num_params == 0) - g_string_append_c (str, '?'); - else - g_string_append_c (str, '&'); - g_string_append (str, params[i]); - num_params++; - } - } - - totem_pl_parser_add_url (parser, - TOTEM_PL_PARSER_FIELD_URL, str->str, - TOTEM_PL_PARSER_FIELD_TITLE, title, - TOTEM_PL_PARSER_FIELD_AUTHOR, author, - TOTEM_PL_PARSER_FIELD_COPYRIGHT, copyright, - TOTEM_PL_PARSER_FIELD_ABSTRACT, abstract, - TOTEM_PL_PARSER_FIELD_SCREENSIZE, screensize, - TOTEM_PL_PARSER_FIELD_UI_MODE, mode, - TOTEM_PL_PARSER_FIELD_STARTTIME, start, - TOTEM_PL_PARSER_FIELD_ENDTIME, end, - NULL); - - g_string_free (str, TRUE); - g_strfreev (params); -} - -TotemPlParserResult -totem_pl_parser_add_ram (TotemPlParser *parser, const char *url, gpointer data) -{ - gboolean retval = TOTEM_PL_PARSER_RESULT_UNHANDLED; - char *contents, **lines; - int size, i; - const char *split_char; - - if (gnome_vfs_read_entire_file (url, &size, &contents) != GNOME_VFS_OK) - return TOTEM_PL_PARSER_RESULT_ERROR; - - /* figure out whether we're a unix or dos RAM file */ - if (strstr(contents,"\x0d") == NULL) - split_char = "\n"; - else - split_char = "\x0d\n"; - - lines = g_strsplit (contents, split_char, 0); - g_free (contents); - - for (i = 0; lines[i] != NULL; i++) { - /* Empty line */ - if (totem_pl_parser_line_is_empty (lines[i]) != FALSE) - continue; - - retval = TOTEM_PL_PARSER_RESULT_SUCCESS; - - /* Either it's a URI, or it has a proper path ... */ - if (strstr(lines[i], "://") != NULL - || lines[i][0] == G_DIR_SEPARATOR) { - /* .ram files can contain .smil entries */ - if (totem_pl_parser_parse_internal (parser, lines[i], NULL) != TOTEM_PL_PARSER_RESULT_SUCCESS) { - totem_pl_parser_parse_ram_url (parser, lines[i]); - } - } else if (strcmp (lines[i], "--stop--") == 0) { - /* For Real Media playlists, handle the stop command */ - break; - } else { - char *base; - - /* Try with a base */ - base = totem_pl_parser_base_url (url); - - if (totem_pl_parser_parse_internal (parser, lines[i], base) != TOTEM_PL_PARSER_RESULT_SUCCESS) - { - char *fullpath; - fullpath = g_strdup_printf ("%s/%s", base, lines[i]); - totem_pl_parser_parse_ram_url (parser, fullpath); - g_free (fullpath); - } - g_free (base); - } - } - - g_strfreev (lines); - - return retval; -} - -static const char * -totem_pl_parser_get_extinfo_title (gboolean extinfo, char **lines, int i) -{ - const char *extinf, *sep; - - if (extinfo == FALSE || lines == NULL || i <= 0) - return NULL; - - /* It's bound to have an EXTINF if we have extinfo */ - extinf = lines[i-1] + strlen(EXTINF); - if (extinf[0] == '\0') - return NULL; - - /* Handle ':' as a field separator */ - sep = strstr (extinf, ":"); - if (sep != NULL && sep[1] != '\0') { - sep++; - return sep; - } - - /* Handle ',' as a field separator */ - sep = strstr (extinf, ","); - if (sep == NULL || sep[1] == '\0') { - if (extinf[1] == '\0') - return NULL; - return extinf; - } - - sep++; - return sep; -} - -static char * -totem_pl_parser_append_path (const char *base, const char *path) -{ - GnomeVFSURI *new, *baseuri; - char *fullpath; - - baseuri = gnome_vfs_uri_new (base); - if (baseuri == NULL) - goto bail; - new = gnome_vfs_uri_append_path (baseuri, path); - gnome_vfs_uri_unref (baseuri); - if (new == NULL) - goto bail; - fullpath = gnome_vfs_uri_to_string (new, 0); - gnome_vfs_uri_unref (new); - - return fullpath; - -bail: - return g_strdup_printf ("%s/%s", base, path); -} - -TotemPlParserResult -totem_pl_parser_add_m3u (TotemPlParser *parser, const char *url, - const char *_base, gpointer data) -{ - TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED; - char *contents, **lines; - int size, i; - const char *split_char; - gboolean extinfo; - - if (gnome_vfs_read_entire_file (url, &size, &contents) != GNOME_VFS_OK) - return TOTEM_PL_PARSER_RESULT_ERROR; - - /* .pls files with a .m3u extension, the nasties */ - if (g_str_has_prefix (contents, "[playlist]") != FALSE - || g_str_has_prefix (contents, "[Playlist]") != FALSE - || g_str_has_prefix (contents, "[PLAYLIST]") != FALSE) { - retval = totem_pl_parser_add_pls_with_contents (parser, url, _base, contents); - g_free (contents); - return retval; - } - - /* is TRUE if there's an EXTINF on the previous line */ - extinfo = FALSE; - - /* figure out whether we're a unix m3u or dos m3u */ - if (strstr(contents,"\x0d") == NULL) - split_char = "\n"; - else - split_char = "\x0d\n"; - - lines = g_strsplit (contents, split_char, 0); - g_free (contents); - - for (i = 0; lines[i] != NULL; i++) { - if (lines[i][0] == '\0') - continue; - - retval = TOTEM_PL_PARSER_RESULT_SUCCESS; - - /* Ignore comments, but mark it if we have extra info */ - if (lines[i][0] == '#') { - extinfo = g_str_has_prefix (lines[i], EXTINF); - continue; - } - - /* Either it's a URI, or it has a proper path ... */ - if (strstr(lines[i], "://") != NULL - || lines[i][0] == G_DIR_SEPARATOR) { - if (totem_pl_parser_parse_internal (parser, lines[i], NULL) != TOTEM_PL_PARSER_RESULT_SUCCESS) { - totem_pl_parser_add_one_url (parser, lines[i], - totem_pl_parser_get_extinfo_title (extinfo, lines, i)); - } - extinfo = FALSE; - } else if (g_ascii_isalpha (lines[i][0]) != FALSE - && g_str_has_prefix (lines[i] + 1, ":\\")) { - /* Path relative to a drive on Windows, we need to use - * the base that was passed to us */ - char *fullpath; - - lines[i] = g_strdelimit (lines[i], "\\", '/'); - /* + 2, skip drive letter */ - fullpath = totem_pl_parser_append_path (_base, lines[i] + 2); - totem_pl_parser_add_one_url (parser, fullpath, - totem_pl_parser_get_extinfo_title (extinfo, lines, i)); - g_free (fullpath); - extinfo = FALSE; - } else if (lines[i][0] == '\\' && lines[i][1] == '\\') { - /* ... Or it's in the windows smb form - * (\\machine\share\filename), Note drive names - * (C:\ D:\ etc) are unhandled (unknown base for - * drive letters) */ - char *tmpurl; - - lines[i] = g_strdelimit (lines[i], "\\", '/'); - tmpurl = g_strjoin (NULL, "smb:", lines[i], NULL); - - totem_pl_parser_add_one_url (parser, lines[i], - totem_pl_parser_get_extinfo_title (extinfo, lines, i)); - extinfo = FALSE; - - g_free (tmpurl); - } else { - /* Try with a base */ - char *fullpath, *base, sep; - - base = totem_pl_parser_base_url (url); - sep = (split_char[0] == '\n' ? '/' : '\\'); - if (sep == '\\') - lines[i] = g_strdelimit (lines[i], "\\", '/'); - fullpath = totem_pl_parser_append_path (base, lines[i]); - totem_pl_parser_add_one_url (parser, fullpath, - totem_pl_parser_get_extinfo_title (extinfo, lines, i)); - g_free (fullpath); - g_free (base); - extinfo = FALSE; - } - } - - g_strfreev (lines); - - return retval; -} - -TotemPlParserResult -totem_pl_parser_add_ra (TotemPlParser *parser, const char *url, - const char *base, gpointer data) -{ - if (data == NULL || totem_pl_parser_is_uri_list (data, strlen (data)) == FALSE) { - totem_pl_parser_add_one_url (parser, url, NULL); - return TOTEM_PL_PARSER_RESULT_SUCCESS; - } - - return totem_pl_parser_add_ram (parser, url, NULL); -} - - -#endif /* !TOTEM_PL_PARSER_MINI */ - -#define CHECK_LEN if (i >= len) { return FALSE; } - -gboolean -totem_pl_parser_is_uri_list (const char *data, gsize len) -{ - guint i = 0; - - /* Find the first bits of text */ - while (data[i] == '\n' || data[i] == '\t' || data[i] == ' ') { - i++; - CHECK_LEN; - } - CHECK_LEN; - - /* scheme always starts with a letter */ - if (g_ascii_isalpha (data[i]) == FALSE) - return FALSE; - while (g_ascii_isalnum (data[i]) != FALSE) { - i++; - CHECK_LEN; - } - - CHECK_LEN; - - /* First non-alphanum character should be a ':' */ - if (data[i] != ':') - return FALSE; - i++; - CHECK_LEN; - - if (data[i] != '/') - return FALSE; - i++; - CHECK_LEN; - - if (data[i] != '/') - return FALSE; - - return TRUE; -} - diff --git a/plparse/totem-pl-parser-lines.h b/plparse/totem-pl-parser-lines.h deleted file mode 100644 index 01b864716..000000000 --- a/plparse/totem-pl-parser-lines.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - 2002, 2003, 2004, 2005, 2006, 2007 Bastien Nocera - Copyright (C) 2003 Colin Walters <walters@verbum.org> - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera <hadess@hadess.net> - */ - -#ifndef TOTEM_PL_PARSER_LINES_H -#define TOTEM_PL_PARSER_LINES_H - -G_BEGIN_DECLS - -#ifndef TOTEM_PL_PARSER_MINI -#include "totem-pl-parser.h" -#else -#include "totem-pl-parser-mini.h" -#endif /* !TOTEM_PL_PARSER_MINI */ - -gboolean totem_pl_parser_is_uri_list (const char *data, gsize len); - -#ifndef TOTEM_PL_PARSER_MINI -gboolean totem_pl_parser_write_m3u (TotemPlParser *parser, - GtkTreeModel *model, - TotemPlParserIterFunc func, - const char *output, - gboolean dos_compatible, - gpointer user_data, - GError **error); -TotemPlParserResult totem_pl_parser_add_ram (TotemPlParser *parser, - const char *url, - gpointer data); -TotemPlParserResult totem_pl_parser_add_m3u (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data); -TotemPlParserResult totem_pl_parser_add_ra (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data); -#endif /* !TOTEM_PL_PARSER_MINI */ - -G_END_DECLS - -#endif /* TOTEM_PL_PARSER_LINES_H */ diff --git a/plparse/totem-pl-parser-media.c b/plparse/totem-pl-parser-media.c deleted file mode 100644 index fdc55e445..000000000 --- a/plparse/totem-pl-parser-media.c +++ /dev/null @@ -1,274 +0,0 @@ -/* - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Bastien Nocera - Copyright (C) 2003, 2004 Colin Walters <walters@rhythmbox.org> - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera <hadess@hadess.net> - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - - -#ifndef TOTEM_PL_PARSER_MINI -#include <string.h> -#include <glib.h> -#include <gtk/gtk.h> -#include <libgnomevfs/gnome-vfs.h> -#include "totem-pl-parser.h" -#include "totemplparser-marshal.h" -#include "totem-disc.h" -#endif /* !TOTEM_PL_PARSER_MINI */ - -#include "totem-pl-parser-mini.h" -#include "totem-pl-parser-media.h" -#include "totem-pl-parser-private.h" - -#ifndef TOTEM_PL_PARSER_MINI -/* Returns NULL if we don't have an ISO image, - * or an empty string if it's non-UTF-8 data */ -static char * -totem_pl_parser_iso_get_title (const char *url) -{ - char *fname; - FILE *file; -#define BUFFER_SIZE 128 - char buf [BUFFER_SIZE+1]; - int res; - char *str; - - fname = g_filename_from_uri (url, NULL, NULL); - if (fname == NULL) - return NULL; - - file = fopen (fname, "rb"); - if (file == NULL) - return NULL; - - /* Verify we have an ISO image */ - /* This check is for the raw sector images */ - res = fseek (file, 37633L, SEEK_SET); - if (res != 0) { - fclose (file); - return NULL; - } - - res = fread (buf, sizeof (char), 5, file); - if (res != 5 || strncmp (buf, "CD001", 5) != 0) { - /* Standard ISO images */ - res = fseek (file, 32769L, SEEK_SET); - if (res != 0) { - fclose (file); - return NULL; - } - res = fread (buf, sizeof (char), 5, file); - if (res != 5 || strncmp (buf, "CD001", 5) != 0) { - /* High Sierra images */ - res = fseek (file, 32776L, SEEK_SET); - if (res != 0) { - fclose (file); - return NULL; - } - res = fread (buf, sizeof (char), 5, file); - if (res != 5 || strncmp (buf, "CDROM", 5) != 0) { - fclose (file); - return NULL; - } - } - } - /* Extract the volume label from the image */ - res = fseek (file, 32808L, SEEK_SET); - if (res != 0) { - fclose (file); - return NULL; - } - res = fread (buf, sizeof(char), BUFFER_SIZE, file); - fclose (file); - if (res != BUFFER_SIZE) - return NULL; - - buf [BUFFER_SIZE] = '\0'; - str = g_strdup (g_strstrip (buf)); - if (!g_utf8_validate (str, -1, NULL)) { - g_free (str); - return g_strdup (""); - } - - return str; -} - -TotemPlParserResult -totem_pl_parser_add_iso (TotemPlParser *parser, const char *url, - const char *base, gpointer data) -{ - GnomeVFSFileInfo *info; - char *item, *label; - - /* This is a hack, it could be a VCD or DVD */ - if (g_str_has_prefix (url, "file://") == FALSE) - return TOTEM_PL_PARSER_RESULT_IGNORED; - - label = totem_pl_parser_iso_get_title (url); - if (label == NULL) { - /* Not an ISO image */ - return TOTEM_PL_PARSER_RESULT_UNHANDLED; - } - if (label[0] == '\0') { - g_free (label); - label = NULL; - } - - info = gnome_vfs_file_info_new (); - if (gnome_vfs_get_file_info (url, info, GNOME_VFS_FILE_INFO_FOLLOW_LINKS) != GNOME_VFS_OK) { - gnome_vfs_file_info_unref (info); - return TOTEM_PL_PARSER_RESULT_IGNORED; - } - - /* Less than 700 megs, and it's a VCD */ - if (info->size < 700 * 1024 * 1024) { - item = totem_cd_mrl_from_type ("vcd", url); - } else { - item = totem_cd_mrl_from_type ("dvd", url); - } - - gnome_vfs_file_info_unref (info); - - totem_pl_parser_add_one_url (parser, item, label); - g_free (label); - g_free (item); - - return TOTEM_PL_PARSER_RESULT_SUCCESS; -} - -TotemPlParserResult -totem_pl_parser_add_cue (TotemPlParser *parser, const char *url, - const char *base, gpointer data) -{ - char *vcdurl; - - vcdurl = totem_cd_mrl_from_type ("vcd", url); - totem_pl_parser_add_one_url (parser, vcdurl, NULL); - g_free (vcdurl); - - return TOTEM_PL_PARSER_RESULT_SUCCESS; -} - -static int -totem_pl_parser_dir_compare (GnomeVFSFileInfo *a, GnomeVFSFileInfo *b) -{ - if (a->name == NULL) { - if (b->name == NULL) - return 0; - else - return -1; - } else { - if (b->name == NULL) - return 1; - else - return strcmp (a->name, b->name); - } -} - -TotemPlParserResult -totem_pl_parser_add_directory (TotemPlParser *parser, const char *url, - const char *base, gpointer data) -{ - TotemDiscMediaType type; - GList *list, *l; - GnomeVFSResult res; - char *media_url; - - type = totem_cd_detect_type_from_dir (url, &media_url, NULL); - if (type != MEDIA_TYPE_DATA && type != MEDIA_TYPE_ERROR) { - if (media_url != NULL) { - char *basename = NULL, *fname; - - fname = g_filename_from_uri (url, NULL, NULL); - if (fname != NULL) { - basename = g_filename_display_basename (fname); - g_free (fname); - } - totem_pl_parser_add_one_url (parser, media_url, basename); - g_free (basename); - g_free (media_url); - return TOTEM_PL_PARSER_RESULT_SUCCESS; - } - } - - res = gnome_vfs_directory_list_load (&list, url, - GNOME_VFS_FILE_INFO_DEFAULT); - if (res != GNOME_VFS_OK) - return TOTEM_PL_PARSER_RESULT_ERROR; - - list = g_list_sort (list, (GCompareFunc) totem_pl_parser_dir_compare); - l = list; - - while (l != NULL) { - char *name, *fullpath; - GnomeVFSFileInfo *info = l->data; - TotemPlParserResult ret; - - if (info->name != NULL && (strcmp (info->name, ".") == 0 - || strcmp (info->name, "..") == 0)) { - l = l->next; - continue; - } - - name = gnome_vfs_escape_string (info->name); - fullpath = g_strconcat (url, "/", name, NULL); - g_free (name); - - ret = totem_pl_parser_parse_internal (parser, fullpath, NULL); - if (ret != TOTEM_PL_PARSER_RESULT_SUCCESS && ret != TOTEM_PL_PARSER_RESULT_IGNORED) - totem_pl_parser_add_one_url (parser, fullpath, NULL); - - l = l->next; - } - - g_list_foreach (list, (GFunc) gnome_vfs_file_info_unref, NULL); - g_list_free (list); - - return TOTEM_PL_PARSER_RESULT_SUCCESS; -} - -TotemPlParserResult -totem_pl_parser_add_block (TotemPlParser *parser, const char *url, - const char *base, gpointer data) -{ - TotemDiscMediaType type; - char *media_url; - GError *err = NULL; - - type = totem_cd_detect_type_with_url (url, &media_url, &err); - if (err != NULL) { - DEBUG(g_print ("Couldn't get CD type for URL '%s': %s\n", url, err->message)); - g_error_free (err); - } - if (type == MEDIA_TYPE_DATA || media_url == NULL) - return TOTEM_PL_PARSER_RESULT_UNHANDLED; - else if (type == MEDIA_TYPE_ERROR) - return TOTEM_PL_PARSER_RESULT_ERROR; - - totem_pl_parser_add_one_url (parser, media_url, NULL); - g_free (media_url); - return TOTEM_PL_PARSER_RESULT_SUCCESS; -} - -#endif /* !TOTEM_PL_PARSER_MINI */ - - diff --git a/plparse/totem-pl-parser-media.h b/plparse/totem-pl-parser-media.h deleted file mode 100644 index 2f9056652..000000000 --- a/plparse/totem-pl-parser-media.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - 2002, 2003, 2004, 2005, 2006, 2007 Bastien Nocera - Copyright (C) 2003 Colin Walters <walters@verbum.org> - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera <hadess@hadess.net> - */ - -#ifndef TOTEM_PL_PARSER_MEDIA_H -#define TOTEM_PL_PARSER_MEDIA_H - -G_BEGIN_DECLS - -#ifndef TOTEM_PL_PARSER_MINI -#include "totem-pl-parser.h" -#endif /* !TOTEM_PL_PARSER_MINI */ - -#ifndef TOTEM_PL_PARSER_MINI -TotemPlParserResult totem_pl_parser_add_iso (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data); -TotemPlParserResult totem_pl_parser_add_cue (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data); -TotemPlParserResult totem_pl_parser_add_directory (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data); -TotemPlParserResult totem_pl_parser_add_block (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data); -#endif /* !TOTEM_PL_PARSER_MINI */ - -G_END_DECLS - -#endif /* TOTEM_PL_PARSER_MEDIA_H */ diff --git a/plparse/totem-pl-parser-mini.h b/plparse/totem-pl-parser-mini.h deleted file mode 100644 index 309e0d592..000000000 --- a/plparse/totem-pl-parser-mini.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - Copyright (C) 2002, 2003, 2004, 2005, 2006 Bastien Nocera - Copyright (C) 2003 Colin Walters <walters@verbum.org> - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera <hadess@hadess.net> - */ - -#ifndef TOTEM_PL_PARSER_MINI_H -#define TOTEM_PL_PARSER_MINI_H - -#include <glib.h> - -G_BEGIN_DECLS - -gboolean totem_pl_parser_can_parse_from_data (const char *data, - gsize len, - gboolean debug); -gboolean totem_pl_parser_can_parse_from_filename (const char *filename, - gboolean debug); - -G_END_DECLS - -#endif /* TOTEM_PL_PARSER_MINI_H */ diff --git a/plparse/totem-pl-parser-misc.c b/plparse/totem-pl-parser-misc.c deleted file mode 100644 index 9cfcda662..000000000 --- a/plparse/totem-pl-parser-misc.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Bastien Nocera - Copyright (C) 2003, 2004 Colin Walters <walters@rhythmbox.org> - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera <hadess@hadess.net> - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include <string.h> -#include <glib.h> -#include <libgnomevfs/gnome-vfs-mime-utils.h> - -#ifndef TOTEM_PL_PARSER_MINI -#include <gtk/gtk.h> -#include <libgnomevfs/gnome-vfs.h> -#include <libgnomevfs/gnome-vfs-mime.h> -#include <libgnomevfs/gnome-vfs-utils.h> -#include "totem-pl-parser.h" -#include "totemplparser-marshal.h" -#include "totem-disc.h" -#endif /* !TOTEM_PL_PARSER_MINI */ - -#include "totem-pl-parser-mini.h" -#include "totem-pl-parser-misc.h" -#include "totem-pl-parser-private.h" - -#ifndef TOTEM_PL_PARSER_MINI -TotemPlParserResult -totem_pl_parser_add_gvp (TotemPlParser *parser, const char *url, - const char *base, gpointer data) -{ - TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED; - char *contents, **lines, *title, *link, *version; - int size; - - if (gnome_vfs_read_entire_file (url, &size, &contents) != GNOME_VFS_OK) - return TOTEM_PL_PARSER_RESULT_ERROR; - - if (g_str_has_prefix (contents, "#.download.the.free.Google.Video.Player") == FALSE && g_str_has_prefix (contents, "# download the free Google Video Player") == FALSE) { - g_free (contents); - return retval; - } - - lines = g_strsplit (contents, "\n", 0); - g_free (contents); - - /* We only handle GVP version 1.1 for now */ - version = totem_pl_parser_read_ini_line_string_with_sep (lines, "gvp_version", FALSE, ":"); - if (version == NULL || strcmp (version, "1.1") != 0) { - g_free (version); - g_strfreev (lines); - return retval; - } - g_free (version); - - link = totem_pl_parser_read_ini_line_string_with_sep (lines, "url", FALSE, ":"); - if (link == NULL) { - g_strfreev (lines); - return retval; - } - - retval = TOTEM_PL_PARSER_RESULT_SUCCESS; - - title = totem_pl_parser_read_ini_line_string_with_sep (lines, "title", FALSE, ":"); - - totem_pl_parser_add_one_url (parser, link, title); - - g_free (link); - g_free (title); - g_strfreev (lines); - - return retval; -} - -TotemPlParserResult -totem_pl_parser_add_desktop (TotemPlParser *parser, const char *url, - const char *base, gpointer data) -{ - char *contents, **lines; - const char *path, *display_name, *type; - int size; - TotemPlParserResult res = TOTEM_PL_PARSER_RESULT_ERROR; - - if (gnome_vfs_read_entire_file (url, &size, &contents) != GNOME_VFS_OK) - return res; - - lines = g_strsplit (contents, "\n", 0); - g_free (contents); - - type = totem_pl_parser_read_ini_line_string (lines, "Type", FALSE); - if (type == NULL) - goto bail; - - if (g_ascii_strcasecmp (type, "Link") != 0 - && g_ascii_strcasecmp (type, "FSDevice") != 0) { - goto bail; - } - - path = totem_pl_parser_read_ini_line_string (lines, "URL", FALSE); - if (path == NULL) - goto bail; - - display_name = totem_pl_parser_read_ini_line_string (lines, "Name", FALSE); - - if (totem_pl_parser_ignore (parser, path) == FALSE - && g_ascii_strcasecmp (type, "FSDevice") != 0) { - totem_pl_parser_add_one_url (parser, path, display_name); - } else { - if (totem_pl_parser_parse_internal (parser, path, NULL) != TOTEM_PL_PARSER_RESULT_SUCCESS) - totem_pl_parser_add_one_url (parser, path, display_name); - } - - res = TOTEM_PL_PARSER_RESULT_SUCCESS; - -bail: - g_strfreev (lines); - - return res; -} - -#endif /* !TOTEM_PL_PARSER_MINI */ - - diff --git a/plparse/totem-pl-parser-misc.h b/plparse/totem-pl-parser-misc.h deleted file mode 100644 index f452228cb..000000000 --- a/plparse/totem-pl-parser-misc.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - 2002, 2003, 2004, 2005, 2006, 2007 Bastien Nocera - Copyright (C) 2003 Colin Walters <walters@verbum.org> - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera <hadess@hadess.net> - */ - -#ifndef TOTEM_PL_PARSER_MISC_H -#define TOTEM_PL_PARSER_MISC_H - -G_BEGIN_DECLS - -#ifndef TOTEM_PL_PARSER_MINI -#include "totem-pl-parser.h" -#else -#include "totem-pl-parser-mini.h" -#endif /* !TOTEM_PL_PARSER_MINI */ - -#ifndef TOTEM_PL_PARSER_MINI -TotemPlParserResult totem_pl_parser_add_gvp (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data); -TotemPlParserResult totem_pl_parser_add_desktop (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data); -#endif /* !TOTEM_PL_PARSER_MINI */ - -G_END_DECLS - -#endif /* TOTEM_PL_PARSER_MISC_H */ diff --git a/plparse/totem-pl-parser-pla.c b/plparse/totem-pl-parser-pla.c deleted file mode 100644 index 8236e64b2..000000000 --- a/plparse/totem-pl-parser-pla.c +++ /dev/null @@ -1,251 +0,0 @@ -/* - Copyright (C) 2007 Jonathan Matthew - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Jonathan Matthew <jonathan@kaolin.wh9.net> - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - -#ifndef TOTEM_PL_PARSER_MINI -#include <string.h> -#include <glib.h> -#include <glib/gi18n-lib.h> -#include <gtk/gtk.h> -#include <libgnomevfs/gnome-vfs.h> -#include "totem-pl-parser.h" -#include "totemplparser-marshal.h" -#endif /* !TOTEM_PL_PARSER_MINI */ - -#include "totem-pl-parser-mini.h" -#include "totem-pl-parser-pla.h" -#include "totem-pl-parser-private.h" - -/* things we know */ -#define PATH_OFFSET 2 -#define FORMAT_ID_OFFSET 4 -#define RECORD_SIZE 512 - -/* things we guessed */ -#define TITLE_OFFSET 32 -#define TITLE_SIZE 64 - -#ifndef TOTEM_PL_PARSER_MINI -gboolean -totem_pl_parser_write_pla (TotemPlParser *parser, GtkTreeModel *model, - TotemPlParserIterFunc func, - const char *output, const char *title, - gpointer user_data, GError **error) -{ - GnomeVFSHandle *handle; - GnomeVFSResult res; - int num_entries_total, num_entries, i; - char *buffer; - gboolean ret; - - num_entries = totem_pl_parser_num_entries (parser, model, func, user_data); - num_entries_total = gtk_tree_model_iter_n_children (model, NULL); - - res = gnome_vfs_open (&handle, output, GNOME_VFS_OPEN_WRITE); - if (res == GNOME_VFS_ERROR_NOT_FOUND) { - res = gnome_vfs_create (&handle, output, - GNOME_VFS_OPEN_WRITE, FALSE, - GNOME_VFS_PERM_USER_WRITE - | GNOME_VFS_PERM_USER_READ - | GNOME_VFS_PERM_GROUP_READ); - } - - if (res != GNOME_VFS_OK) { - g_set_error(error, - TOTEM_PL_PARSER_ERROR, - TOTEM_PL_PARSER_ERROR_VFS_OPEN, - _("Couldn't open file '%s': %s"), - output, gnome_vfs_result_to_string (res)); - return FALSE; - } - - /* write the header */ - buffer = g_malloc0 (RECORD_SIZE); - *((gint32 *)buffer) = GINT32_TO_BE (num_entries_total); - strcpy (buffer + FORMAT_ID_OFFSET, "iriver UMS PLA"); - - /* the player doesn't display this, but it stores - * the 'quick list' name there. - */ - strncpy (buffer + TITLE_OFFSET, title, TITLE_SIZE); - if (totem_pl_parser_write_buffer (handle, buffer, RECORD_SIZE, error) == FALSE) - { - DEBUG(g_print ("Couldn't write header block")); - gnome_vfs_close (handle); - g_free (buffer); - return FALSE; - } - - ret = TRUE; - for (i = 1; i <= num_entries_total; i++) { - GtkTreeIter iter; - char *uri, *title, *path, *converted; - gsize written; - gboolean custom_title; - - if (gtk_tree_model_iter_nth_child (model, &iter, NULL, i - 1) == FALSE) - continue; - - func (model, &iter, &uri, &title, &custom_title, user_data); - g_free (title); - - memset (buffer, 0, RECORD_SIZE); - /* this value appears to identify the directory holding the file, - * but it doesn't seem to matter if it doesn't. - */ - buffer[1] = 0x1A; - - /* convert to filename */ - path = g_filename_from_uri (uri, NULL, error); - if (path == NULL) - { - DEBUG(g_print ("Couldn't convert URI '%s' to a filename: %s\n", uri, (*error)->message)); - g_free (uri); - ret = FALSE; - break; - } - g_free (uri); - - /* replace slashes */ - g_strdelimit (path, "/", '\\'); - - /* convert to big-endian utf16 and write it into the buffer */ - converted = g_convert (path, -1, "UTF-16BE", "UTF-8", NULL, &written, error); - if (converted == NULL) - { - DEBUG(g_print ("Couldn't convert filename '%s' to UTF-16BE\n", path)); - g_free (path); - ret = FALSE; - break; - } - g_free (path); - - if (written > RECORD_SIZE - PATH_OFFSET) - written = RECORD_SIZE - PATH_OFFSET; - - memcpy (buffer + PATH_OFFSET, converted, written); - g_free (converted); - - if (totem_pl_parser_write_buffer (handle, buffer, RECORD_SIZE, error) == FALSE) - { - DEBUG(g_print ("Couldn't write entry %d to the file\n", i)); - ret = FALSE; - break; - } - } - - g_free (buffer); - gnome_vfs_close (handle); - return ret; -} - -TotemPlParserResult -totem_pl_parser_add_pla (TotemPlParser *parser, const char *url, - const char *base, gpointer data) -{ - TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED; - char *contents, *title; - int size, offset, max_entries, entry; - - if (gnome_vfs_read_entire_file (url, &size, &contents) != GNOME_VFS_OK) - return TOTEM_PL_PARSER_RESULT_ERROR; - - if (size < RECORD_SIZE) - { - g_free (contents); - DEBUG(g_print ("playlist '%s' is too short: %d\n", url, size)); - return TOTEM_PL_PARSER_RESULT_ERROR; - } - - /* read header block */ - max_entries = GINT32_FROM_BE (*((gint32 *)contents)); - if (strcmp (contents + FORMAT_ID_OFFSET, "iriver UMS PLA") != 0) - { - g_free (contents); - DEBUG(g_print ("playlist '%s' signature doesn't match: %s\n", url, contents + 4)); - return TOTEM_PL_PARSER_RESULT_ERROR; - } - - /* read playlist title starting at offset 32 */ - title = NULL; - if (contents[TITLE_OFFSET] != '\0') - { - title = contents + TITLE_OFFSET; - totem_pl_parser_add_url (parser, - TOTEM_PL_PARSER_FIELD_IS_PLAYLIST, TRUE, - TOTEM_PL_PARSER_FIELD_URL, url, - TOTEM_PL_PARSER_FIELD_TITLE, title, - NULL); - } - - offset = RECORD_SIZE; - entry = 0; - while (offset + RECORD_SIZE <= size && entry < max_entries) { - char *path, *uri; - GError *error = NULL; - - /* path starts at +2, is at most 500 bytes, in big-endian utf16 .. */ - path = g_convert (contents + offset + PATH_OFFSET, - RECORD_SIZE - PATH_OFFSET, - "UTF-8", "UTF-16BE", - NULL, NULL, &error); - if (path == NULL) - { - DEBUG(g_print ("error converting entry %d to UTF-8: %s\n", entry, error->message)); - g_error_free (error); - retval = TOTEM_PL_PARSER_RESULT_ERROR; - break; - } - - /* .. with backslashes.. */ - g_strdelimit (path, "\\", '/'); - - /* and that's all we get. */ - uri = g_filename_to_uri (path, NULL, NULL); - if (uri == NULL) - { - DEBUG(g_print ("error converting path %s to URI: %s\n", path, error->message)); - g_error_free (error); - retval = TOTEM_PL_PARSER_RESULT_ERROR; - break; - } - - totem_pl_parser_add_url (parser, TOTEM_PL_PARSER_FIELD_URL, uri, NULL); - - g_free (uri); - g_free (path); - offset += RECORD_SIZE; - entry++; - } - - if (title != NULL) - totem_pl_parser_playlist_end (parser, title); - - g_free (contents); - - return TOTEM_PL_PARSER_RESULT_SUCCESS; -} - -#endif /* !TOTEM_PL_PARSER_MINI */ - diff --git a/plparse/totem-pl-parser-pla.h b/plparse/totem-pl-parser-pla.h deleted file mode 100644 index 186699da7..000000000 --- a/plparse/totem-pl-parser-pla.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - 2002, 2003, 2004, 2005, 2006, 2007 Bastien Nocera - Copyright (C) 2003 Colin Walters <walters@verbum.org> - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera <hadess@hadess.net> - */ - -#ifndef TOTEM_PL_PARSER_PLA_H -#define TOTEM_PL_PARSER_PLA_H - -G_BEGIN_DECLS - -#ifdef TOTEM_PL_PARSER_MINI -#include "totem-pl-parser-mini.h" -#endif /* TOTEM_PL_PARSER_MINI */ - -#ifndef TOTEM_PL_PARSER_MINI -gboolean totem_pl_parser_write_pla (TotemPlParser *parser, - GtkTreeModel *model, - TotemPlParserIterFunc func, - const char *output, - const char *title, - gpointer user_data, - GError **error); -TotemPlParserResult totem_pl_parser_add_pla (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data); -#endif /* !TOTEM_PL_PARSER_MINI */ - -G_END_DECLS - -#endif /* TOTEM_PL_PARSER_PLA_H */ diff --git a/plparse/totem-pl-parser-pls.c b/plparse/totem-pl-parser-pls.c deleted file mode 100644 index 0ceb96fdc..000000000 --- a/plparse/totem-pl-parser-pls.c +++ /dev/null @@ -1,329 +0,0 @@ -/* - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Bastien Nocera - Copyright (C) 2003, 2004 Colin Walters <walters@rhythmbox.org> - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera <hadess@hadess.net> - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - -#ifndef TOTEM_PL_PARSER_MINI -#include <string.h> -#include <glib.h> -#include <glib/gi18n-lib.h> -#include <gtk/gtk.h> -#include <libgnomevfs/gnome-vfs.h> -#include "totem-pl-parser.h" -#include "totemplparser-marshal.h" -#endif /* !TOTEM_PL_PARSER_MINI */ - -#include "totem-pl-parser-mini.h" -#include "totem-pl-parser-pls.h" -#include "totem-pl-parser-private.h" - -#ifndef TOTEM_PL_PARSER_MINI -gboolean -totem_pl_parser_write_pls (TotemPlParser *parser, GtkTreeModel *model, - TotemPlParserIterFunc func, - const char *output, const char *title, - gpointer user_data, GError **error) -{ - GnomeVFSHandle *handle; - GnomeVFSResult res; - int num_entries_total, num_entries, i; - char *buf; - gboolean success; - - num_entries = totem_pl_parser_num_entries (parser, model, func, user_data); - num_entries_total = gtk_tree_model_iter_n_children (model, NULL); - - res = gnome_vfs_open (&handle, output, GNOME_VFS_OPEN_WRITE); - if (res == GNOME_VFS_ERROR_NOT_FOUND) { - res = gnome_vfs_create (&handle, output, - GNOME_VFS_OPEN_WRITE, FALSE, - GNOME_VFS_PERM_USER_WRITE - | GNOME_VFS_PERM_USER_READ - | GNOME_VFS_PERM_GROUP_READ); - } - - if (res != GNOME_VFS_OK) { - g_set_error(error, - TOTEM_PL_PARSER_ERROR, - TOTEM_PL_PARSER_ERROR_VFS_OPEN, - _("Couldn't open file '%s': %s"), - output, gnome_vfs_result_to_string (res)); - return FALSE; - } - - buf = g_strdup ("[playlist]\n"); - success = totem_pl_parser_write_string (handle, buf, error); - g_free (buf); - if (success == FALSE) - return FALSE; - - if (title != NULL) { - buf = g_strdup_printf ("X-GNOME-Title=%s\n", title); - success = totem_pl_parser_write_string (handle, buf, error); - g_free (buf); - if (success == FALSE) - { - gnome_vfs_close (handle); - return FALSE; - } - } - - buf = g_strdup_printf ("NumberOfEntries=%d\n", num_entries); - success = totem_pl_parser_write_string (handle, buf, error); - g_free (buf); - if (success == FALSE) - { - gnome_vfs_close (handle); - return FALSE; - } - - for (i = 1; i <= num_entries_total; i++) { - GtkTreeIter iter; - char *url, *title, *relative; - gboolean custom_title; - - if (gtk_tree_model_iter_nth_child (model, &iter, NULL, i - 1) == FALSE) - continue; - - func (model, &iter, &url, &title, &custom_title, user_data); - - if (totem_pl_parser_scheme_is_ignored (parser, url) != FALSE) - { - g_free (url); - g_free (title); - continue; - } - - relative = totem_pl_parser_relative (url, output); - buf = g_strdup_printf ("File%d=%s\n", i, - relative ? relative : url); - g_free (relative); - g_free (url); - success = totem_pl_parser_write_string (handle, buf, error); - g_free (buf); - if (success == FALSE) - { - gnome_vfs_close (handle); - g_free (title); - return FALSE; - } - - if (custom_title == FALSE) { - g_free (title); - continue; - } - - buf = g_strdup_printf ("Title%d=%s\n", i, title); - success = totem_pl_parser_write_string (handle, buf, error); - g_free (buf); - g_free (title); - if (success == FALSE) - { - gnome_vfs_close (handle); - return FALSE; - } - } - - gnome_vfs_close (handle); - return TRUE; -} - -TotemPlParserResult -totem_pl_parser_add_pls_with_contents (TotemPlParser *parser, const char *url, - const char *base, const char *contents) -{ - TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED; - char **lines; - int i, num_entries; - char *split_char, *playlist_title; - gboolean dos_mode = FALSE; - gboolean fallback; - - /* figure out whether we're a unix pls or dos pls */ - if (strstr(contents,"\x0d") == NULL) { - split_char = "\n"; - } else { - split_char = "\x0d\n"; - dos_mode = TRUE; - } - lines = g_strsplit (contents, split_char, 0); - - /* [playlist] */ - i = 0; - playlist_title = NULL; - - /* Ignore empty lines */ - while (totem_pl_parser_line_is_empty (lines[i]) != FALSE) - i++; - - if (lines[i] == NULL - || g_ascii_strncasecmp (lines[i], "[playlist]", - (gsize)strlen ("[playlist]")) != 0) { - goto bail; - } - - playlist_title = totem_pl_parser_read_ini_line_string (lines, - "X-GNOME-Title", dos_mode); - - if (playlist_title != NULL) { - totem_pl_parser_add_url (parser, - TOTEM_PL_PARSER_FIELD_IS_PLAYLIST, TRUE, - TOTEM_PL_PARSER_FIELD_URL, url, - TOTEM_PL_PARSER_FIELD_TITLE, playlist_title, - NULL); - } - - /* numberofentries=? */ - num_entries = totem_pl_parser_read_ini_line_int (lines, "numberofentries"); - - if (num_entries == -1) { - num_entries = 0; - - for (i = 0; lines[i] != NULL; i++) { - if (totem_pl_parser_line_is_empty (lines[i])) - continue; - - if (g_ascii_strncasecmp (g_strchug (lines[i]), "file", (gsize)strlen ("file")) == 0) - num_entries++; - } - - if (num_entries == 0) - goto bail; - } - - retval = TOTEM_PL_PARSER_RESULT_SUCCESS; - - for (i = 1; i <= num_entries; i++) { - char *file, *title, *genre, *length; - char *file_key, *title_key, *genre_key, *length_key; - gint64 length_num; - - file_key = g_strdup_printf ("file%d", i); - title_key = g_strdup_printf ("title%d", i); - length_key = g_strdup_printf ("length%d", i); - length_num = 0; - /* Genre is our own little extension */ - genre_key = g_strdup_printf ("genre%d", i); - - file = totem_pl_parser_read_ini_line_string (lines, (const char*)file_key, dos_mode); - title = totem_pl_parser_read_ini_line_string (lines, (const char*)title_key, dos_mode); - genre = totem_pl_parser_read_ini_line_string (lines, (const char*)genre_key, dos_mode); - length = totem_pl_parser_read_ini_line_string (lines, (const char*)length_key, dos_mode); - - g_free (file_key); - g_free (title_key); - g_free (genre_key); - g_free (length_key); - - if (file == NULL) - { - g_free (title); - g_free (genre); - g_free (length); - continue; - } - - fallback = parser->priv->fallback; - if (parser->priv->recurse) - parser->priv->fallback = FALSE; - - /* Get the length, if it's negative, that means that we have a stream - * and should push the entry straight away */ - if (length != NULL) - length_num = totem_pl_parser_parse_duration (length, parser->priv->debug); - - if (strstr (file, "://") != NULL || file[0] == G_DIR_SEPARATOR) { - if (length_num < 0 || totem_pl_parser_parse_internal (parser, file, NULL) != TOTEM_PL_PARSER_RESULT_SUCCESS) { - totem_pl_parser_add_url (parser, - TOTEM_PL_PARSER_FIELD_URL, file, - TOTEM_PL_PARSER_FIELD_TITLE, title, - TOTEM_PL_PARSER_FIELD_GENRE, genre, - TOTEM_PL_PARSER_FIELD_DURATION, length, - TOTEM_PL_PARSER_FIELD_BASE, base, NULL); - } - } else { - char *base; - - /* Try with a base */ - base = totem_pl_parser_base_url (url); - - if (length_num < 0 || totem_pl_parser_parse_internal (parser, file, base) != TOTEM_PL_PARSER_RESULT_SUCCESS) { - char *escaped, *uri; - - escaped = gnome_vfs_escape_path_string (file); - uri = g_strdup_printf ("%s/%s", base, escaped); - g_free (escaped); - totem_pl_parser_add_url (parser, - TOTEM_PL_PARSER_FIELD_URL, uri, - TOTEM_PL_PARSER_FIELD_TITLE, title, - TOTEM_PL_PARSER_FIELD_GENRE, genre, - TOTEM_PL_PARSER_FIELD_DURATION, length, - TOTEM_PL_PARSER_FIELD_BASE, base, NULL); - g_free (uri); - } - - g_free (base); - } - - parser->priv->fallback = fallback; - g_free (file); - g_free (title); - g_free (genre); - g_free (length); - } - - if (playlist_title != NULL) - totem_pl_parser_playlist_end (parser, playlist_title); - -bail: - g_free (playlist_title); - g_strfreev (lines); - - return retval; -} - -TotemPlParserResult -totem_pl_parser_add_pls (TotemPlParser *parser, const char *url, - const char *base, gpointer data) -{ - TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED; - char *contents; - int size; - - if (gnome_vfs_read_entire_file (url, &size, &contents) != GNOME_VFS_OK) - return TOTEM_PL_PARSER_RESULT_ERROR; - - if (size == 0) { - g_free (contents); - return TOTEM_PL_PARSER_RESULT_SUCCESS; - } - - retval = totem_pl_parser_add_pls_with_contents (parser, url, base, contents); - g_free (contents); - - return retval; -} - -#endif /* !TOTEM_PL_PARSER_MINI */ - diff --git a/plparse/totem-pl-parser-pls.h b/plparse/totem-pl-parser-pls.h deleted file mode 100644 index d2f97977d..000000000 --- a/plparse/totem-pl-parser-pls.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - 2002, 2003, 2004, 2005, 2006, 2007 Bastien Nocera - Copyright (C) 2003 Colin Walters <walters@verbum.org> - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera <hadess@hadess.net> - */ - -#ifndef TOTEM_PL_PARSER_PLS_H -#define TOTEM_PL_PARSER_PLS_H - -G_BEGIN_DECLS - -#ifdef TOTEM_PL_PARSER_MINI -#include "totem-pl-parser-mini.h" -#endif /* TOTEM_PL_PARSER_MINI */ - -#ifndef TOTEM_PL_PARSER_MINI -gboolean totem_pl_parser_write_pls (TotemPlParser *parser, - GtkTreeModel *model, - TotemPlParserIterFunc func, - const char *output, - const char *title, - gpointer user_data, - GError **error); -TotemPlParserResult totem_pl_parser_add_pls_with_contents (TotemPlParser *parser, - const char *url, - const char *base, - const char *contents); -TotemPlParserResult totem_pl_parser_add_pls (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data); -#endif /* !TOTEM_PL_PARSER_MINI */ - -G_END_DECLS - -#endif /* TOTEM_PL_PARSER_PLS_H */ diff --git a/plparse/totem-pl-parser-podcast.c b/plparse/totem-pl-parser-podcast.c deleted file mode 100644 index 32da514b2..000000000 --- a/plparse/totem-pl-parser-podcast.c +++ /dev/null @@ -1,830 +0,0 @@ -/* - Copyright (C) 2007 Bastien Nocera <hadess@hadess.net> - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera <hadess@hadess.net> - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include <string.h> -#include <glib.h> -#include <libgnomevfs/gnome-vfs-mime-utils.h> - -#ifndef TOTEM_PL_PARSER_MINI -#include <zlib.h> -#include <gtk/gtk.h> -#include <libgnomevfs/gnome-vfs.h> -#include <libgnomevfs/gnome-vfs-mime.h> -#include <libgnomevfs/gnome-vfs-utils.h> -#include "xmlparser.h" -#include "totem-pl-parser.h" -#include "totemplparser-marshal.h" -#include "totem-disc.h" -#endif /* !TOTEM_PL_PARSER_MINI */ - -#include "totem-pl-parser-mini.h" -#include "totem-pl-parser-podcast.h" -#include "totem-pl-parser-private.h" - -gboolean -totem_pl_parser_is_rss (const char *data, gsize len) -{ - char *buffer; - - if (len == 0) - return FALSE; - if (len > MIME_READ_CHUNK_SIZE) - len = MIME_READ_CHUNK_SIZE; - - /* FIXME would be nicer to have an strnstr */ - buffer = g_memdup (data, len); - if (buffer == NULL) { - g_warning ("Couldn't dup data in totem_pl_parser_is_rss"); - return FALSE; - } - buffer[len - 1] = '\0'; - if (strstr (buffer, "<rss ") != NULL) { - g_free (buffer); - return TRUE; - } - g_free (buffer); - return FALSE; -} - -gboolean -totem_pl_parser_is_atom (const char *data, gsize len) -{ - char *buffer; - - if (len == 0) - return FALSE; - if (len > MIME_READ_CHUNK_SIZE) - len = MIME_READ_CHUNK_SIZE; - - /* FIXME would be nicer to have an strnstr */ - buffer = g_memdup (data, len); - if (buffer == NULL) { - g_warning ("Couldn't dup data in totem_pl_parser_is_atom"); - return FALSE; - } - buffer[len - 1] = '\0'; - if (strstr (buffer, "<feed ") != NULL) { - g_free (buffer); - return TRUE; - } - g_free (buffer); - return FALSE; -} - -gboolean -totem_pl_parser_is_opml (const char *data, gsize len) -{ - char *buffer; - - if (len == 0) - return FALSE; - if (len > MIME_READ_CHUNK_SIZE) - len = MIME_READ_CHUNK_SIZE; - - /* FIXME would be nicer to have an strnstr */ - buffer = g_memdup (data, len); - if (buffer == NULL) { - g_warning ("Couldn't dup data in totem_pl_parser_is_opml"); - return FALSE; - } - buffer[len - 1] = '\0'; - if (strstr (buffer, "<opml ") != NULL) { - g_free (buffer); - return TRUE; - } - g_free (buffer); - return FALSE; -} - -gboolean -totem_pl_parser_is_xml_feed (const char *data, gsize len) -{ - if (totem_pl_parser_is_rss (data, len) != FALSE) - return TRUE; - if (totem_pl_parser_is_atom (data, len) != FALSE) - return TRUE; - if (totem_pl_parser_is_opml (data, len) != FALSE) - return TRUE; - return FALSE; -} - -#ifndef TOTEM_PL_PARSER_MINI - -static TotemPlParserResult -parse_rss_item (TotemPlParser *parser, xml_node_t *parent) -{ - const char *title, *url, *description, *author; - const char *pub_date, *duration, *filesize; - xml_node_t *node; - - title = url = description = author = NULL; - pub_date = duration = filesize = NULL; - - for (node = parent->child; node != NULL; node = node->next) { - if (node->name == NULL) - continue; - - if (g_ascii_strcasecmp (node->name, "title") == 0) { - title = node->data; - } else if (g_ascii_strcasecmp (node->name, "url") == 0) { - url = node->data; - } else if (g_ascii_strcasecmp (node->name, "pubDate") == 0) { - pub_date = node->data; - } else if (g_ascii_strcasecmp (node->name, "description") == 0 - || g_ascii_strcasecmp (node->name, "itunes:summary") == 0) { - description = node->data; - } else if (g_ascii_strcasecmp (node->name, "author") == 0 - || g_ascii_strcasecmp (node->name, "itunes:author") == 0) { - author = node->data; - } else if (g_ascii_strcasecmp (node->name, "itunes:duration") == 0) { - duration = node->data; - } else if (g_ascii_strcasecmp (node->name, "length") == 0) { - filesize = node->data; - } else if (g_ascii_strcasecmp (node->name, "enclosure") == 0) { - const char *tmp; - - tmp = xml_parser_get_property (node, "url"); - if (tmp != NULL) - url = tmp; - else - continue; - tmp = xml_parser_get_property (node, "length"); - if (tmp != NULL) - filesize = tmp; - } - } - - if (url != NULL) { - totem_pl_parser_add_url (parser, - TOTEM_PL_PARSER_FIELD_URL, url, - TOTEM_PL_PARSER_FIELD_TITLE, title, - TOTEM_PL_PARSER_FIELD_PUB_DATE, pub_date, - TOTEM_PL_PARSER_FIELD_DESCRIPTION, description, - TOTEM_PL_PARSER_FIELD_AUTHOR, author, - TOTEM_PL_PARSER_FIELD_DURATION, duration, - TOTEM_PL_PARSER_FIELD_FILESIZE, filesize, - NULL); - } - - return TOTEM_PL_PARSER_RESULT_SUCCESS; -} - -static TotemPlParserResult -parse_rss_items (TotemPlParser *parser, const char *url, xml_node_t *parent) -{ - const char *title, *language, *description, *author; - const char *contact, *img, *pub_date, *copyright; - xml_node_t *node; - - title = language = description = author = NULL; - contact = img = pub_date = copyright = NULL; - - /* We need to parse for the feed metadata first, then for the items */ - for (node = parent->child; node != NULL; node = node->next) { - if (node->name == NULL) - continue; - - if (g_ascii_strcasecmp (node->name, "title") == 0) { - title = node->data; - } else if (g_ascii_strcasecmp (node->name, "language") == 0) { - language = node->data; - } else if (g_ascii_strcasecmp (node->name, "description") == 0 - || g_ascii_strcasecmp (node->name, "itunes:subtitle") == 0) { - description = node->data; - } else if (g_ascii_strcasecmp (node->name, "author") == 0 - || g_ascii_strcasecmp (node->name, "itunes:author") == 0 - || (g_ascii_strcasecmp (node->name, "generator") == 0 && author == NULL)) { - author = node->data; - } else if (g_ascii_strcasecmp (node->name, "webMaster") == 0) { - contact = node->data; - } else if (g_ascii_strcasecmp (node->name, "image") == 0) { - img = node->data; - } else if (g_ascii_strcasecmp (node->name, "itunes:image") == 0) { - const char *href; - - href = xml_parser_get_property (node, "href"); - if (href != NULL) - img = href; - } else if (g_ascii_strcasecmp (node->name, "lastBuildDate") == 0 - || g_ascii_strcasecmp (node->name, "pubDate") == 0) { - pub_date = node->data; - } else if (g_ascii_strcasecmp (node->name, "copyright") == 0) { - copyright = node->data; - } - } - - /* Send the info we already have about the feed */ - totem_pl_parser_add_url (parser, - TOTEM_PL_PARSER_FIELD_IS_PLAYLIST, TRUE, - TOTEM_PL_PARSER_FIELD_URL, url, - TOTEM_PL_PARSER_FIELD_TITLE, title, - TOTEM_PL_PARSER_FIELD_LANGUAGE, language, - TOTEM_PL_PARSER_FIELD_DESCRIPTION, description, - TOTEM_PL_PARSER_FIELD_AUTHOR, author, - TOTEM_PL_PARSER_FIELD_PUB_DATE, pub_date, - TOTEM_PL_PARSER_FIELD_COPYRIGHT, copyright, - TOTEM_PL_PARSER_FIELD_IMAGE_URL, img, - NULL); - - for (node = parent->child; node != NULL; node = node->next) { - if (node->name == NULL) - continue; - - if (g_ascii_strcasecmp (node->name, "item") == 0) - parse_rss_item (parser, node); - } - - totem_pl_parser_playlist_end (parser, url); - - return TOTEM_PL_PARSER_RESULT_SUCCESS; -} - -TotemPlParserResult -totem_pl_parser_add_rss (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data) -{ - xml_node_t* doc, *channel; - char *contents; - int size; - - if (gnome_vfs_read_entire_file (url, &size, &contents) != GNOME_VFS_OK) - return TOTEM_PL_PARSER_RESULT_ERROR; - - xml_parser_init (contents, size, XML_PARSER_CASE_INSENSITIVE); - if (xml_parser_build_tree_with_options (&doc, XML_PARSER_RELAXED | XML_PARSER_MULTI_TEXT) < 0) { - g_free (contents); - return TOTEM_PL_PARSER_RESULT_ERROR; - } - /* If the document has no name */ - if (doc->name == NULL - || g_ascii_strcasecmp (doc->name , "rss") != 0) { - g_free (contents); - xml_parser_free_tree (doc); - return TOTEM_PL_PARSER_RESULT_ERROR; - } - - for (channel = doc->child; channel != NULL; channel = channel->next) { - if (g_ascii_strcasecmp (channel->name, "channel") == 0) { - parse_rss_items (parser, url, channel); - /* One channel per file */ - break; - } - } - - g_free (contents); - xml_parser_free_tree (doc); - - return TOTEM_PL_PARSER_RESULT_SUCCESS; -} - -/* http://www.apple.com/itunes/store/podcaststechspecs.html */ -TotemPlParserResult -totem_pl_parser_add_itpc (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data) -{ - TotemPlParserResult ret; - char *new_url; - - new_url = g_strdup (url); - memcpy (new_url, "http", 4); - ret = totem_pl_parser_add_rss (parser, new_url, base, data); - g_free (new_url); - - return ret; -} - -/* Atom docs: - * http://www.atomenabled.org/developers/syndication/atom-format-spec.php#rfc.section.4.1 - * http://tools.ietf.org/html/rfc4287 - * http://tools.ietf.org/html/rfc4946 */ -static TotemPlParserResult -parse_atom_entry (TotemPlParser *parser, xml_node_t *parent) -{ - const char *title, *author, *img, *url, *filesize; - const char *copyright, *pub_date, *description; - xml_node_t *node; - - title = author = img = url = filesize = NULL; - copyright = pub_date = description = NULL; - - for (node = parent->child; node != NULL; node = node->next) { - if (node->name == NULL) - continue; - - if (g_ascii_strcasecmp (node->name, "title") == 0) { - title = node->data; - } else if (g_ascii_strcasecmp (node->name, "author") == 0) { - //FIXME - } else if (g_ascii_strcasecmp (node->name, "logo") == 0) { - img = node->data; - } else if (g_ascii_strcasecmp (node->name, "link") == 0) { - const char *rel; - - //FIXME how do we choose the default enclosure type? - rel = xml_parser_get_property (node, "rel"); - if (g_ascii_strcasecmp (rel, "enclosure") == 0) { - const char *href; - - //FIXME what's the difference between url and href there? - href = xml_parser_get_property (node, "href"); - if (href == NULL) - continue; - url = href; - filesize = xml_parser_get_property (node, "length"); - } else if (g_ascii_strcasecmp (node->name, "license") == 0) { - const char *href; - - href = xml_parser_get_property (node, "href"); - if (href == NULL) - continue; - /* This isn't really a copyright, but what the hey */ - copyright = href; - } - } else if (g_ascii_strcasecmp (node->name, "updated") == 0 - || (g_ascii_strcasecmp (node->name, "modified") == 0 && pub_date == NULL)) { - pub_date = node->data; - } else if (g_ascii_strcasecmp (node->name, "summary") == 0 - || (g_ascii_strcasecmp (node->name, "content") == 0 && description == NULL)) { - const char *type; - - type = xml_parser_get_property (node, "content"); - if (type != NULL && g_ascii_strcasecmp (type, "text/plain") == 0) - description = node->data; - } - //FIXME handle category - } - - if (url != NULL) { - totem_pl_parser_add_url (parser, - TOTEM_PL_PARSER_FIELD_TITLE, title, - TOTEM_PL_PARSER_FIELD_AUTHOR, author, - TOTEM_PL_PARSER_FIELD_URL, url, - TOTEM_PL_PARSER_FIELD_FILESIZE, filesize, - TOTEM_PL_PARSER_FIELD_COPYRIGHT, copyright, - TOTEM_PL_PARSER_FIELD_PUB_DATE, pub_date, - TOTEM_PL_PARSER_FIELD_DESCRIPTION, description, - NULL); - } - - return TOTEM_PL_PARSER_RESULT_SUCCESS; -} - -static TotemPlParserResult -parse_atom_entries (TotemPlParser *parser, const char *url, xml_node_t *parent) -{ - const char *title, *pub_date, *description; - const char *author, *img; - xml_node_t *node; - gboolean started = FALSE; - - title = pub_date = description = NULL; - author = img = NULL; - - for (node = parent->child; node != NULL; node = node->next) { - if (node->name == NULL) - continue; - - if (g_ascii_strcasecmp (node->name, "title") == 0) { - title = node->data; - } else if (g_ascii_strcasecmp (node->name, "tagline") == 0) { - description = node->data; - } else if (g_ascii_strcasecmp (node->name, "modified") == 0 - || g_ascii_strcasecmp (node->name, "updated") == 0) { - pub_date = node->data; - } else if (g_ascii_strcasecmp (node->name, "author") == 0 - || (g_ascii_strcasecmp (node->name, "generator") == 0 && author == NULL)) { - author = node->data; - } else if ((g_ascii_strcasecmp (node->name, "icon") == 0 && img == NULL) - || g_ascii_strcasecmp (node->name, "logo") == 0) { - img = node->data; - } - - if (g_ascii_strcasecmp (node->name, "entry") == 0) { - if (started == FALSE) { - /* Send the info we already have about the feed */ - totem_pl_parser_add_url (parser, - TOTEM_PL_PARSER_FIELD_IS_PLAYLIST, TRUE, - TOTEM_PL_PARSER_FIELD_URL, url, - TOTEM_PL_PARSER_FIELD_TITLE, title, - TOTEM_PL_PARSER_FIELD_DESCRIPTION, description, - TOTEM_PL_PARSER_FIELD_AUTHOR, author, - TOTEM_PL_PARSER_FIELD_PUB_DATE, pub_date, - TOTEM_PL_PARSER_FIELD_IMAGE_URL, img, - NULL); - started = TRUE; - } - - parse_atom_entry (parser, node); - } - } - - totem_pl_parser_playlist_end (parser, url); - - return TOTEM_PL_PARSER_RESULT_SUCCESS; -} - -TotemPlParserResult -totem_pl_parser_add_atom (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data) -{ - xml_node_t* doc; - char *contents; - int size; - - if (gnome_vfs_read_entire_file (url, &size, &contents) != GNOME_VFS_OK) - return TOTEM_PL_PARSER_RESULT_ERROR; - - xml_parser_init (contents, size, XML_PARSER_CASE_INSENSITIVE); - if (xml_parser_build_tree_with_options (&doc, XML_PARSER_RELAXED | XML_PARSER_MULTI_TEXT) < 0) { - g_free (contents); - return TOTEM_PL_PARSER_RESULT_ERROR; - } - /* If the document has no name */ - if (doc->name == NULL - || g_ascii_strcasecmp (doc->name , "feed") != 0) { - g_free (contents); - xml_parser_free_tree (doc); - return TOTEM_PL_PARSER_RESULT_ERROR; - } - - parse_atom_entries (parser, url, doc); - - g_free (contents); - xml_parser_free_tree (doc); - - return TOTEM_PL_PARSER_RESULT_SUCCESS; -} - -TotemPlParserResult -totem_pl_parser_add_xml_feed (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data) -{ - guint len; - - if (data == NULL) - return TOTEM_PL_PARSER_RESULT_UNHANDLED; - - len = strlen (data); - - if (totem_pl_parser_is_rss (data, len) != FALSE) - return totem_pl_parser_add_rss (parser, url, base, data); - if (totem_pl_parser_is_atom (data, len) != FALSE) - return totem_pl_parser_add_atom (parser, url, base, data); - if (totem_pl_parser_is_opml (data, len) != FALSE) - return totem_pl_parser_add_opml (parser, url, base, data); - - return TOTEM_PL_PARSER_RESULT_UNHANDLED; -} - -/* From libgsf's gsf-utils.h */ -#define GSF_LE_GET_GUINT32(p) \ - (guint32)((((guint8 const *)(p))[0] << 0) | \ - (((guint8 const *)(p))[1] << 8) | \ - (((guint8 const *)(p))[2] << 16) | \ - (((guint8 const *)(p))[3] << 24)) - -/* From libgsf's gsf-input-gzip.c */ -/* gzip flag byte */ -#define GZIP_IS_ASCII 0x01 /* file contains text ? */ -#define GZIP_HEADER_CRC 0x02 /* there is a CRC in the header */ -#define GZIP_EXTRA_FIELD 0x04 /* there is an 'extra' field */ -#define GZIP_ORIGINAL_NAME 0x08 /* the original is stored */ -#define GZIP_HAS_COMMENT 0x10 /* There is a comment in the header */ -#define GZIP_HEADER_FLAGS (unsigned)(GZIP_IS_ASCII |GZIP_HEADER_CRC |GZIP_EXTRA_FIELD |GZIP_ORIGINAL_NAME |GZIP_HAS_COMMENT) - -static guint32 -check_header (char *data, gsize len) -{ - static guint8 const signature[2] = {0x1f, 0x8b}; - unsigned flags; - - if (len < 2 + 1 + 1 + 6) - return -1; - - /* Check signature */ - if (memcmp (data, signature, sizeof (signature)) != 0) - return -1; - - /* verify flags and compression type */ - flags = data[3]; - if (data[2] != Z_DEFLATED || (flags & ~GZIP_HEADER_FLAGS) != 0) - return -1; - - /* Get the uncompressed size */ - /* FIXME, but how? The size read here is modulo 2^32. */ - return GSF_LE_GET_GUINT32 (data + len - 4); -} - -static char * -decompress_gzip (char *data, gsize len) -{ - guint32 retlen; - char *ret; - int zerr; - z_stream stream; - - retlen = check_header (data, len); - if (retlen < 0) - return NULL; - - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - stream.opaque = (voidpf)0; - stream.next_in = Z_NULL; - stream.next_out = Z_NULL; - stream.avail_in = stream.avail_out = 0; - - /* 16 + MAX_WBITS as per http://hewgill.com/journal/entries/349 */ - if (Z_OK != inflateInit2 (&stream, 16 + MAX_WBITS)) - return NULL; - - /* +1 so it's NULL-terminated */ - ret = g_malloc0 (retlen + 1); - - stream.next_in = (unsigned char *) data; - stream.avail_in = len; - - stream.next_out = (unsigned char *) ret; - stream.avail_out = retlen; - - zerr = inflate (&stream, Z_NO_FLUSH); - if (zerr != Z_OK && zerr != Z_STREAM_END) { - g_free (ret); - return NULL; - } - zerr = inflateEnd (&stream); - if (zerr != Z_OK) { - g_free (ret); - return NULL; - } - - return ret; -} - -static const char * -totem_pl_parser_parse_itms_doc (xml_node_t *item) -{ - for (item = item->child; item != NULL; item = item->next) { - /* What we're looking for looks like: - * <key>feedURL</key><string>URL</string> */ - if (g_ascii_strcasecmp (item->name, "key") == 0 - && g_ascii_strcasecmp (item->data, "feedURL") == 0) { - item = item->next; - if (g_ascii_strcasecmp (item->name, "string") == 0) - return item->data; - } else { - const char *ret; - - ret = totem_pl_parser_parse_itms_doc (item); - if (ret != NULL) - return ret; - } - } - - return NULL; -} - -static char * -totem_pl_parser_get_feed_url (const char *data, gsize len) -{ - xml_node_t* doc; - const char *url; - char *ret; - - url = NULL; - - xml_parser_init (data, len, XML_PARSER_CASE_INSENSITIVE); - if (xml_parser_build_tree_with_options (&doc, XML_PARSER_RELAXED | XML_PARSER_MULTI_TEXT) < 0) - return NULL; - - /* If the document has no name */ - if (doc->name == NULL - || g_ascii_strcasecmp (doc->name , "Document") != 0) { - xml_parser_free_tree (doc); - return NULL; - } - - url = totem_pl_parser_parse_itms_doc (doc); - if (url == NULL) { - xml_parser_free_tree (doc); - return NULL; - } - - ret = g_strdup (url); - xml_parser_free_tree (doc); - - return ret; -} - -static char * -totem_pl_parser_get_itms_url (const char *data) -{ - char *s, *end, *ret; -#define ITMS_OPEN "<body onload=\"return itmsOpen('" - - /* The bit of text looks like: - * <body onload="return itmsOpen('itms://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wa/viewPodcast?id=207870198&ign-mscache=1','http://www.apple.com/uk/itunes/affiliates/download/?itmsUrl=itms%3A%2F%2Fax.phobos.apple.com.edgesuite.net%2FWebObjects%2FMZStore.woa%2Fwa%2FviewPodcast%3Fid%3D207870198%26ign-mscache%3D1','userOverridePanel',false)"> */ - - s = strstr (data, ITMS_OPEN); - if (s == NULL) - return NULL; - s = s + strlen (ITMS_OPEN); - end = strchr (s, '\''); - if (end == NULL) - return NULL; - - ret = g_strndup (s, end - s); - memcpy (ret, "http", 4); - return ret; -} - -TotemPlParserResult -totem_pl_parser_add_itms (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data) -{ - char *contents, *uncompressed, *itms_url, *feed_url; - TotemPlParserResult ret; - int size; - - if (g_str_has_prefix (url, "itms") == FALSE) { - /* Get the webpage */ - if (gnome_vfs_read_entire_file (url, &size, &contents) != GNOME_VFS_OK) - return TOTEM_PL_PARSER_RESULT_ERROR; - - uncompressed = decompress_gzip (contents, size); - g_free (contents); - if (uncompressed == NULL) - return TOTEM_PL_PARSER_RESULT_ERROR; - - /* Look for the link to the itms on phobos */ - itms_url = totem_pl_parser_get_itms_url (uncompressed); - g_free (uncompressed); - } else { - itms_url= g_strdup (url); - memcpy (itms_url, "http", 4); - } - - /* Get the phobos linked, in some weird iTunes only format */ - if (gnome_vfs_read_entire_file (itms_url, &size, &contents) != GNOME_VFS_OK) { - g_free (itms_url); - return TOTEM_PL_PARSER_RESULT_ERROR; - } - g_free (itms_url); - - uncompressed = decompress_gzip (contents, size); - g_free (contents); - if (uncompressed == NULL) - return TOTEM_PL_PARSER_RESULT_ERROR; - - /* And look in the file for the feedURL */ - feed_url = totem_pl_parser_get_feed_url (uncompressed, strlen (uncompressed) + 1); - if (feed_url == NULL) - return TOTEM_PL_PARSER_RESULT_ERROR; - - ret = totem_pl_parser_add_rss (parser, feed_url, NULL, NULL); - g_free (feed_url); - - return ret; -} - -gboolean -totem_pl_parser_is_itms_feed (const char *url) -{ - g_return_val_if_fail (url != NULL, FALSE); - - if (g_str_has_prefix (url, "itms:") != FALSE - && strstr (url, "phobos.apple.com") != NULL - && strstr (url, "viewPodcast") != NULL) - return TRUE; - if (strstr (url, "phobos.apple.com/") != NULL - && strstr (url, "viewPodcast") != NULL) - return TRUE; - if (strstr (url, "itunes.com/podcast") != NULL) - return TRUE; - - return FALSE; -} - -static TotemPlParserResult -parse_opml_outline (TotemPlParser *parser, xml_node_t *parent) -{ - xml_node_t* node; - const char *title, *url; - - title = url = NULL; - for (node = parent->child; node != NULL; node = node->next) { - if (node->name == NULL || g_ascii_strcasecmp (node->name, "outline") != 0) - continue; - - url = xml_parser_get_property (node, "xmlUrl"); - title = xml_parser_get_property (node, "text"); - - if (url == NULL) - continue; - - totem_pl_parser_add_url (parser, - TOTEM_PL_PARSER_FIELD_TITLE, title, - TOTEM_PL_PARSER_FIELD_URL, url, - NULL); - } - - return TOTEM_PL_PARSER_RESULT_SUCCESS; -} - -static TotemPlParserResult -parse_opml_head_body (TotemPlParser *parser, const char *url, xml_node_t *parent) -{ - xml_node_t* node; - gboolean started; - - started = FALSE; - - for (node = parent->child; node != NULL; node = node->next) { - if (node->name == NULL) - continue; - - if (g_ascii_strcasecmp (node->name, "body") == 0) { - if (started == FALSE) { - /* Send the info we already have about the feed */ - totem_pl_parser_add_url (parser, - TOTEM_PL_PARSER_FIELD_IS_PLAYLIST, TRUE, - TOTEM_PL_PARSER_FIELD_URL, url, - NULL); - started = TRUE; - } - - parse_opml_outline (parser, node); - } - } - - return TOTEM_PL_PARSER_RESULT_SUCCESS; -} - -TotemPlParserResult -totem_pl_parser_add_opml (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data) -{ - xml_node_t* doc; - char *contents; - int size; - - if (gnome_vfs_read_entire_file (url, &size, &contents) != GNOME_VFS_OK) - return TOTEM_PL_PARSER_RESULT_ERROR; - - xml_parser_init (contents, size, XML_PARSER_CASE_INSENSITIVE); - if (xml_parser_build_tree_with_options (&doc, XML_PARSER_RELAXED | XML_PARSER_MULTI_TEXT) < 0) { - g_free (contents); - return TOTEM_PL_PARSER_RESULT_ERROR; - } - /* If the document has no name */ - if (doc->name == NULL - || g_ascii_strcasecmp (doc->name , "opml") != 0) { - g_free (contents); - xml_parser_free_tree (doc); - return TOTEM_PL_PARSER_RESULT_ERROR; - } - - parse_opml_head_body (parser, url, doc); - - g_free (contents); - xml_parser_free_tree (doc); - - return TOTEM_PL_PARSER_RESULT_SUCCESS; -} - -#endif /* !TOTEM_PL_PARSER_MINI */ - diff --git a/plparse/totem-pl-parser-podcast.h b/plparse/totem-pl-parser-podcast.h deleted file mode 100644 index be89c200f..000000000 --- a/plparse/totem-pl-parser-podcast.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - Copyright (C) 2007 Bastien Nocera <hadess@hadess.net> - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera <hadess@hadess.net> - */ - -#ifndef TOTEM_PL_PARSER_PODCAST_H -#define TOTEM_PL_PARSER_PODCAST_H - -G_BEGIN_DECLS - -#ifndef TOTEM_PL_PARSER_MINI -#include "totem-pl-parser.h" -#else -#include "totem-pl-parser-mini.h" -#endif /* !TOTEM_PL_PARSER_MINI */ - -gboolean totem_pl_parser_is_rss (const char *data, gsize len); -gboolean totem_pl_parser_is_atom (const char *data, gsize len); -gboolean totem_pl_parser_is_opml (const char *data, gsize len); -gboolean totem_pl_parser_is_xml_feed (const char *data, gsize len); - -#ifndef TOTEM_PL_PARSER_MINI -gboolean totem_pl_parser_is_itms_feed (const char *url); - -TotemPlParserResult totem_pl_parser_add_xml_feed (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data); -TotemPlParserResult totem_pl_parser_add_atom (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data); -TotemPlParserResult totem_pl_parser_add_rss (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data); -TotemPlParserResult totem_pl_parser_add_itpc (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data); -TotemPlParserResult totem_pl_parser_add_itms (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data); -TotemPlParserResult totem_pl_parser_add_opml (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data); - -#endif /* !TOTEM_PL_PARSER_MINI */ - -G_END_DECLS - -#endif /* TOTEM_PL_PARSER_PODCAST_H */ diff --git a/plparse/totem-pl-parser-private.h b/plparse/totem-pl-parser-private.h deleted file mode 100644 index 4d45084d9..000000000 --- a/plparse/totem-pl-parser-private.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - 2002, 2003, 2004, 2005, 2006 Bastien Nocera - Copyright (C) 2003 Colin Walters <walters@verbum.org> - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera <hadess@hadess.net> - */ - -#ifndef TOTEM_PL_PARSER_PRIVATE_H -#define TOTEM_PL_PARSER_PRIVATE_H - -#include <glib.h> - -#ifndef TOTEM_PL_PARSER_MINI -#include "totem-pl-parser.h" -#include <glib-object.h> -#else -#include "totem-pl-parser-mini.h" -#endif /* !TOTEM_PL_PARSER_MINI */ - -#define MIME_READ_CHUNK_SIZE 1024 -#define DEBUG(x) { if (parser->priv->debug) x; } - -struct TotemPlParserPrivate -{ - GList *ignore_schemes; - GList *ignore_mimetypes; -#ifndef TOTEM_PL_PARSER_MINI - GParamSpecPool *pspec_pool; -#endif - guint recurse_level; - guint fallback : 1; - guint recurse : 1; - guint debug : 1; - guint force : 1; - guint disable_unsafe : 1; -}; - -char *totem_pl_parser_read_ini_line_string (char **lines, const char *key, - gboolean dos_mode); -int totem_pl_parser_read_ini_line_int (char **lines, const char *key); -char *totem_pl_parser_read_ini_line_string_with_sep (char **lines, const char *key, - gboolean dos_mode, const char *sep); -char *totem_pl_parser_base_url (const char *url); - -#ifndef TOTEM_PL_PARSER_MINI -void totem_pl_parser_playlist_end (TotemPlParser *parser, - const char *playlist_title); -int totem_pl_parser_num_entries (TotemPlParser *parser, - GtkTreeModel *model, - TotemPlParserIterFunc func, - gpointer user_data); -gboolean totem_pl_parser_scheme_is_ignored (TotemPlParser *parser, - const char *url); -gboolean totem_pl_parser_line_is_empty (const char *line); -gboolean totem_pl_parser_write_string (GnomeVFSHandle *handle, - const char *buf, - GError **error); -gboolean totem_pl_parser_write_buffer (GnomeVFSHandle *handle, - const char *buf, - guint size, - GError **error); -char * totem_pl_parser_relative (const char *url, - const char *output); -TotemPlParserResult totem_pl_parser_parse_internal (TotemPlParser *parser, - const char *url, - const char *base); -void totem_pl_parser_add_one_url (TotemPlParser *parser, - const char *url, - const char *title); -void totem_pl_parser_add_url (TotemPlParser *parser, - const char *first_property_name, - ...); -gboolean totem_pl_parser_ignore (TotemPlParser *parser, const char *url); -#endif /* !TOTEM_PL_PARSER_MINI */ - -G_END_DECLS - -#endif /* TOTEM_PL_PARSER_PRIVATE_H */ diff --git a/plparse/totem-pl-parser-qt.c b/plparse/totem-pl-parser-qt.c deleted file mode 100644 index b121c4d92..000000000 --- a/plparse/totem-pl-parser-qt.c +++ /dev/null @@ -1,220 +0,0 @@ -/* - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Bastien Nocera - Copyright (C) 2003, 2004 Colin Walters <walters@rhythmbox.org> - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera <hadess@hadess.net> - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include <string.h> -#include <glib.h> - -#ifndef TOTEM_PL_PARSER_MINI -#include "xmlparser.h" -#include <gtk/gtk.h> -#include <libgnomevfs/gnome-vfs.h> -#include "totem-pl-parser.h" -#include "totemplparser-marshal.h" -#endif /* !TOTEM_PL_PARSER_MINI */ - -#include "totem-pl-parser-mini.h" -#include "totem-pl-parser-qt.h" -#include "totem-pl-parser-smil.h" -#include "totem-pl-parser-private.h" - -#ifndef TOTEM_PL_PARSER_MINI - -static TotemPlParserResult -totem_pl_parser_add_quicktime_rtsptext (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data) -{ - char *contents = NULL; - gboolean dos_mode = FALSE; - char *volume, *autoplay, *rtspurl; - int size; - char **lines; - - if (gnome_vfs_read_entire_file (url, &size, &contents) != GNOME_VFS_OK) - return TOTEM_PL_PARSER_RESULT_ERROR; - - if (strstr(contents,"\x0d") != NULL) - dos_mode = TRUE; - - lines = g_strsplit (contents, dos_mode ? "\x0d\n" : "\n", 0); - - volume = totem_pl_parser_read_ini_line_string_with_sep - (lines, "volume", dos_mode, "="); - autoplay = totem_pl_parser_read_ini_line_string_with_sep - (lines, "autoplay", dos_mode, "="); - - rtspurl = g_strdup (lines[0] + strlen ("RTSPtext")); - g_strstrip (rtspurl); - - totem_pl_parser_add_url (parser, - TOTEM_PL_PARSER_FIELD_URL, rtspurl, - TOTEM_PL_PARSER_FIELD_VOLUME, volume, - TOTEM_PL_PARSER_FIELD_AUTOPLAY, autoplay, - NULL); - g_free (rtspurl); - g_free (volume); - g_free (autoplay); - g_strfreev (lines); - - return TOTEM_PL_PARSER_RESULT_SUCCESS; -} - -static TotemPlParserResult -totem_pl_parser_add_quicktime_metalink (TotemPlParser *parser, const char *url, - const char *base, gpointer data) -{ - xml_node_t *doc, *node; - int size; - char *contents; - const char *item_url, *autoplay; - gboolean found; - - if (g_str_has_prefix (data, "RTSPtext") != FALSE - || g_str_has_prefix (data, "rtsptext") != FALSE) { - return totem_pl_parser_add_quicktime_rtsptext (parser, url, base, data); - } - if (g_str_has_prefix (data, "SMILtext") != FALSE) { - char *contents; - int size; - TotemPlParserResult retval; - - if (gnome_vfs_read_entire_file (url, &size, &contents) != GNOME_VFS_OK) - return TOTEM_PL_PARSER_RESULT_ERROR; - - retval = totem_pl_parser_add_smil_with_data (parser, - url, base, - contents + strlen ("SMILtext"), - size - strlen ("SMILtext")); - g_free (contents); - return retval; - } - - if (gnome_vfs_read_entire_file (url, &size, &contents) != GNOME_VFS_OK) - return TOTEM_PL_PARSER_RESULT_ERROR; - - xml_parser_init (contents, size, XML_PARSER_CASE_INSENSITIVE); - if (xml_parser_build_tree_with_options (&doc, XML_PARSER_RELAXED | XML_PARSER_MULTI_TEXT) < 0) { - g_free (contents); - return TOTEM_PL_PARSER_RESULT_ERROR; - } - g_free (contents); - - /* Check for quicktime type */ - for (node = doc, found = FALSE; node != NULL; node = node->next) { - const char *type; - - if (node->name == NULL) - continue; - if (g_ascii_strcasecmp (node->name , "?quicktime") != 0) - continue; - type = xml_parser_get_property (node, "type"); - if (g_ascii_strcasecmp ("application/x-quicktime-media-link", type) != 0) - continue; - found = TRUE; - } - - if (found == FALSE) { - xml_parser_free_tree (doc); - return TOTEM_PL_PARSER_RESULT_ERROR; - } - - if (!doc || !doc->name - || g_ascii_strcasecmp (doc->name, "embed") != 0) { - xml_parser_free_tree (doc); - return TOTEM_PL_PARSER_RESULT_ERROR; - } - - item_url = xml_parser_get_property (doc, "src"); - if (!item_url) { - xml_parser_free_tree (doc); - return TOTEM_PL_PARSER_RESULT_ERROR; - } - - autoplay = xml_parser_get_property (doc, "autoplay"); - /* Add a default as per the QuickTime docs */ - if (autoplay == NULL) - autoplay = "true"; - - totem_pl_parser_add_url (parser, - TOTEM_PL_PARSER_FIELD_URL, item_url, - TOTEM_PL_PARSER_FIELD_AUTOPLAY, autoplay, - NULL); - xml_parser_free_tree (doc); - - return TOTEM_PL_PARSER_RESULT_SUCCESS; -} - -TotemPlParserResult -totem_pl_parser_add_quicktime (TotemPlParser *parser, const char *url, - const char *base, gpointer data) -{ - if (data == NULL || totem_pl_parser_is_quicktime (data, strlen (data)) == FALSE) { - totem_pl_parser_add_one_url (parser, url, NULL); - return TOTEM_PL_PARSER_RESULT_SUCCESS; - } - - return totem_pl_parser_add_quicktime_metalink (parser, url, base, data); -} - -#endif /* !TOTEM_PL_PARSER_MINI */ - -gboolean -totem_pl_parser_is_quicktime (const char *data, gsize len) -{ - char *buffer; - - if (len == 0) - return FALSE; - if (len > MIME_READ_CHUNK_SIZE) - len = MIME_READ_CHUNK_SIZE; - - /* Check for RTSPtextRTSP Quicktime references */ - if (len <= strlen ("RTSPtextRTSP://")) - return FALSE; - if (g_str_has_prefix (data, "RTSPtext") != FALSE - || g_str_has_prefix (data, "rtsptext") != FALSE) { - return TRUE; - } - if (g_str_has_prefix (data, "SMILtext") != FALSE) - return TRUE; - - /* FIXME would be nicer to have an strnstr */ - buffer = g_memdup (data, len); - if (buffer == NULL) { - g_warning ("Couldn't dup data in totem_pl_parser_is_quicktime"); - return FALSE; - } - buffer[len - 1] = '\0'; - if (strstr (buffer, "<?quicktime") != NULL) { - g_free (buffer); - return TRUE; - } - g_free (buffer); - return FALSE; -} - - diff --git a/plparse/totem-pl-parser-qt.h b/plparse/totem-pl-parser-qt.h deleted file mode 100644 index 886beed1b..000000000 --- a/plparse/totem-pl-parser-qt.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - 2002, 2003, 2004, 2005, 2006, 2007 Bastien Nocera - Copyright (C) 2003 Colin Walters <walters@verbum.org> - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera <hadess@hadess.net> - */ - -#ifndef TOTEM_PL_PARSER_QT_H -#define TOTEM_PL_PARSER_QT_H - -G_BEGIN_DECLS - -#ifndef TOTEM_PL_PARSER_MINI -#include "totem-pl-parser.h" -#else -#include "totem-pl-parser-mini.h" -#endif /* !TOTEM_PL_PARSER_MINI */ - -gboolean totem_pl_parser_is_quicktime (const char *data, gsize len); - -#ifndef TOTEM_PL_PARSER_MINI -TotemPlParserResult totem_pl_parser_add_quicktime (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data); -#endif /* !TOTEM_PL_PARSER_MINI */ - -G_END_DECLS - -#endif /* TOTEM_PL_PARSER_QT_H */ diff --git a/plparse/totem-pl-parser-smil.c b/plparse/totem-pl-parser-smil.c deleted file mode 100644 index be3839e57..000000000 --- a/plparse/totem-pl-parser-smil.c +++ /dev/null @@ -1,209 +0,0 @@ -/* - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Bastien Nocera - Copyright (C) 2003, 2004 Colin Walters <walters@rhythmbox.org> - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera <hadess@hadess.net> - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - - -#ifndef TOTEM_PL_PARSER_MINI -#include <glib.h> -#include <gtk/gtk.h> -#include <libgnomevfs/gnome-vfs.h> -#include "xmlparser.h" -#include "totem-pl-parser.h" -#include "totemplparser-marshal.h" -#endif /* !TOTEM_PL_PARSER_MINI */ - -#include "totem-pl-parser-mini.h" -#include "totem-pl-parser-smil.h" -#include "totem-pl-parser-private.h" - -#ifndef TOTEM_PL_PARSER_MINI -static TotemPlParserResult -parse_smil_entry (TotemPlParser *parser, - char *base, - xml_node_t *doc, - xml_node_t *parent, - const char *parent_title) -{ - xml_node_t *node; - const char *title, *url, *author, *abstract, *dur, *clip_begin, *copyright; - TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_ERROR; - - title = NULL; - url = NULL; - author = NULL; - abstract = NULL; - dur = NULL; - clip_begin = NULL; - copyright = NULL; - - for (node = parent->child; node != NULL; node = node->next) - { - if (node->name == NULL) - continue; - - /* ENTRY should only have one ref and one title nodes */ - if (g_ascii_strcasecmp (node->name, "video") == 0 || g_ascii_strcasecmp (node->name, "audio") == 0) { - url = xml_parser_get_property (node, "src"); - title = xml_parser_get_property (node, "title"); - author = xml_parser_get_property (node, "author"); - dur = xml_parser_get_property (node, "dur"); - clip_begin = xml_parser_get_property (node, "clip-begin"); - abstract = xml_parser_get_property (node, "abstract"); - copyright = xml_parser_get_property (node, "copyright"); - - if (url != NULL) { - char *fullpath; - - fullpath = totem_pl_parser_resolve_url (base, url); - totem_pl_parser_add_url (parser, - TOTEM_PL_PARSER_FIELD_URL, fullpath, - TOTEM_PL_PARSER_FIELD_TITLE, title ? title : parent_title, - TOTEM_PL_PARSER_FIELD_ABSTRACT, abstract, - TOTEM_PL_PARSER_FIELD_COPYRIGHT, copyright, - TOTEM_PL_PARSER_FIELD_AUTHOR, author, - TOTEM_PL_PARSER_FIELD_STARTTIME, clip_begin, - TOTEM_PL_PARSER_FIELD_DURATION, dur, - NULL); - g_free (fullpath); - retval = TOTEM_PL_PARSER_RESULT_SUCCESS; - } - } else { - if (parse_smil_entry (parser, - base, doc, node, parent_title) != FALSE) - retval = TOTEM_PL_PARSER_RESULT_SUCCESS; - } - } - - return retval; -} - -static const char* -parse_smil_head (TotemPlParser *parser, xml_node_t *doc, xml_node_t *parent) -{ - xml_node_t *node; - const char *title; - - title = NULL; - - for (node = parent->child; node != NULL; node = node->next) { - if (g_ascii_strcasecmp (node->name, "meta") == 0) { - const char *prop; - prop = xml_parser_get_property (node, "name"); - if (prop != NULL && g_ascii_strcasecmp (prop, "title") == 0) { - title = xml_parser_get_property (node, "content"); - if (title != NULL) - break; - } - } - } - - return title; -} - -static TotemPlParserResult -parse_smil_entries (TotemPlParser *parser, char *base, xml_node_t *doc) -{ - TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_ERROR; - const char *title; - xml_node_t *node; - - title = NULL; - - for (node = doc->child; node != NULL; node = node->next) { - if (node->name == NULL) - continue; - - if (g_ascii_strcasecmp (node->name, "body") == 0) { - if (parse_smil_entry (parser, base, - doc, node, title) != FALSE) { - retval = TOTEM_PL_PARSER_RESULT_SUCCESS; - } - } else if (title == NULL) { - if (g_ascii_strcasecmp (node->name, "head") == 0) - title = parse_smil_head (parser, doc, node); - } - } - - return retval; -} - -static TotemPlParserResult -totem_pl_parser_add_smil_with_doc (TotemPlParser *parser, const char *url, - const char *_base, xml_node_t *doc) -{ - TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED; - char *base; - - /* If the document has no root, or no name */ - if(doc->name == NULL - || g_ascii_strcasecmp (doc->name, "smil") != 0) { - return TOTEM_PL_PARSER_RESULT_ERROR; - } - - base = totem_pl_parser_base_url (url); - - retval = parse_smil_entries (parser, base, doc); - - g_free (base); - - return retval; -} - -TotemPlParserResult -totem_pl_parser_add_smil (TotemPlParser *parser, const char *url, - const char *_base, gpointer data) -{ - char *contents; - int size; - TotemPlParserResult retval; - - if (gnome_vfs_read_entire_file (url, &size, &contents) != GNOME_VFS_OK) - return TOTEM_PL_PARSER_RESULT_ERROR; - - retval = totem_pl_parser_add_smil_with_data (parser, url, - _base, contents, size); - g_free (contents); - return retval; -} - -TotemPlParserResult -totem_pl_parser_add_smil_with_data (TotemPlParser *parser, const char *url, - const char *_base, const char *contents, int size) -{ - xml_node_t* doc; - TotemPlParserResult retval; - - xml_parser_init (contents, size, XML_PARSER_CASE_INSENSITIVE); - if (xml_parser_build_tree_with_options (&doc, XML_PARSER_RELAXED | XML_PARSER_MULTI_TEXT) < 0) - return TOTEM_PL_PARSER_RESULT_ERROR; - - retval = totem_pl_parser_add_smil_with_doc (parser, url, _base, doc); - xml_parser_free_tree (doc); - - return retval; -} - -#endif /* !TOTEM_PL_PARSER_MINI */ - diff --git a/plparse/totem-pl-parser-smil.h b/plparse/totem-pl-parser-smil.h deleted file mode 100644 index a5b8de5dd..000000000 --- a/plparse/totem-pl-parser-smil.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - 2002, 2003, 2004, 2005, 2006, 2007 Bastien Nocera - Copyright (C) 2003 Colin Walters <walters@verbum.org> - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera <hadess@hadess.net> - */ - -#ifndef TOTEM_PL_PARSER_SMIL_H -#define TOTEM_PL_PARSER_SMIL_H - -G_BEGIN_DECLS - -#ifndef TOTEM_PL_PARSER_MINI -#include "totem-pl-parser.h" -#else -#include "totem-pl-parser-mini.h" -#endif /* !TOTEM_PL_PARSER_MINI */ - -#ifndef TOTEM_PL_PARSER_MINI -TotemPlParserResult totem_pl_parser_add_smil (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data); -TotemPlParserResult totem_pl_parser_add_smil_with_data (TotemPlParser *parser, - const char *url, - const char *base, - const char *contents, - int size); -#endif /* !TOTEM_PL_PARSER_MINI */ - -G_END_DECLS - -#endif /* TOTEM_PL_PARSER_SMIL_H */ diff --git a/plparse/totem-pl-parser-wm.c b/plparse/totem-pl-parser-wm.c deleted file mode 100644 index fd1cdfab0..000000000 --- a/plparse/totem-pl-parser-wm.c +++ /dev/null @@ -1,445 +0,0 @@ -/* - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Bastien Nocera - Copyright (C) 2003, 2004 Colin Walters <walters@rhythmbox.org> - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera <hadess@hadess.net> - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include <string.h> -#include <glib.h> -#include <libgnomevfs/gnome-vfs-mime-utils.h> - -#ifndef TOTEM_PL_PARSER_MINI -#include "xmlparser.h" -#include <gtk/gtk.h> -#include <libgnomevfs/gnome-vfs.h> -#include <libgnomevfs/gnome-vfs-mime.h> -#include <libgnomevfs/gnome-vfs-utils.h> -#include "totem-pl-parser.h" -#include "totemplparser-marshal.h" -#include "totem-disc.h" -#endif /* !TOTEM_PL_PARSER_MINI */ - -#include "totem-pl-parser-mini.h" -#include "totem-pl-parser-wm.h" -#include "totem-pl-parser-lines.h" -#include "totem-pl-parser-private.h" - -#ifndef TOTEM_PL_PARSER_MINI - -static TotemPlParserResult -totem_pl_parser_add_asf_reference_parser (TotemPlParser *parser, - const char *url, const char *base, - gpointer data) -{ - char *contents, **lines, *ref, *split_char; - int size; - - if (gnome_vfs_read_entire_file (url, &size, &contents) != GNOME_VFS_OK) - return TOTEM_PL_PARSER_RESULT_ERROR; - - if (strstr(contents,"\x0d") == NULL) { - split_char = "\n"; - } else { - split_char = "\x0d\n"; - } - - lines = g_strsplit (contents, split_char, 0); - g_free (contents); - - /* Try to get Ref1 first */ - ref = totem_pl_parser_read_ini_line_string (lines, "Ref1", FALSE); - if (ref == NULL) { - g_strfreev (lines); - return totem_pl_parser_add_asx (parser, url, base, data); - } - - /* change http to mmsh, thanks Microsoft */ - if (g_str_has_prefix (ref, "http") != FALSE) - memcpy(ref, "mmsh", 4); - - totem_pl_parser_add_one_url (parser, ref, NULL); - g_free (ref); - - /* Don't try to get Ref2, as it's only ever - * supposed to be a fallback */ - - g_strfreev (lines); - - return TOTEM_PL_PARSER_RESULT_SUCCESS; -} - -static TotemPlParserResult -totem_pl_parser_add_asf_parser (TotemPlParser *parser, - const char *url, const char *base, - gpointer data) -{ - TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED; - char *contents, *ref; - int size; - - /* NSC files are handled directly by GStreamer */ - if (g_str_has_prefix (data, "[Address]") != FALSE) - return TOTEM_PL_PARSER_RESULT_UNHANDLED; - - if (g_str_has_prefix (data, "ASF ") == FALSE) { - return totem_pl_parser_add_asf_reference_parser (parser, url, base, data); - } - - if (gnome_vfs_read_entire_file (url, &size, &contents) != GNOME_VFS_OK) - return TOTEM_PL_PARSER_RESULT_ERROR; - - if (size <= 4) { - g_free (contents); - return TOTEM_PL_PARSER_RESULT_ERROR; - } - - /* Skip 'ASF ' */ - ref = contents + 4; - if (g_str_has_prefix (ref, "http") != FALSE) { - memcpy(ref, "mmsh", 4); - totem_pl_parser_add_one_url (parser, ref, NULL); - retval = TOTEM_PL_PARSER_RESULT_SUCCESS; - } - - g_free (contents); - return retval; -} - -static gboolean -parse_asx_entry (TotemPlParser *parser, const char *base, xml_node_t *parent) -{ - xml_node_t *node; - TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_SUCCESS; - char *fullpath; - const char *url; - const char *title, *duration, *starttime, *author; - const char *moreinfo, *abstract, *copyright; - - fullpath = NULL; - title = NULL; - url = NULL; - duration = NULL; - starttime = NULL; - moreinfo = NULL; - abstract = NULL; - copyright = NULL; - author = NULL; - - for (node = parent->child; node != NULL; node = node->next) { - if (node->name == NULL) - continue; - - /* ENTRY can only have one title node but multiple REFs */ - if (g_ascii_strcasecmp (node->name, "ref") == 0) { - const char *tmp; - - tmp = xml_parser_get_property (node, "href"); - if (tmp == NULL) - continue; - /* FIXME, should we prefer mms streams, or non-mms? - * See bug #352559 */ - if (url == NULL) - url = tmp; - - continue; - } - - if (g_ascii_strcasecmp (node->name, "title") == 0) - title = node->data; - - if (g_ascii_strcasecmp (node->name, "author") == 0) - author = node->data; - - if (g_ascii_strcasecmp (node->name, "moreinfo") == 0) { - const char *tmp; - - tmp = xml_parser_get_property (node, "href"); - if (tmp == NULL) - continue; - moreinfo = tmp; - } - - if (g_ascii_strcasecmp (node->name, "copyright") == 0) - copyright = node->data; - - if (g_ascii_strcasecmp (node->name, "abstract") == 0) - abstract = node->data; - - if (g_ascii_strcasecmp (node->name, "duration") == 0) { - const char *tmp; - - tmp = xml_parser_get_property (node, "value"); - if (tmp == NULL) - continue; - duration = tmp; - } - - if (g_ascii_strcasecmp (node->name, "starttime") == 0) { - const char *tmp; - - tmp = xml_parser_get_property (node, "value"); - if (tmp == NULL) - continue; - starttime = tmp; - } - - if (g_ascii_strcasecmp (node->name, "param") == 0) { - const char *name, *value; - - name = xml_parser_get_property (node, "name"); - if (name == NULL || g_ascii_strcasecmp (name, "showwhilebuffering") != 0) - continue; - value = xml_parser_get_property (node, "value"); - if (value == NULL || g_ascii_strcasecmp (value, "true") != 0) - continue; - - /* We ignore items that are the buffering images */ - retval = TOTEM_PL_PARSER_RESULT_IGNORED; - goto bail; - } - } - - if (url == NULL) - return TOTEM_PL_PARSER_RESULT_ERROR; - - fullpath = totem_pl_parser_resolve_url (base, url); - - /* .asx files can contain references to other .asx files */ - retval = totem_pl_parser_parse_internal (parser, fullpath, NULL); - if (retval != TOTEM_PL_PARSER_RESULT_SUCCESS) { - totem_pl_parser_add_url (parser, - TOTEM_PL_PARSER_FIELD_URL, fullpath, - TOTEM_PL_PARSER_FIELD_TITLE, title, - TOTEM_PL_PARSER_FIELD_ABSTRACT, abstract, - TOTEM_PL_PARSER_FIELD_COPYRIGHT, copyright, - TOTEM_PL_PARSER_FIELD_AUTHOR, author, - TOTEM_PL_PARSER_FIELD_STARTTIME, starttime, - TOTEM_PL_PARSER_FIELD_DURATION, duration, - TOTEM_PL_PARSER_FIELD_MOREINFO, moreinfo, - NULL); - retval = TOTEM_PL_PARSER_RESULT_SUCCESS; - } - -bail: - g_free (fullpath); - - return retval; -} - -static gboolean -parse_asx_entryref (TotemPlParser *parser, const char *base, xml_node_t *node) -{ - TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_SUCCESS; - const char *url; - char *fullpath; - - fullpath = NULL; - url = NULL; - - url = xml_parser_get_property (node, "href"); - - if (url == NULL) { - return TOTEM_PL_PARSER_RESULT_ERROR; - } - - fullpath = totem_pl_parser_resolve_url (base, url); - - /* .asx files can contain references to other .asx files */ - retval = totem_pl_parser_parse_internal (parser, fullpath, NULL); - if (retval != TOTEM_PL_PARSER_RESULT_SUCCESS) { - totem_pl_parser_add_url (parser, - TOTEM_PL_PARSER_FIELD_URL, fullpath, - NULL); - retval = TOTEM_PL_PARSER_RESULT_SUCCESS; - } - - g_free (fullpath); - - return retval; -} - -//FIXME the retval is completely wrong -static gboolean -parse_asx_entries (TotemPlParser *parser, const char *url, const char *_base, xml_node_t *parent) -{ - char *title = NULL; - const char *newbase = NULL, *base = NULL; - xml_node_t *node; - TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_ERROR; - - base = _base; - - for (node = parent->child; node != NULL; node = node->next) { - if (node->name == NULL) - continue; - - if (g_ascii_strcasecmp (node->name, "title") == 0) { - g_free (title); - title = g_strdup (node->data); - totem_pl_parser_add_url (parser, - TOTEM_PL_PARSER_FIELD_IS_PLAYLIST, TRUE, - TOTEM_PL_PARSER_FIELD_URL, url, - TOTEM_PL_PARSER_FIELD_TITLE, title, - NULL); - } - if (g_ascii_strcasecmp (node->name, "base") == 0) { - newbase = xml_parser_get_property (node, "href"); - if (newbase != NULL) - base = newbase; - } - if (g_ascii_strcasecmp (node->name, "entry") == 0) { - /* Whee! found an entry here, find the REF and TITLE */ - if (parse_asx_entry (parser, base, node) != FALSE) - retval = TOTEM_PL_PARSER_RESULT_SUCCESS; - } - if (g_ascii_strcasecmp (node->name, "entryref") == 0) { - /* Found an entryref, extract the REF attribute */ - if (parse_asx_entryref (parser, base, node) != FALSE) - retval = TOTEM_PL_PARSER_RESULT_SUCCESS; - } - if (g_ascii_strcasecmp (node->name, "repeat") == 0) { - /* Repeat at the top-level */ - if (parse_asx_entries (parser, url, base, node) != FALSE) - retval = TOTEM_PL_PARSER_RESULT_SUCCESS; - } - } - - if (title != NULL) - totem_pl_parser_playlist_end (parser, url); - g_free (title); - - return retval; -} - -TotemPlParserResult -totem_pl_parser_add_asx (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data) -{ - xml_node_t* doc; - char *_base, *contents; - int size; - TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED; - - if (data != NULL && totem_pl_parser_is_uri_list (data, strlen (data)) != FALSE) { - return totem_pl_parser_add_ram (parser, url, data); - } - - if (gnome_vfs_read_entire_file (url, &size, &contents) != GNOME_VFS_OK) - return TOTEM_PL_PARSER_RESULT_ERROR; - - xml_parser_init (contents, size, XML_PARSER_CASE_INSENSITIVE); - if (xml_parser_build_tree_with_options (&doc, XML_PARSER_RELAXED | XML_PARSER_MULTI_TEXT) < 0) { - g_free (contents); - return TOTEM_PL_PARSER_RESULT_ERROR; - } - /* If the document has no name */ - if (doc->name == NULL - || g_ascii_strcasecmp (doc->name , "asx") != 0) { - g_free (contents); - xml_parser_free_tree (doc); - return TOTEM_PL_PARSER_RESULT_ERROR; - } - - if (base == NULL) { - _base = totem_pl_parser_base_url (url); - } else { - _base = g_strdup (base); - } - - if (parse_asx_entries (parser, url, _base, doc) != FALSE) - retval = TOTEM_PL_PARSER_RESULT_SUCCESS; - - g_free (_base); - g_free (contents); - xml_parser_free_tree (doc); - - return retval; -} - -TotemPlParserResult -totem_pl_parser_add_asf (TotemPlParser *parser, const char *url, - const char *base, gpointer data) -{ - if (data == NULL) { - totem_pl_parser_add_one_url (parser, url, NULL); - return TOTEM_PL_PARSER_RESULT_SUCCESS; - } - - if (totem_pl_parser_is_asf (data, strlen (data)) == FALSE) { - totem_pl_parser_add_one_url (parser, url, NULL); - return TOTEM_PL_PARSER_RESULT_SUCCESS; - } - - return totem_pl_parser_add_asf_parser (parser, url, base, data); -} - -#endif /* !TOTEM_PL_PARSER_MINI */ - -gboolean -totem_pl_parser_is_asx (const char *data, gsize len) -{ - char *buffer; - - if (len == 0) - return FALSE; - - if (g_ascii_strncasecmp (data, "<ASX", strlen ("<ASX")) == 0) - return TRUE; - - if (len > MIME_READ_CHUNK_SIZE) - len = MIME_READ_CHUNK_SIZE; - - /* FIXME would be nicer to have an strnstr */ - buffer = g_memdup (data, len); - if (buffer == NULL) { - g_warning ("Couldn't dup data in totem_pl_parser_is_asx"); - return FALSE; - } - buffer[len - 1] = '\0'; - if (strstr (buffer, "<ASX") != NULL - || strstr (buffer, "<asx") != NULL) { - g_free (buffer); - return TRUE; - } - g_free (buffer); - - return FALSE; -} - -gboolean -totem_pl_parser_is_asf (const char *data, gsize len) -{ - if (len == 0) - return FALSE; - - if (g_str_has_prefix (data, "[Reference]") != FALSE - || g_str_has_prefix (data, "ASF ") != FALSE - || g_str_has_prefix (data, "[Address]") != FALSE) { - return TRUE; - } - - return totem_pl_parser_is_asx (data, len); -} - diff --git a/plparse/totem-pl-parser-wm.h b/plparse/totem-pl-parser-wm.h deleted file mode 100644 index bca4e810f..000000000 --- a/plparse/totem-pl-parser-wm.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - 2002, 2003, 2004, 2005, 2006, 2007 Bastien Nocera - Copyright (C) 2003 Colin Walters <walters@verbum.org> - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera <hadess@hadess.net> - */ - -#ifndef TOTEM_PL_PARSER_WM_H -#define TOTEM_PL_PARSER_WM_H - -G_BEGIN_DECLS - -#ifndef TOTEM_PL_PARSER_MINI -#include "totem-pl-parser.h" -#else -#include "totem-pl-parser-mini.h" -#endif /* !TOTEM_PL_PARSER_MINI */ - -gboolean totem_pl_parser_is_asf (const char *data, gsize len); -gboolean totem_pl_parser_is_asx (const char *data, gsize len); - -#ifndef TOTEM_PL_PARSER_MINI -TotemPlParserResult totem_pl_parser_add_asf (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data); -TotemPlParserResult totem_pl_parser_add_asx (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data); -#endif /* !TOTEM_PL_PARSER_MINI */ - -G_END_DECLS - -#endif /* TOTEM_PL_PARSER_WM_H */ diff --git a/plparse/totem-pl-parser-xspf.c b/plparse/totem-pl-parser-xspf.c deleted file mode 100644 index 718968052..000000000 --- a/plparse/totem-pl-parser-xspf.c +++ /dev/null @@ -1,294 +0,0 @@ -/* - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Bastien Nocera - Copyright (C) 2003, 2004 Colin Walters <walters@rhythmbox.org> - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera <hadess@hadess.net> - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - - -#ifndef TOTEM_PL_PARSER_MINI -#include <string.h> -#include <glib.h> -#include <glib/gi18n-lib.h> -#include <libxml/tree.h> -#include <libxml/parser.h> -#include <gtk/gtk.h> -#include <libgnomevfs/gnome-vfs.h> -#include "totem-pl-parser.h" -#include "totemplparser-marshal.h" -#endif /* !TOTEM_PL_PARSER_MINI */ - -#include "totem-pl-parser-mini.h" -#include "totem-pl-parser-xspf.h" -#include "totem-pl-parser-private.h" - -#ifndef TOTEM_PL_PARSER_MINI - -static xmlDocPtr -totem_pl_parser_parse_xml_file (const char *url) -{ - xmlDocPtr doc; - char *contents; - int size; - - if (gnome_vfs_read_entire_file (url, &size, &contents) != GNOME_VFS_OK) - return NULL; - - /* Try to remove HTML style comments */ - { - char *needle; - - while ((needle = strstr (contents, "<!--")) != NULL) { - while (strncmp (needle, "-->", 3) != 0) { - *needle = ' '; - needle++; - if (*needle == '\0') - break; - } - } - } - - doc = xmlParseMemory (contents, size); - if (doc == NULL) - doc = xmlRecoverMemory (contents, size); - g_free (contents); - - return doc; -} - -gboolean -totem_pl_parser_write_xspf (TotemPlParser *parser, GtkTreeModel *model, - TotemPlParserIterFunc func, - const char *output, const char *title, - gpointer user_data, GError **error) -{ - GnomeVFSHandle *handle; - GnomeVFSResult res; - int num_entries_total, num_entries, i; - char *buf; - gboolean success; - - num_entries = totem_pl_parser_num_entries (parser, model, func, user_data); - num_entries_total = gtk_tree_model_iter_n_children (model, NULL); - - res = gnome_vfs_open (&handle, output, GNOME_VFS_OPEN_WRITE); - if (res == GNOME_VFS_ERROR_NOT_FOUND) { - res = gnome_vfs_create (&handle, output, - GNOME_VFS_OPEN_WRITE, FALSE, - GNOME_VFS_PERM_USER_WRITE - | GNOME_VFS_PERM_USER_READ - | GNOME_VFS_PERM_GROUP_READ); - } - - if (res != GNOME_VFS_OK) { - g_set_error(error, - TOTEM_PL_PARSER_ERROR, - TOTEM_PL_PARSER_ERROR_VFS_OPEN, - _("Couldn't open file '%s': %s"), - output, gnome_vfs_result_to_string (res)); - return FALSE; - } - - buf = g_strdup_printf ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" - "<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\">\n" - " <trackList>\n"); - success = totem_pl_parser_write_string (handle, buf, error); - g_free (buf); - if (success == FALSE) - { - gnome_vfs_close (handle); - return FALSE; - } - - for (i = 1; i <= num_entries_total; i++) { - GtkTreeIter iter; - char *url, *url_escaped, *relative, *title; - gboolean custom_title; - - if (gtk_tree_model_iter_nth_child (model, &iter, NULL, i - 1) == FALSE) - continue; - - func (model, &iter, &url, &title, &custom_title, user_data); - - if (totem_pl_parser_scheme_is_ignored (parser, url) != FALSE) - { - g_free (url); - g_free (title); - continue; - } - - relative = totem_pl_parser_relative (url, output); - url_escaped = g_markup_escape_text (relative ? relative : url, -1); - buf = g_strdup_printf (" <track>\n" - " <location>%s</location>\n", url_escaped); - success = totem_pl_parser_write_string (handle, buf, error); - g_free (url); - g_free (url_escaped); - g_free (relative); - g_free (buf); - if (success == FALSE) - { - gnome_vfs_close (handle); - g_free (title); - return FALSE; - } - - if (custom_title == TRUE) - buf = g_strdup_printf (" <title>%s</title>\n" - " </track>\n", title); - else - buf = g_strdup_printf (" </track>\n"); - - success = totem_pl_parser_write_string (handle, buf, error); - g_free (buf); - g_free (title); - if (success == FALSE) - { - gnome_vfs_close (handle); - return FALSE; - } - } - - buf = g_strdup_printf (" </trackList>\n" - "</playlist>"); - success = totem_pl_parser_write_string (handle, buf, error); - g_free (buf); - gnome_vfs_close (handle); - - return success; -} - -static gboolean -parse_xspf_track (TotemPlParser *parser, char *base, xmlDocPtr doc, - xmlNodePtr parent) -{ - xmlNodePtr node; - xmlChar *title, *url; - gchar *fullpath; - TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_ERROR; - - title = NULL; - url = NULL; - - for (node = parent->children; node != NULL; node = node->next) - { - if (node->name == NULL) - continue; - - if (g_ascii_strcasecmp ((char *)node->name, "location") == 0) - url = xmlNodeListGetString (doc, node->xmlChildrenNode, 1); - - if (g_ascii_strcasecmp ((char *)node->name, "title") == 0) - title = xmlNodeListGetString (doc, node->xmlChildrenNode, 1); - } - - if (url == NULL) { - if (title) - xmlFree (title); - return TOTEM_PL_PARSER_RESULT_ERROR; - } - - fullpath = totem_pl_parser_resolve_url (base, (char *)url); - totem_pl_parser_add_one_url (parser, fullpath, (char *)title); - retval = TOTEM_PL_PARSER_RESULT_SUCCESS; - - if (title) - xmlFree (title); - if (url) - xmlFree (url); - g_free (fullpath); - - return retval; -} - -static gboolean -parse_xspf_trackList (TotemPlParser *parser, char *base, xmlDocPtr doc, - xmlNodePtr parent) -{ - xmlNodePtr node; - TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_ERROR; - - for (node = parent->children; node != NULL; node = node->next) - { - if (node->name == NULL) - continue; - - if (g_ascii_strcasecmp ((char *)node->name, "track") == 0) - if (parse_xspf_track (parser, base, doc, node) != FALSE) - retval = TOTEM_PL_PARSER_RESULT_SUCCESS; - } - - return retval; -} - -static gboolean -parse_xspf_entries (TotemPlParser *parser, char *base, xmlDocPtr doc, - xmlNodePtr parent) -{ - xmlNodePtr node; - TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_ERROR; - - for (node = parent->children; node != NULL; node = node->next) { - if (node->name == NULL) - continue; - - if (g_ascii_strcasecmp ((char *)node->name, "trackList") == 0) - if (parse_xspf_trackList (parser, base, doc, node) != FALSE) - retval = TOTEM_PL_PARSER_RESULT_SUCCESS; - } - - return retval; -} - -TotemPlParserResult -totem_pl_parser_add_xspf (TotemPlParser *parser, const char *url, - const char *_base, gpointer data) -{ - xmlDocPtr doc; - xmlNodePtr node; - char *base; - TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED; - - doc = totem_pl_parser_parse_xml_file (url); - - /* If the document has no root, or no name */ - if(!doc || !doc->children - || !doc->children->name - || g_ascii_strcasecmp ((char *)doc->children->name, - "playlist") != 0) { - if (doc != NULL) - xmlFreeDoc(doc); - return TOTEM_PL_PARSER_RESULT_ERROR; - } - - base = totem_pl_parser_base_url (url); - - for (node = doc->children; node != NULL; node = node->next) - if (parse_xspf_entries (parser, base, doc, node) != FALSE) - retval = TOTEM_PL_PARSER_RESULT_SUCCESS; - - g_free (base); - xmlFreeDoc(doc); - return retval; -} -#endif /* !TOTEM_PL_PARSER_MINI */ - diff --git a/plparse/totem-pl-parser-xspf.h b/plparse/totem-pl-parser-xspf.h deleted file mode 100644 index e79380867..000000000 --- a/plparse/totem-pl-parser-xspf.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - 2002, 2003, 2004, 2005, 2006, 2007 Bastien Nocera - Copyright (C) 2003 Colin Walters <walters@verbum.org> - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera <hadess@hadess.net> - */ - -#ifndef TOTEM_PL_PARSER_XSPF_H -#define TOTEM_PL_PARSER_XSPF_H - -G_BEGIN_DECLS - -#ifdef TOTEM_PL_PARSER_MINI -#include "totem-pl-parser-mini.h" -#endif /* TOTEM_PL_PARSER_MINI */ - -#ifndef TOTEM_PL_PARSER_MINI -gboolean totem_pl_parser_write_xspf (TotemPlParser *parser, - GtkTreeModel *model, - TotemPlParserIterFunc func, - const char *output, - const char *title, - gpointer user_data, - GError **error); -TotemPlParserResult totem_pl_parser_add_xspf (TotemPlParser *parser, - const char *url, - const char *base, - gpointer data); -#endif /* !TOTEM_PL_PARSER_MINI */ - -G_END_DECLS - -#endif /* TOTEM_PL_PARSER_XSPF_H */ diff --git a/plparse/totem-pl-parser.c b/plparse/totem-pl-parser.c deleted file mode 100644 index c639ddae3..000000000 --- a/plparse/totem-pl-parser.c +++ /dev/null @@ -1,1497 +0,0 @@ -/* - Copyright (C) 2002, 2003, 2004, 2005, 2006 Bastien Nocera - Copyright (C) 2003, 2004 Colin Walters <walters@rhythmbox.org> - - Copyright (C) 2005 Renato Araujo Oliveira Filho - INdT <renato.filho@indt.org.br> - for totem_pl_parser_parse_date () - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Authors: Bastien Nocera <hadess@hadess.net> - - for totem_pl_parser_parse_date (): - James Livingston <doclivingston@gmail.com> - William Jon McCann <mccann@jhu.edu> - Renato Araujo Oliveira Filho - INdT <renato.filho@indt.org.br> - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - -#define _XOPEN_SOURCE -#include <time.h> - -#include <string.h> -#include <glib.h> -#include <glib/gi18n-lib.h> -#include <libgnomevfs/gnome-vfs-mime-utils.h> - -#ifndef TOTEM_PL_PARSER_MINI -#include <gobject/gvaluecollector.h> -#include <gtk/gtk.h> -#include <libgnomevfs/gnome-vfs.h> -#include <libgnomevfs/gnome-vfs-mime.h> -#include <libgnomevfs/gnome-vfs-utils.h> - -#include "totem-pl-parser.h" -#include "totemplparser-marshal.h" -#include "totem-disc.h" -#endif /* !TOTEM_PL_PARSER_MINI */ - -#include "totem-pl-parser-mini.h" -#include "totem-pl-parser-wm.h" -#include "totem-pl-parser-qt.h" -#include "totem-pl-parser-pls.h" -#include "totem-pl-parser-xspf.h" -#include "totem-pl-parser-media.h" -#include "totem-pl-parser-smil.h" -#include "totem-pl-parser-pla.h" -#include "totem-pl-parser-podcast.h" -#include "totem-pl-parser-lines.h" -#include "totem-pl-parser-misc.h" -#include "totem-pl-parser-private.h" - -#define READ_CHUNK_SIZE 8192 -#define RECURSE_LEVEL_MAX 4 -#define DIR_MIME_TYPE "x-directory/normal" -#define BLOCK_DEVICE_TYPE "x-special/device-block" -#define EMPTY_FILE_TYPE "application/x-zerosize" -#define TEXT_URI_TYPE "text/uri-list" -#define AUDIO_MPEG_TYPE "audio/mpeg" - -#define D(x) if (debug) x - -typedef gboolean (*PlaylistIdenCallback) (const char *data, gsize len); - -#ifndef TOTEM_PL_PARSER_MINI -typedef TotemPlParserResult (*PlaylistCallback) (TotemPlParser *parser, const char *url, const char *base, gpointer data); -#endif - -typedef struct { - char *mimetype; -#ifndef TOTEM_PL_PARSER_MINI - PlaylistCallback func; -#endif - PlaylistIdenCallback iden; -#ifndef TOTEM_PL_PARSER_MINI - guint unsafe : 1; -#endif -} PlaylistTypes; - -#ifndef TOTEM_PL_PARSER_MINI - -static void totem_pl_parser_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void totem_pl_parser_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -enum { - PROP_NONE, - PROP_RECURSE, - PROP_DEBUG, - PROP_FORCE, - PROP_DISABLE_UNSAFE -}; - -/* Signals */ -enum { - ENTRY_PARSED, - PLAYLIST_STARTED, - PLAYLIST_ENDED, - LAST_SIGNAL -}; - -static int totem_pl_parser_table_signals[LAST_SIGNAL]; -static gboolean i18n_done = FALSE; - -static void totem_pl_parser_class_init (TotemPlParserClass *class); -static void totem_pl_parser_init (TotemPlParser *parser); -static void totem_pl_parser_finalize (GObject *object); - -G_DEFINE_TYPE(TotemPlParser, totem_pl_parser, G_TYPE_OBJECT) - -static void -totem_pl_parser_class_init (TotemPlParserClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (klass, sizeof (TotemPlParserPrivate)); - - object_class->finalize = totem_pl_parser_finalize; - object_class->set_property = totem_pl_parser_set_property; - object_class->get_property = totem_pl_parser_get_property; - - /* properties */ - g_object_class_install_property (object_class, - PROP_RECURSE, - g_param_spec_boolean ("recurse", - "recurse", - "Whether or not to process URLs further", - TRUE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - g_object_class_install_property (object_class, - PROP_DEBUG, - g_param_spec_boolean ("debug", - "debug", - "Whether or not to enable debugging output", - FALSE, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_FORCE, - g_param_spec_boolean ("force", - "force", - "Whether or not to force parsing the file if the playlist looks unsupported", - FALSE, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_DISABLE_UNSAFE, - g_param_spec_boolean ("disable-unsafe", - "disable-unsafe", - "Whether or not to disable parsing of unsafe locations", - FALSE, - G_PARAM_READWRITE)); - - /* Signals */ - totem_pl_parser_table_signals[ENTRY_PARSED] = - g_signal_new ("entry-parsed", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (TotemPlParserClass, entry_parsed), - NULL, NULL, - totemplparser_marshal_VOID__STRING_POINTER, - G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_POINTER); - totem_pl_parser_table_signals[PLAYLIST_STARTED] = - g_signal_new ("playlist-started", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (TotemPlParserClass, playlist_started), - NULL, NULL, - totemplparser_marshal_VOID__STRING_POINTER, - G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_POINTER); - totem_pl_parser_table_signals[PLAYLIST_ENDED] = - g_signal_new ("playlist-ended", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (TotemPlParserClass, playlist_ended), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, G_TYPE_STRING); -} - -static void -totem_pl_parser_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - TotemPlParser *parser = TOTEM_PL_PARSER (object); - - switch (prop_id) - { - case PROP_RECURSE: - parser->priv->recurse = g_value_get_boolean (value) != FALSE; - break; - case PROP_DEBUG: - parser->priv->debug = g_value_get_boolean (value) != FALSE; - break; - case PROP_FORCE: - parser->priv->force = g_value_get_boolean (value) != FALSE; - break; - case PROP_DISABLE_UNSAFE: - parser->priv->disable_unsafe = g_value_get_boolean (value) != FALSE; - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -totem_pl_parser_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - TotemPlParser *parser = TOTEM_PL_PARSER (object); - - switch (prop_id) - { - case PROP_RECURSE: - g_value_set_boolean (value, parser->priv->recurse); - break; - case PROP_DEBUG: - g_value_set_boolean (value, parser->priv->debug); - break; - case PROP_FORCE: - g_value_set_boolean (value, parser->priv->force); - break; - case PROP_DISABLE_UNSAFE: - g_value_set_boolean (value, parser->priv->disable_unsafe); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -GQuark -totem_pl_parser_error_quark (void) -{ - static GQuark quark; - if (!quark) - quark = g_quark_from_static_string ("totem_pl_parser_error"); - - return quark; -} - -static void -totem_pl_parser_init_i18n (void) -{ - if (i18n_done == FALSE) { - /* set up translation catalog */ - bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - i18n_done = TRUE; - } -} - -TotemPlParser * -totem_pl_parser_new (void) -{ - totem_pl_parser_init_i18n (); - return TOTEM_PL_PARSER (g_object_new (TOTEM_TYPE_PL_PARSER, NULL)); -} - -void -totem_pl_parser_playlist_end (TotemPlParser *parser, const char *playlist_uri) -{ - g_signal_emit (G_OBJECT (parser), - totem_pl_parser_table_signals[PLAYLIST_ENDED], - 0, playlist_uri); -} - -static char * -my_gnome_vfs_get_mime_type_with_data (const char *uri, gpointer *data, TotemPlParser *parser) -{ - GnomeVFSResult result; - GnomeVFSHandle *handle; - char *buffer; - const char *mimetype; - GnomeVFSFileSize total_bytes_read; - GnomeVFSFileSize bytes_read; - - *data = NULL; - - /* Stat for a block device, we're screwed as far as speed - * is concerned now */ - if (g_str_has_prefix (uri, "file://") != FALSE) { - struct stat buf; - if (stat (uri + strlen ("file://"), &buf) == 0) { - if (S_ISBLK (buf.st_mode)) - return g_strdup (BLOCK_DEVICE_TYPE); - } - } - - /* Open the file. */ - result = gnome_vfs_open (&handle, uri, GNOME_VFS_OPEN_READ); - if (result != GNOME_VFS_OK) { - if (result == GNOME_VFS_ERROR_IS_DIRECTORY) - return g_strdup (DIR_MIME_TYPE); - DEBUG(g_print ("URL '%s' couldn't be opened in _get_mime_type_with_data: '%s'\n", uri, gnome_vfs_result_to_string (result))); - return NULL; - } - DEBUG(g_print ("URL '%s' was opened successfully in _get_mime_type_with_data:\n", uri)); - - /* Read the whole thing, up to MIME_READ_CHUNK_SIZE */ - buffer = NULL; - total_bytes_read = 0; - bytes_read = 0; - do { - buffer = g_realloc (buffer, total_bytes_read - + MIME_READ_CHUNK_SIZE); - result = gnome_vfs_read (handle, - buffer + total_bytes_read, - MIME_READ_CHUNK_SIZE, - &bytes_read); - if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_EOF) { - g_free (buffer); - gnome_vfs_close (handle); - return NULL; - } - - /* Check for overflow. */ - if (total_bytes_read + bytes_read < total_bytes_read) { - g_free (buffer); - gnome_vfs_close (handle); - return NULL; - } - - total_bytes_read += bytes_read; - } while (result == GNOME_VFS_OK - && total_bytes_read < MIME_READ_CHUNK_SIZE); - - /* Close the file but don't overwrite the possible error */ - if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_EOF) - gnome_vfs_close (handle); - else - result = gnome_vfs_close (handle); - - if (result != GNOME_VFS_OK) { - DEBUG(g_print ("URL '%s' couldn't be read or closed in _get_mime_type_with_data: '%s'\n", uri, gnome_vfs_result_to_string (result))); - g_free (buffer); - return NULL; - } - - /* Empty file */ - if (total_bytes_read == 0) { - DEBUG(g_print ("URL '%s' is empty in _get_mime_type_with_data\n", uri)); - return g_strdup (EMPTY_FILE_TYPE); - } - - /* Return the file null-terminated. */ - buffer = g_realloc (buffer, total_bytes_read + 1); - buffer[total_bytes_read] = '\0'; - *data = buffer; - - mimetype = gnome_vfs_get_mime_type_for_data (*data, total_bytes_read); - - if (mimetype != NULL && strcmp (mimetype, "text/plain") == 0) { - if (totem_pl_parser_is_uri_list (*data, total_bytes_read) != FALSE) - return g_strdup (TEXT_URI_TYPE); - } - - return g_strdup (mimetype); -} - -char * -totem_pl_parser_base_url (const char *url) -{ - /* Yay, let's reconstruct the base by hand */ - GnomeVFSURI *uri, *parent; - char *base; - - uri = gnome_vfs_uri_new (url); - if (uri == NULL) - return NULL; - - parent = gnome_vfs_uri_get_parent (uri); - if (!parent) { - parent = uri; - } - base = gnome_vfs_uri_to_string (parent, 0); - - gnome_vfs_uri_unref (uri); - if (parent != uri) { - gnome_vfs_uri_unref (parent); - } - - return base; -} - -gboolean -totem_pl_parser_line_is_empty (const char *line) -{ - guint i; - - if (line == NULL) - return TRUE; - - for (i = 0; line[i] != '\0'; i++) { - if (line[i] != '\t' && line[i] != ' ') - return FALSE; - } - return TRUE; -} - -gboolean -totem_pl_parser_write_string (GnomeVFSHandle *handle, const char *buf, GError **error) -{ - guint len; - - len = strlen (buf); - return totem_pl_parser_write_buffer (handle, buf, len, error); -} - -gboolean -totem_pl_parser_write_buffer (GnomeVFSHandle *handle, const char *buf, guint len, GError **error) -{ - GnomeVFSResult res; - GnomeVFSFileSize written; - - res = gnome_vfs_write (handle, buf, len, &written); - if (res != GNOME_VFS_OK || written < len) { - g_set_error (error, - TOTEM_PL_PARSER_ERROR, - TOTEM_PL_PARSER_ERROR_VFS_WRITE, - _("Couldn't write parser: %s"), - gnome_vfs_result_to_string (res)); - gnome_vfs_close (handle); - return FALSE; - } - - return TRUE; -} - -int -totem_pl_parser_num_entries (TotemPlParser *parser, GtkTreeModel *model, - TotemPlParserIterFunc func, gpointer user_data) -{ - int num_entries, i, ignored; - - num_entries = gtk_tree_model_iter_n_children (model, NULL); - ignored = 0; - - for (i = 1; i <= num_entries; i++) - { - GtkTreeIter iter; - char *url, *title; - gboolean custom_title; - - if (gtk_tree_model_iter_nth_child (model, &iter, NULL, i -1) == FALSE) - return i - ignored; - - func (model, &iter, &url, &title, &custom_title, user_data); - if (totem_pl_parser_scheme_is_ignored (parser, url) != FALSE) - ignored++; - - g_free (url); - g_free (title); - } - - return num_entries - ignored; -} - -char * -totem_pl_parser_relative (const char *url, const char *output) -{ - char *url_base, *output_base; - char *base, *needle; - - base = NULL; - url_base = totem_pl_parser_base_url (url); - if (url_base == NULL) - return NULL; - - output_base = totem_pl_parser_base_url (output); - - needle = strstr (url_base, output_base); - if (needle != NULL) - { - GnomeVFSURI *uri; - char *newurl; - - uri = gnome_vfs_uri_new (url); - newurl = gnome_vfs_uri_to_string (uri, 0); - if (newurl[strlen (output_base)] == '/') { - base = g_strdup (newurl + strlen (output_base) + 1); - } else { - base = g_strdup (newurl + strlen (output_base)); - } - gnome_vfs_uri_unref (uri); - g_free (newurl); - - /* And finally unescape the string */ - newurl = gnome_vfs_unescape_string (base, NULL); - g_free (base); - base = newurl; - } - - g_free (url_base); - g_free (output_base); - - return base; -} - -#ifndef TOTEM_PL_PARSER_MINI -gboolean -totem_pl_parser_write_with_title (TotemPlParser *parser, GtkTreeModel *model, - TotemPlParserIterFunc func, - const char *output, const char *title, - TotemPlParserType type, - gpointer user_data, GError **error) -{ - switch (type) - { - case TOTEM_PL_PARSER_PLS: - return totem_pl_parser_write_pls (parser, model, func, - output, title, user_data, error); - case TOTEM_PL_PARSER_M3U: - case TOTEM_PL_PARSER_M3U_DOS: - return totem_pl_parser_write_m3u (parser, model, func, - output, (type == TOTEM_PL_PARSER_M3U_DOS), - user_data, error); - case TOTEM_PL_PARSER_XSPF: - return totem_pl_parser_write_xspf (parser, model, func, - output, title, user_data, error); - case TOTEM_PL_PARSER_IRIVER_PLA: - return totem_pl_parser_write_pla (parser, model, func, - output, title, user_data, error); - default: - g_assert_not_reached (); - } - - return FALSE; -} - -gboolean -totem_pl_parser_write (TotemPlParser *parser, GtkTreeModel *model, - TotemPlParserIterFunc func, - const char *output, TotemPlParserType type, - gpointer user_data, - GError **error) -{ - return totem_pl_parser_write_with_title (parser, model, func, output, - NULL, type, user_data, error); -} - -#endif /* TOTEM_PL_PARSER_MINI */ - -int -totem_pl_parser_read_ini_line_int (char **lines, const char *key) -{ - int retval = -1; - int i; - - if (lines == NULL || key == NULL) - return -1; - - for (i = 0; (lines[i] != NULL && retval == -1); i++) { - char *line = lines[i]; - - while (*line == '\t' || *line == ' ') - line++; - - if (g_ascii_strncasecmp (line, key, strlen (key)) == 0) { - char **bits; - - bits = g_strsplit (line, "=", 2); - if (bits[0] == NULL || bits [1] == NULL) { - g_strfreev (bits); - return -1; - } - - retval = (gint) g_strtod (bits[1], NULL); - g_strfreev (bits); - } - } - - return retval; -} - -char* -totem_pl_parser_read_ini_line_string_with_sep (char **lines, const char *key, - gboolean dos_mode, const char *sep) -{ - char *retval = NULL; - int i; - - if (lines == NULL || key == NULL) - return NULL; - - for (i = 0; (lines[i] != NULL && retval == NULL); i++) { - char *line = lines[i]; - - while (*line == '\t' || *line == ' ') - line++; - - if (g_ascii_strncasecmp (line, key, strlen (key)) == 0) { - char **bits; - ssize_t len; - - bits = g_strsplit (line, sep, 2); - if (bits[0] == NULL || bits [1] == NULL) { - g_strfreev (bits); - return NULL; - } - - retval = g_strdup (bits[1]); - len = strlen (retval); - if (dos_mode && len >= 2 && retval[len-2] == '\r') { - retval[len-2] = '\n'; - retval[len-1] = '\0'; - } - - g_strfreev (bits); - } - } - - return retval; -} - -char* -totem_pl_parser_read_ini_line_string (char **lines, const char *key, gboolean dos_mode) -{ - return totem_pl_parser_read_ini_line_string_with_sep (lines, key, dos_mode, "="); -} - -static void -totem_pl_parser_init (TotemPlParser *parser) -{ - GParamSpec *pspec; - parser->priv = G_TYPE_INSTANCE_GET_PRIVATE (parser, TOTEM_TYPE_PL_PARSER, TotemPlParserPrivate); - - parser->priv->pspec_pool = g_param_spec_pool_new (FALSE); - pspec = g_param_spec_string ("url", "url", - "URL to be added", NULL, - G_PARAM_READABLE & G_PARAM_WRITABLE); - g_param_spec_pool_insert (parser->priv->pspec_pool, pspec, TOTEM_TYPE_PL_PARSER); - pspec = g_param_spec_string ("title", "title", - "Title of the item to be added", NULL, - G_PARAM_READABLE & G_PARAM_WRITABLE); - g_param_spec_pool_insert (parser->priv->pspec_pool, pspec, TOTEM_TYPE_PL_PARSER); - pspec = g_param_spec_string ("author", "author", - "Author of the item to be added", NULL, - G_PARAM_READABLE & G_PARAM_WRITABLE); - g_param_spec_pool_insert (parser->priv->pspec_pool, pspec, TOTEM_TYPE_PL_PARSER); - pspec = g_param_spec_string ("genre", "genre", - "Genre of the item to be added", NULL, - G_PARAM_READABLE & G_PARAM_WRITABLE); - g_param_spec_pool_insert (parser->priv->pspec_pool, pspec, TOTEM_TYPE_PL_PARSER); - pspec = g_param_spec_string ("base", "base", - "Base URL of the item to be added", NULL, - G_PARAM_READABLE & G_PARAM_WRITABLE); - g_param_spec_pool_insert (parser->priv->pspec_pool, pspec, TOTEM_TYPE_PL_PARSER); - pspec = g_param_spec_string ("volume", "volume", - "Default playback volume (in percents)", NULL, - G_PARAM_READABLE & G_PARAM_WRITABLE); - g_param_spec_pool_insert (parser->priv->pspec_pool, pspec, TOTEM_TYPE_PL_PARSER); - pspec = g_param_spec_string ("autoplay", "autoplay", - "Whether or not to autoplay the stream", NULL, - G_PARAM_READABLE & G_PARAM_WRITABLE); - g_param_spec_pool_insert (parser->priv->pspec_pool, pspec, TOTEM_TYPE_PL_PARSER); - pspec = g_param_spec_string ("duration", "duration", - "String representing the duration of the entry, used for still images", NULL, - G_PARAM_READABLE & G_PARAM_WRITABLE); - g_param_spec_pool_insert (parser->priv->pspec_pool, pspec, TOTEM_TYPE_PL_PARSER); - pspec = g_param_spec_string ("starttime", "starttime", - "String representing the start time of the stream (initial seek)", NULL, - G_PARAM_READABLE & G_PARAM_WRITABLE); - g_param_spec_pool_insert (parser->priv->pspec_pool, pspec, TOTEM_TYPE_PL_PARSER); - pspec = g_param_spec_string ("copyright", "copyright", - "Copyright of the item to be added", NULL, - G_PARAM_READABLE & G_PARAM_WRITABLE); - g_param_spec_pool_insert (parser->priv->pspec_pool, pspec, TOTEM_TYPE_PL_PARSER); - pspec = g_param_spec_string ("abstract", "abstract", - "Abstract of the item to be added", NULL, - G_PARAM_READABLE & G_PARAM_WRITABLE); - g_param_spec_pool_insert (parser->priv->pspec_pool, pspec, TOTEM_TYPE_PL_PARSER); - pspec = g_param_spec_string ("moreinfo", "moreinfo", - "URL to get more information for item to be added", NULL, - G_PARAM_READABLE & G_PARAM_WRITABLE); - g_param_spec_pool_insert (parser->priv->pspec_pool, pspec, TOTEM_TYPE_PL_PARSER); - pspec = g_param_spec_string ("screensize", "screensize", - "String representing the default movie size (double, full or original)", NULL, - G_PARAM_READABLE & G_PARAM_WRITABLE); - g_param_spec_pool_insert (parser->priv->pspec_pool, pspec, TOTEM_TYPE_PL_PARSER); - pspec = g_param_spec_string ("ui-mode", "ui-mode", - "String representing the default UI mode (only compact is supported)", NULL, - G_PARAM_READABLE & G_PARAM_WRITABLE); - g_param_spec_pool_insert (parser->priv->pspec_pool, pspec, TOTEM_TYPE_PL_PARSER); - pspec = g_param_spec_string ("endtime", "endtime", - "String representing the end time of the stream", NULL, - G_PARAM_READABLE & G_PARAM_WRITABLE); - g_param_spec_pool_insert (parser->priv->pspec_pool, pspec, TOTEM_TYPE_PL_PARSER); - pspec = g_param_spec_boolean ("is-playlist", "is-playlist", - "Boolean saying whether the entry pushed is the top-level of a playlist", FALSE, - G_PARAM_READABLE & G_PARAM_WRITABLE); - g_param_spec_pool_insert (parser->priv->pspec_pool, pspec, TOTEM_TYPE_PL_PARSER); - pspec = g_param_spec_string ("description", "description", - "String representing the description of the stream", NULL, - G_PARAM_READABLE & G_PARAM_WRITABLE); - g_param_spec_pool_insert (parser->priv->pspec_pool, pspec, TOTEM_TYPE_PL_PARSER); - pspec = g_param_spec_string ("publication-date", "publication-date", - "String representing the publication date of the stream", NULL, - G_PARAM_READABLE & G_PARAM_WRITABLE); - g_param_spec_pool_insert (parser->priv->pspec_pool, pspec, TOTEM_TYPE_PL_PARSER); - pspec = g_param_spec_string ("filesize", "filesize", - "String representing the filesize of a file", NULL, - G_PARAM_READABLE & G_PARAM_WRITABLE); - g_param_spec_pool_insert (parser->priv->pspec_pool, pspec, TOTEM_TYPE_PL_PARSER); - pspec = g_param_spec_string ("language", "language", - "String representing the language of a stream", NULL, - G_PARAM_READABLE & G_PARAM_WRITABLE); - g_param_spec_pool_insert (parser->priv->pspec_pool, pspec, TOTEM_TYPE_PL_PARSER); - pspec = g_param_spec_string ("contact", "contact", - "String representing the contact for a playlist", NULL, - G_PARAM_READABLE & G_PARAM_WRITABLE); - g_param_spec_pool_insert (parser->priv->pspec_pool, pspec, TOTEM_TYPE_PL_PARSER); - pspec = g_param_spec_string ("image-url", "image-url", - "String representing the location of an image for a playlist", NULL, - G_PARAM_READABLE & G_PARAM_WRITABLE); - g_param_spec_pool_insert (parser->priv->pspec_pool, pspec, TOTEM_TYPE_PL_PARSER); -} - -static void -totem_pl_parser_finalize (GObject *object) -{ - TotemPlParser *parser = TOTEM_PL_PARSER (object); - - g_return_if_fail (object != NULL); - g_return_if_fail (parser->priv != NULL); - - g_list_foreach (parser->priv->ignore_schemes, (GFunc) g_free, NULL); - g_list_free (parser->priv->ignore_schemes); - - g_list_foreach (parser->priv->ignore_mimetypes, (GFunc) g_free, NULL); - g_list_free (parser->priv->ignore_mimetypes); - - G_OBJECT_CLASS (totem_pl_parser_parent_class)->finalize (object); -} - -static void -totem_pl_parser_add_url_valist (TotemPlParser *parser, - const gchar *first_property_name, - va_list var_args) -{ - const char *name; - char *title, *url; - GHashTable *metadata; - gboolean is_playlist; - - title = url = NULL; - is_playlist = FALSE; - - g_object_ref (G_OBJECT (parser)); - metadata = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); - - name = first_property_name; - - while (name) { - GValue value = { 0, }; - GParamSpec *pspec; - char *error = NULL; - const char *string; - - pspec = g_param_spec_pool_lookup (parser->priv->pspec_pool, - name, - G_OBJECT_TYPE (parser), - FALSE); - - if (!pspec) { - g_warning ("Unknown property '%s'", name); - name = va_arg (var_args, char*); - continue; - } - - g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec)); - G_VALUE_COLLECT (&value, var_args, 0, &error); - if (error != NULL) { - g_warning ("Error getting the value for property '%s'", name); - break; - } - - if (strcmp (name, TOTEM_PL_PARSER_FIELD_URL) == 0) - url = g_value_dup_string (&value); - else if (strcmp (name, TOTEM_PL_PARSER_FIELD_IS_PLAYLIST) == 0) { - is_playlist = g_value_get_boolean (&value); - g_value_unset (&value); - name = va_arg (var_args, char*); - continue; - } - - /* Ignore empty values */ - string = g_value_get_string (&value); - if (string != NULL && string[0] != '\0') { - char *fixed = NULL; - - if (g_utf8_validate (string, -1, NULL) == FALSE) { - fixed = g_convert (string, -1, "UTF-8", "ISO8859-1", NULL, NULL, NULL); - if (fixed == NULL) { - g_value_unset (&value); - name = va_arg (var_args, char*); - continue; - } - } - - /* Add other values to the metadata hashtable */ - g_hash_table_insert (metadata, - g_strdup (name), - g_strdup (fixed ? fixed : string)); - } - - g_value_unset (&value); - name = va_arg (var_args, char*); - } - - if (parser->priv->disable_unsafe != FALSE) { - //FIXME fix this! 396710 - } - - if (g_hash_table_size (metadata) > 0 || url != NULL) { - if (is_playlist == FALSE) { - g_signal_emit (G_OBJECT (parser), - totem_pl_parser_table_signals[ENTRY_PARSED], - 0, url, metadata); - } else { - g_signal_emit (G_OBJECT (parser), - totem_pl_parser_table_signals[PLAYLIST_STARTED], - 0, url, metadata); - } - } - - g_hash_table_destroy (metadata); - - g_free (url); - g_object_unref (G_OBJECT (parser)); -} - -void -totem_pl_parser_add_url (TotemPlParser *parser, - const char *first_property_name, - ...) -{ - va_list var_args; - va_start (var_args, first_property_name); - totem_pl_parser_add_url_valist (parser, first_property_name, var_args); - va_end (var_args); -} - -void -totem_pl_parser_add_one_url (TotemPlParser *parser, const char *url, const char *title) -{ - totem_pl_parser_add_url (parser, - TOTEM_PL_PARSER_FIELD_URL, url, - TOTEM_PL_PARSER_FIELD_TITLE, title, - NULL); -} - -static char * -totem_pl_parser_remove_filename (const char *url) -{ - char *no_frag, *no_file, *no_qmark, *qmark; - - no_frag = gnome_vfs_make_uri_canonical_strip_fragment (url); - qmark = strrchr (no_frag, '?'); - if (qmark == NULL) - return no_frag; - no_qmark = g_strndup (no_frag, qmark - no_frag); - no_file = totem_pl_parser_base_url (no_qmark); - g_free (no_qmark); - g_free (no_frag); - - return no_file; -} - -char * -totem_pl_parser_resolve_url (const char *base, const char *url) -{ - GnomeVFSURI *base_uri, *new; - char *resolved, *base_no_frag; - - g_return_val_if_fail (url != NULL, NULL); - g_return_val_if_fail (base != NULL, g_strdup (url)); - - /* If the URI isn't relative, just leave */ - if (strstr (url, "://") != NULL) - return g_strdup (url); - - /* Strip fragment and filename */ - base_no_frag = totem_pl_parser_remove_filename (base); - - /* gnome_vfs_uri_append_path is trying to be clever and - * merges paths that look like they're the same */ - if (url[0] != '/') { - char *newbase = g_strdup_printf ("%s/", base_no_frag); - base_uri = gnome_vfs_uri_new (newbase); - g_free (newbase); - } else { - base_uri = gnome_vfs_uri_new (base_no_frag); - } - g_free (base_no_frag); - - g_return_val_if_fail (base_uri != NULL, g_strdup (url)); - - if (url[0] == '/') - new = gnome_vfs_uri_resolve_symbolic_link (base_uri, url); - else - new = gnome_vfs_uri_append_path (base_uri, url); - - g_return_val_if_fail (new != NULL, g_strdup (url)); - gnome_vfs_uri_unref (base_uri); - resolved = gnome_vfs_uri_to_string (new, GNOME_VFS_URI_HIDE_NONE); - gnome_vfs_uri_unref (new); - - return resolved; -} - -#endif /* !TOTEM_PL_PARSER_MINI */ - -#ifndef TOTEM_PL_PARSER_MINI -#define PLAYLIST_TYPE(mime,cb,identcb,unsafe) { mime, cb, identcb, unsafe } -#define PLAYLIST_TYPE2(mime,cb,identcb) { mime, cb, identcb } -#define PLAYLIST_TYPE3(mime) { mime, NULL, NULL, FALSE } -#else -#define PLAYLIST_TYPE(mime,cb,identcb,unsafe) { mime } -#define PLAYLIST_TYPE2(mime,cb,identcb) { mime, identcb } -#define PLAYLIST_TYPE3(mime) { mime } -#endif - -/* These ones need a special treatment, mostly parser formats */ -static PlaylistTypes special_types[] = { - PLAYLIST_TYPE ("audio/x-mpegurl", totem_pl_parser_add_m3u, NULL, FALSE), - PLAYLIST_TYPE ("audio/playlist", totem_pl_parser_add_m3u, NULL, FALSE), - PLAYLIST_TYPE ("audio/x-scpls", totem_pl_parser_add_pls, NULL, FALSE), - PLAYLIST_TYPE ("application/x-smil", totem_pl_parser_add_smil, NULL, FALSE), - PLAYLIST_TYPE ("application/smil", totem_pl_parser_add_smil, NULL, FALSE), - PLAYLIST_TYPE ("video/x-ms-wvx", totem_pl_parser_add_asx, NULL, FALSE), - PLAYLIST_TYPE ("audio/x-ms-wax", totem_pl_parser_add_asx, NULL, FALSE), - PLAYLIST_TYPE ("application/xspf+xml", totem_pl_parser_add_xspf, NULL, FALSE), - PLAYLIST_TYPE ("text/uri-list", totem_pl_parser_add_ra, totem_pl_parser_is_uri_list, FALSE), - PLAYLIST_TYPE ("text/x-google-video-pointer", totem_pl_parser_add_gvp, NULL, FALSE), - PLAYLIST_TYPE ("text/google-video-pointer", totem_pl_parser_add_gvp, NULL, FALSE), - PLAYLIST_TYPE ("audio/x-iriver-pla", totem_pl_parser_add_pla, NULL, FALSE), - PLAYLIST_TYPE ("application/atom+xml", totem_pl_parser_add_atom, NULL, FALSE), - PLAYLIST_TYPE ("application/rss+xml", totem_pl_parser_add_rss, NULL, FALSE), - PLAYLIST_TYPE ("text/x-opml+xml", totem_pl_parser_add_opml, NULL, FALSE), -#ifndef TOTEM_PL_PARSER_MINI - PLAYLIST_TYPE ("application/x-desktop", totem_pl_parser_add_desktop, NULL, TRUE), - PLAYLIST_TYPE ("application/x-gnome-app-info", totem_pl_parser_add_desktop, NULL, TRUE), - PLAYLIST_TYPE ("application/x-cd-image", totem_pl_parser_add_iso, NULL, TRUE), - PLAYLIST_TYPE ("application/x-extension-img", totem_pl_parser_add_iso, NULL, TRUE), - PLAYLIST_TYPE ("application/x-cue", totem_pl_parser_add_cue, NULL, TRUE), - PLAYLIST_TYPE (DIR_MIME_TYPE, totem_pl_parser_add_directory, NULL, TRUE), - PLAYLIST_TYPE (BLOCK_DEVICE_TYPE, totem_pl_parser_add_block, NULL, TRUE), -#endif -}; - -/* These ones are "dual" types, might be a video, might be a parser */ -static PlaylistTypes dual_types[] = { - PLAYLIST_TYPE2 ("audio/x-real-audio", totem_pl_parser_add_ra, totem_pl_parser_is_uri_list), - PLAYLIST_TYPE2 ("audio/x-pn-realaudio", totem_pl_parser_add_ra, totem_pl_parser_is_uri_list), - PLAYLIST_TYPE2 ("application/ram", totem_pl_parser_add_ra, totem_pl_parser_is_uri_list), - PLAYLIST_TYPE2 ("application/vnd.rn-realmedia", totem_pl_parser_add_ra, totem_pl_parser_is_uri_list), - PLAYLIST_TYPE2 ("audio/x-pn-realaudio-plugin", totem_pl_parser_add_ra, totem_pl_parser_is_uri_list), - PLAYLIST_TYPE2 ("audio/vnd.rn-realaudio", totem_pl_parser_add_ra, totem_pl_parser_is_uri_list), - PLAYLIST_TYPE2 ("audio/x-realaudio", totem_pl_parser_add_ra, totem_pl_parser_is_uri_list), - PLAYLIST_TYPE2 ("text/plain", totem_pl_parser_add_ra, totem_pl_parser_is_uri_list), - PLAYLIST_TYPE2 ("audio/x-ms-asx", totem_pl_parser_add_asx, totem_pl_parser_is_asx), - PLAYLIST_TYPE2 ("video/x-ms-asf", totem_pl_parser_add_asf, totem_pl_parser_is_asf), - PLAYLIST_TYPE2 ("video/x-ms-wmv", totem_pl_parser_add_asf, totem_pl_parser_is_asf), - PLAYLIST_TYPE2 ("video/quicktime", totem_pl_parser_add_quicktime, totem_pl_parser_is_quicktime), - PLAYLIST_TYPE2 ("application/x-quicktime-media-link", totem_pl_parser_add_quicktime, totem_pl_parser_is_quicktime), - PLAYLIST_TYPE2 ("application/x-quicktimeplayer", totem_pl_parser_add_quicktime, totem_pl_parser_is_quicktime), - PLAYLIST_TYPE2 ("application/xml", totem_pl_parser_add_xml_feed, totem_pl_parser_is_xml_feed), -}; - -#ifndef TOTEM_PL_PARSER_MINI - -static PlaylistTypes ignore_types[] = { - PLAYLIST_TYPE3 ("image/*"), - PLAYLIST_TYPE3 ("text/plain"), - PLAYLIST_TYPE3 ("application/x-rar"), - PLAYLIST_TYPE3 ("application/zip"), - PLAYLIST_TYPE3 ("application/x-trash"), -}; - -gboolean -totem_pl_parser_scheme_is_ignored (TotemPlParser *parser, const char *url) -{ - GList *l; - - if (parser->priv->ignore_schemes == NULL) - return FALSE; - - for (l = parser->priv->ignore_schemes; l != NULL; l = l->next) - { - const char *scheme = l->data; - if (g_str_has_prefix (url, scheme) != FALSE) - return TRUE; - } - - return FALSE; -} - -//FIXME remove ? -static gboolean -totem_pl_parser_mimetype_is_ignored (TotemPlParser *parser, - const char *mimetype) -{ - GList *l; - - if (parser->priv->ignore_mimetypes == NULL) - return FALSE; - - for (l = parser->priv->ignore_mimetypes; l != NULL; l = l->next) - { - const char *item = l->data; - if (strcmp (mimetype, item) == 0) - return TRUE; - } - - return FALSE; - -} - -gboolean -totem_pl_parser_ignore (TotemPlParser *parser, const char *url) -{ - const char *mimetype; - guint i; - - if (totem_pl_parser_scheme_is_ignored (parser, url) != FALSE) - return TRUE; - - mimetype = gnome_vfs_get_file_mime_type (url, NULL, TRUE); - if (mimetype == NULL || strcmp (mimetype, GNOME_VFS_MIME_TYPE_UNKNOWN) == 0) - return FALSE; - - for (i = 0; i < G_N_ELEMENTS (special_types); i++) - if (strcmp (special_types[i].mimetype, mimetype) == 0) - return FALSE; - - for (i = 0; i < G_N_ELEMENTS (dual_types); i++) - if (strcmp (dual_types[i].mimetype, mimetype) == 0) - return FALSE; - - return TRUE; -} - -static gboolean -totem_pl_parser_ignore_from_mimetype (TotemPlParser *parser, const char *mimetype) -{ - char *super; - guint i; - - super = gnome_vfs_get_supertype_from_mime_type (mimetype); - for (i = 0; i < G_N_ELEMENTS (ignore_types) && super != NULL; i++) { - if (gnome_vfs_mime_type_is_supertype (ignore_types[i].mimetype) != FALSE) { - if (strcmp (super, ignore_types[i].mimetype) == 0) { - g_free (super); - return TRUE; - } - } else { - GnomeVFSMimeEquivalence eq; - - eq = gnome_vfs_mime_type_get_equivalence (mimetype, ignore_types[i].mimetype); - if (eq == GNOME_VFS_MIME_PARENT || eq == GNOME_VFS_MIME_IDENTICAL) { - g_free (super); - return TRUE; - } - } - } - g_free (super); - - return FALSE; -} - -TotemPlParserResult -totem_pl_parser_parse_internal (TotemPlParser *parser, const char *url, - const char *base) -{ - char *mimetype; - guint i; - gpointer data = NULL; - TotemPlParserResult ret = TOTEM_PL_PARSER_RESULT_UNHANDLED; - gboolean found = FALSE; - - if (parser->priv->recurse_level > RECURSE_LEVEL_MAX) - return TOTEM_PL_PARSER_RESULT_ERROR; - - /* Shouldn't gnome-vfs have a list of schemes it supports? */ - if (g_str_has_prefix (url, "mms") != FALSE - || g_str_has_prefix (url, "rtsp") != FALSE - || g_str_has_prefix (url, "icy") != FALSE) { - DEBUG(g_print ("URL '%s' is MMS, RTSP or ICY, ignoring\n", url)); - return TOTEM_PL_PARSER_RESULT_UNHANDLED; - } - - /* Fix up itpc, see http://www.apple.com/itunes/store/podcaststechspecs.html */ - if (g_str_has_prefix (url, "itpc") != FALSE) { - DEBUG(g_print ("URL '%s' is getting special cased for ITPC parsing\n", url)); - return totem_pl_parser_add_itpc (parser, url, base, NULL); - } - /* Try itms Podcast references, see itunes.py in PenguinTV */ - if (totem_pl_parser_is_itms_feed (url) != FALSE) { - DEBUG(g_print ("URL '%s' is getting special cased for ITMS parsing\n", url)); - return totem_pl_parser_add_itms (parser, url, NULL, NULL); - } - - if (!parser->priv->recurse && parser->priv->recurse_level > 0) { - return TOTEM_PL_PARSER_RESULT_UNHANDLED; - } - - /* In force mode we want to get the data */ - if (parser->priv->force != FALSE) { - mimetype = my_gnome_vfs_get_mime_type_with_data (url, &data, parser); - } else { - mimetype = g_strdup (gnome_vfs_get_mime_type_for_name (url)); - } - - DEBUG(g_print ("_get_mime_type_for_name for '%s' returned '%s'\n", url, mimetype)); - if (mimetype == NULL || strcmp (GNOME_VFS_MIME_TYPE_UNKNOWN, mimetype) == 0) { - g_free (mimetype); - mimetype = my_gnome_vfs_get_mime_type_with_data (url, &data, parser); - DEBUG(g_print ("_get_mime_type_with_data for '%s' returned '%s'\n", url, mimetype ? mimetype : "NULL")); - } - - if (mimetype == NULL) { - g_free (data); - return TOTEM_PL_PARSER_RESULT_UNHANDLED; - } - - if (strcmp (mimetype, EMPTY_FILE_TYPE) == 0) { - g_free (data); - g_free (mimetype); - return TOTEM_PL_PARSER_RESULT_SUCCESS; - } - - /* If we're at the top-level of the parsing, try to get more - * data from the playlist parser */ - if (strcmp (mimetype, AUDIO_MPEG_TYPE) == 0 && parser->priv->recurse_level == 0 && data == NULL) { - char *tmp; - tmp = my_gnome_vfs_get_mime_type_with_data (url, &data, parser); - if (tmp != NULL) { - g_free (mimetype); - mimetype = tmp; - } - DEBUG(g_print ("_get_mime_type_with_data for '%s' returned '%s' (was %s)\n", url, mimetype, AUDIO_MPEG_TYPE)); - } - - if (totem_pl_parser_mimetype_is_ignored (parser, mimetype) != FALSE) { - g_free (mimetype); - g_free (data); - return TOTEM_PL_PARSER_RESULT_IGNORED; - } - - if (parser->priv->recurse || parser->priv->recurse_level == 0) { - parser->priv->recurse_level++; - - for (i = 0; i < G_N_ELEMENTS(special_types); i++) { - if (strcmp (special_types[i].mimetype, mimetype) == 0) { - DEBUG(g_print ("URL '%s' is special type '%s'\n", url, mimetype)); - if (parser->priv->disable_unsafe != FALSE && special_types[i].unsafe != FALSE) { - g_free (mimetype); - g_free (data); - return TOTEM_PL_PARSER_RESULT_IGNORED; - } - ret = (* special_types[i].func) (parser, url, base, data); - found = TRUE; - break; - } - } - - for (i = 0; i < G_N_ELEMENTS(dual_types) && found == FALSE; i++) { - if (strcmp (dual_types[i].mimetype, mimetype) == 0) { - DEBUG(g_print ("URL '%s' is dual type '%s'\n", url, mimetype)); - if (data == NULL) { - g_free (mimetype); - mimetype = my_gnome_vfs_get_mime_type_with_data (url, &data, parser); - } - ret = (* dual_types[i].func) (parser, url, base, data); - found = TRUE; - break; - } - } - - g_free (data); - - parser->priv->recurse_level--; - } - - if (ret == TOTEM_PL_PARSER_RESULT_SUCCESS) { - g_free (mimetype); - return ret; - } - - if (totem_pl_parser_ignore_from_mimetype (parser, mimetype)) { - g_free (mimetype); - return TOTEM_PL_PARSER_RESULT_IGNORED; - } - g_free (mimetype); - - if (ret != TOTEM_PL_PARSER_RESULT_SUCCESS && parser->priv->fallback) { - totem_pl_parser_add_one_url (parser, url, NULL); - return TOTEM_PL_PARSER_RESULT_SUCCESS; - } - - return ret; -} - -TotemPlParserResult -totem_pl_parser_parse_with_base (TotemPlParser *parser, const char *url, - const char *base, gboolean fallback) -{ - g_return_val_if_fail (TOTEM_IS_PL_PARSER (parser), TOTEM_PL_PARSER_RESULT_UNHANDLED); - g_return_val_if_fail (url != NULL, TOTEM_PL_PARSER_RESULT_UNHANDLED); - - if (totem_pl_parser_scheme_is_ignored (parser, url) != FALSE) - return TOTEM_PL_PARSER_RESULT_UNHANDLED; - - g_return_val_if_fail (strstr (url, "://") != NULL, - TOTEM_PL_PARSER_RESULT_ERROR); - - parser->priv->recurse_level = 0; - parser->priv->fallback = fallback != FALSE; - return totem_pl_parser_parse_internal (parser, url, base); -} - -TotemPlParserResult -totem_pl_parser_parse (TotemPlParser *parser, const char *url, - gboolean fallback) -{ - return totem_pl_parser_parse_with_base (parser, url, NULL, fallback); -} - -void -totem_pl_parser_add_ignored_scheme (TotemPlParser *parser, - const char *scheme) -{ - g_return_if_fail (TOTEM_IS_PL_PARSER (parser)); - - parser->priv->ignore_schemes = g_list_prepend - (parser->priv->ignore_schemes, g_strdup (scheme)); -} - -void -totem_pl_parser_add_ignored_mimetype (TotemPlParser *parser, - const char *mimetype) -{ - g_return_if_fail (TOTEM_IS_PL_PARSER (parser)); - - parser->priv->ignore_mimetypes = g_list_prepend - (parser->priv->ignore_mimetypes, g_strdup (mimetype)); -} - -gint64 -totem_pl_parser_parse_duration (const char *duration, gboolean debug) -{ - int hours, minutes, seconds, fractions; - - if (duration == NULL) { - D(g_print ("No duration passed\n")); - return -1; - } - - /* Formats used by both ASX and RAM files */ - if (sscanf (duration, "%d:%d:%d.%d", &hours, &minutes, &seconds, &fractions) == 4) { - gint64 ret = hours * 3600 + minutes * 60 + seconds; - if (ret == 0 && fractions > 0) { - D(g_print ("Used 00:00:00.00 format, with fractions rounding\n")); - ret = 1; - } else { - D(g_print ("Used 00:00:00.00 format\n")); - } - return ret; - } - if (sscanf (duration, "%d:%d:%d", &hours, &minutes, &seconds) == 3) { - D(g_print ("Used 00:00:00 format\n")); - return hours * 3600 + minutes * 60 + seconds; - } - if (sscanf (duration, "%d:%d.%d", &minutes, &seconds, &fractions) == 3) { - gint64 ret = minutes * 60 + seconds; - if (ret == 0 && fractions > 0) { - D(g_print ("Used 00:00.00 format, with fractions rounding\n")); - ret = 1; - } else { - D(g_print ("Used 00:00.00 format\n")); - } - return ret; - } - if (sscanf (duration, "%d:%d", &minutes, &seconds) == 2) { - D(g_print ("Used 00:00 format\n")); - return minutes * 60 + seconds; - } - /* PLS files format */ - if (sscanf (duration, "%d", &seconds) == 1) { - D(g_print ("Used PLS format\n")); - return seconds; - } - - D(g_message ("Couldn't parse duration '%s'\n", duration)); - - return -1; -} - -guint64 -totem_pl_parser_parse_date (const char *date_str, gboolean debug) -{ - struct tm tm; - char *result; - - /* RFC 2822 date format */ - result = strptime (date_str, "%a, %d %b %Y %T", &tm); - - /* same as above, but without comma */ - if (result == NULL) { - memset (&tm, 0, sizeof (struct tm)); - result = strptime (date_str, "%a %d %b %Y %T", &tm); - } - - /* close-to-RFC 2822, but with extra 0 */ - if (result == NULL) { - memset (&tm, 0, sizeof (struct tm)); - result = strptime (date_str, "%a, %d %b %Y 0%T", &tm); - } - - /* close-to-RFC 2822, but with no seconds */ - if (result == NULL) { - memset (&tm, 0, sizeof (struct tm)); - result = strptime (date_str, "%a, %d %b %Y %R", &tm); - } - - /* format without weekday */ - if (result == NULL) { - memset (&tm, 0, sizeof (struct tm)); - result = strptime (date_str, "%d %b %Y %T", &tm); - } - - /* reversed day and long month */ - if (result == NULL) { - memset (&tm, 0, sizeof (struct tm)); - result = strptime (date_str, "%a, %B %d %Y %T", &tm); - } - - /* ISO date like */ - if (result == NULL) { - memset (&tm, 0, sizeof (struct tm)); - result = strptime (date_str, "%Y-%m-%d %T", &tm); - } - - /* ISO date like without timezone */ - if (result == NULL) { - memset (&tm, 0, sizeof (struct tm)); - result = strptime (date_str, "%Y-%m-%d", &tm); - } - - /* Broken weekday short names */ - if (result == NULL) { - char *tmp; - - /* strip off the erroneous weekday */ - tmp = strstr (date_str, ","); - if (tmp != NULL) { - tmp++; - memset (&tm, 0, sizeof (struct tm)); - result = strptime (tmp, "%d %b %Y %T", &tm); - } - } - - /* format with timezone offset from GMT */ - if (result == NULL) { - memset (&tm, 0, sizeof (struct tm)); - result = strptime (date_str, "%a %b %d %T %z %Y", &tm); - } - - /* format with timezone name */ - if (result == NULL) { - char *tmp; - - memset (&tm, 0, sizeof (struct tm)); - - /* match first part of time string */ - result = strptime (date_str, "%a %b %d %T ", &tm); - - /* look for anything with a timezone name-like format - i.e. at least one all caps alphabetical character */ - if (result != NULL) { - size_t n; - - n = strspn(result, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); - tmp = result+n; - - /* make sure there was at least one character that matched */ - if ((tmp != NULL) && n > 0) - /* remaining part must be the year */ - result = strptime (tmp, "%Y", &tm); - else - result = NULL; - } - } - - if (result == NULL) - D(g_message ("Couldn't parse date '%s'\n", date_str)); - - return (guint64) ((result == NULL) ? 0 : mktime (&tm)); -} - -#endif /* !TOTEM_PL_PARSER_MINI */ - -gboolean -totem_pl_parser_can_parse_from_data (const char *data, - gsize len, - gboolean debug) -{ - const char *mimetype; - guint i; - - g_return_val_if_fail (data != NULL, FALSE); - - /* Bad cast! */ - mimetype = gnome_vfs_get_mime_type_for_data ((gpointer) data, (int) len); - - if (mimetype == NULL || strcmp (GNOME_VFS_MIME_TYPE_UNKNOWN, mimetype) == 0) { - D(g_message ("totem_pl_parser_can_parse_from_data couldn't get mimetype")); - return FALSE; - } - - for (i = 0; i < G_N_ELEMENTS(special_types); i++) { - if (strcmp (special_types[i].mimetype, mimetype) == 0) { - D(g_message ("Is special type '%s'", mimetype)); - return TRUE; - } - } - - for (i = 0; i < G_N_ELEMENTS(dual_types); i++) { - if (strcmp (dual_types[i].mimetype, mimetype) == 0) { - D(g_message ("Should be dual type '%s', making sure now", mimetype)); - if (dual_types[i].iden != NULL) { - gboolean retval = (* dual_types[i].iden) (data, len); - D(g_message ("%s dual type '%s'", - retval ? "Is" : "Is not", mimetype)); - return retval; - } - return FALSE; - } - } - - D(g_message ("Is unsupported mime-type '%s'", mimetype)); - - return FALSE; -} - -gboolean -totem_pl_parser_can_parse_from_filename (const char *filename, gboolean debug) -{ - GMappedFile *map; - GError *err = NULL; - gboolean retval; - - g_return_val_if_fail (filename != NULL, FALSE); - - map = g_mapped_file_new (filename, FALSE, &err); - if (map == NULL) { - D(g_message ("couldn't mmap %s: %s", filename, err->message)); - g_error_free (err); - return FALSE; - } - - retval = totem_pl_parser_can_parse_from_data - (g_mapped_file_get_contents (map), - g_mapped_file_get_length (map), debug); - - g_mapped_file_free (map); - - return retval; -} - diff --git a/plparse/totem-pl-parser.h b/plparse/totem-pl-parser.h deleted file mode 100644 index 4d21a4e85..000000000 --- a/plparse/totem-pl-parser.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - 2002, 2003, 2004, 2005, 2006 Bastien Nocera - Copyright (C) 2003 Colin Walters <walters@verbum.org> - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera <hadess@hadess.net> - */ - -#ifndef TOTEM_PL_PARSER_H -#define TOTEM_PL_PARSER_H - -#include <glib.h> - -#include <gtk/gtktreemodel.h> -#include "totem-pl-parser-features.h" -#include "totem-pl-parser-builtins.h" - -G_BEGIN_DECLS - -#define TOTEM_TYPE_PL_PARSER (totem_pl_parser_get_type ()) -#define TOTEM_PL_PARSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOTEM_TYPE_PL_PARSER, TotemPlParser)) -#define TOTEM_PL_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOTEM_TYPE_PL_PARSER, TotemPlParserClass)) -#define TOTEM_IS_PL_PARSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOTEM_TYPE_PL_PARSER)) -#define TOTEM_IS_PL_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOTEM_TYPE_PL_PARSER)) - -typedef enum -{ - TOTEM_PL_PARSER_RESULT_UNHANDLED, - TOTEM_PL_PARSER_RESULT_ERROR, - TOTEM_PL_PARSER_RESULT_SUCCESS, - TOTEM_PL_PARSER_RESULT_IGNORED -} TotemPlParserResult; - -typedef struct TotemPlParser TotemPlParser; -typedef struct TotemPlParserClass TotemPlParserClass; -typedef struct TotemPlParserPrivate TotemPlParserPrivate; - -struct TotemPlParser { - GObject parent; - TotemPlParserPrivate *priv; -}; - -/* Known metadata fields */ -#define TOTEM_PL_PARSER_FIELD_URL "url" -#define TOTEM_PL_PARSER_FIELD_GENRE "genre" -#define TOTEM_PL_PARSER_FIELD_TITLE "title" -#define TOTEM_PL_PARSER_FIELD_AUTHOR "author" -#define TOTEM_PL_PARSER_FIELD_BASE "base" -#define TOTEM_PL_PARSER_FIELD_VOLUME "volume" -#define TOTEM_PL_PARSER_FIELD_AUTOPLAY "autoplay" -#define TOTEM_PL_PARSER_FIELD_DURATION "duration" -#define TOTEM_PL_PARSER_FIELD_STARTTIME "starttime" -#define TOTEM_PL_PARSER_FIELD_ENDTIME "endtime" -#define TOTEM_PL_PARSER_FIELD_COPYRIGHT "copyright" -#define TOTEM_PL_PARSER_FIELD_ABSTRACT "abstract" -#define TOTEM_PL_PARSER_FIELD_DESCRIPTION "description" -#define TOTEM_PL_PARSER_FIELD_SUMMARY TOTEM_PL_PARSER_FIELD_DESCRIPTION -#define TOTEM_PL_PARSER_FIELD_MOREINFO "moreinfo" -#define TOTEM_PL_PARSER_FIELD_SCREENSIZE "screensize" -#define TOTEM_PL_PARSER_FIELD_UI_MODE "ui-mode" -#define TOTEM_PL_PARSER_FIELD_PUB_DATE "publication-date" -#define TOTEM_PL_PARSER_FIELD_FILESIZE "filesize" -#define TOTEM_PL_PARSER_FIELD_LANGUAGE "language" -#define TOTEM_PL_PARSER_FIELD_CONTACT "contact" -#define TOTEM_PL_PARSER_FIELD_IMAGE_URL "image-url" - -#define TOTEM_PL_PARSER_FIELD_IS_PLAYLIST "is-playlist" - -struct TotemPlParserClass { - GObjectClass parent_class; - - /* signals */ - void (*entry_parsed) (TotemPlParser *parser, - const char *uri, - GHashTable *metadata); - void (*playlist_started) (TotemPlParser *parser, - const char *uri, - GHashTable *metadata); - void (*playlist_ended) (TotemPlParser *parser, - const char *uri); -}; - -typedef enum -{ - TOTEM_PL_PARSER_PLS, - TOTEM_PL_PARSER_M3U, - TOTEM_PL_PARSER_M3U_DOS, - TOTEM_PL_PARSER_XSPF, - TOTEM_PL_PARSER_IRIVER_PLA, -} TotemPlParserType; - -typedef enum -{ - TOTEM_PL_PARSER_ERROR_VFS_OPEN, - TOTEM_PL_PARSER_ERROR_VFS_WRITE, -} TotemPlParserError; - -#define TOTEM_PL_PARSER_ERROR (totem_pl_parser_error_quark ()) - -GQuark totem_pl_parser_error_quark (void); - -typedef void (*TotemPlParserIterFunc) (GtkTreeModel *model, GtkTreeIter *iter, - char **uri, char **title, - gboolean *custom_title, - gpointer user_data); - -GType totem_pl_parser_get_type (void); - -gint64 totem_pl_parser_parse_duration (const char *duration, gboolean debug); -guint64 totem_pl_parser_parse_date (const char *date_str, gboolean debug); -char *totem_pl_parser_resolve_url (const char *base, const char *url); - -gboolean totem_pl_parser_write (TotemPlParser *parser, GtkTreeModel *model, - TotemPlParserIterFunc func, - const char *output, TotemPlParserType type, - gpointer user_data, - GError **error); - -gboolean totem_pl_parser_write_with_title (TotemPlParser *parser, - GtkTreeModel *model, - TotemPlParserIterFunc func, - const char *output, - const char *title, - TotemPlParserType type, - gpointer user_data, - GError **error); - -void totem_pl_parser_add_ignored_scheme (TotemPlParser *parser, - const char *scheme); -void totem_pl_parser_add_ignored_mimetype (TotemPlParser *parser, - const char *mimetype); - -TotemPlParserResult totem_pl_parser_parse (TotemPlParser *parser, - const char *url, gboolean fallback); -TotemPlParserResult totem_pl_parser_parse_with_base (TotemPlParser *parser, - const char *url, - const char *base, - gboolean fallback); - -TotemPlParser *totem_pl_parser_new (void); - -G_END_DECLS - -#endif /* TOTEM_PL_PARSER_H */ diff --git a/plparse/totemplparser-marshal.list b/plparse/totemplparser-marshal.list deleted file mode 100644 index 6e1d8851a..000000000 --- a/plparse/totemplparser-marshal.list +++ /dev/null @@ -1,2 +0,0 @@ -VOID:STRING,STRING,STRING -VOID:STRING,POINTER diff --git a/plparse/xmllexer.c b/plparse/xmllexer.c deleted file mode 100644 index cb206d6bf..000000000 --- a/plparse/xmllexer.c +++ /dev/null @@ -1,584 +0,0 @@ -/* - * Copyright (C) 2002-2003,2007 the xine project - * - * This file is part of xine, a free video player. - * - * The xine-lib XML parser is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * The xine-lib XML parser 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with the Gnome Library; see the file COPYING.LIB. If not, - * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * $Id: xmllexer.c,v 1.13 2007/03/04 16:19:12 hadess Exp $ - * - */ - -#define LOG_MODULE "xmllexer" -#define LOG_VERBOSE -/* -#define LOG -*/ - -#ifdef XINE_COMPILE -#include "xineutils.h" -#else -#define lprintf(...) -#define xine_xmalloc malloc -#endif -#include "xmllexer.h" -#include <stdio.h> -#include <ctype.h> -#include <string.h> -#include <stdlib.h> -#ifdef HAVE_ICONV -#include <iconv.h> -#endif - -/* private constants*/ - -/* private global variables */ -static const char * lexbuf; -static int lexbuf_size = 0; -static int lexbuf_pos = 0; -static int in_comment = 0; - -static enum { - NORMAL, - DATA, - CDATA, -} lex_mode = NORMAL; - -void lexer_init(const char * buf, int size) { - lexbuf = buf; - lexbuf_size = size; - lexbuf_pos = 0; - lex_mode = NORMAL; - in_comment = 0; - - lprintf("buffer length %d\n", size); -} - -typedef enum { - STATE_UNKNOWN = -1, - STATE_IDLE, - STATE_EOL, - STATE_SEPAR, - STATE_T_M_START, - STATE_T_M_STOP_1, - STATE_T_M_STOP_2, - STATE_T_EQUAL, - STATE_T_STRING_SINGLE, - STATE_T_STRING_DOUBLE, - STATE_T_COMMENT, - STATE_T_TI_STOP, - STATE_T_DASHDASH, - STATE_T_C_STOP, - STATE_IDENT /* must be last */ -} lexer_state_t; - -int lexer_get_token(char * tok, int tok_size) { - int tok_pos = 0; - lexer_state_t state = STATE_IDLE; - char c; - - if (tok) { - while ((tok_pos < tok_size) && (lexbuf_pos < lexbuf_size)) { - c = lexbuf[lexbuf_pos]; - lprintf("c=%c, state=%d, lex_mode=%d, in_comment=%d\n", c, state, lex_mode, in_comment); - - switch (lex_mode) { - case NORMAL: - switch (state) { - /* init state */ - case STATE_IDLE: - switch (c) { - case '\n': - case '\r': - state = STATE_EOL; - tok[tok_pos] = c; - tok_pos++; - break; - - case ' ': - case '\t': - state = STATE_SEPAR; - tok[tok_pos] = c; - tok_pos++; - break; - - case '<': - state = STATE_T_M_START; - tok[tok_pos] = c; - tok_pos++; - break; - - case '>': - state = STATE_T_M_STOP_1; - tok[tok_pos] = c; - tok_pos++; - break; - - case '/': - if (!in_comment) - state = STATE_T_M_STOP_2; - tok[tok_pos] = c; - tok_pos++; - break; - - case '=': - state = STATE_T_EQUAL; - tok[tok_pos] = c; - tok_pos++; - break; - - case '\"': /* " */ - state = STATE_T_STRING_DOUBLE; - break; - - case '\'': /* " */ - state = STATE_T_STRING_SINGLE; - break; - - case '-': - state = STATE_T_DASHDASH; - tok[tok_pos] = c; - tok_pos++; - break; - - case '?': - if (!in_comment) - state = STATE_T_TI_STOP; - tok[tok_pos] = c; - tok_pos++; - break; - - default: - state = STATE_IDENT; - tok[tok_pos] = c; - tok_pos++; - break; - } - lexbuf_pos++; - break; - - /* end of line */ - case STATE_EOL: - if (c == '\n' || (c == '\r')) { - tok[tok_pos] = c; - lexbuf_pos++; - tok_pos++; - } else { - tok[tok_pos] = '\0'; - return T_EOL; - } - break; - - /* T_SEPAR */ - case STATE_SEPAR: - if (c == ' ' || (c == '\t')) { - tok[tok_pos] = c; - lexbuf_pos++; - tok_pos++; - } else { - tok[tok_pos] = '\0'; - return T_SEPAR; - } - break; - - /* T_M_START < or </ or <! or <? */ - case STATE_T_M_START: - switch (c) { - case '/': - tok[tok_pos] = c; - lexbuf_pos++; - tok_pos++; /* FIXME */ - tok[tok_pos] = '\0'; - return T_M_START_2; - break; - case '!': - tok[tok_pos] = c; - lexbuf_pos++; - tok_pos++; - state = STATE_T_COMMENT; - break; - case '?': - tok[tok_pos] = c; - lexbuf_pos++; - tok_pos++; /* FIXME */ - tok[tok_pos] = '\0'; - return T_TI_START; - break; - default: - tok[tok_pos] = '\0'; - return T_M_START_1; - } - break; - - /* T_M_STOP_1 */ - case STATE_T_M_STOP_1: - tok[tok_pos] = '\0'; - if (!in_comment) - lex_mode = DATA; - return T_M_STOP_1; - break; - - /* T_M_STOP_2 */ - case STATE_T_M_STOP_2: - if (c == '>') { - tok[tok_pos] = c; - lexbuf_pos++; - tok_pos++; /* FIXME */ - tok[tok_pos] = '\0'; - if (!in_comment) - lex_mode = DATA; - return T_M_STOP_2; - } else { - tok[tok_pos] = '\0'; - return T_ERROR; - } - break; - - /* T_EQUAL */ - case STATE_T_EQUAL: - tok[tok_pos] = '\0'; - return T_EQUAL; - break; - - /* T_STRING */ - case STATE_T_STRING_DOUBLE: - tok[tok_pos] = c; - lexbuf_pos++; - if (c == '\"') { /* " */ - tok[tok_pos] = '\0'; /* FIXME */ - return T_STRING; - } - tok_pos++; - break; - - /* T_C_START or T_DOCTYPE_START or T_CDATA_START */ - case STATE_T_COMMENT: - switch (c) { - case '-': - lexbuf_pos++; - if (lexbuf[lexbuf_pos] == '-') - { - lexbuf_pos++; - tok[tok_pos++] = '-'; /* FIXME */ - tok[tok_pos++] = '-'; - tok[tok_pos] = '\0'; - in_comment = 1; - return T_C_START; - } - break; - case 'D': - lexbuf_pos++; - if (strncmp(lexbuf + lexbuf_pos, "OCTYPE", 6) == 0) { - strncpy(tok + tok_pos, "DOCTYPE", 7); /* FIXME */ - lexbuf_pos += 6; - return T_DOCTYPE_START; - } else { - return T_ERROR; - } - break; - case '[': - lexbuf_pos++; - if (strncmp(lexbuf + lexbuf_pos, "CDATA[", 6) == 0) { - strncpy (tok + tok_pos, "[CDATA[", 7); /* FIXME */ - lexbuf_pos += 6; - lex_mode = CDATA; - return T_CDATA_START; - } else{ - return T_ERROR; - } - break; - default: - /* error */ - return T_ERROR; - } - break; - - /* T_TI_STOP */ - case STATE_T_TI_STOP: - if (c == '>') { - tok[tok_pos] = c; - lexbuf_pos++; - tok_pos++; /* FIXME */ - tok[tok_pos] = '\0'; - if (!in_comment) - lex_mode = DATA; - return T_TI_STOP; - } else { - tok[tok_pos] = '\0'; - return T_ERROR; - } - break; - - /* -- */ - case STATE_T_DASHDASH: - switch (c) { - case '-': - tok[tok_pos] = c; - tok_pos++; - lexbuf_pos++; - state = STATE_T_C_STOP; - break; - default: - tok[tok_pos] = c; - tok_pos++; - lexbuf_pos++; - state = STATE_IDENT; - } - break; - - /* --> */ - case STATE_T_C_STOP: - switch (c) { - case '>': - tok[tok_pos] = c; - tok_pos++; - lexbuf_pos++; - tok[tok_pos] = '\0'; /* FIX ME */ - if (strlen(tok) != 3) { - tok[tok_pos - 3] = '\0'; - lexbuf_pos -= 3; - return T_IDENT; - } else { - in_comment = 0; - return T_C_STOP; - } - break; - default: - tok[tok_pos] = c; - tok_pos++; - lexbuf_pos++; - state = STATE_IDENT; - } - break; - - /* T_STRING (single quotes) */ - case STATE_T_STRING_SINGLE: - tok[tok_pos] = c; - lexbuf_pos++; - if (c == '\'') { /* " */ - tok[tok_pos] = '\0'; /* FIXME */ - return T_STRING; - } - tok_pos++; - break; - - /* IDENT */ - case STATE_IDENT: - switch (c) { - case '<': - case '>': - case '\\': - case '\"': /* " */ - case ' ': - case '\t': - case '=': - case '/': - tok[tok_pos] = '\0'; - return T_IDENT; - break; - case '?': - tok[tok_pos] = c; - tok_pos++; - lexbuf_pos++; - state = STATE_T_TI_STOP; - break; - case '-': - tok[tok_pos] = c; - tok_pos++; - lexbuf_pos++; - state = STATE_T_DASHDASH; - break; - default: - tok[tok_pos] = c; - tok_pos++; - lexbuf_pos++; - } - break; - default: - lprintf("expected char \'%c\'\n", tok[tok_pos - 1]); /* FIX ME */ - return T_ERROR; - } - break; - - case DATA: /* data mode, stop if char equal '<' */ - switch (c) - { - case '<': - tok[tok_pos] = '\0'; - lex_mode = NORMAL; - return T_DATA; - default: - tok[tok_pos] = c; - tok_pos++; - lexbuf_pos++; - } - break; - - case CDATA: /* cdata mode, stop if next token is "]]>" */ - switch (c) - { - case ']': - if (strncmp(lexbuf + lexbuf_pos, "]]>", 3) == 0) { - lexbuf_pos += 3; - lex_mode = DATA; - return T_CDATA_STOP; - } else { - tok[tok_pos] = c; - tok_pos++; - lexbuf_pos++; - } - break; - default: - tok[tok_pos] = c; - tok_pos++; - lexbuf_pos++; - } - break; - } - } - lprintf ("loop done tok_pos = %d, tok_size=%d, lexbuf_pos=%d, lexbuf_size=%d\n", - tok_pos, tok_size, lexbuf_pos, lexbuf_size); - - /* pb */ - if (tok_pos >= tok_size) { - lprintf("token buffer is too little\n"); - } else { - if (lexbuf_pos >= lexbuf_size) { - /* Terminate the current token */ - tok[tok_pos] = '\0'; - switch (state) { - case 0: - case 1: - case 2: - return T_EOF; - break; - case 3: - return T_M_START_1; - break; - case 4: - return T_M_STOP_1; - break; - case 5: - return T_ERROR; - break; - case 6: - return T_EQUAL; - break; - case 7: - return T_STRING; - break; - case 100: - return T_DATA; - break; - default: - lprintf("unknown state, state=%d\n", state); - } - } else { - lprintf("abnormal end of buffer, state=%d\n", state); - } - } - return T_ERROR; - } - /* tok == null */ - lprintf("token buffer is null\n"); - return T_ERROR; -} - -static struct { - char code; - unsigned char namelen; - char name[6]; -} lexer_entities[] = { - { '"', 4, "quot" }, - { '&', 3, "amp" }, - { '\'', 4, "apos" }, - { '<', 2, "lt" }, - { '>', 2, "gt" }, - { '\0', 0, "" } -}; - -char *lexer_decode_entities (const char *tok) -{ - char *buf = xine_xmalloc (strlen (tok) + 1); - char *bp = buf; - char c; - - while ((c = *tok++)) - { - if (c != '&') - *bp++ = c; - else - { - /* parse the character entity (on failure, treat it as literal text) */ - const char *tp = tok; - signed long i; - - for (i = 0; lexer_entities[i].code; ++i) - if (!strncmp (lexer_entities[i].name, tok, lexer_entities[i].namelen) - && tok[lexer_entities[i].namelen] == ';') - break; - if (lexer_entities[i].code) - { - tok += lexer_entities[i].namelen + 1; - *bp++ = lexer_entities[i].code; - continue; - } - - if (*tp++ != '#') - { - /* not a recognised name and not numeric */ - *bp++ = '&'; - continue; - } - - /* entity is a number - * (note: strtol() allows "0x" prefix for hexadecimal, but we don't) - */ - if (*tp == 'x' && tp[1] && tp[2] != 'x') - i = strtol (tp + 1, (char **)&tp, 16); - else - i = strtol (tp, (char **)&tp, 10); - - if (*tp != ';' || i < 1) - { - /* out of range, or format error */ - *bp++ = '&'; - continue; - } - - tok = tp + 1; - - if (i < 128) - /* ASCII - store as-is */ - *bp++ = i; - else - { - /* Non-ASCII, so convert to UTF-8 */ - int count = (i >= 0x04000000) ? 5 : - (i >= 0x00200000) ? 4 : - (i >= 0x00010000) ? 3 : - (i >= 0x00000800) ? 2 : 1; - *bp = (char)(0x1F80 >> count); - count *= 6; - *bp++ |= i >> count; - while ((count -= 6) >= 0) - *bp++ = 128 | ((i >> count) & 0x3F); - } - } - } - *bp = 0; - return buf; -} diff --git a/plparse/xmllexer.h b/plparse/xmllexer.h deleted file mode 100644 index 524049a44..000000000 --- a/plparse/xmllexer.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2002-2003,2007 the xine project - * - * This file is part of xine, a free video player. - * - * The xine-lib XML parser is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * The xine-lib XML parser 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with the Gnome Library; see the file COPYING.LIB. If not, - * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * $Id: xmllexer.h,v 1.8 2007/03/04 16:19:12 hadess Exp $ - * - */ - -/* xml lexer */ -#ifndef XML_LEXER_H -#define XML_LEXER_H - -#ifndef XINE_PROTECTED -#define XINE_PROTECTED -#endif - -/* public constants */ -#define T_ERROR -1 /* lexer error */ -#define T_EOF 0 /* end of file */ -#define T_EOL 1 /* end of line */ -#define T_SEPAR 2 /* separator ' ' '/t' '\n' '\r' */ -#define T_M_START_1 3 /* markup start < */ -#define T_M_START_2 4 /* markup start </ */ -#define T_M_STOP_1 5 /* markup stop > */ -#define T_M_STOP_2 6 /* markup stop /> */ -#define T_EQUAL 7 /* = */ -#define T_QUOTE 8 /* \" or \' */ -#define T_STRING 9 /* "string" */ -#define T_IDENT 10 /* identifier */ -#define T_DATA 11 /* data */ -#define T_C_START 12 /* <!-- */ -#define T_C_STOP 13 /* --> */ -#define T_TI_START 14 /* <? */ -#define T_TI_STOP 15 /* ?> */ -#define T_DOCTYPE_START 16 /* <!DOCTYPE */ -#define T_DOCTYPE_STOP 17 /* > */ -#define T_CDATA_START 18 /* <![CDATA[ */ -#define T_CDATA_STOP 19 /* ]]> */ - - -/* public functions */ -void lexer_init(const char * buf, int size) XINE_PROTECTED; -int lexer_get_token(char * tok, int tok_size) XINE_PROTECTED; -char *lexer_decode_entities (const char *tok) XINE_PROTECTED; - -#endif diff --git a/plparse/xmlparser.c b/plparse/xmlparser.c deleted file mode 100644 index 89e449fd7..000000000 --- a/plparse/xmlparser.c +++ /dev/null @@ -1,808 +0,0 @@ -/* - * Copyright (C) 2002-2003,2007 the xine project - * - * This file is part of xine, a free video player. - * - * The xine-lib XML parser is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * The xine-lib XML parser 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with the Gnome Library; see the file COPYING.LIB. If not, - * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * $Id: xmlparser.c,v 1.16 2007/03/04 16:19:12 hadess Exp $ - * - */ - -#ifdef XINE_COMPILE -# include "config.h" -#endif - -#include <unistd.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> -#include <ctype.h> - -#define LOG_MODULE "xmlparser" -#define LOG_VERBOSE -/* -#define LOG -*/ - -#include <totem_internal.h> -#ifdef XINE_COMPILE -#include "xineutils.h" -#else -#define lprintf -#define xine_xmalloc malloc -#endif -#include "xmllexer.h" -#include "xmlparser.h" - - -#define TOKEN_SIZE 32 * 1024 -#define DATA_SIZE 32 * 1024 -#define MAX_RECURSION 23 - -/* private global variables */ -static int xml_parser_mode; - -/* private functions */ - -static char * strtoupper(char * str) { - int i = 0; - - while (str[i] != '\0') { - str[i] = (char)toupper((int)str[i]); - i++; - } - return str; -} - -static xml_node_t * new_xml_node(void) { - xml_node_t * new_node; - - new_node = (xml_node_t*) malloc(sizeof(xml_node_t)); - new_node->name = NULL; - new_node->data = NULL; - new_node->props = NULL; - new_node->child = NULL; - new_node->next = NULL; - return new_node; -} - -static const char cdata[] = CDATA_MARKER; - -static void free_xml_node(xml_node_t * node) { - if (node->name != cdata) - free (node->name); - free (node->data); - free(node); -} - -static xml_property_t * new_xml_property(void) { - xml_property_t * new_property; - - new_property = (xml_property_t*) malloc(sizeof(xml_property_t)); - new_property->name = NULL; - new_property->value = NULL; - new_property->next = NULL; - return new_property; -} - -static void free_xml_property(xml_property_t * property) { - free (property->name); - free (property->value); - free(property); -} - -void xml_parser_init(const char * buf, int size, int mode) { - - lexer_init(buf, size); - xml_parser_mode = mode; -} - -static void xml_parser_free_props(xml_property_t *current_property) { - if (current_property) { - if (!current_property->next) { - free_xml_property(current_property); - } else { - xml_parser_free_props(current_property->next); - free_xml_property(current_property); - } - } -} - -static void xml_parser_free_tree_rec(xml_node_t *current_node, int free_next) { - lprintf("xml_parser_free_tree_rec: %s\n", current_node->name); - - if (current_node) { - /* properties */ - if (current_node->props) { - xml_parser_free_props(current_node->props); - } - - /* child nodes */ - if (current_node->child) { - lprintf("xml_parser_free_tree_rec: child\n"); - xml_parser_free_tree_rec(current_node->child, 1); - } - - /* next nodes */ - if (free_next) { - xml_node_t *next_node = current_node->next; - xml_node_t *next_next_node; - - while (next_node) { - next_next_node = next_node->next; - lprintf("xml_parser_free_tree_rec: next\n"); - xml_parser_free_tree_rec(next_node, 0); - next_node = next_next_node; - } - } - - free_xml_node(current_node); - } -} - -void xml_parser_free_tree(xml_node_t *current_node) { - lprintf("xml_parser_free_tree\n"); - xml_parser_free_tree_rec(current_node, 1); -} - -typedef enum { - /*0*/ - STATE_IDLE, - /* <foo ...> */ - STATE_NODE, - STATE_ATTRIBUTE, - STATE_NODE_CLOSE, - STATE_TAG_TERM, - STATE_ATTRIBUTE_EQUALS, - STATE_STRING, - STATE_TAG_TERM_IGNORE, - /* <?foo ...?> */ - STATE_Q_NODE, - STATE_Q_ATTRIBUTE, - STATE_Q_NODE_CLOSE, - STATE_Q_TAG_TERM, - STATE_Q_ATTRIBUTE_EQUALS, - STATE_Q_STRING, - /* Others */ - STATE_COMMENT, - STATE_DOCTYPE, - STATE_CDATA, -} parser_state_t; - -static xml_node_t *xml_parser_append_text (xml_node_t *node, xml_node_t *subnode, const char *text, int flags) -{ - if (!text || !*text) - return subnode; /* empty string -> nothing to do */ - - if ((flags & XML_PARSER_MULTI_TEXT) && subnode) { - /* we have a subtree, so we can't use node->data */ - if (subnode->name == cdata) { - /* most recent node is CDATA - append to it */ - char *newtext; - asprintf (&newtext, "%s%s", subnode->data, text); - free (subnode->data); - subnode->data = newtext; - } else { - /* most recent node is not CDATA - add a sibling */ - subnode->next = new_xml_node (); - subnode->next->name = cdata; - subnode->next->data = strdup (text); - subnode = subnode->next; - } - } else if (node->data) { - /* "no" subtree, but we have existing text - append to it */ - char *newtext; - asprintf (&newtext, "%s%s", node->data, text); - free (node->data); - node->data = newtext; - } else { - /* no text, "no" subtree - duplicate & assign */ - while (isspace (*text)) - ++text; - if (*text) - node->data = strdup (text); - } - - return subnode; -} - -#define Q_STATE(CURRENT,NEW) (STATE_##NEW + state - STATE_##CURRENT) - -static int xml_parser_get_node_internal (xml_node_t *current_node, char *root_names[], int rec, int flags) -{ - char tok[TOKEN_SIZE]; - char property_name[TOKEN_SIZE]; - char node_name[TOKEN_SIZE]; - parser_state_t state = STATE_IDLE; - int res = 0; - int parse_res; - int bypass_get_token = 0; - int retval = 0; /* used when state==4; non-0 if there are missing </...> */ - xml_node_t *subtree = NULL; - xml_node_t *current_subtree = NULL; - xml_property_t *current_property = NULL; - xml_property_t *properties = NULL; - - if (rec < MAX_RECURSION) { - - memset (tok, 0, TOKEN_SIZE); - - while ((bypass_get_token) || (res = lexer_get_token(tok, TOKEN_SIZE)) != T_ERROR) { - bypass_get_token = 0; - lprintf("info: %d - %d : '%s'\n", state, res, tok); - - switch (state) { - case STATE_IDLE: - switch (res) { - case (T_EOL): - case (T_SEPAR): - /* do nothing */ - break; - case (T_EOF): - return retval; /* normal end */ - break; - case (T_M_START_1): - state = STATE_NODE; - break; - case (T_M_START_2): - state = STATE_NODE_CLOSE; - break; - case (T_C_START): - state = STATE_COMMENT; - break; - case (T_TI_START): - state = STATE_Q_NODE; - break; - case (T_DOCTYPE_START): - state = STATE_DOCTYPE; - break; - case (T_CDATA_START): - state = STATE_CDATA; - break; - case (T_DATA): - /* current data */ - { - char *decoded = lexer_decode_entities (tok); - current_subtree = xml_parser_append_text (current_node, current_subtree, decoded, flags); - free (decoded); - } - lprintf("info: node data : %s\n", current_node->data); - break; - default: - lprintf("error: unexpected token \"%s\", state %d\n", tok, state); - return -1; - break; - } - break; - - case STATE_NODE: - case STATE_Q_NODE: - switch (res) { - case (T_IDENT): - properties = NULL; - current_property = NULL; - - /* save node name */ - if (xml_parser_mode == XML_PARSER_CASE_INSENSITIVE) { - strtoupper(tok); - } - if (state == STATE_Q_NODE) { - snprintf (node_name, TOKEN_SIZE, "?%s", tok); - state = STATE_Q_ATTRIBUTE; - } else { - strcpy(node_name, tok); - state = STATE_ATTRIBUTE; - } - lprintf("info: current node name \"%s\"\n", node_name); - break; - default: - lprintf("error: unexpected token \"%s\", state %d\n", tok, state); - return -1; - break; - } - break; - - case STATE_ATTRIBUTE: - switch (res) { - case (T_EOL): - case (T_SEPAR): - /* nothing */ - break; - case (T_M_STOP_1): - /* new subtree */ - subtree = new_xml_node(); - - /* set node name */ - subtree->name = strdup(node_name); - - /* set node propertys */ - subtree->props = properties; - lprintf("info: rec %d new subtree %s\n", rec, node_name); - root_names[rec + 1] = node_name; - parse_res = xml_parser_get_node_internal(subtree, root_names, rec + 1, flags); - if (parse_res == -1 || parse_res > 0) { - return parse_res; - } - if (current_subtree == NULL) { - current_node->child = subtree; - current_subtree = subtree; - } else { - current_subtree->next = subtree; - current_subtree = subtree; - } - if (parse_res < -1) { - /* badly-formed XML (missing close tag) */ - return parse_res + 1 + (parse_res == -2); - } - state = STATE_IDLE; - break; - case (T_M_STOP_2): - /* new leaf */ - /* new subtree */ - new_leaf: - subtree = new_xml_node(); - - /* set node name */ - subtree->name = strdup (node_name); - - /* set node propertys */ - subtree->props = properties; - - lprintf("info: rec %d new subtree %s\n", rec, node_name); - - if (current_subtree == NULL) { - current_node->child = subtree; - current_subtree = subtree; - } else { - current_subtree->next = subtree; - current_subtree = subtree; - } - state = STATE_IDLE; - break; - case (T_IDENT): - /* save property name */ - new_prop: - if (xml_parser_mode == XML_PARSER_CASE_INSENSITIVE) { - strtoupper(tok); - } - strcpy(property_name, tok); - state = Q_STATE(ATTRIBUTE, ATTRIBUTE_EQUALS); - lprintf("info: current property name \"%s\"\n", property_name); - break; - default: - lprintf("error: unexpected token \"%s\", state %d\n", tok, state); - return -1; - break; - } - break; - - case STATE_Q_ATTRIBUTE: - switch (res) { - case (T_EOL): - case (T_SEPAR): - /* nothing */ - break; - case (T_TI_STOP): - goto new_leaf; - case (T_IDENT): - goto new_prop; - default: - lprintf("error: unexpected token \"%s\", state %d\n", tok, state); - return -1; - break; - } - break; - - case STATE_NODE_CLOSE: - switch (res) { - case (T_IDENT): - /* must be equal to root_name */ - if (xml_parser_mode == XML_PARSER_CASE_INSENSITIVE) { - strtoupper(tok); - } - if (strcmp(tok, root_names[rec]) == 0) { - state = STATE_TAG_TERM; - } else if (flags & XML_PARSER_RELAXED) { - int r = rec; - while (--r >= 0) - if (strcmp(tok, root_names[r]) == 0) { - lprintf("warning: wanted %s, got %s - assuming missing close tags\n", root_names[rec], tok); - retval = r - rec - 1; /* -1 - (no. of implied close tags) */ - state = STATE_TAG_TERM; - break; - } - /* relaxed parsing, ignoring extra close tag (but we don't handle out-of-order) */ - if (r < 0) { - lprintf("warning: extra close tag %s - ignoring\n", tok); - state = STATE_TAG_TERM_IGNORE; - } - } - else - { - lprintf("error: xml struct, tok=%s, waited_tok=%s\n", tok, root_names[rec]); - return -1; - } - break; - default: - lprintf("error: unexpected token \"%s\", state %d\n", tok, state); - return -1; - break; - } - break; - - /* > expected */ - case STATE_TAG_TERM: - switch (res) { - case (T_M_STOP_1): - return retval; - break; - default: - lprintf("error: unexpected token \"%s\", state %d\n", tok, state); - return -1; - break; - } - break; - - /* = or > or ident or separator expected */ - case STATE_ATTRIBUTE_EQUALS: - switch (res) { - case (T_EOL): - case (T_SEPAR): - /* do nothing */ - break; - case (T_EQUAL): - state = STATE_STRING; - break; - case (T_IDENT): - bypass_get_token = 1; /* jump to state 2 without get a new token */ - state = STATE_ATTRIBUTE; - break; - case (T_M_STOP_1): - /* add a new property without value */ - if (current_property == NULL) { - properties = new_xml_property(); - current_property = properties; - } else { - current_property->next = new_xml_property(); - current_property = current_property->next; - } - current_property->name = strdup (property_name); - lprintf("info: new property %s\n", current_property->name); - bypass_get_token = 1; /* jump to state 2 without get a new token */ - state = STATE_ATTRIBUTE; - break; - default: - lprintf("error: unexpected token \"%s\", state %d\n", tok, state); - return -1; - break; - } - break; - - /* = or ?> or ident or separator expected */ - case STATE_Q_ATTRIBUTE_EQUALS: - switch (res) { - case (T_EOL): - case (T_SEPAR): - /* do nothing */ - break; - case (T_EQUAL): - state = STATE_Q_STRING; - break; - case (T_IDENT): - bypass_get_token = 1; /* jump to state 2 without get a new token */ - state = STATE_Q_ATTRIBUTE; - break; - case (T_TI_STOP): - /* add a new property without value */ - if (current_property == NULL) { - properties = new_xml_property(); - current_property = properties; - } else { - current_property->next = new_xml_property(); - current_property = current_property->next; - } - current_property->name = strdup (property_name); - lprintf("info: new property %s\n", current_property->name); - bypass_get_token = 1; /* jump to state 2 without get a new token */ - state = STATE_Q_ATTRIBUTE; - break; - default: - lprintf("error: unexpected token \"%s\", state %d\n", tok, state); - return -1; - break; - } - break; - - /* string or ident or separator expected */ - case STATE_STRING: - case STATE_Q_STRING: - switch (res) { - case (T_EOL): - case (T_SEPAR): - /* do nothing */ - break; - case (T_STRING): - case (T_IDENT): - /* add a new property */ - if (current_property == NULL) { - properties = new_xml_property(); - current_property = properties; - } else { - current_property->next = new_xml_property(); - current_property = current_property->next; - } - current_property->name = strdup(property_name); - current_property->value = lexer_decode_entities(tok); - lprintf("info: new property %s=%s\n", current_property->name, current_property->value); - state = Q_STATE(STRING, ATTRIBUTE); - break; - default: - lprintf("error: unexpected token \"%s\", state %d\n", tok, state); - return -1; - break; - } - break; - - /* --> expected */ - case STATE_COMMENT: - switch (res) { - case (T_C_STOP): - state = STATE_IDLE; - break; - default: - break; - } - break; - - /* > expected */ - case STATE_DOCTYPE: - switch (res) { - case (T_M_STOP_1): - state = 0; - break; - default: - break; - } - break; - - /* ]]> expected */ - case STATE_CDATA: - switch (res) { - case (T_CDATA_STOP): - current_subtree = xml_parser_append_text (current_node, current_subtree, tok, flags); - lprintf("info: node cdata : %s\n", tok); - state = STATE_IDLE; - break; - default: - lprintf("error: unexpected token \"%s\", state %d\n", tok, state); - return -1; - break; - } - break; - - /* > expected (following unmatched "</...") */ - case STATE_TAG_TERM_IGNORE: - switch (res) { - case (T_M_STOP_1): - state = STATE_IDLE; - break; - default: - lprintf("error: unexpected token \"%s\", state %d\n", tok, state); - return -1; - break; - } - break; - - - default: - lprintf("error: unknown parser state, state=%d\n", state); - return -1; - } - } - /* lex error */ - lprintf("error: lexer error\n"); - return -1; - } else { - /* max recursion */ - lprintf("error: max recursion\n"); - return -1; - } -} - -static int xml_parser_get_node (xml_node_t *current_node, int flags) -{ - char *root_names[MAX_RECURSION + 1]; - root_names[0] = ""; - return xml_parser_get_node_internal (current_node, root_names, 0, flags); -} - -int xml_parser_build_tree_with_options(xml_node_t **root_node, int flags) { - xml_node_t *tmp_node, *pri_node, *q_node; - int res; - - tmp_node = new_xml_node(); - res = xml_parser_get_node(tmp_node, flags); - - /* delete any top-level [CDATA] nodes */; - pri_node = tmp_node->child; - q_node = NULL; - while (pri_node) { - if (pri_node->name == cdata) { - xml_node_t *old = pri_node; - if (q_node) - q_node->next = pri_node->next; - else - q_node = pri_node; - pri_node = pri_node->next; - free_xml_node (old); - } else { - q_node = pri_node; - pri_node = pri_node->next; - } - } - - /* find first non-<?...?> node */; - for (pri_node = tmp_node->child, q_node = NULL; - pri_node && pri_node->name[0] == '?'; - pri_node = pri_node->next) - q_node = pri_node; /* last <?...?> node (eventually), or NULL */ - - if (pri_node && !pri_node->next) { - /* move the tail to the head (for compatibility reasons) */ - if (q_node) { - pri_node->next = tmp_node->child; - q_node->next = NULL; - } - *root_node = pri_node; - free_xml_node(tmp_node); - res = 0; - } else { - lprintf("error: xml struct\n"); - xml_parser_free_tree(tmp_node); - res = -1; - } - return res; -} - -int xml_parser_build_tree(xml_node_t **root_node) { - return xml_parser_build_tree_with_options (root_node, 0); -} - -const char *xml_parser_get_property (const xml_node_t *node, const char *name) { - - xml_property_t *prop; - - prop = node->props; - while (prop) { - - lprintf ("looking for %s in %s\n", name, prop->name); - - if (!strcasecmp (prop->name, name)) { - lprintf ("found it. value=%s\n", prop->value); - return prop->value; - } - - prop = prop->next; - } - - return NULL; -} - -int xml_parser_get_property_int (const xml_node_t *node, const char *name, - int def_value) { - - const char *v; - int ret; - - v = xml_parser_get_property (node, name); - - if (!v) - return def_value; - - if (sscanf (v, "%d", &ret) != 1) - return def_value; - else - return ret; -} - -int xml_parser_get_property_bool (const xml_node_t *node, const char *name, - int def_value) { - - const char *v; - - v = xml_parser_get_property (node, name); - - if (!v) - return def_value; - - return !strcasecmp (v, "true"); -} - -static int xml_escape_string_internal (char *buf, const char *s, - xml_escape_quote_t quote_type) -{ - int c, length = 0; - int sl = buf ? 8 : 0; - /* calculate max required buffer size */ - while ((c = *s++ & 0xFF)) - switch (c) - { - case '"': if (quote_type != XML_ESCAPE_DOUBLE_QUOTE) goto literal; - length += snprintf (buf + length, sl, """); break; - case '\'': if (quote_type != XML_ESCAPE_SINGLE_QUOTE) goto literal; - length += snprintf (buf + length, sl, "'"); break; - case '&': length += snprintf (buf + length, sl, "&"); break; - case '<': length += snprintf (buf + length, sl, "<"); break; - case '>': length += snprintf (buf + length, sl, ">"); break; - case 127: length += snprintf (buf + length, sl, ""); break; - case '\t': - case '\n': - literal: if (buf) buf[length] = c; ++length; break; - default: if (c >= ' ') goto literal; - length += snprintf (buf + length, sl, "&#%d;", c); break; - } - if (buf) - buf[length] = 0; - return length + 1; -} - -char *xml_escape_string (const char *s, xml_escape_quote_t quote_type) -{ - char *buf = xine_xmalloc (xml_escape_string_internal (NULL, s, quote_type)); - return buf ? (xml_escape_string_internal (buf, s, quote_type), buf) : NULL; -} - -static void xml_parser_dump_node (const xml_node_t *node, int indent) { - - xml_property_t *p; - xml_node_t *n; - int l; - - printf ("%*s<%s ", indent, "", node->name); - - l = strlen (node->name); - - p = node->props; - while (p) { - char *value = xml_escape_string (p->value, XML_ESCAPE_SINGLE_QUOTE); - printf ("%s='%s'", p->name, value); - free (value); - p = p->next; - if (p) { - printf ("\n%*s", indent+2+l, ""); - } - } - printf (">\n"); - - n = node->child; - while (n) { - - xml_parser_dump_node (n, indent+2); - - n = n->next; - } - - printf ("%*s</%s>\n", indent, "", node->name); -} - -void xml_parser_dump_tree (const xml_node_t *node) { - do { - xml_parser_dump_node (node, 0); - node = node->next; - } while (node); -} diff --git a/plparse/xmlparser.h b/plparse/xmlparser.h deleted file mode 100644 index 420f2c36c..000000000 --- a/plparse/xmlparser.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2002-2003,2007 the xine project - * - * This file is part of xine, a free video player. - * - * The xine-lib XML parser is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * The xine-lib XML parser 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with the Gnome Library; see the file COPYING.LIB. If not, - * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * $Id: xmlparser.h,v 1.6 2007/03/04 16:19:12 hadess Exp $ - * - */ - -#ifndef XML_PARSER_H -#define XML_PARSER_H - -#ifndef XINE_PROTECTED -#define XINE_PROTECTED -#endif - -/* parser modes */ -#define XML_PARSER_CASE_INSENSITIVE 0 -#define XML_PARSER_CASE_SENSITIVE 1 - -/* return codes */ -#define XML_PARSER_OK 0 -#define XML_PARSER_ERROR 1 - -/* xml_parser_build_tree_with_options flag bits */ -#define XML_PARSER_RELAXED 1 -#define XML_PARSER_MULTI_TEXT 2 - -/* node name for extra text chunks */ -#define CDATA_MARKER "[CDATA]" - -/* xml property */ -typedef struct xml_property_s { - char *name; - char *value; - struct xml_property_s *next; -} xml_property_t; - -/* xml node */ -/* .data contains any text which precedes any subtree elements; - * subtree elements may also contain only text; if so, name is "[CDATA]". - * e.g. <a>b<c />d</a> - * node1: .name="a" .data="b" .child=node2 .next=NULL - * node2: .name="c" .data=NULL .child=NULL .next=node3 - * node3: .name="[CDATA]" .data="d" .child=NULL .next=NULL - * Adjacent text items are merged. - */ -typedef struct xml_node_s { - char *name; - char *data; - struct xml_property_s *props; - struct xml_node_s *child; - struct xml_node_s *next; -} xml_node_t; - -void xml_parser_init(const char * buf, int size, int mode) XINE_PROTECTED; - -int xml_parser_build_tree(xml_node_t **root_node) XINE_PROTECTED; -int xml_parser_build_tree_with_options(xml_node_t **root_node, int flags) XINE_PROTECTED; - -void xml_parser_free_tree(xml_node_t *root_node) XINE_PROTECTED; - -const char *xml_parser_get_property (const xml_node_t *node, const char *name) XINE_PROTECTED; -int xml_parser_get_property_int (const xml_node_t *node, const char *name, - int def_value) XINE_PROTECTED; -int xml_parser_get_property_bool (const xml_node_t *node, const char *name, - int def_value) XINE_PROTECTED; - -/* for output: - * returns an escaped string (free() it when done) - * input must be in ASCII or UTF-8 - */ - -typedef enum { - XML_ESCAPE_NO_QUOTE, - XML_ESCAPE_SINGLE_QUOTE, - XML_ESCAPE_DOUBLE_QUOTE -} xml_escape_quote_t; -char *xml_escape_string (const char *s, xml_escape_quote_t quote_type) XINE_PROTECTED; - -/* for debugging purposes: dump read-in xml tree in a nicely - * indented fashion - */ - -void xml_parser_dump_tree (const xml_node_t *node) XINE_PROTECTED; - -#endif diff --git a/po/ChangeLog b/po/ChangeLog index 7daa43f27..c6de5ca76 100644 --- a/po/ChangeLog +++ b/po/ChangeLog @@ -1,3 +1,7 @@ +2007-12-03 Bastien Nocera <hadess@hadess.net> + + * POTFILES.in: remove removed files + 2007-12-03 Priit Laes <plaes@svn.gnome.org> * et.po: Translation updated by Ivar Smolin. diff --git a/po/POTFILES.in b/po/POTFILES.in index d441f56f8..88c3f8629 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -31,12 +31,6 @@ src/totem.c src/backend/bacon-video-widget-gst-0.10.c src/backend/bacon-video-widget-xine.c src/backend/video-utils.c -plparse/totem-disc.c -plparse/totem-pl-parser.c -plparse/totem-pl-parser-lines.c -plparse/totem-pl-parser-pla.c -plparse/totem-pl-parser-pls.c -plparse/totem-pl-parser-xspf.c src/plugins/totem-plugin-manager.c src/plugins/totem-plugins-engine.c [type: gettext/ini]src/plugins/bemused/bemused.totem-plugin.in diff --git a/src/Makefile.am b/src/Makefile.am index dfadca30f..59a36359c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -139,7 +139,6 @@ totem_LDFLAGS = \ $(AM_LDFLAGS) totem_LDADD = \ - $(top_builddir)/plparse/libtotem-plparser.la \ backend/libbaconvideowidget.la \ plugins/libtotemmodule.la \ libbaconmessageconnection.la \ diff --git a/src/backend/bacon-video-widget.h b/src/backend/bacon-video-widget.h index f652d7279..7026f64bd 100644 --- a/src/backend/bacon-video-widget.h +++ b/src/backend/bacon-video-widget.h @@ -29,9 +29,8 @@ #define HAVE_BACON_VIDEO_WIDGET_H #include <gtk/gtkeventbox.h> - /* for optical disc enumeration type */ -#include "plparse/totem-disc.h" +#include <totem-disc.h> G_BEGIN_DECLS diff --git a/src/totem-playlist.h b/src/totem-playlist.h index 705d16d7a..fb6c2b6ba 100644 --- a/src/totem-playlist.h +++ b/src/totem-playlist.h @@ -25,8 +25,7 @@ #include <gtk/gtkvbox.h> #include <libgnomevfs/gnome-vfs-volume.h> - -#include "plparse/totem-pl-parser.h" +#include <totem-pl-parser.h> G_BEGIN_DECLS diff --git a/src/totem.c b/src/totem.c index 52a0babc1..92d3b345d 100644 --- a/src/totem.c +++ b/src/totem.c @@ -31,6 +31,7 @@ #include <glib/gi18n.h> #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> +#include <totem-disc.h> #include <stdlib.h> #include <math.h> @@ -65,7 +66,6 @@ #include "totem.h" #include "totem-private.h" #include "totem-preferences.h" -#include "plparse/totem-disc.h" #include "debug.h" diff --git a/src/totem.h b/src/totem.h index 483150eb2..bf99bda35 100644 --- a/src/totem.h +++ b/src/totem.h @@ -30,7 +30,7 @@ #include <glib-object.h> #include <gtk/gtk.h> -#include "plparse/totem-disc.h" +#include <totem-disc.h> #include "totem-playlist.h" #define TOTEM_GCONF_PREFIX "/apps/totem" diff --git a/totem-plparser-uninstalled.pc.in b/totem-plparser-uninstalled.pc.in deleted file mode 100644 index dd9128cc4..000000000 --- a/totem-plparser-uninstalled.pc.in +++ /dev/null @@ -1,14 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ -gconf_serverdir=@libexecdir@ - - -Name: totem-plparser -Description: Totem Playlist Parser library -Version: @VERSION@ -Requires: gtk+-2.0 -Requires.private: libxml-2.0 gnome-vfs-2.0 gnome-vfs-module-2.0 -Libs: ${pc_top_builddir}/${pcfiledir}/src/plparse/libtotem-plparser.la -Cflags: -I${pc_top_builddir}/${pcfiledir}/src/plparse diff --git a/totem-plparser.pc.in b/totem-plparser.pc.in deleted file mode 100644 index 8bb1e5963..000000000 --- a/totem-plparser.pc.in +++ /dev/null @@ -1,14 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ -gconf_serverdir=@libexecdir@ - - -Name: totem-plparser -Description: Totem Playlist Parser library -Version: @VERSION@ -Requires: gtk+-2.0 -Requires.private: libxml-2.0 gnome-vfs-2.0 gnome-vfs-module-2.0 -Libs: -L${libdir} -ltotem-plparser -Cflags: -I${includedir}/totem/1/plparser |