totem-pl-parser r81 - in trunk: . plparse



Author: hadess
Date: Mon Mar 17 14:28:21 2008
New Revision: 81
URL: http://svn.gnome.org/viewvc/totem-pl-parser?rev=81&view=rev

Log:
2008-03-17  Bastien Nocera  <hadess hadess net>

	* *: First pass at porting to GIO. Completely broken, please
	bear with me.



Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/plparse/test-parser.c
   trunk/plparse/totem-pl-parser-lines.c
   trunk/plparse/totem-pl-parser-lines.h
   trunk/plparse/totem-pl-parser-media.c
   trunk/plparse/totem-pl-parser-media.h
   trunk/plparse/totem-pl-parser-misc.c
   trunk/plparse/totem-pl-parser-misc.h
   trunk/plparse/totem-pl-parser-pla.c
   trunk/plparse/totem-pl-parser-pla.h
   trunk/plparse/totem-pl-parser-pls.c
   trunk/plparse/totem-pl-parser-pls.h
   trunk/plparse/totem-pl-parser-podcast.c
   trunk/plparse/totem-pl-parser-podcast.h
   trunk/plparse/totem-pl-parser-private.h
   trunk/plparse/totem-pl-parser-qt.c
   trunk/plparse/totem-pl-parser-qt.h
   trunk/plparse/totem-pl-parser-smil.c
   trunk/plparse/totem-pl-parser-smil.h
   trunk/plparse/totem-pl-parser-wm.c
   trunk/plparse/totem-pl-parser-wm.h
   trunk/plparse/totem-pl-parser-xspf.c
   trunk/plparse/totem-pl-parser-xspf.h
   trunk/plparse/totem-pl-parser.c

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Mon Mar 17 14:28:21 2008
@@ -77,7 +77,7 @@
 AM_CONDITIONAL(HAVE_HAL, test x"$with_hal" = xyes)
 
 dnl Check for packages for building libtotem-plparser.la
-PKG_CHECK_MODULES(TOTEM_PLPARSER, [glib-2.0 >= $GLIB_REQS gtk+-2.0 libxml-2.0 gnome-vfs-2.0 >= $GNOMEVFS_REQS gnome-vfs-module-2.0 camel-1.2])
+PKG_CHECK_MODULES(TOTEM_PLPARSER, [glib-2.0 >= $GLIB_REQS gtk+-2.0 libxml-2.0 gnome-vfs-2.0 >= $GNOMEVFS_REQS gnome-vfs-module-2.0 camel-1.2 gio-2.0])
 
 PKG_CHECK_MODULES([TOTEM_PLPARSER_MINI], [gnome-vfs-2.0 gnome-vfs-module-2.0])
 

Modified: trunk/plparse/test-parser.c
==============================================================================
--- trunk/plparse/test-parser.c	(original)
+++ trunk/plparse/test-parser.c	Mon Mar 17 14:28:21 2008
@@ -3,11 +3,12 @@
 #include <locale.h>
 
 #include <glib.h>
+#include <gio/gio.h>
+
 #include <string.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <time.h>
-#include <libgnomevfs/gnome-vfs.h>
 
 #include "totem-pl-parser.h"
 #include "totem-pl-parser-mini.h"
@@ -117,6 +118,7 @@
 {
 	header ("Resolve URL");
 
+	test_resolve_real ("http://localhost:12345/foobar/";, "another_file", "http://localhost:12345/foobar/another_file";);
 	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&param2=bar";, "dir/image.jpg", "http://localhost/video.dir/dir/image.jpg";);
@@ -294,62 +296,43 @@
 static char *
 test_data_get_data (const char *uri, guint *len)
 {
-	GnomeVFSResult result;
-	GnomeVFSHandle *handle;
+	gssize bytes_read;
+	GFileInputStream *stream;
+	GFile *file;
+	GError *error = NULL;
 	char *buffer;
-	GnomeVFSFileSize total_bytes_read;
-	GnomeVFSFileSize bytes_read;
 
 	*len = 0;
 
+	file = g_file_new_for_uri (uri);
+
 	/* Open the file. */
-	result = gnome_vfs_open (&handle, uri, GNOME_VFS_OPEN_READ);
-	if (result != GNOME_VFS_OK)
+	stream = g_file_read (file, NULL, &error);
+	if (stream == NULL) {
+		g_print ("URL '%s' couldn't be opened in test_data_get_data: '%s'\n", uri, error->message);
+		g_error_free (error);
 		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);
+	buffer = g_malloc (MIME_READ_CHUNK_SIZE);
+	bytes_read = g_input_stream_read (G_INPUT_STREAM (stream), buffer, MIME_READ_CHUNK_SIZE, NULL, &error);
+	g_input_stream_close (G_INPUT_STREAM (stream), NULL, NULL);
+	if (bytes_read == -1) {
+		g_free (buffer);
+		return NULL;
+	}
 
-	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));
+	if (bytes_read == -1) {
+		g_message ("URL '%s' couldn't be read or closed in _get_mime_type_with_data: '%s'\n", uri, error->message);
+		g_error_free (error);
 		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;
+	buffer = g_realloc (buffer, bytes_read + 1);
+	buffer[bytes_read] = '\0';
+	*len = bytes_read;
 
 	return buffer;
 }
@@ -443,6 +426,7 @@
 	setlocale (LC_ALL, "");
 
 	g_thread_init (NULL);
+	g_type_init ();
 
 	context = g_option_context_new (NULL);
 	g_option_context_add_main_entries (context, option_entries, NULL);
@@ -458,8 +442,6 @@
 		exit (1);
 	}
 
-	gnome_vfs_init();
-
 	if (g_fatal_warnings) {
 		GLogLevelFlags fatal_mask;
 
@@ -492,9 +474,9 @@
 
 	if (files == NULL) {
 		test_duration ();
-		test_resolve ();
-		test_relative ();
 		test_date ();
+		test_relative ();
+		test_resolve ();
 		test_parsing ();
 	} else {
 		if (option_data) {

Modified: trunk/plparse/totem-pl-parser-lines.c
==============================================================================
--- trunk/plparse/totem-pl-parser-lines.c	(original)
+++ trunk/plparse/totem-pl-parser-lines.c	Mon Mar 17 14:28:21 2008
@@ -28,7 +28,8 @@
 #ifndef TOTEM_PL_PARSER_MINI
 #include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
-#include <libgnomevfs/gnome-vfs.h>
+#include <gio/gio.h>
+
 #include "totem-pl-parser.h"
 #include "totemplparser-marshal.h"
 #include "totem-pl-parser-pls.h"
@@ -78,33 +79,23 @@
 
 gboolean
 totem_pl_parser_write_m3u (TotemPlParser *parser, GtkTreeModel *model,
-		TotemPlParserIterFunc func, const char *output,
-		gboolean dos_compatible, gpointer user_data, GError **error)
+			   TotemPlParserIterFunc func, const char *output,
+			   gboolean dos_compatible, gpointer user_data, GError **error)
 {
-	GnomeVFSHandle *handle;
-	GnomeVFSResult res;
+	GFile *out;
+	GFileOutputStream *stream;
 	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));
+	out = g_file_new_for_commandline_arg (output);
+	stream = g_file_replace (out, NULL, FALSE, G_FILE_CREATE_NONE, NULL, error);
+	if (stream == NULL) {
+		g_object_unref (out);
 		return FALSE;
 	}
+	g_object_unref (out);
 
 	cr = dos_compatible ? "\r\n" : "\n";
 	num_entries_total = gtk_tree_model_iter_n_children (model, NULL);
@@ -115,27 +106,30 @@
 		GtkTreeIter iter;
 		char *url, *title, *path2;
 		gboolean custom_title;
+		GFile *file;
 
 		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)
-		{
+		file = g_file_new_for_uri (url);
+		if (totem_pl_parser_scheme_is_ignored (parser, file) != FALSE) {
+			g_object_unref (file);
 			g_free (url);
 			g_free (title);
 			continue;
 		}
+		g_object_unref (file);
 
 		if (custom_title != FALSE) {
 			buf = g_strdup_printf (EXTINF",%s%s", title, cr);
-			success = totem_pl_parser_write_string (handle, buf, error);
+			success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
 			g_free (buf);
 			if (success == FALSE) {
 				g_free (title);
 				g_free (url);
-				gnome_vfs_close (handle);
+				g_output_stream_close (G_OUTPUT_STREAM (stream), NULL, NULL);
 				return FALSE;
 			}
 		}
@@ -157,17 +151,16 @@
 		g_free (path2);
 		g_free (url);
 
-		success = totem_pl_parser_write_string (handle, buf, error);
+		success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
 		g_free (buf);
 
-		if (success == FALSE)
-		{
-			gnome_vfs_close (handle);
+		if (success == FALSE) {
+			g_output_stream_close (G_OUTPUT_STREAM (stream), NULL, NULL);
 			return FALSE;
 		}
 	}
 
-	gnome_vfs_close (handle);
+	g_output_stream_close (G_OUTPUT_STREAM (stream), NULL, NULL);
 
 	return TRUE;
 }
@@ -251,14 +244,15 @@
 }
 
 TotemPlParserResult
-totem_pl_parser_add_ram (TotemPlParser *parser, const char *url, gpointer data)
+totem_pl_parser_add_ram (TotemPlParser *parser, GFile *file, gpointer data)
 {
 	gboolean retval = TOTEM_PL_PARSER_RESULT_UNHANDLED;
 	char *contents, **lines;
-	int size, i;
+	gsize size;
+	guint i;
 	const char *split_char;
 
-	if (gnome_vfs_read_entire_file (url, &size, &contents) != GNOME_VFS_OK)
+	if (g_file_load_contents (file, NULL, &contents, &size, NULL, NULL) == FALSE)
 		return TOTEM_PL_PARSER_RESULT_ERROR;
 
 	/* figure out whether we're a unix or dos RAM file */
@@ -280,14 +274,19 @@
 		/* Either it's a URI, or it has a proper path ... */
 		if (strstr(lines[i], "://") != NULL
 				|| lines[i][0] == G_DIR_SEPARATOR) {
+			GFile *line_file;
+
+			line_file = g_file_new_for_uri (lines[i]);
 			/* .ram files can contain .smil entries */
-			if (totem_pl_parser_parse_internal (parser, lines[i], NULL) != TOTEM_PL_PARSER_RESULT_SUCCESS) {
+			if (totem_pl_parser_parse_internal (parser, line_file, NULL) != TOTEM_PL_PARSER_RESULT_SUCCESS)
 				totem_pl_parser_parse_ram_url (parser, lines[i]);
-			}
+			g_object_unref (line_file);
 		} else if (strcmp (lines[i], "--stop--") == 0) {
 			/* For Real Media playlists, handle the stop command */
 			break;
 		} else {
+			//FIXME
+#if 0
 			char *base;
 
 			/* Try with a base */
@@ -301,6 +300,7 @@
 				g_free (fullpath);
 			}
 			g_free (base);
+#endif
 		}
 	}
 
@@ -344,6 +344,7 @@
 static char *
 totem_pl_parser_append_path (const char *base, const char *path)
 {
+#if 0
 	GnomeVFSURI *new, *baseuri;
 	char *fullpath;
 
@@ -361,12 +362,16 @@
 
 bail:
 	return g_strdup_printf ("%s/%s", base, path);
+#endif
 }
 
 TotemPlParserResult
-totem_pl_parser_add_m3u (TotemPlParser *parser, const char *url,
-			const char *_base, gpointer data)
+totem_pl_parser_add_m3u (TotemPlParser *parser,
+			 GFile *file,
+			 GFile *_base_file,
+			 gpointer data)
 {
+#if 0
 	TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED;
 	char *contents, **lines;
 	int size, i;
@@ -465,21 +470,22 @@
 	g_strfreev (lines);
 
 	return retval;
+#endif
 }
 
 TotemPlParserResult
-totem_pl_parser_add_ra (TotemPlParser *parser, const char *url,
-			const char *base, gpointer data)
+totem_pl_parser_add_ra (TotemPlParser *parser,
+			GFile *file,
+			GFile *base_file, gpointer data)
 {
 	if (data == NULL || totem_pl_parser_is_uri_list (data, strlen (data)) == NULL) {
-		totem_pl_parser_add_one_url (parser, url, NULL);
+		totem_pl_parser_add_one_file (parser, file, NULL);
 		return TOTEM_PL_PARSER_RESULT_SUCCESS;
 	}
 
-	return totem_pl_parser_add_ram (parser, url, NULL);
+	return totem_pl_parser_add_ram (parser, file, NULL);
 }
 
-
 #endif /* !TOTEM_PL_PARSER_MINI */
 
 #define CHECK_LEN if (i >= len) { return NULL; }

Modified: trunk/plparse/totem-pl-parser-lines.h
==============================================================================
--- trunk/plparse/totem-pl-parser-lines.h	(original)
+++ trunk/plparse/totem-pl-parser-lines.h	Mon Mar 17 14:28:21 2008
@@ -27,6 +27,7 @@
 
 #ifndef TOTEM_PL_PARSER_MINI
 #include "totem-pl-parser.h"
+#include <gio/gio.h>
 #else
 #include "totem-pl-parser-mini.h"
 #endif /* !TOTEM_PL_PARSER_MINI */
@@ -42,15 +43,15 @@
 				    gpointer user_data,
 				    GError **error);
 TotemPlParserResult totem_pl_parser_add_ram (TotemPlParser *parser,
-					     const char *url,
+					     GFile *file,
 					     gpointer data);
 TotemPlParserResult totem_pl_parser_add_m3u (TotemPlParser *parser,
-					     const char *url,
-					     const char *base,
+					     GFile *file,
+					     GFile *base_file,
 					     gpointer data);
 TotemPlParserResult totem_pl_parser_add_ra (TotemPlParser *parser,
-					    const char *url,
-					    const char *base,
+					    GFile *file,
+					    GFile *base_file,
 					    gpointer data);
 #endif /* !TOTEM_PL_PARSER_MINI */
 

Modified: trunk/plparse/totem-pl-parser-media.c
==============================================================================
--- trunk/plparse/totem-pl-parser-media.c	(original)
+++ trunk/plparse/totem-pl-parser-media.c	Mon Mar 17 14:28:21 2008
@@ -44,8 +44,10 @@
 /* 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)
+totem_pl_parser_iso_get_title (GFile *file)
 {
+	//FIXME
+#if 0
 	char *fname;
 	FILE  *file;
 #define BUFFER_SIZE 128
@@ -111,20 +113,25 @@
 	}
 
 	return str;
+#endif
+	return NULL;
 }
 
 TotemPlParserResult
-totem_pl_parser_add_iso (TotemPlParser *parser, const char *url,
-			 const char *base, gpointer data)
+totem_pl_parser_add_iso (TotemPlParser *parser,
+			 GFile *file,
+			 GFile *base_file,
+			 gpointer data)
 {
-	GnomeVFSFileInfo *info;
+	GFileInfo *info;
+//	GnomeVFSFileInfo *info;
 	char *item, *label;
 
 	/* This is a hack, it could be a VCD or DVD */
-	if (g_str_has_prefix (url, "file://") == FALSE)
+	if (g_file_has_uri_scheme (file, "file") == FALSE)
 		return TOTEM_PL_PARSER_RESULT_IGNORED;
 
-	label = totem_pl_parser_iso_get_title (url);
+	label = totem_pl_parser_iso_get_title (file);
 	if (label == NULL) {
 		/* Not an ISO image */
 		return TOTEM_PL_PARSER_RESULT_UNHANDLED;
@@ -134,32 +141,36 @@
 		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);
+	info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SIZE, G_FILE_QUERY_INFO_NONE, NULL, NULL);
+	if (info == NULL) {
+		g_free (label);
 		return TOTEM_PL_PARSER_RESULT_IGNORED;
 	}
 
+#if 0
 	/* Less than 700 megs, and it's a VCD */
-	if (info->size < 700 * 1024 * 1024) {
+	if (g_file_info_get_size (info) < 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);
-
+#endif
+	g_object_unref (info);
+#if 0
 	totem_pl_parser_add_one_url (parser, item, label);
+#endif
 	g_free (label);
-	g_free (item);
+//	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)
+totem_pl_parser_add_cue (TotemPlParser *parser,
+			 GFile *file,
+			 GFile *base_file, gpointer data)
 {
+#if 0
 	char *vcdurl;
 
 	vcdurl = totem_cd_mrl_from_type ("vcd", url);
@@ -167,6 +178,7 @@
 	g_free (vcdurl);
 
 	return TOTEM_PL_PARSER_RESULT_SUCCESS;
+#endif
 }
 
 static int
@@ -206,9 +218,12 @@
 }
 
 TotemPlParserResult
-totem_pl_parser_add_directory (TotemPlParser *parser, const char *url,
-			       const char *base, gpointer data)
+totem_pl_parser_add_directory (TotemPlParser *parser,
+			       GFile *file,
+			       GFile *base_file,
+			       gpointer data)
 {
+#if 0
 	TotemDiscMediaType type;
 	GList *list, *l;
 	GnomeVFSResult res;
@@ -265,12 +280,16 @@
 	g_list_free (list);
 
 	return TOTEM_PL_PARSER_RESULT_SUCCESS;
+#endif
 }
 
 TotemPlParserResult
-totem_pl_parser_add_block (TotemPlParser *parser, const char *url,
-			   const char *base, gpointer data)
+totem_pl_parser_add_block (TotemPlParser *parser,
+			   GFile *file,
+			   GFile *base_file,
+			   gpointer data)
 {
+#if 0
 	TotemDiscMediaType type;
 	char *media_url;
 	GError *err = NULL;
@@ -288,6 +307,7 @@
 	totem_pl_parser_add_one_url (parser, media_url, NULL);
 	g_free (media_url);
 	return TOTEM_PL_PARSER_RESULT_SUCCESS;
+#endif
 }
 
 #endif /* !TOTEM_PL_PARSER_MINI */

Modified: trunk/plparse/totem-pl-parser-media.h
==============================================================================
--- trunk/plparse/totem-pl-parser-media.h	(original)
+++ trunk/plparse/totem-pl-parser-media.h	Mon Mar 17 14:28:21 2008
@@ -27,24 +27,25 @@
 
 #ifndef TOTEM_PL_PARSER_MINI
 #include "totem-pl-parser.h"
+#include <gio/gio.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,
+					     GFile *file,
+					     GFile *base_file,
 					     gpointer data);
 TotemPlParserResult totem_pl_parser_add_cue (TotemPlParser *parser,
-					     const char *url,
-					     const char *base,
+					     GFile *file,
+					     GFile *base_file,
 					     gpointer data);
 TotemPlParserResult totem_pl_parser_add_directory (TotemPlParser *parser,
-						   const char *url,
-						   const char *base,
+						   GFile *file,
+						   GFile *base_file,
 						   gpointer data);
 TotemPlParserResult totem_pl_parser_add_block (TotemPlParser *parser,
-					       const char *url,
-					       const char *base,
+					       GFile *file,
+					       GFile *base_file,
 					       gpointer data);
 #endif /* !TOTEM_PL_PARSER_MINI */
 

Modified: trunk/plparse/totem-pl-parser-misc.c
==============================================================================
--- trunk/plparse/totem-pl-parser-misc.c	(original)
+++ trunk/plparse/totem-pl-parser-misc.c	Mon Mar 17 14:28:21 2008
@@ -42,9 +42,12 @@
 
 #ifndef TOTEM_PL_PARSER_MINI
 TotemPlParserResult
-totem_pl_parser_add_gvp (TotemPlParser *parser, const char *url,
-			 const char *base, gpointer data)
+totem_pl_parser_add_gvp (TotemPlParser *parser,
+			 GFile *url,
+			 GFile *base_file,
+			 gpointer data)
 {
+#if 0
 	TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED;
 	char *contents, **lines, *title, *link, *version;
 	int size;
@@ -86,12 +89,16 @@
 	g_strfreev (lines);
 
 	return retval;
+#endif
 }
 
 TotemPlParserResult
-totem_pl_parser_add_desktop (TotemPlParser *parser, const char *url,
-			     const char *base, gpointer data)
+totem_pl_parser_add_desktop (TotemPlParser *parser,
+			     GFile *file,
+			     GFile *base_file,
+			     gpointer data)
 {
+#if 0
 	char *contents, **lines;
 	const char *path, *display_name, *type;
 	int size;
@@ -132,6 +139,7 @@
 	g_strfreev (lines);
 
 	return res;
+#endif
 }
 
 #endif /* !TOTEM_PL_PARSER_MINI */

Modified: trunk/plparse/totem-pl-parser-misc.h
==============================================================================
--- trunk/plparse/totem-pl-parser-misc.h	(original)
+++ trunk/plparse/totem-pl-parser-misc.h	Mon Mar 17 14:28:21 2008
@@ -27,18 +27,19 @@
 
 #ifndef TOTEM_PL_PARSER_MINI
 #include "totem-pl-parser.h"
+#include <gio/gio.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,
+					     GFile *file,
+					     GFile *base_file,
 					     gpointer data);
 TotemPlParserResult totem_pl_parser_add_desktop (TotemPlParser *parser,
-						 const char *url,
-						 const char *base,
+						 GFile *file,
+						 GFile *base_file,
 						 gpointer data);
 #endif /* !TOTEM_PL_PARSER_MINI */
 

Modified: trunk/plparse/totem-pl-parser-pla.c
==============================================================================
--- trunk/plparse/totem-pl-parser-pla.c	(original)
+++ trunk/plparse/totem-pl-parser-pla.c	Mon Mar 17 14:28:21 2008
@@ -89,7 +89,7 @@
 	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"));
+		DEBUG(NULL, g_print ("Couldn't write header block"));
 		gnome_vfs_close (handle);
 		g_free (buffer);
 		return FALSE;
@@ -118,7 +118,7 @@
 		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));
+			DEBUG(NULL, g_print ("Couldn't convert URI '%s' to a filename: %s\n", uri, (*error)->message));
 			g_free (uri);
 			ret = FALSE;
 			break;
@@ -132,7 +132,7 @@
 		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));
+			DEBUG(NULL, g_print ("Couldn't convert filename '%s' to UTF-16BE\n", path));
 			g_free (path);
 			ret = FALSE;
 			break;
@@ -147,7 +147,7 @@
 
 		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));
+			DEBUG(NULL, g_print ("Couldn't write entry %d to the file\n", i));
 			ret = FALSE;
 			break;
 		}
@@ -159,9 +159,12 @@
 }
 
 TotemPlParserResult
-totem_pl_parser_add_pla (TotemPlParser *parser, const char *url,
-			 const char *base, gpointer data)
+totem_pl_parser_add_pla (TotemPlParser *parser,
+			 GFile *file,
+			 GFile *base_file,
+			 gpointer data)
 {
+#if 0
 	TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED;
 	char *contents, *title;
 	int size, offset, max_entries, entry;
@@ -243,6 +246,7 @@
 	g_free (contents);
 
 	return TOTEM_PL_PARSER_RESULT_SUCCESS;
+#endif
 }
 
 #endif /* !TOTEM_PL_PARSER_MINI */

Modified: trunk/plparse/totem-pl-parser-pla.h
==============================================================================
--- trunk/plparse/totem-pl-parser-pla.h	(original)
+++ trunk/plparse/totem-pl-parser-pla.h	Mon Mar 17 14:28:21 2008
@@ -25,9 +25,10 @@
 
 G_BEGIN_DECLS
 
-#ifdef TOTEM_PL_PARSER_MINI
-#include "totem-pl-parser-mini.h"
-#endif /* TOTEM_PL_PARSER_MINI */
+#ifndef TOTEM_PL_PARSER_MINI
+#include "totem-pl-parser.h"
+#include <gio/gio.h>
+#endif /* !TOTEM_PL_PARSER_MINI */
 
 #ifndef TOTEM_PL_PARSER_MINI
 gboolean totem_pl_parser_write_pla				(TotemPlParser *parser,
@@ -38,8 +39,8 @@
 								 gpointer user_data,
 								 GError **error);
 TotemPlParserResult totem_pl_parser_add_pla			(TotemPlParser *parser,
-								 const char *url,
-								 const char *base,
+								 GFile *file,
+								 GFile *base_file,
 								 gpointer data);
 #endif /* !TOTEM_PL_PARSER_MINI */
 

Modified: trunk/plparse/totem-pl-parser-pls.c
==============================================================================
--- trunk/plparse/totem-pl-parser-pls.c	(original)
+++ trunk/plparse/totem-pl-parser-pls.c	Mon Mar 17 14:28:21 2008
@@ -148,9 +148,12 @@
 }
 
 TotemPlParserResult
-totem_pl_parser_add_pls_with_contents (TotemPlParser *parser, const char *url,
-				       const char *base, const char *contents)
+totem_pl_parser_add_pls_with_contents (TotemPlParser *parser,
+				       GFile *file,
+				       GFile *base_file,
+				       const char *contents)
 {
+#if 0
 	TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED;
 	char **lines;
 	int i, num_entries;
@@ -299,12 +302,16 @@
 	g_strfreev (lines);
 
 	return retval;
+#endif
 }
 
 TotemPlParserResult
-totem_pl_parser_add_pls (TotemPlParser *parser, const char *url,
-			 const char *base, gpointer data)
+totem_pl_parser_add_pls (TotemPlParser *parser,
+			 GFile *file,
+			 GFile *base_file,
+			 gpointer data)
 {
+#if 0
 	TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED;
 	char *contents;
 	int size;
@@ -321,6 +328,7 @@
 	g_free (contents);
 
 	return retval;
+#endif
 }
 
 #endif /* !TOTEM_PL_PARSER_MINI */

Modified: trunk/plparse/totem-pl-parser-pls.h
==============================================================================
--- trunk/plparse/totem-pl-parser-pls.h	(original)
+++ trunk/plparse/totem-pl-parser-pls.h	Mon Mar 17 14:28:21 2008
@@ -25,9 +25,10 @@
 
 G_BEGIN_DECLS
 
-#ifdef TOTEM_PL_PARSER_MINI
-#include "totem-pl-parser-mini.h"
-#endif /* TOTEM_PL_PARSER_MINI */
+#ifndef TOTEM_PL_PARSER_MINI
+#include "totem-pl-parser.h"
+#include <gio/gio.h>
+#endif /* !TOTEM_PL_PARSER_MINI */
 
 #ifndef TOTEM_PL_PARSER_MINI
 gboolean totem_pl_parser_write_pls				(TotemPlParser *parser,
@@ -38,12 +39,12 @@
 								 gpointer user_data,
 								 GError **error);
 TotemPlParserResult totem_pl_parser_add_pls_with_contents	(TotemPlParser *parser,
-								 const char *url,
-								 const char *base,
+								 GFile *file,
+								 GFile *base_file,
 								 const char *contents);
 TotemPlParserResult totem_pl_parser_add_pls			(TotemPlParser *parser,
-								 const char *url,
-								 const char *base,
+								 GFile *file,
+								 GFile *base_file,
 								 gpointer data);
 #endif /* !TOTEM_PL_PARSER_MINI */
 

Modified: trunk/plparse/totem-pl-parser-podcast.c
==============================================================================
--- trunk/plparse/totem-pl-parser-podcast.c	(original)
+++ trunk/plparse/totem-pl-parser-podcast.c	Mon Mar 17 14:28:21 2008
@@ -235,10 +235,11 @@
 
 TotemPlParserResult
 totem_pl_parser_add_rss (TotemPlParser *parser,
-			 const char *url,
-			 const char *base,
+			 GFile *file,
+			 GFile *base_file,
 			 gpointer data)
 {
+#if 0
 	xml_node_t* doc, *channel;
 	char *contents;
 	int size;
@@ -269,17 +270,18 @@
 
 	g_free (contents);
 	xml_parser_free_tree (doc);
-
+#endif
 	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,
+			  GFile *file,
+			  GFile *base_file,
 			  gpointer data)
 {
+#if 0
 	TotemPlParserResult ret;
 	char *new_url;
 
@@ -289,6 +291,7 @@
 	g_free (new_url);
 
 	return ret;
+#endif
 }
 
 /* Atom docs:
@@ -423,10 +426,11 @@
 
 TotemPlParserResult
 totem_pl_parser_add_atom (TotemPlParser *parser,
-			  const char *url,
-			  const char *base,
+			  GFile *file,
+			  GFile *base_file,
 			  gpointer data)
 {
+#if 0
 	xml_node_t* doc;
 	char *contents;
 	int size;
@@ -451,14 +455,14 @@
 
 	g_free (contents);
 	xml_parser_free_tree (doc);
-
+#endif
 	return TOTEM_PL_PARSER_RESULT_SUCCESS;
 }
 
 TotemPlParserResult
 totem_pl_parser_add_xml_feed (TotemPlParser *parser,
-			      const char *url,
-			      const char *base,
+			      GFile *file,
+			      GFile *base_file,
 			      gpointer data)
 {
 	guint len;
@@ -469,11 +473,11 @@
 	len = strlen (data);
 
 	if (totem_pl_parser_is_rss (data, len) != FALSE)
-		return totem_pl_parser_add_rss (parser, url, base, data);
+		return totem_pl_parser_add_rss (parser, file, base_file, data);
 	if (totem_pl_parser_is_atom (data, len) != FALSE)
-		return totem_pl_parser_add_atom (parser, url, base, data);
+		return totem_pl_parser_add_atom (parser, file, base_file, data);
 	if (totem_pl_parser_is_opml (data, len) != FALSE)
-		return totem_pl_parser_add_opml (parser, url, base, data);
+		return totem_pl_parser_add_opml (parser, file, base_file, data);
 
 	return TOTEM_PL_PARSER_RESULT_UNHANDLED;
 }
@@ -642,10 +646,11 @@
 
 TotemPlParserResult
 totem_pl_parser_add_itms (TotemPlParser *parser,
-			  const char *url,
-			  const char *base,
+			  GFile *file,
+			  GFile *base_file,
 			  gpointer data)
 {
+#if 0
 	char *contents, *uncompressed, *itms_url, *feed_url;
 	TotemPlParserResult ret;
 	int size;
@@ -689,14 +694,16 @@
 	g_free (feed_url);
 
 	return ret;
+#endif
 }
 
 gboolean
-totem_pl_parser_is_itms_feed (const char *url)
+totem_pl_parser_is_itms_feed (GFile *file)
 {
+#if 0
 	g_return_val_if_fail (url != NULL, FALSE);
 
-	if (g_str_has_prefix (url, "itms:") != FALSE
+	if (g_file_has_uri_scheme (file, "itms:") != FALSE
 	    && strstr (url, "phobos.apple.com") != NULL
 	    && strstr (url, "viewPodcast") != NULL)
 		return TRUE;
@@ -705,7 +712,7 @@
 		return TRUE;
 	if (strstr (url, "itunes.com/podcast") != NULL)
 		return TRUE;
-
+#endif
 	return FALSE;
 }
 
@@ -766,10 +773,11 @@
 
 TotemPlParserResult
 totem_pl_parser_add_opml (TotemPlParser *parser,
-			  const char *url,
-			  const char *base,
+			  GFile *file,
+			  GFile *base_file,
 			  gpointer data)
 {
+#if 0
 	xml_node_t* doc;
 	char *contents;
 	int size;
@@ -794,7 +802,7 @@
 
 	g_free (contents);
 	xml_parser_free_tree (doc);
-
+#endif
 	return TOTEM_PL_PARSER_RESULT_SUCCESS;
 }
 

Modified: trunk/plparse/totem-pl-parser-podcast.h
==============================================================================
--- trunk/plparse/totem-pl-parser-podcast.h	(original)
+++ trunk/plparse/totem-pl-parser-podcast.h	Mon Mar 17 14:28:21 2008
@@ -26,6 +26,7 @@
 
 #ifndef TOTEM_PL_PARSER_MINI
 #include "totem-pl-parser.h"
+#include <gio/gio.h>
 #else
 #include "totem-pl-parser-mini.h"
 #endif /* !TOTEM_PL_PARSER_MINI */
@@ -36,31 +37,31 @@
 const char * 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);
+gboolean totem_pl_parser_is_itms_feed (GFile *file);
 
 TotemPlParserResult totem_pl_parser_add_xml_feed (TotemPlParser *parser,
-						  const char *url,
-						  const char *base,
+						  GFile *file,
+						  GFile *base_file,
 						  gpointer data);
 TotemPlParserResult totem_pl_parser_add_atom (TotemPlParser *parser,
-					      const char *url,
-					      const char *base,
+					      GFile *file,
+					      GFile *base_file,
 					      gpointer data);
 TotemPlParserResult totem_pl_parser_add_rss (TotemPlParser *parser,
-					     const char *url,
-					     const char *base,
+					     GFile *file,
+					     GFile *base_file,
 					     gpointer data);
 TotemPlParserResult totem_pl_parser_add_itpc (TotemPlParser *parser,
-					      const char *url,
-					      const char *base,
+					      GFile *file,
+					      GFile *base_file,
 					      gpointer data);
 TotemPlParserResult totem_pl_parser_add_itms (TotemPlParser *parser,
-					      const char *url,
-					      const char *base,
+					      GFile *file,
+					      GFile *base_file,
 					      gpointer data);
 TotemPlParserResult totem_pl_parser_add_opml (TotemPlParser *parser,
-					      const char *url,
-					      const char *base,
+					      GFile *file,
+					      GFile *base_file,
 					      gpointer data);
 
 #endif /* !TOTEM_PL_PARSER_MINI */

Modified: trunk/plparse/totem-pl-parser-private.h
==============================================================================
--- trunk/plparse/totem-pl-parser-private.h	(original)
+++ trunk/plparse/totem-pl-parser-private.h	Mon Mar 17 14:28:21 2008
@@ -29,6 +29,8 @@
 #ifndef TOTEM_PL_PARSER_MINI
 #include "totem-pl-parser.h"
 #include <glib-object.h>
+#include <gio/gio.h>
+#include <gio/gio.h>
 #else
 #include "totem-pl-parser-mini.h"
 #endif /* !TOTEM_PL_PARSER_MINI */
@@ -46,7 +48,26 @@
 #define ASX_MIME_TYPE "audio/x-ms-asx"
 #define ASF_REF_MIME_TYPE "video/x-ms-asf"
 
+#define TOTEM_PL_PARSER_FIELD_FILE		"gfile-object"
+
+#ifndef TOTEM_PL_PARSER_MINI
+#define DEBUG(file, x) {					\
+	if (parser->priv->debug) {				\
+		if (file != NULL) {				\
+			char *uri;				\
+								\
+			uri = g_file_get_uri (file);		\
+			x;					\
+			g_free (uri);				\
+		} else {					\
+			const char *uri = "empty";		\
+			x;					\
+		}						\
+	}							\
+}
+#else
 #define DEBUG(x) { if (parser->priv->debug) x; }
+#endif
 
 struct TotemPlParserPrivate
 {
@@ -61,14 +82,13 @@
 	guint disable_unsafe : 1;
 };
 
+#ifndef TOTEM_PL_PARSER_MINI
 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
+char *totem_pl_parser_base_url			(GFile *file);
 void totem_pl_parser_playlist_end		(TotemPlParser *parser,
 						 const char *playlist_title);
 int totem_pl_parser_num_entries			(TotemPlParser *parser,
@@ -76,23 +96,26 @@
 						 TotemPlParserIterFunc func,
 						 gpointer user_data);
 gboolean totem_pl_parser_scheme_is_ignored	(TotemPlParser *parser,
-						 const char *url);
+						 GFile *file);
 gboolean totem_pl_parser_line_is_empty		(const char *line);
-gboolean totem_pl_parser_write_string		(GnomeVFSHandle *handle,
+gboolean totem_pl_parser_write_string		(GOutputStream *stream,
 						 const char *buf,
 						 GError **error);
-gboolean totem_pl_parser_write_buffer		(GnomeVFSHandle *handle,
+gboolean totem_pl_parser_write_buffer		(GOutputStream *stream,
 						 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);
+						    GFile *file,
+						    GFile *base_file);
 void totem_pl_parser_add_one_url		(TotemPlParser *parser,
 						 const char *url,
 						 const char *title);
+void totem_pl_parser_add_one_file		(TotemPlParser *parser,
+						 GFile *file,
+						 const char *title);
 void totem_pl_parser_add_url			(TotemPlParser *parser,
 						 const char *first_property_name,
 						 ...);

Modified: trunk/plparse/totem-pl-parser-qt.c
==============================================================================
--- trunk/plparse/totem-pl-parser-qt.c	(original)
+++ trunk/plparse/totem-pl-parser-qt.c	Mon Mar 17 14:28:21 2008
@@ -69,10 +69,11 @@
 
 static TotemPlParserResult
 totem_pl_parser_add_quicktime_rtsptext (TotemPlParser *parser,
-					const char *url,
-					const char *base,
+					GFile *file,
+					GFile *base_file,
 					gpointer data)
 {
+#if 0
 	char *contents = NULL;
 	gboolean dos_mode = FALSE;
 	char *volume, *autoplay, *rtspurl;
@@ -108,14 +109,16 @@
 	g_free (volume);
 	g_free (autoplay);
 	g_strfreev (lines);
-
+#endif
 	return TOTEM_PL_PARSER_RESULT_SUCCESS;
 }
 
 static TotemPlParserResult
-totem_pl_parser_add_quicktime_metalink (TotemPlParser *parser, const char *url,
-					const char *base, gpointer data)
+totem_pl_parser_add_quicktime_metalink (TotemPlParser *parser,
+					GFile *file,
+					GFile *base_file, gpointer data)
 {
+#if 0
 	xml_node_t *doc, *node;
 	int size;
 	char *contents;
@@ -193,20 +196,23 @@
 				 TOTEM_PL_PARSER_FIELD_AUTOPLAY, autoplay,
 				 NULL);
 	xml_parser_free_tree (doc);
-
+#endif
 	return TOTEM_PL_PARSER_RESULT_SUCCESS;
 }
 
 TotemPlParserResult
-totem_pl_parser_add_quicktime (TotemPlParser *parser, const char *url,
-			       const char *base, gpointer data)
+totem_pl_parser_add_quicktime (TotemPlParser *parser,
+			       GFile *file,
+			       GFile *base_file,
+			       gpointer data)
 {
+#if 0
 	if (data == NULL || totem_pl_parser_is_quicktime (data, strlen (data)) == NULL) {
 		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
+	return totem_pl_parser_add_quicktime_metalink (parser, file, base_file, data);
 }
 
 #endif /* !TOTEM_PL_PARSER_MINI */

Modified: trunk/plparse/totem-pl-parser-qt.h
==============================================================================
--- trunk/plparse/totem-pl-parser-qt.h	(original)
+++ trunk/plparse/totem-pl-parser-qt.h	Mon Mar 17 14:28:21 2008
@@ -27,6 +27,7 @@
 
 #ifndef TOTEM_PL_PARSER_MINI
 #include "totem-pl-parser.h"
+#include <gio/gio.h>
 #else
 #include "totem-pl-parser-mini.h"
 #endif /* !TOTEM_PL_PARSER_MINI */
@@ -35,8 +36,8 @@
 
 #ifndef TOTEM_PL_PARSER_MINI
 TotemPlParserResult totem_pl_parser_add_quicktime (TotemPlParser *parser,
-						   const char *url,
-						   const char *base,
+						   GFile *file,
+						   GFile *base_file,
 						   gpointer data);
 #endif /* !TOTEM_PL_PARSER_MINI */
 

Modified: trunk/plparse/totem-pl-parser-smil.c
==============================================================================
--- trunk/plparse/totem-pl-parser-smil.c	(original)
+++ trunk/plparse/totem-pl-parser-smil.c	Mon Mar 17 14:28:21 2008
@@ -25,7 +25,7 @@
 #ifndef TOTEM_PL_PARSER_MINI
 #include <glib.h>
 #include <gtk/gtk.h>
-#include <libgnomevfs/gnome-vfs.h>
+#include <gio/gio.h>
 #include "xmlparser.h"
 #include "totem-pl-parser.h"
 #include "totemplparser-marshal.h"
@@ -147,8 +147,8 @@
 }
 
 static TotemPlParserResult
-totem_pl_parser_add_smil_with_doc (TotemPlParser *parser, const char *url,
-				   const char *_base, xml_node_t *doc)
+totem_pl_parser_add_smil_with_doc (TotemPlParser *parser, GFile *file,
+				   GFile *_base_file, xml_node_t *doc)
 {
 	TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED;
 	char *base;
@@ -159,7 +159,7 @@
 		return TOTEM_PL_PARSER_RESULT_ERROR;
 	}
 
-	base = totem_pl_parser_base_url (url);
+	base = totem_pl_parser_base_url (file);
 
 	retval = parse_smil_entries (parser, base, doc);
 
@@ -169,25 +169,29 @@
 }
 
 TotemPlParserResult
-totem_pl_parser_add_smil (TotemPlParser *parser, const char *url,
-			  const char *_base, gpointer data)
+totem_pl_parser_add_smil (TotemPlParser *parser,
+			  GFile *file,
+			  GFile *base_file, gpointer data)
 {
 	char *contents;
-	int size;
+	gsize size;
 	TotemPlParserResult retval;
 
-	if (gnome_vfs_read_entire_file (url, &size, &contents) != GNOME_VFS_OK)
+	if (g_file_load_contents (file, NULL, &contents, &size, NULL, NULL) == FALSE)
 		return TOTEM_PL_PARSER_RESULT_ERROR;
 
-	retval = totem_pl_parser_add_smil_with_data (parser, url,
-						     _base, contents, size);
+	retval = totem_pl_parser_add_smil_with_data (parser, file,
+						     base_file, 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)
+totem_pl_parser_add_smil_with_data (TotemPlParser *parser,
+				    GFile *file,
+				    GFile *base_file,
+				    const char *contents, int size)
 {
 	xml_node_t* doc;
 	TotemPlParserResult retval;
@@ -196,7 +200,7 @@
 	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);
+	retval = totem_pl_parser_add_smil_with_doc (parser, file, base_file, doc);
 	xml_parser_free_tree (doc);
 
 	return retval;

Modified: trunk/plparse/totem-pl-parser-smil.h
==============================================================================
--- trunk/plparse/totem-pl-parser-smil.h	(original)
+++ trunk/plparse/totem-pl-parser-smil.h	Mon Mar 17 14:28:21 2008
@@ -27,18 +27,19 @@
 
 #ifndef TOTEM_PL_PARSER_MINI
 #include "totem-pl-parser.h"
+#include <gio/gio.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,
+					      GFile *file,
+					      GFile *base_file,
 					      gpointer data);
 TotemPlParserResult totem_pl_parser_add_smil_with_data (TotemPlParser *parser,
-							const char *url,
-							const char *base,
+							GFile *file,
+							GFile *base_file,
 							const char *contents,
 							int size);
 #endif /* !TOTEM_PL_PARSER_MINI */

Modified: trunk/plparse/totem-pl-parser-wm.c
==============================================================================
--- trunk/plparse/totem-pl-parser-wm.c	(original)
+++ trunk/plparse/totem-pl-parser-wm.c	Mon Mar 17 14:28:21 2008
@@ -87,9 +87,11 @@
 
 static TotemPlParserResult
 totem_pl_parser_add_asf_reference_parser (TotemPlParser *parser,
-					  const char *url, const char *base,
+					  GFile *file,
+					  GFile *base_file,
 					  gpointer data)
 {
+#if 0
 	char *contents, **lines, *ref, *split_char;
 	int size;
 
@@ -123,15 +125,17 @@
 	 * supposed to be a fallback */
 
 	g_strfreev (lines);
-
+#endif
 	return TOTEM_PL_PARSER_RESULT_SUCCESS;
 }
 
 static TotemPlParserResult
 totem_pl_parser_add_asf_parser (TotemPlParser *parser,
-				const char *url, const char *base,
+				GFile *file,
+				GFile *base_file,
 				gpointer data)
 {
+#if 0
 	TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED;
 	char *contents, *ref;
 	int size;
@@ -161,7 +165,9 @@
 	}
 
 	g_free (contents);
+
 	return retval;
+#endif
 }
 
 static gboolean
@@ -264,7 +270,8 @@
 	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);
+	//FIXME
+	//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,
@@ -372,10 +379,11 @@
 
 TotemPlParserResult
 totem_pl_parser_add_asx (TotemPlParser *parser,
-			 const char *url,
-			 const char *base,
+			 GFile *file,
+			 GFile *base_file,
 			 gpointer data)
 {
+#if 0
 	xml_node_t* doc;
 	char *_base, *contents;
 	int size;
@@ -415,12 +423,16 @@
 	xml_parser_free_tree (doc);
 
 	return retval;
+#endif
 }
 
 TotemPlParserResult
-totem_pl_parser_add_asf (TotemPlParser *parser, const char *url,
-			 const char *base, gpointer data)
+totem_pl_parser_add_asf (TotemPlParser *parser,
+			 GFile *file,
+			 GFile *base_file,
+			 gpointer data)
 {
+#if 0
 	if (data == NULL) {
 		totem_pl_parser_add_one_url (parser, url, NULL);
 		return TOTEM_PL_PARSER_RESULT_SUCCESS;
@@ -430,8 +442,8 @@
 		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
+	return totem_pl_parser_add_asf_parser (parser, file, base_file, data);
 }
 
 #endif /* !TOTEM_PL_PARSER_MINI */

Modified: trunk/plparse/totem-pl-parser-wm.h
==============================================================================
--- trunk/plparse/totem-pl-parser-wm.h	(original)
+++ trunk/plparse/totem-pl-parser-wm.h	Mon Mar 17 14:28:21 2008
@@ -27,6 +27,7 @@
 
 #ifndef TOTEM_PL_PARSER_MINI
 #include "totem-pl-parser.h"
+#include <gio/gio.h>
 #else
 #include "totem-pl-parser-mini.h"
 #endif /* !TOTEM_PL_PARSER_MINI */
@@ -36,12 +37,12 @@
 
 #ifndef TOTEM_PL_PARSER_MINI
 TotemPlParserResult totem_pl_parser_add_asf (TotemPlParser *parser,
-					     const char *url,
-					     const char *base,
+					     GFile *file,
+					     GFile *base_file,
 					     gpointer data);
 TotemPlParserResult totem_pl_parser_add_asx (TotemPlParser *parser,
-					     const char *url,
-					     const char *base,
+					     GFile *file,
+					     GFile *base_file,
 					     gpointer data);
 #endif /* !TOTEM_PL_PARSER_MINI */
 

Modified: trunk/plparse/totem-pl-parser-xspf.c
==============================================================================
--- trunk/plparse/totem-pl-parser-xspf.c	(original)
+++ trunk/plparse/totem-pl-parser-xspf.c	Mon Mar 17 14:28:21 2008
@@ -306,9 +306,12 @@
 }
 
 TotemPlParserResult
-totem_pl_parser_add_xspf (TotemPlParser *parser, const char *url,
-			  const char *_base, gpointer data)
+totem_pl_parser_add_xspf (TotemPlParser *parser,
+			  GFile *file,
+			  GFile *_base_file,
+			  gpointer data)
 {
+#if 0
 	xmlDocPtr doc;
 	xmlNodePtr node;
 	char *base;
@@ -335,6 +338,7 @@
 	g_free (base);
 	xmlFreeDoc(doc);
 	return retval;
+#endif
 }
 #endif /* !TOTEM_PL_PARSER_MINI */
 

Modified: trunk/plparse/totem-pl-parser-xspf.h
==============================================================================
--- trunk/plparse/totem-pl-parser-xspf.h	(original)
+++ trunk/plparse/totem-pl-parser-xspf.h	Mon Mar 17 14:28:21 2008
@@ -25,9 +25,10 @@
 
 G_BEGIN_DECLS
 
-#ifdef TOTEM_PL_PARSER_MINI
-#include "totem-pl-parser-mini.h"
-#endif /* TOTEM_PL_PARSER_MINI */
+#ifndef TOTEM_PL_PARSER_MINI
+#include "totem-pl-parser.h"
+#include <gio/gio.h>
+#endif /* !TOTEM_PL_PARSER_MINI */
 
 #ifndef TOTEM_PL_PARSER_MINI
 gboolean totem_pl_parser_write_xspf (TotemPlParser *parser,
@@ -38,8 +39,8 @@
 				     gpointer user_data,
 				     GError **error);
 TotemPlParserResult totem_pl_parser_add_xspf (TotemPlParser *parser,
-					      const char *url,
-					      const char *base,
+					      GFile *file,
+					      GFile *base_file,
 					      gpointer data);
 #endif /* !TOTEM_PL_PARSER_MINI */
 

Modified: trunk/plparse/totem-pl-parser.c
==============================================================================
--- trunk/plparse/totem-pl-parser.c	(original)
+++ trunk/plparse/totem-pl-parser.c	Mon Mar 17 14:28:21 2008
@@ -98,14 +98,11 @@
 #include <string.h>
 #include <glib.h>
 #include <glib/gi18n-lib.h>
-#include <libgnomevfs/gnome-vfs-mime-utils.h>
+#include <gio/gio.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 <camel/camel-mime-utils.h>
 
 #include "totem-pl-parser.h"
@@ -134,7 +131,7 @@
 typedef const char * (*PlaylistIdenCallback) (const char *data, gsize len);
 
 #ifndef TOTEM_PL_PARSER_MINI
-typedef TotemPlParserResult (*PlaylistCallback) (TotemPlParser *parser, const char *url, const char *base, gpointer data);
+typedef TotemPlParserResult (*PlaylistCallback) (TotemPlParser *parser, GFile *url, GFile *base_file, gpointer data);
 #endif
 
 typedef struct {
@@ -206,7 +203,7 @@
 	PLAYLIST_TYPE2 ("application/xml", totem_pl_parser_add_xml_feed, totem_pl_parser_is_xml_feed),
 };
 
-static char *my_gnome_vfs_get_mime_type_for_data (gconstpointer data, int len);
+static char *totem_pl_parser_mime_type_from_data (gconstpointer data, int len);
 
 #ifndef TOTEM_PL_PARSER_MINI
 
@@ -494,6 +491,10 @@
 				     "String representing the location of an image for a playlist", NULL,
 				     G_PARAM_READABLE & G_PARAM_WRITABLE);
 	g_param_spec_pool_insert (totem_pl_parser_pspec_pool, pspec, TOTEM_TYPE_PL_PARSER);
+	pspec = g_param_spec_object ("gfile-object", "gfile-object",
+				     "Object representing the GFile for an entry", G_TYPE_FILE,
+				     G_PARAM_READABLE & G_PARAM_WRITABLE);
+	g_param_spec_pool_insert (totem_pl_parser_pspec_pool, pspec, TOTEM_TYPE_PL_PARSER);
 	pspec = g_param_spec_string ("download-url", "download-url",
 				     "String representing the location of a download URL", NULL,
 				     G_PARAM_READABLE & G_PARAM_WRITABLE);
@@ -510,8 +511,7 @@
 	GList *list, *node;
 
 	list = g_param_spec_pool_list_owned (totem_pl_parser_pspec_pool, G_OBJECT_CLASS_TYPE (klass));
-	for (node = list; node; node = node->next)
-	{
+	for (node = list; node; node = node->next) {
 		GParamSpec *pspec = node->data;
 
 		g_param_spec_pool_remove (totem_pl_parser_pspec_pool, pspec);
@@ -628,88 +628,63 @@
 }
 
 static char *
-my_gnome_vfs_get_mime_type_with_data (const char *uri, gpointer *data, TotemPlParser *parser)
+my_g_file_info_get_mime_type_with_data (GFile *file, gpointer *data, TotemPlParser *parser)
 {
-	GnomeVFSResult result;
-	GnomeVFSHandle *handle;
 	char *buffer;
-	GnomeVFSFileSize total_bytes_read;
-	GnomeVFSFileSize bytes_read;
+	gssize bytes_read;
+	GFileInputStream *stream;
+	GError *error = NULL;
 
 	*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);
+	if (g_file_has_uri_scheme (file, "file") != FALSE) {
+		GFileInfo *info;
+		info = g_file_query_info (file, G_FILE_ATTRIBUTE_UNIX_DEVICE,
+					  G_FILE_QUERY_INFO_NONE, NULL, NULL);
+		if (info != NULL && g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_UNIX_DEVICE)) {
+			g_object_unref (info);
+			return g_strdup (BLOCK_DEVICE_TYPE);
 		}
+		g_object_unref (info);
 	}
 
 	/* 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)
+	stream = g_file_read (file, NULL, &error);
+	if (stream == NULL) {
+		if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_IS_DIRECTORY) != FALSE) {
+			g_error_free (error);
 			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)));
+		}
+		DEBUG(file, g_print ("URL '%s' couldn't be opened in _get_mime_type_with_data: '%s'\n", uri, error->message));
+		g_error_free (error);
 		return NULL;
 	}
-	DEBUG(g_print ("URL '%s' was opened successfully in _get_mime_type_with_data:\n", uri));
+	DEBUG(file, 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)));
+	buffer = g_malloc (MIME_READ_CHUNK_SIZE);
+	bytes_read = g_input_stream_read (G_INPUT_STREAM (stream), buffer, MIME_READ_CHUNK_SIZE, NULL, &error);
+	g_input_stream_close (G_INPUT_STREAM (stream), NULL, NULL);
+	if (bytes_read == -1) {
 		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));
+	if (bytes_read == 0) {
+		g_free (buffer);
+		DEBUG(file, 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';
+	buffer = g_realloc (buffer, bytes_read + 1);
+	buffer[bytes_read] = '\0';
 	*data = buffer;
 
-	return my_gnome_vfs_get_mime_type_for_data (*data, total_bytes_read);
+	return totem_pl_parser_mime_type_from_data (*data, bytes_read);
 }
 
 /**
@@ -721,28 +696,16 @@
  * Return value: a newly-allocated string containing @url's parent URI, or %NULL
  **/
 char *
-totem_pl_parser_base_url (const char *url)
+totem_pl_parser_base_url (GFile *file)
 {
-	/* Yay, let's reconstruct the base by hand */
-	GnomeVFSURI *uri, *parent;
-	char *base;
+	GFile *parent;
+	char *ret;
 
-	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);
+	parent = g_file_get_parent (file);
+	ret = g_file_get_uri (parent);
+	g_object_unref (file);
 
-	gnome_vfs_uri_unref (uri);
-	if (parent != uri) {
-		gnome_vfs_uri_unref (parent);
-	}
-
-	return base;
+	return ret;
 }
 
 /**
@@ -771,7 +734,7 @@
 
 /**
  * totem_pl_parser_write_string:
- * @handle: a #GnomeVFSHandle to an open file
+ * @handle: a #GFileOutputStream to an open file
  * @buf: the string buffer to write out
  * @error: return location for a #GError, or %NULL
  *
@@ -780,12 +743,12 @@
  * Return value: %TRUE on success
  **/
 gboolean
-totem_pl_parser_write_string (GnomeVFSHandle *handle, const char *buf, GError **error)
+totem_pl_parser_write_string (GOutputStream *stream, const char *buf, GError **error)
 {
 	guint len;
 
 	len = strlen (buf);
-	return totem_pl_parser_write_buffer (handle, buf, len, error);
+	return totem_pl_parser_write_buffer (stream, buf, len, error);
 }
 
 /**
@@ -800,19 +763,15 @@
  * Return value: %TRUE on success
  **/
 gboolean
-totem_pl_parser_write_buffer (GnomeVFSHandle *handle, const char *buf, guint len, GError **error)
+totem_pl_parser_write_buffer (GOutputStream *stream, const char *buf, guint len, GError **error)
 {
-	GnomeVFSResult res;
-	GnomeVFSFileSize written;
+	gsize bytes_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);
+	if (g_output_stream_write_all (stream,
+				       buf, len,
+				       &bytes_written,
+				       NULL, error) == FALSE) {
+		g_output_stream_close (stream, NULL, NULL);
 		return FALSE;
 	}
 
@@ -844,15 +803,18 @@
 	{
 		GtkTreeIter iter;
 		char *url, *title;
+		GFile *file;
 		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)
+		file = g_file_new_for_uri (url);
+		if (totem_pl_parser_scheme_is_ignored (parser, file) != FALSE)
 			ignored++;
 
+		g_object_unref (file);
 		g_free (url);
 		g_free (title);
 	}
@@ -876,46 +838,24 @@
 char *
 totem_pl_parser_relative (const char *url, const char *output)
 {
-	char *url_base, *output_base;
-	char *base, *needle;
+	GFile *parent, *descendant, *out_file;
+	char *retval;
 
-	base = NULL;
-	url_base = totem_pl_parser_base_url (url);
-	if (url_base == NULL)
+	out_file = g_file_new_for_commandline_arg (output);
+	parent = g_file_get_parent (out_file);
+	if (parent == NULL) {
+		g_object_unref (out_file);
 		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 {
-			/* Special case when the output and file are at the root */
-			if (strchr (newurl + strlen (output_base), '/') == NULL)
-				base = g_strdup (newurl + strlen (output_base));
-		}
-		gnome_vfs_uri_unref (uri);
-		g_free (newurl);
-
-		if (base != NULL) {
-			/* And finally unescape the string */
-			newurl = gnome_vfs_unescape_string (base, NULL);
-			g_free (base);
-			base = newurl;
-		}
 	}
+	g_object_unref (out_file);
+	descendant = g_file_new_for_commandline_arg (url);
 
-	g_free (url_base);
-	g_free (output_base);
+	retval = g_file_get_relative_path (parent, descendant);
 
-	return base;
+	g_object_unref (parent);
+	g_object_unref (descendant);
+
+	return retval;
 }
 
 #ifndef TOTEM_PL_PARSER_MINI
@@ -1076,7 +1016,7 @@
 
 		if (g_ascii_strncasecmp (line, key, strlen (key)) == 0) {
 			char **bits;
-			ssize_t len;
+			glong len;
 
 			bits = g_strsplit (line, sep, 2);
 			if (bits[0] == NULL || bits [1] == NULL) {
@@ -1180,9 +1120,20 @@
 			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) {
+		if (strcmp (name, TOTEM_PL_PARSER_FIELD_URL) == 0) {
+			if (url == NULL)
+				url = g_value_dup_string (&value);
+		} else if (strcmp (name, TOTEM_PL_PARSER_FIELD_FILE) == 0) {
+			GFile *file;
+
+			file = g_value_get_object (&value);
+			url = g_file_get_uri (file);
+			g_object_unref (file);
+
+			g_value_unset (&value);
+			name = va_arg (var_args, char*);
+			continue;
+		} 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*);
@@ -1273,30 +1224,57 @@
 				 NULL);
 }
 
+void
+totem_pl_parser_add_one_file (TotemPlParser *parser, GFile *file, const char *title)
+{
+	totem_pl_parser_add_url (parser,
+				 TOTEM_PL_PARSER_FIELD_FILE, file,
+				 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;
+	char *no_frag, *no_file, *no_qmark, *qmark, *fragment;
+	GFile *file;
+
+	/* Remove fragment */
+	fragment = strchr (url, '#');
+	if (fragment != NULL)
+		no_frag = g_strndup (url, fragment - url);
+	else
+		no_frag = g_strdup (url);
 
-	no_frag = gnome_vfs_make_uri_canonical_strip_fragment (url);
+	/* Remove parameters */
 	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);
+	if (qmark != NULL)
+		no_qmark = g_strndup (no_frag, qmark - no_frag);
+	else
+		no_qmark = g_strdup (no_frag);
+
+	/* Remove the filename */
+	file = g_file_new_for_uri (no_qmark);
+	no_file = totem_pl_parser_base_url (file);
+	g_object_unref (file);
+
 	g_free (no_qmark);
 	g_free (no_frag);
 
 	return no_file;
 }
 
+#define GNOME_VFS_MIME_TYPE_UNKNOWN "bleh"
+
 static gboolean
 totem_pl_parser_might_be_file (const char *url)
 {
-	const char *mimetype;
+	char *content_type;
 
-	mimetype = gnome_vfs_get_mime_type_for_name (url);
-	if (mimetype == NULL || strcmp (mimetype, GNOME_VFS_MIME_TYPE_UNKNOWN) == 0)
+	content_type = g_content_type_guess (url, NULL, 0, NULL);
+	g_message ("content type %s", content_type);
+	//FIXME leak
+	if (content_type == NULL || strcmp (content_type, GNOME_VFS_MIME_TYPE_UNKNOWN) == 0)
 		return FALSE;
 	return TRUE;
 }
@@ -1317,8 +1295,9 @@
 char *
 totem_pl_parser_resolve_url (const char *base, const char *url)
 {
-	GnomeVFSURI *base_uri, *new;
-	char *resolved, *base_no_frag;
+	//char *resolved, *base_no_frag;
+	char *base_no_frag;
+	GFile *file, *rel;
 
 	g_return_val_if_fail (url != NULL, NULL);
 	g_return_val_if_fail (base != NULL, g_strdup (url));
@@ -1329,7 +1308,14 @@
 
 	/* Strip fragment and filename */
 	base_no_frag = totem_pl_parser_remove_filename (base);
+	g_message ("base no frag: %s", base_no_frag);
+
+	file = g_file_new_for_uri (base_no_frag);
+	g_free (base_no_frag);
+	rel = g_file_resolve_relative_path (file, url);
 
+	return g_file_get_uri (rel);
+#if 0
 	/* gnome_vfs_uri_append_path is trying to be clever and
 	 * merges paths that look like they're the same */
 	if (totem_pl_parser_might_be_file (base) != FALSE) {
@@ -1360,6 +1346,7 @@
 	gnome_vfs_uri_unref (new);
 
 	return resolved;
+#endif
 }
 
 static PlaylistTypes ignore_types[] = {
@@ -1381,24 +1368,22 @@
  * Return value: %TRUE if @url's scheme is ignored
  **/
 gboolean
-totem_pl_parser_scheme_is_ignored (TotemPlParser *parser, const char *url)
+totem_pl_parser_scheme_is_ignored (TotemPlParser *parser, GFile *file)
 {
 	GList *l;
 
 	if (parser->priv->ignore_schemes == NULL)
 		return FALSE;
 
-	for (l = parser->priv->ignore_schemes; l != NULL; l = l->next)
-	{
+	for (l = parser->priv->ignore_schemes; l != NULL; l = l->next) {
 		const char *scheme = l->data;
-		if (g_str_has_prefix (url, scheme) != FALSE)
+		if (g_file_has_uri_scheme (file, scheme) != FALSE)
 			return TRUE;
 	}
 
 	return FALSE;
 }
 
-//FIXME remove ?
 static gboolean
 totem_pl_parser_mimetype_is_ignored (TotemPlParser *parser,
 				     const char *mimetype)
@@ -1438,33 +1423,59 @@
 gboolean
 totem_pl_parser_ignore (TotemPlParser *parser, const char *url)
 {
-	const char *mimetype;
+	char *mimetype;
+	GFile *file;
 	guint i;
 
-	if (totem_pl_parser_scheme_is_ignored (parser, url) != FALSE)
+	file = g_file_new_for_path (url);
+	if (totem_pl_parser_scheme_is_ignored (parser, file) != FALSE) {
+		g_object_unref (file);
 		return TRUE;
+	}
+	g_object_unref (file);
 
-	mimetype = gnome_vfs_get_file_mime_type (url, NULL, TRUE);
-	if (mimetype == NULL || strcmp (mimetype, GNOME_VFS_MIME_TYPE_UNKNOWN) == 0)
+	//FIXME wrong for win32
+	mimetype = g_content_type_guess (url, NULL, 0, NULL);
+	if (mimetype == NULL || strcmp (mimetype, GNOME_VFS_MIME_TYPE_UNKNOWN) == 0) {
+		g_free (mimetype);
 		return FALSE;
+	}
 
-	for (i = 0; i < G_N_ELEMENTS (special_types); i++)
-		if (strcmp (special_types[i].mimetype, mimetype) == 0)
+	for (i = 0; i < G_N_ELEMENTS (special_types); i++) {
+		if (strcmp (special_types[i].mimetype, mimetype) == 0) {
+			g_free (mimetype);
 			return FALSE;
+		}
+	}
 
-	for (i = 0; i < G_N_ELEMENTS (dual_types); i++)
-		if (strcmp (dual_types[i].mimetype, mimetype) == 0)
+	for (i = 0; i < G_N_ELEMENTS (dual_types); i++) {
+		if (strcmp (dual_types[i].mimetype, mimetype) == 0) {
+			g_free (mimetype);
 			return FALSE;
+		}
+	}
+
+	g_free (mimetype);
 
 	return TRUE;
 }
 
+//FIXME this probably doesn't work on Windows
 static gboolean
 totem_pl_parser_ignore_from_mimetype (TotemPlParser *parser, const char *mimetype)
 {
-	char *super;
+//	char *super;
 	guint i;
 
+	for (i = 0; i < G_N_ELEMENTS (ignore_types); i++) {
+		if (g_content_type_is_a (mimetype, ignore_types[i].mimetype) != FALSE)
+			return TRUE;
+		if (g_content_type_equals (mimetype, ignore_types[i].mimetype) != FALSE)
+			return TRUE;
+	}
+
+	return FALSE;
+#if 0
 	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) {
@@ -1485,11 +1496,13 @@
 	g_free (super);
 
 	return FALSE;
+#endif
 }
 
 TotemPlParserResult
-totem_pl_parser_parse_internal (TotemPlParser *parser, const char *url,
-				const char *base)
+totem_pl_parser_parse_internal (TotemPlParser *parser,
+				GFile *file,
+				GFile *base_file)
 {
 	char *mimetype;
 	guint i;
@@ -1500,41 +1513,54 @@
 	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));
+	if (g_file_has_uri_scheme (file, "mms") != FALSE
+			|| g_file_has_uri_scheme (file, "rtsp") != FALSE
+			|| g_file_has_uri_scheme (file, "icy") != FALSE) {
+		DEBUG(file, g_print ("URL '%s' is MMS, RTSP or ICY, ignoring\n", uri));
 		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);
+	/* Fix up itpc, see http://www.apple.com/itunes/store/podcaststechspecs.html,
+	 * as well as feed:// as used by Firefox 3 */
+	if (g_file_has_uri_scheme (file, "itpc") != FALSE || g_file_has_uri_scheme (file, "feed") != FALSE) {
+		DEBUG(file, g_print ("URL '%s' is getting special cased for ITPC/FEED parsing\n", uri));
+		return totem_pl_parser_add_itpc (parser, file, base_file, 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 (totem_pl_parser_is_itms_feed (file) != FALSE) {
+	    	DEBUG(file, g_print ("URL '%s' is getting special cased for ITMS parsing\n", uri));
+	    	return totem_pl_parser_add_itms (parser, file, NULL, NULL);
 	}
 
-	if (!parser->priv->recurse && parser->priv->recurse_level > 0) {
+	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);
+		mimetype = my_g_file_info_get_mime_type_with_data (file, &data, parser);
 	} else {
-		mimetype = g_strdup (gnome_vfs_get_mime_type_for_name (url));
+		char *uri;
+
+		uri = g_file_get_uri (file);
+#ifdef G_OS_WIN32
+		{
+			char *content_type;
+			content_type = g_content_type_guess (uri, NULL, 0, NULL);
+			mimetype = g_content_type_get_mime_type (content_type);
+			g_free (content_type);
+		}
+#else
+		mimetype = g_content_type_guess (uri, NULL, 0, NULL);
+#endif
+
+		g_free (uri);
 	}
 
-	DEBUG(g_print ("_get_mime_type_for_name for '%s' returned '%s'\n", url, mimetype));
+	DEBUG(file, g_print ("_get_mime_type_for_name for '%s' returned '%s'\n", uri, 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"));
+		mimetype = my_g_file_info_get_mime_type_with_data (file, &data, parser);
+		DEBUG(file, g_print ("_get_mime_type_with_data for '%s' returned '%s'\n", uri, mimetype ? mimetype : "NULL"));
 	}
 
 	if (mimetype == NULL) {
@@ -1552,12 +1578,12 @@
 	 * 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);
+		tmp = my_g_file_info_get_mime_type_with_data (file, &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));
+		DEBUG(file, g_print ("_get_mime_type_with_data for '%s' returned '%s' (was %s)\n", uri, mimetype, AUDIO_MPEG_TYPE));
 	}
 
 	if (totem_pl_parser_mimetype_is_ignored (parser, mimetype) != FALSE) {
@@ -1571,13 +1597,13 @@
 
 		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));
+				DEBUG(file, g_print ("URL '%s' is special type '%s'\n", uri, 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);
+				ret = (* special_types[i].func) (parser, file, base_file, data);
 				found = TRUE;
 				break;
 			}
@@ -1585,10 +1611,10 @@
 
 		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));
+				DEBUG(file, g_print ("URL '%s' is dual type '%s'\n", uri, mimetype));
 				if (data == NULL) {
 					g_free (mimetype);
-					mimetype = my_gnome_vfs_get_mime_type_with_data (url, &data, parser);
+					mimetype = my_g_file_info_get_mime_type_with_data (file, &data, parser);
 					/* If it's _still_ a text/plain, we don't want it */
 					if (mimetype == NULL || strcmp (mimetype, "text/plain") == 0) {
 						g_free (mimetype);
@@ -1596,7 +1622,7 @@
 						break;
 					}
 				}
-				ret = (* dual_types[i].func) (parser, url, base, data);
+				ret = (* dual_types[i].func) (parser, file, base_file, data);
 				found = TRUE;
 				break;
 			}
@@ -1619,7 +1645,7 @@
 	g_free (mimetype);
 
 	if (ret != TOTEM_PL_PARSER_RESULT_SUCCESS && parser->priv->fallback) {
-		totem_pl_parser_add_one_url (parser, url, NULL);
+		totem_pl_parser_add_one_file (parser, file, NULL);
 		return TOTEM_PL_PARSER_RESULT_SUCCESS;
 	}
 
@@ -1643,18 +1669,33 @@
 totem_pl_parser_parse_with_base (TotemPlParser *parser, const char *url,
 				 const char *base, gboolean fallback)
 {
+	GFile *file, *base_file;
+	TotemPlParserResult retval;
+
 	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);
 
+	file = g_file_new_for_uri (url);
+	base_file = NULL;
+
+	if (totem_pl_parser_scheme_is_ignored (parser, file) != FALSE) {
+		g_object_unref (file);
+		return TOTEM_PL_PARSER_RESULT_UNHANDLED;
+	}
+
 	parser->priv->recurse_level = 0;
 	parser->priv->fallback = fallback != FALSE;
-	return totem_pl_parser_parse_internal (parser, url, base);
+	if (base != NULL)
+		base_file = g_file_new_for_uri (base);
+	retval = totem_pl_parser_parse_internal (parser, file, base_file);
+
+	g_object_unref (file);
+	if (base_file != NULL)
+		g_object_unref (base_file);
+
+	return retval;
 }
 
 /**
@@ -1775,21 +1816,6 @@
 	return -1;
 }
 
-/* FIXME remove when http://bugzilla.gnome.org/show_bug.cgi?id=503029
- * is fixed */
-static gboolean
-totem_pl_parser_is_iso8601_date (const char *date_str)
-{
-	while (g_ascii_isspace (*date_str))
-		date_str++;
-	if (*date_str == '\0')
-		return FALSE;
-	if (!g_ascii_isdigit (*date_str) && *date_str != '-' && *date_str != '+')
-		return FALSE;
-
-	return TRUE;
-}
-
 /**
  * totem_pl_parser_parse_date:
  * @date_str: the date string to parse
@@ -1809,8 +1835,7 @@
 
 	memset (&val, 0, sizeof(val));
 	/* Try to parse as an ISO8601/RFC3339 date */
-	if (totem_pl_parser_is_iso8601_date (date_str) != FALSE
-	    && g_time_val_from_iso8601 (date_str, &val) != FALSE) {
+	if (g_time_val_from_iso8601 (date_str, &val) != FALSE) {
 		D(g_message ("Parsed duration '%s' using the ISO8601 parser", date_str));
 		return val.tv_sec;
 	}
@@ -1823,13 +1848,30 @@
 #endif /* !TOTEM_PL_PARSER_MINI */
 
 static char *
-my_gnome_vfs_get_mime_type_for_data (gconstpointer data, int len)
+totem_pl_parser_mime_type_from_data (gconstpointer data, int len)
 {
-	const char *mimetype;
+	char *mime_type;
+	gboolean uncertain;
 
-	mimetype = gnome_vfs_get_mime_type_for_data (data, len);
+#ifdef G_OS_WIN32
+	char *content_type;
+
+	content_type = g_content_type_guess (NULL, data, len, &uncertain);
+	if (uncertain == FALSE) {
+		mime_type = g_content_type_get_mime_type (content_type);
+		g_free (content_type);
+	} else {
+		mime_type = NULL;
+	}
+#else
+	mime_type = g_content_type_guess (NULL, data, len, &uncertain);
+	if (uncertain != FALSE) {
+		g_free (mime_type);
+		mime_type = NULL;
+	}
+#endif
 
-	if (mimetype != NULL && strcmp (mimetype, "text/plain") == 0) {
+	if (mime_type != NULL && strcmp (mime_type, "text/plain") == 0) {
 		PlaylistIdenCallback func;
 		guint i;
 
@@ -1842,12 +1884,14 @@
 				continue;
 			func = dual_types[i].iden;
 			res = func (data, len);
-			if (res != NULL)
+			if (res != NULL) {
+				g_free (mime_type);
 				return g_strdup (res);
+			}
 		}
 	}
 
-	return g_strdup (mimetype);
+	return mime_type;
 }
 
 /**
@@ -1872,9 +1916,9 @@
 	g_return_val_if_fail (data != NULL, FALSE);
 
 	/* Bad cast! */
-	mimetype = my_gnome_vfs_get_mime_type_for_data ((gpointer) data, (int) len);
+	mimetype = totem_pl_parser_mime_type_from_data ((gpointer) data, (int) len);
 
-	if (mimetype == NULL || strcmp (GNOME_VFS_MIME_TYPE_UNKNOWN, mimetype) == 0) {
+	if (mimetype == NULL) {
 		D(g_message ("totem_pl_parser_can_parse_from_data couldn't get mimetype"));
 		return FALSE;
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]