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



Author: hadess
Date: Thu May  8 15:25:39 2008
New Revision: 117
URL: http://svn.gnome.org/viewvc/totem-pl-parser?rev=117&view=rev

Log:
2008-05-08  Bastien Nocera  <hadess hadess net>

	* plparse/totem-pl-parser-pla.c (totem_pl_parser_add_pla):
	Remove unneeded include, fix warning

	* plparse/totem-pl-parser-private.h:
	* plparse/totem-pl-parser.c (totem_pl_parser_relative),
	(totem_pl_parser_ignore_from_mimetype):
	Update totem_pl_parser_relative() to take in a GFile as the output
	target, and simplify
	Remove old code in totem_pl_parser_ignore_from_mimetype()

	* plparse/test-parser.c (test_relative_real):
	Fix usage of totem_pl_parser_relative()

	* plparse/totem-pl-parser-lines.c (totem_pl_parser_url_to_dos),
	(totem_pl_parser_write_m3u):
	* plparse/totem-pl-parser-pls.c (totem_pl_parser_write_pls):
	* plparse/totem-pl-parser-xspf.c (totem_pl_parser_write_xspf):
	Use totem_pl_parser_relative() where needed, and fix usage



Modified:
   trunk/ChangeLog
   trunk/plparse/test-parser.c
   trunk/plparse/totem-pl-parser-lines.c
   trunk/plparse/totem-pl-parser-pla.c
   trunk/plparse/totem-pl-parser-pls.c
   trunk/plparse/totem-pl-parser-private.h
   trunk/plparse/totem-pl-parser-xspf.c
   trunk/plparse/totem-pl-parser.c

Modified: trunk/plparse/test-parser.c
==============================================================================
--- trunk/plparse/test-parser.c	(original)
+++ trunk/plparse/test-parser.c	Thu May  8 15:25:39 2008
@@ -40,9 +40,13 @@
 static void
 test_relative_real (const char *url, const char *output, const char *expected)
 {
+	GFile *output_file;
 	char *base;
 
-	base = totem_pl_parser_relative (url, output);
+	output_file = g_file_new_for_commandline_arg (output);
+	base = totem_pl_parser_relative (output_file, url);
+	g_object_unref (output_file);
+
 	if (base == NULL && expected == NULL) {
 		g_print ("Relative: '%s' with output '%s' has no relative path\n",
 			 url, output);

Modified: trunk/plparse/totem-pl-parser-lines.c
==============================================================================
--- trunk/plparse/totem-pl-parser-lines.c	(original)
+++ trunk/plparse/totem-pl-parser-lines.c	Thu May  8 15:25:39 2008
@@ -47,16 +47,10 @@
 static char *
 totem_pl_parser_url_to_dos (const char *url, GFile *output)
 {
-	GFile *url_file, *parent;
 	char *retval, *i;
 
-	parent = g_file_get_parent (output);
-	url_file = g_file_new_for_uri (url);
-
-	retval = g_file_get_relative_path (parent, url_file);
-
-	g_object_unref (parent);
-	g_object_unref (url_file);
+	/* Get a relative URL if there is one */
+	retval = totem_pl_parser_relative (output, url);
 
 	if (retval == NULL)
 		retval = g_strdup (url);
@@ -137,14 +131,9 @@
 		g_free (title);
 
 		if (dos_compatible == FALSE) {
-			GFile *parent, *url_file;
 			char *tmp;
 
-			parent = g_file_get_parent (output);
-			url_file = g_file_new_for_uri (url);
-			tmp = g_file_get_relative_path (parent, url_file);
-			g_object_unref (parent);
-			g_object_unref (url_file);
+			tmp = totem_pl_parser_relative (output, url);
 
 			if (tmp == NULL && g_str_has_prefix (url, "file:")) {
 				path2 = g_filename_from_uri (url, NULL, NULL);

Modified: trunk/plparse/totem-pl-parser-pla.c
==============================================================================
--- trunk/plparse/totem-pl-parser-pla.c	(original)
+++ trunk/plparse/totem-pl-parser-pla.c	Thu May  8 15:25:39 2008
@@ -26,7 +26,6 @@
 #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 */
@@ -160,7 +159,7 @@
 	if (size < RECORD_SIZE)
 	{
 		g_free (contents);
-		DEBUG(file, g_print ("playlist '%s' is too short: %d\n", uri, size));
+		DEBUG(file, g_print ("playlist '%s' is too short: %d\n", uri, (unsigned int) size));
 		return TOTEM_PL_PARSER_RESULT_ERROR;
 	}
 

Modified: trunk/plparse/totem-pl-parser-pls.c
==============================================================================
--- trunk/plparse/totem-pl-parser-pls.c	(original)
+++ trunk/plparse/totem-pl-parser-pls.c	Thu May  8 15:25:39 2008
@@ -27,7 +27,6 @@
 #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 */
@@ -85,16 +84,14 @@
 
 		func (model, &iter, &url, &title, &custom_title, user_data);
 
-		if (totem_pl_parser_scheme_is_ignored (parser, url) != FALSE)
-		{
+		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);
+		relative = totem_pl_parser_relative (output, url);
+		buf = g_strdup_printf ("File%d=%s\n", i, relative ? relative : url);
 		g_free (relative);
 		g_free (url);
 		success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);

Modified: trunk/plparse/totem-pl-parser-private.h
==============================================================================
--- trunk/plparse/totem-pl-parser-private.h	(original)
+++ trunk/plparse/totem-pl-parser-private.h	Thu May  8 15:25:39 2008
@@ -107,8 +107,8 @@
 						 const char *buf,
 						 guint size,
 						 GError **error);
-char * totem_pl_parser_relative			(const char *url,
-						 const char *output);
+char * totem_pl_parser_relative			(GFile *output,
+						 const char *filepath);
 TotemPlParserResult totem_pl_parser_parse_internal (TotemPlParser *parser,
 						    GFile *file,
 						    GFile *base_file);

Modified: trunk/plparse/totem-pl-parser-xspf.c
==============================================================================
--- trunk/plparse/totem-pl-parser-xspf.c	(original)
+++ trunk/plparse/totem-pl-parser-xspf.c	Thu May  8 15:25:39 2008
@@ -29,7 +29,6 @@
 #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 */
@@ -117,7 +116,7 @@
 			continue;
 		}
 
-		relative = totem_pl_parser_relative (url, output);
+		relative = totem_pl_parser_relative (output, url);
 		url_escaped = g_markup_escape_text (relative ? relative : url, -1);
 		buf = g_strdup_printf ("  <track>\n"
 					"   <location>%s</location>\n", url_escaped);

Modified: trunk/plparse/totem-pl-parser.c
==============================================================================
--- trunk/plparse/totem-pl-parser.c	(original)
+++ trunk/plparse/totem-pl-parser.c	Thu May  8 15:25:39 2008
@@ -822,38 +822,19 @@
 	return num_entries - ignored;
 }
 
-/**
- * totem_pl_parser_relative:
- * @url: a URI
- * @output: a base path and filename
- *
- * Returns the URI of @url relative to @output if possible, and %NULL
- * if not.
- *
- * <emphasis>See totem_pl_parser_resolve_url() to convert from relative URLs
- * to absolute URLs.</emphasis>
- *
- * Return value: a newly-allocated relative URI string, or %NULL
- **/
 char *
-totem_pl_parser_relative (const char *url, const char *output)
+totem_pl_parser_relative (GFile *output, const char *filepath)
 {
-	GFile *parent, *descendant, *out_file;
+	GFile *parent, *file;
 	char *retval;
 
-	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;
-	}
-	g_object_unref (out_file);
-	descendant = g_file_new_for_commandline_arg (url);
+	parent = g_file_get_parent (output);
+	file = g_file_new_for_commandline_arg (filepath);
 
-	retval = g_file_get_relative_path (parent, descendant);
+	retval = g_file_get_relative_path (parent, file);
 
 	g_object_unref (parent);
-	g_object_unref (descendant);
+	g_object_unref (file);
 
 	return retval;
 }
@@ -1373,11 +1354,9 @@
 	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;
 	guint i;
 
 	for (i = 0; i < G_N_ELEMENTS (ignore_types); i++) {
@@ -1388,28 +1367,6 @@
 	}
 
 	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) {
-			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;
-#endif
 }
 
 TotemPlParserResult



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