? src/plparse/P Index: configure.in =================================================================== RCS file: /cvs/gnome/totem/configure.in,v retrieving revision 1.281 diff -p -u -B -u -p -r1.281 configure.in --- configure.in 10 Aug 2006 13:39:23 -0000 1.281 +++ configure.in 10 Aug 2006 15:24:48 -0000 @@ -28,6 +24,9 @@ AC_PROG_CXX AC_PROG_LIBTOOL() PKG_PROG_PKG_CONFIG +AC_PATH_PROG([GLIB_GENMARSHAL],[glib-genmarshal]) +AC_PATH_PROG([GLIB_MKENUMS],[glib-mkenums]) + # Requirements GLIB_REQS=2.6.3 GTK_REQS=2.5.6 @@ -615,6 +659,14 @@ dnl Check for packages for building libt 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]) +GNOME_CXX_WARNINGS +GNOME_MAINTAINER_MODE_DEFINES dnl debug AC_ARG_ENABLE(debug, @@ -639,6 +691,11 @@ if test "$GCC" = "yes" ; then $CFLAGS" fi +AC_SUBST([AM_CPPFLAGS]) +AC_SUBST([AM_CFLAGS]) +AC_SUBST([AM_CXXFLAGS]) +AC_SUBST([AM_LDFLAGS]) + AC_OUTPUT([ Makefile totem.spec Index: src/plparse/Makefile.am =================================================================== RCS file: /cvs/gnome/totem/src/plparse/Makefile.am,v retrieving revision 1.8 diff -p -u -B -u -p -r1.8 Makefile.am --- src/plparse/Makefile.am 10 Aug 2006 08:43:48 -0000 1.8 +++ src/plparse/Makefile.am 10 Aug 2006 15:24:48 -0000 @@ -1,22 +1,27 @@ noinst_PROGRAMS = test-parser -INCLUDES = \ - -I$(top_srcdir) \ - -I$(top_builddir)/src/plparser \ - -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ - $(EXTRA_GNOME_CFLAGS) \ - $(HAL_CFLAGS) \ - $(DBUS_CFLAGS) - test_parser_SOURCES = test-parser.c + +test_parser_CPPFLAGS = \ + -I$(top_srcdir) \ + -I$(top_builddir)/src/plparser \ + -DGNOMELOCALEDIR=\""$(datadir)/locale"\"\ + $(AM_CPPFLAGS) + +test_parser_CFLAGS = \ + $(EXTRA_GNOME_CFLAGS) \ + $(HAL_CFLAGS) \ + $(DBUS_CFLAGS) \ + $(AM_CFLAGS) + test_parser_LDADD = \ $(EXTRA_GNOME_LIBS) \ libtotem-plparser.la lib_LTLIBRARIES = libtotem-plparser.la +noinst_LTLIBRARIES = libtotem-plparser-mini.la MARSHALFILES = totemplparser-marshal.c totemplparser-marshal.h -GLIB_GENMARSHAL=`pkg-config --variable=glib_genmarshal glib-2.0` BUILT_SOURCES = $(MARSHALFILES) totemplparser-marshal.c: totemplparser-marshal.h @@ -24,6 +29,13 @@ totemplparser-marshal.c: totemplparser-m totemplparser-marshal.h: totemplparser-marshal.list ( $(GLIB_GENMARSHAL) --prefix=totemplparser_marshal $(srcdir)/totemplparser-marshal.list --header > totemplparser-marshal.h ) +plparserincludedir = $(includedir)/totem/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-pl-parser-builtins.c \ totemplparser-marshal.c \ @@ -31,20 +43,49 @@ libtotem_plparser_la_SOURCES = \ totem-disc.c \ totem-pl-parser.c -plparserincludedir = $(includedir)/totem/1/plparser -plparserinclude_HEADERS = \ - totem-pl-parser-builtins.h \ - totem-pl-parser-features.h \ - totem-pl-parser.h \ - totem-disc.h +libtotem_plparser_la_CPPFLAGS = \ + -I$(top_srcdir) \ + -I$(top_builddir)/src/plparser \ + -DGNOMELOCALEDIR=\""$(datadir)/locale"\"\ + $(AM_CPPFLAGS) + +libtotem_plparser_la_CFLAGS = \ + $(EXTRA_GNOME_CFLAGS) \ + $(HAL_CFLAGS) \ + $(DBUS_CFLAGS) \ + $(AM_CFLAGS) + +libtotem_plparser_la_LIBADD = \ + $(TOTEM_PLPARSER_LIBS) \ + $(HAL_LIBS) libtotem_plparser_la_LDFLAGS = \ -version-info $(PLPARSER_LT_VERSION) \ -no-undefined \ - $(TOTEM_PLPARSER_LIBS) \ - $(HAL_LIBS) + $(AM_LDFLAGS) + +libtotem_plparser_mini_la_SOURCES = \ + totem-pl-parser-mini.h \ + totem-pl-parser.c + +libtotem_plparser_mini_la_CPPFLAGS = \ + -I$(top_srcdir) \ + -I$(top_builddir)/src/plparser \ + -DTOTEM_PL_PARSER_MINI \ + $(AM_CPPFLAGS) + +# FIXME! +libtotem_plparser_mini_la_CFLAGS = \ + $(TOTEM_PLPARSER_MINI_CFLAGS) \ + $(AM_CFLAGS) + +libtotem_plparser_mini_la_LIBADD = \ + $(TOTEM_PLPARSER_MINI_LIBS) + +libtotem_plparser_mini_la_LDFLAGS = \ + -no-undefined \ + $(AM_LDFLAGS) -GLIB_MKENUMS=`pkg-config --variable=glib_mkenums glib-2.0` totem-pl-parser-builtins.h: stamp-totem-pl-parser-builtins.h @true Index: src/plparse/test-parser.c =================================================================== RCS file: /cvs/gnome/totem/src/plparse/test-parser.c,v retrieving revision 1.13 diff -p -u -B -u -p -r1.13 test-parser.c --- src/plparse/test-parser.c 10 Aug 2006 08:43:48 -0000 1.13 +++ src/plparse/test-parser.c 10 Aug 2006 15:24:48 -0000 @@ -196,7 +196,7 @@ test_data (void) g_message ("Couldn't get data for %s", (char *) l->data); continue; } - if (totem_pl_parser_can_parse_from_data (data, len)) { + if (totem_pl_parser_can_parse_from_data (NULL, data, len)) { g_message ("IS a playlist: %s", (char *) l->data); } else { g_message ("ISNOT playlist: %s", (char *) l->data); @@ -237,10 +237,6 @@ test_parsing (void) int main (int argc, char **argv) { gnome_vfs_init(); - - bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); while (argc > 1 && argv[1]) { if (strcmp (argv[1], "--no-recurse") == 0 || strcmp (argv[1], "-n") == 0) { Index: src/plparse/totem-pl-parser-mini.h =================================================================== RCS file: src/plparse/totem-pl-parser-mini.h diff -N src/plparse/totem-pl-parser-mini.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/plparse/totem-pl-parser-mini.h 10 Aug 2006 15:24:48 -0000 @@ -0,0 +1,38 @@ +/* + arch-tag: Header for Rhythmbox playlist parser + + Copyright (C) 2002, 2003 Bastien Nocera + Copyright (C) 2003 Colin Walters + + 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 + */ + +#ifndef TOTEM_PL_PARSER_MINI_H +#define TOTEM_PL_PARSER_MINI_H + +#include + +G_BEGIN_DECLS + +gboolean totem_pl_parser_can_parse_from_data (const char *mime_type, + const char *data, + gsize len); + +G_END_DECLS + +#endif /* TOTEM_PL_PARSER_MINI_H */ Index: src/plparse/totem-pl-parser.c =================================================================== RCS file: /cvs/gnome/totem/src/plparse/totem-pl-parser.c,v retrieving revision 1.113 diff -p -u -B -u -p -r1.113 totem-pl-parser.c --- src/plparse/totem-pl-parser.c 10 Aug 2006 08:43:48 -0000 1.113 +++ src/plparse/totem-pl-parser.c 10 Aug 2006 15:24:49 -0000 @@ -26,21 +26,24 @@ #include "config.h" #endif /* HAVE_CONFIG_H */ -#include "totem-pl-parser.h" - -#include "totemplparser-marshal.h" -#include "totem-disc.h" - +#include #include #include -#include +#include + +#ifndef TOTEM_PL_PARSER_MINI #include #include +#include #include #include -#include #include -#include +#include "totem-pl-parser.h" +#include "totemplparser-marshal.h" +#include "totem-disc.h" +#endif /* !TOTEM_PL_PARSER_MINI */ + +#include "totem-pl-parser-mini.h" #define READ_CHUNK_SIZE 8192 #define MIME_READ_CHUNK_SIZE 1024 @@ -50,28 +53,31 @@ #define EXTINF "#EXTINF:" #define DEBUG(x) { if (parser->priv->debug) x; } -typedef TotemPlParserResult (*PlaylistCallback) (TotemPlParser *parser, const char *url, gpointer data); -typedef gboolean (*PlaylistIdenCallback) (gpointer data, guint len); -static gboolean totem_pl_parser_scheme_is_ignored (TotemPlParser *parser, const char *url); -static gboolean totem_pl_parser_ignore (TotemPlParser *parser, const char *url); -static TotemPlParserResult totem_pl_parser_parse_internal (TotemPlParser *parser, const char *url); -static TotemPlParserResult totem_pl_parser_add_asx (TotemPlParser *parser, const char *url, gpointer data); +typedef gboolean (*PlaylistIdenCallback) (const char *data, gsize len); -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); +#ifndef TOTEM_PL_PARSER_MINI +typedef TotemPlParserResult (*PlaylistCallback) (TotemPlParser *parser, const char *url, gpointer data); +#endif typedef struct { char *mimetype; +#ifndef TOTEM_PL_PARSER_MINI PlaylistCallback func; +#endif PlaylistIdenCallback iden; } PlaylistTypes; +static gboolean totem_pl_parser_is_ra (const char *data, gsize len); +static gboolean totem_pl_parser_is_asf (const char *data, gsize len); +static gboolean totem_pl_parser_is_quicktime (const char *data, gsize len); + +#ifndef TOTEM_PL_PARSER_MINI + +static gboolean totem_pl_parser_scheme_is_ignored (TotemPlParser *parser, const char *url); +static gboolean totem_pl_parser_ignore (TotemPlParser *parser, const char *url); +static TotemPlParserResult totem_pl_parser_parse_internal (TotemPlParser *parser, const char *url); +static TotemPlParserResult totem_pl_parser_add_asx (TotemPlParser *parser, const char *url, gpointer data); + struct TotemPlParserPrivate { GList *ignore_schemes; @@ -82,6 +88,15 @@ struct TotemPlParserPrivate guint debug : 1; }; +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, @@ -96,11 +111,9 @@ enum { LAST_SIGNAL }; -static int totem_pl_parser_table_signals[LAST_SIGNAL] = { 0 }; +static int totem_pl_parser_table_signals[LAST_SIGNAL]; static gboolean i18n_done = FALSE; -static GObjectClass *parent_class = NULL; - 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); @@ -112,8 +125,6 @@ totem_pl_parser_class_init (TotemPlParse { GObjectClass *object_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - 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; @@ -446,6 +457,7 @@ totem_pl_parser_relative (const char *ur return base; } +#ifndef TOTEM_PL_PARSER_MINI static gboolean totem_pl_parser_write_pls (TotemPlParser *parser, GtkTreeModel *model, TotemPlParserIterFunc func, @@ -825,6 +837,8 @@ totem_pl_parser_write (TotemPlParser *pa NULL, type, user_data, error); } +#endif /* TOTEM_PL_PARSER_MINI */ + static int read_ini_line_int (char **lines, const char *key) { @@ -919,9 +933,7 @@ totem_pl_parser_finalize (GObject *objec g_free (parser->priv); parser->priv = NULL; - if (G_OBJECT_CLASS (parent_class)->finalize != NULL) { - (* G_OBJECT_CLASS (parent_class)->finalize) (object); - } + G_OBJECT_CLASS (totem_pl_parser_parent_class)->finalize (object); } static gboolean @@ -1518,21 +1530,6 @@ totem_pl_parser_add_block (TotemPlParser return TOTEM_PL_PARSER_RESULT_SUCCESS; } -static gboolean -totem_pl_parser_is_ra (gpointer data, guint len) -{ - /* pnm is the smallest, 6 chars */ - if (len < 7) - return FALSE; - - if (g_str_has_prefix (data, "http://") != FALSE - || g_str_has_prefix (data, "rtsp://") != FALSE - || g_str_has_prefix (data, "pnm://") != FALSE) { - return TRUE; - } - return FALSE; -} - static TotemPlParserResult totem_pl_parser_add_ra (TotemPlParser *parser, const char *url, gpointer data) { @@ -1661,32 +1658,6 @@ totem_pl_parser_add_smil (TotemPlParser return retval; } -static gboolean -totem_pl_parser_is_asf (gpointer data, guint len) -{ - char *buffer; - - if (len == 0) - return FALSE; - - if (g_str_has_prefix (data, "[Reference]") != FALSE - || g_ascii_strncasecmp (data, "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)); +} + +#endif /* !TOTEM_PL_PARSER_MINI */ + +#define DD(x) x + gboolean -totem_pl_parser_can_parse_from_data (gpointer data, guint len) +totem_pl_parser_can_parse_from_data (const char *mimetype, + const char *data, + gsize len) { - const char *mimetype; guint i; - totem_pl_parser_init_i18n (); + /* Bad cast! */ + if (mimetype == NULL || strcmp (mimetype, "application/octet-stream") == 0) { + mimetype = gnome_vfs_get_mime_type_for_data ((gpointer) data, (int) len); + } - mimetype = gnome_vfs_get_mime_type_for_data (data, len); if (mimetype == NULL || strcmp (GNOME_VFS_MIME_TYPE_UNKNOWN, mimetype) == 0) { - g_message ("totem_pl_parser_can_parse_from_data couldn't get mimetype"); + DD(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) { - g_message ("Is special type '%s'\n", mimetype); + DD(g_message ("Is special type '%s'\n", mimetype)); return TRUE; } } for (i = 0; i < G_N_ELEMENTS(dual_types); i++) { if (strcmp (dual_types[i].mimetype, mimetype) == 0) { - g_message ("Is dual type '%s'\n", mimetype); + DD(g_message ("Is dual type '%s'\n", mimetype)); if (dual_types[i].iden != NULL) return (* dual_types[i].iden) (data, len); return FALSE; @@ -2333,24 +2386,3 @@ totem_pl_parser_can_parse_from_data (gpo return FALSE; } - -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)); -} - Index: src/plparse/totem-pl-parser.h =================================================================== RCS file: /cvs/gnome/totem/src/plparse/totem-pl-parser.h,v retrieving revision 1.13 diff -p -u -B -u -p -r1.13 totem-pl-parser.h --- src/plparse/totem-pl-parser.h 10 Aug 2006 08:43:48 -0000 1.13 +++ src/plparse/totem-pl-parser.h 10 Aug 2006 15:24:49 -0000 @@ -26,8 +26,8 @@ #define TOTEM_PL_PARSER_H #include -#include +#include #include "totem-pl-parser-features.h" #include "totem-pl-parser-builtins.h" @@ -105,8 +105,6 @@ gboolean totem_pl_parser_write_with_ti TotemPlParserType type, gpointer user_data, GError **error); - -gboolean totem_pl_parser_can_parse_from_data (gpointer data, guint len); void totem_pl_parser_add_ignored_scheme (TotemPlParser *parser, const char *scheme);