totem-pl-parser r114 - in trunk: . plparse
- From: hadess svn gnome org
- To: svn-commits-list gnome org
- Subject: totem-pl-parser r114 - in trunk: . plparse
- Date: Wed, 7 May 2008 18:14:24 +0100 (BST)
Author: hadess
Date: Wed May 7 17:14:24 2008
New Revision: 114
URL: http://svn.gnome.org/viewvc/totem-pl-parser?rev=114&view=rev
Log:
2008-05-07 Bastien Nocera <hadess hadess net>
* plparse/plparser.symbols:
* plparse/test-parser.c (main):
* plparse/totem-pl-parser-lines.c (totem_pl_parser_url_to_dos),
(totem_pl_parser_write_m3u), (totem_pl_parser_add_m3u):
* plparse/totem-pl-parser-lines.h:
* plparse/totem-pl-parser-pla.c (totem_pl_parser_write_pla),
(totem_pl_parser_add_pla):
* plparse/totem-pl-parser-pla.h:
* plparse/totem-pl-parser-pls.c (totem_pl_parser_write_pls),
(totem_pl_parser_add_pls_with_contents), (totem_pl_parser_add_pls):
* plparse/totem-pl-parser-pls.h:
* plparse/totem-pl-parser-podcast.c (totem_pl_parser_is_itms_feed):
* plparse/totem-pl-parser-private.h:
* plparse/totem-pl-parser-smil.c (parse_smil_entry),
(parse_smil_entries), (totem_pl_parser_add_smil_with_doc):
* plparse/totem-pl-parser-wm.c (parse_asx_entry),
(parse_asx_entryref), (parse_asx_entries),
(totem_pl_parser_add_asx):
* plparse/totem-pl-parser-xspf.c (totem_pl_parser_parse_xml_file),
(totem_pl_parser_write_xspf), (parse_xspf_track),
(parse_xspf_trackList), (parse_xspf_entries),
(totem_pl_parser_add_xspf):
* plparse/totem-pl-parser-xspf.h:
* plparse/totem-pl-parser.c (totem_pl_parser_write_with_title),
(totem_pl_parser_add_url_valist):
* plparse/totem-pl-parser.h: Port playlist writers to GIO, removed
totem_pl_parser_resolve_url and totem_pl_parser_relative, as those
should be replaced by their GIO equivalents, and had completely broken
semantics
Doesn't compile, file a bug and I'll kick your arse
Modified:
trunk/ChangeLog
trunk/plparse/plparser.symbols
trunk/plparse/test-parser.c
trunk/plparse/totem-pl-parser-lines.c
trunk/plparse/totem-pl-parser-lines.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-private.h
trunk/plparse/totem-pl-parser-smil.c
trunk/plparse/totem-pl-parser-wm.c
trunk/plparse/totem-pl-parser-xspf.c
trunk/plparse/totem-pl-parser-xspf.h
trunk/plparse/totem-pl-parser.c
trunk/plparse/totem-pl-parser.h
Modified: trunk/plparse/plparser.symbols
==============================================================================
--- trunk/plparse/plparser.symbols (original)
+++ trunk/plparse/plparser.symbols Wed May 7 17:14:24 2008
@@ -17,8 +17,6 @@
totem_pl_parser_parse_date
totem_pl_parser_parse_duration
totem_pl_parser_parse_with_base
-totem_pl_parser_relative
-totem_pl_parser_resolve_url
totem_pl_parser_result_get_type
totem_pl_parser_type_get_type
totem_pl_parser_write
Modified: trunk/plparse/test-parser.c
==============================================================================
--- trunk/plparse/test-parser.c (original)
+++ trunk/plparse/test-parser.c Wed May 7 17:14:24 2008
@@ -99,34 +99,6 @@
}
static void
-test_resolve_real (const char *base, const char *url, const char *expected)
-{
- char *result;
-
- result = totem_pl_parser_resolve_url (base, url);
- if (result == NULL)
- error ("NULL output resolving '%s' with base '%s'", url, base);
- if (strcmp (result, expected) != 0)
- error ("Resolving '%s' with base '%s', different results than expected:\n'%s' instead of '%s'",
- url, base, result, expected);
- g_print ("Resolved: '%s' with base '%s' to '%s'\n", url, base, result);
- g_free (result);
-}
-
-static void
-test_resolve (void)
-{
- header ("Resolve URL");
-
- test_resolve_real ("http://localhost:12345/foobar/", "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¶m2=bar", "dir/image.jpg", "http://localhost/video.dir/dir/image.jpg");
- test_resolve_real ("http://movies.apple.com/movies/us/apple/ipoditunes/2007/touch/features/apple_ipodtouch_safari_r640-9cie.mov", "/movies/us/apple/ipoditunes/2007/touch/features/apple_ipodtouch_safari_i320x180.m4v", "http://movies.apple.com/movies/us/apple/ipoditunes/2007/touch/features/apple_ipodtouch_safari_i320x180.m4v");
- test_resolve_real ("http://movies.apple.com/movies/fox/jumper/jumper-tlrd_h.480.mov", "jumper-tlrd_h480.mov", "http://movies.apple.com/movies/fox/jumper/jumper-tlrd_h480.mov");
-}
-
-static void
test_duration_real (const char *duration, gint64 expected)
{
gint64 res;
@@ -476,7 +448,6 @@
test_duration ();
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 Wed May 7 17:14:24 2008
@@ -45,18 +45,24 @@
#define EXTVLCOPT "#EXTVLCOPT"
static char *
-totem_pl_parser_url_to_dos (const char *url, const char *output)
+totem_pl_parser_url_to_dos (const char *url, GFile *output)
{
+ GFile *url_file, *parent;
char *retval, *i;
- retval = totem_pl_parser_relative (url, output);
+ 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);
if (retval == NULL)
retval = g_strdup (url);
/* Don't change URIs, but change smb:// */
- if (g_str_has_prefix (retval, "smb://") != FALSE)
- {
+ if (g_str_has_prefix (retval, "smb://") != FALSE) {
char *tmp;
tmp = g_strdup (retval + strlen ("smb:"));
g_free (retval);
@@ -79,23 +85,18 @@
gboolean
totem_pl_parser_write_m3u (TotemPlParser *parser, GtkTreeModel *model,
- TotemPlParserIterFunc func, const char *output,
+ TotemPlParserIterFunc func, GFile *output,
gboolean dos_compatible, gpointer user_data, GError **error)
{
- GFile *out;
GFileOutputStream *stream;
int num_entries_total, i;
gboolean success;
char *buf;
char *cr;
- 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);
+ stream = g_file_replace (output, NULL, FALSE, G_FILE_CREATE_NONE, NULL, error);
+ if (stream == NULL)
return FALSE;
- }
- g_object_unref (out);
cr = dos_compatible ? "\r\n" : "\n";
num_entries_total = gtk_tree_model_iter_n_children (model, NULL);
@@ -136,8 +137,15 @@
g_free (title);
if (dos_compatible == FALSE) {
+ GFile *parent, *url_file;
char *tmp;
- tmp = totem_pl_parser_relative (url, output);
+
+ 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);
+
if (tmp == NULL && g_str_has_prefix (url, "file:")) {
path2 = g_filename_from_uri (url, NULL, NULL);
} else {
@@ -341,50 +349,26 @@
return sep;
}
-static char *
-totem_pl_parser_append_path (const char *base, const char *path)
-{
-#if 0
- GnomeVFSURI *new, *baseuri;
- char *fullpath;
-
- baseuri = gnome_vfs_uri_new (base);
- if (baseuri == NULL)
- goto bail;
- new = gnome_vfs_uri_append_path (baseuri, path);
- gnome_vfs_uri_unref (baseuri);
- if (new == NULL)
- goto bail;
- fullpath = gnome_vfs_uri_to_string (new, 0);
- gnome_vfs_uri_unref (new);
-
- return fullpath;
-
-bail:
- return g_strdup_printf ("%s/%s", base, path);
-#endif
-}
-
TotemPlParserResult
totem_pl_parser_add_m3u (TotemPlParser *parser,
GFile *file,
- GFile *_base_file,
+ GFile *base_file,
gpointer data)
{
-#if 0
TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED;
char *contents, **lines;
- int size, i;
+ gsize size;
+ int i;
const char *split_char, *extinfo;
- 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;
/* .pls files with a .m3u extension, the nasties */
if (g_str_has_prefix (contents, "[playlist]") != FALSE
|| g_str_has_prefix (contents, "[Playlist]") != FALSE
|| g_str_has_prefix (contents, "[PLAYLIST]") != FALSE) {
- retval = totem_pl_parser_add_pls_with_contents (parser, url, _base, contents);
+ retval = totem_pl_parser_add_pls_with_contents (parser, file, base_file, contents);
g_free (contents);
return retval;
}
@@ -417,23 +401,27 @@
/* Either it's a URI, or it has a proper path ... */
if (strstr(lines[i], "://") != NULL
|| lines[i][0] == G_DIR_SEPARATOR) {
- if (totem_pl_parser_parse_internal (parser, lines[i], NULL) != TOTEM_PL_PARSER_RESULT_SUCCESS) {
+ GFile *url;
+
+ url = g_file_new_for_commandline_arg (lines[i]);
+ if (totem_pl_parser_parse_internal (parser, url, NULL) != TOTEM_PL_PARSER_RESULT_SUCCESS) {
totem_pl_parser_add_one_url (parser, lines[i],
totem_pl_parser_get_extinfo_title (extinfo));
}
+ g_object_unref (url);
extinfo = NULL;
} else if (g_ascii_isalpha (lines[i][0]) != FALSE
&& g_str_has_prefix (lines[i] + 1, ":\\")) {
/* Path relative to a drive on Windows, we need to use
* the base that was passed to us */
- char *fullpath;
+ GFile *url;
lines[i] = g_strdelimit (lines[i], "\\", '/');
/* + 2, skip drive letter */
- fullpath = totem_pl_parser_append_path (_base, lines[i] + 2);
- totem_pl_parser_add_one_url (parser, fullpath,
+ url = g_file_get_child (base_file, lines[i] + 2);
+ totem_pl_parser_add_one_file (parser, url,
totem_pl_parser_get_extinfo_title (extinfo));
- g_free (fullpath);
+ g_object_unref (url);
extinfo = NULL;
} else if (lines[i][0] == '\\' && lines[i][1] == '\\') {
/* ... Or it's in the windows smb form
@@ -452,17 +440,18 @@
g_free (tmpurl);
} else {
/* Try with a base */
- char *fullpath, *base, sep;
+ GFile *url, *_base_file;
+ char sep;
- base = totem_pl_parser_base_url (url);
+ _base_file = g_file_get_parent (file);
sep = (split_char[0] == '\n' ? '/' : '\\');
if (sep == '\\')
lines[i] = g_strdelimit (lines[i], "\\", '/');
- fullpath = totem_pl_parser_append_path (base, lines[i]);
- totem_pl_parser_add_one_url (parser, fullpath,
+ url = g_file_get_child (_base_file, lines[i]);
+ g_object_unref (_base_file);
+ totem_pl_parser_add_one_file (parser, url,
totem_pl_parser_get_extinfo_title (extinfo));
- g_free (fullpath);
- g_free (base);
+ g_object_unref (url);
extinfo = NULL;
}
}
@@ -470,7 +459,6 @@
g_strfreev (lines);
return retval;
-#endif
}
TotemPlParserResult
Modified: trunk/plparse/totem-pl-parser-lines.h
==============================================================================
--- trunk/plparse/totem-pl-parser-lines.h (original)
+++ trunk/plparse/totem-pl-parser-lines.h Wed May 7 17:14:24 2008
@@ -38,7 +38,7 @@
gboolean totem_pl_parser_write_m3u (TotemPlParser *parser,
GtkTreeModel *model,
TotemPlParserIterFunc func,
- const char *output,
+ GFile *output,
gboolean dos_compatible,
gpointer user_data,
GError **error);
Modified: trunk/plparse/totem-pl-parser-pla.c
==============================================================================
--- trunk/plparse/totem-pl-parser-pla.c (original)
+++ trunk/plparse/totem-pl-parser-pla.c Wed May 7 17:14:24 2008
@@ -48,11 +48,10 @@
gboolean
totem_pl_parser_write_pla (TotemPlParser *parser, GtkTreeModel *model,
TotemPlParserIterFunc func,
- const char *output, const char *title,
+ GFile *output, const char *title,
gpointer user_data, GError **error)
{
- GnomeVFSHandle *handle;
- GnomeVFSResult res;
+ GFileOutputStream *stream;
int num_entries_total, num_entries, i;
char *buffer;
gboolean ret;
@@ -60,23 +59,9 @@
num_entries = totem_pl_parser_num_entries (parser, model, func, user_data);
num_entries_total = gtk_tree_model_iter_n_children (model, NULL);
- res = gnome_vfs_open (&handle, output, GNOME_VFS_OPEN_WRITE);
- if (res == GNOME_VFS_ERROR_NOT_FOUND) {
- res = gnome_vfs_create (&handle, output,
- GNOME_VFS_OPEN_WRITE, FALSE,
- GNOME_VFS_PERM_USER_WRITE
- | GNOME_VFS_PERM_USER_READ
- | GNOME_VFS_PERM_GROUP_READ);
- }
-
- if (res != GNOME_VFS_OK) {
- g_set_error(error,
- TOTEM_PL_PARSER_ERROR,
- TOTEM_PL_PARSER_ERROR_VFS_OPEN,
- _("Couldn't open file '%s': %s"),
- output, gnome_vfs_result_to_string (res));
+ stream = g_file_replace (output, NULL, FALSE, G_FILE_CREATE_NONE, NULL, error);
+ if (stream == NULL)
return FALSE;
- }
/* write the header */
buffer = g_malloc0 (RECORD_SIZE);
@@ -87,10 +72,9 @@
* the 'quick list' name there.
*/
strncpy (buffer + TITLE_OFFSET, title, TITLE_SIZE);
- if (totem_pl_parser_write_buffer (handle, buffer, RECORD_SIZE, error) == FALSE)
+ if (totem_pl_parser_write_buffer (G_OUTPUT_STREAM (stream), buffer, RECORD_SIZE, error) == FALSE)
{
- DEBUG(NULL, g_print ("Couldn't write header block"));
- gnome_vfs_close (handle);
+ DEBUG(NULL, g_print ("Couldn't write header block for '%s'", uri));
g_free (buffer);
return FALSE;
}
@@ -145,7 +129,7 @@
memcpy (buffer + PATH_OFFSET, converted, written);
g_free (converted);
- if (totem_pl_parser_write_buffer (handle, buffer, RECORD_SIZE, error) == FALSE)
+ if (totem_pl_parser_write_buffer (G_OUTPUT_STREAM (stream), buffer, RECORD_SIZE, error) == FALSE)
{
DEBUG(NULL, g_print ("Couldn't write entry %d to the file\n", i));
ret = FALSE;
@@ -154,7 +138,8 @@
}
g_free (buffer);
- gnome_vfs_close (handle);
+ g_output_stream_close (G_OUTPUT_STREAM (stream), NULL, NULL);
+
return ret;
}
@@ -164,18 +149,18 @@
GFile *base_file,
gpointer data)
{
-#if 0
TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED;
char *contents, *title;
- int size, offset, max_entries, entry;
+ guint offset, max_entries, entry;
+ gsize size;
- 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;
if (size < RECORD_SIZE)
{
g_free (contents);
- DEBUG(g_print ("playlist '%s' is too short: %d\n", url, size));
+ DEBUG(file, g_print ("playlist '%s' is too short: %d\n", uri, size));
return TOTEM_PL_PARSER_RESULT_ERROR;
}
@@ -184,7 +169,7 @@
if (strcmp (contents + FORMAT_ID_OFFSET, "iriver UMS PLA") != 0)
{
g_free (contents);
- DEBUG(g_print ("playlist '%s' signature doesn't match: %s\n", url, contents + 4));
+ DEBUG(file, g_print ("playlist '%s' signature doesn't match: %s\n", uri, contents + 4));
return TOTEM_PL_PARSER_RESULT_ERROR;
}
@@ -195,7 +180,7 @@
title = contents + TITLE_OFFSET;
totem_pl_parser_add_url (parser,
TOTEM_PL_PARSER_FIELD_IS_PLAYLIST, TRUE,
- TOTEM_PL_PARSER_FIELD_URL, url,
+ TOTEM_PL_PARSER_FIELD_FILE, file,
TOTEM_PL_PARSER_FIELD_TITLE, title,
NULL);
}
@@ -213,7 +198,7 @@
NULL, NULL, &error);
if (path == NULL)
{
- DEBUG(g_print ("error converting entry %d to UTF-8: %s\n", entry, error->message));
+ DEBUG(NULL, g_print ("error converting entry %d to UTF-8: %s\n", entry, error->message));
g_error_free (error);
retval = TOTEM_PL_PARSER_RESULT_ERROR;
break;
@@ -226,7 +211,7 @@
uri = g_filename_to_uri (path, NULL, NULL);
if (uri == NULL)
{
- DEBUG(g_print ("error converting path %s to URI: %s\n", path, error->message));
+ DEBUG(file, g_print ("error converting path %s to URI: %s\n", path, error->message));
g_error_free (error);
retval = TOTEM_PL_PARSER_RESULT_ERROR;
break;
@@ -246,7 +231,6 @@
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 Wed May 7 17:14:24 2008
@@ -34,7 +34,7 @@
gboolean totem_pl_parser_write_pla (TotemPlParser *parser,
GtkTreeModel *model,
TotemPlParserIterFunc func,
- const char *output,
+ GFile *output,
const char *title,
gpointer user_data,
GError **error);
Modified: trunk/plparse/totem-pl-parser-pls.c
==============================================================================
--- trunk/plparse/totem-pl-parser-pls.c (original)
+++ trunk/plparse/totem-pl-parser-pls.c Wed May 7 17:14:24 2008
@@ -40,11 +40,10 @@
gboolean
totem_pl_parser_write_pls (TotemPlParser *parser, GtkTreeModel *model,
TotemPlParserIterFunc func,
- const char *output, const char *title,
+ GFile *output, const char *title,
gpointer user_data, GError **error)
{
- GnomeVFSHandle *handle;
- GnomeVFSResult res;
+ GFileOutputStream *stream;
int num_entries_total, num_entries, i;
char *buf;
gboolean success;
@@ -52,49 +51,29 @@
num_entries = totem_pl_parser_num_entries (parser, model, func, user_data);
num_entries_total = gtk_tree_model_iter_n_children (model, NULL);
- res = gnome_vfs_open (&handle, output, GNOME_VFS_OPEN_WRITE);
- if (res == GNOME_VFS_ERROR_NOT_FOUND) {
- res = gnome_vfs_create (&handle, output,
- GNOME_VFS_OPEN_WRITE, FALSE,
- GNOME_VFS_PERM_USER_WRITE
- | GNOME_VFS_PERM_USER_READ
- | GNOME_VFS_PERM_GROUP_READ);
- }
-
- if (res != GNOME_VFS_OK) {
- g_set_error(error,
- TOTEM_PL_PARSER_ERROR,
- TOTEM_PL_PARSER_ERROR_VFS_OPEN,
- _("Couldn't open file '%s': %s"),
- output, gnome_vfs_result_to_string (res));
+ stream = g_file_replace (output, NULL, FALSE, G_FILE_CREATE_NONE, NULL, error);
+ if (stream == NULL)
return FALSE;
- }
buf = g_strdup ("[playlist]\n");
- 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)
return FALSE;
if (title != NULL) {
buf = g_strdup_printf ("X-GNOME-Title=%s\n", title);
- 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);
return FALSE;
- }
}
buf = g_strdup_printf ("NumberOfEntries=%d\n", num_entries);
- 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);
return FALSE;
- }
for (i = 1; i <= num_entries_total; i++) {
GtkTreeIter iter;
@@ -118,11 +97,9 @@
relative ? relative : url);
g_free (relative);
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_free (title);
return FALSE;
}
@@ -133,17 +110,14 @@
}
buf = g_strdup_printf ("Title%d=%s\n", i, title);
- success = totem_pl_parser_write_string (handle, buf, error);
+ success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
g_free (buf);
g_free (title);
if (success == FALSE)
- {
- gnome_vfs_close (handle);
return FALSE;
- }
}
- gnome_vfs_close (handle);
+ g_output_stream_close (G_OUTPUT_STREAM (stream), NULL, NULL);
return TRUE;
}
@@ -153,7 +127,6 @@
GFile *base_file,
const char *contents)
{
-#if 0
TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED;
char **lines;
int i, num_entries;
@@ -190,7 +163,7 @@
if (playlist_title != NULL) {
totem_pl_parser_add_url (parser,
TOTEM_PL_PARSER_FIELD_IS_PLAYLIST, TRUE,
- TOTEM_PL_PARSER_FIELD_URL, url,
+ TOTEM_PL_PARSER_FIELD_FILE, file,
TOTEM_PL_PARSER_FIELD_TITLE, playlist_title,
NULL);
}
@@ -261,13 +234,13 @@
TOTEM_PL_PARSER_FIELD_TITLE, title,
TOTEM_PL_PARSER_FIELD_GENRE, genre,
TOTEM_PL_PARSER_FIELD_DURATION, length,
- TOTEM_PL_PARSER_FIELD_BASE, base, NULL);
+ TOTEM_PL_PARSER_FIELD_BASE_FILE, base_file, NULL);
}
} else {
char *base;
/* Try with a base */
- base = totem_pl_parser_base_url (url);
+ base = totem_pl_parser_base_url (file);
if (length_num < 0 || totem_pl_parser_parse_internal (parser, file, base) != TOTEM_PL_PARSER_RESULT_SUCCESS) {
char *escaped, *uri;
@@ -302,7 +275,6 @@
g_strfreev (lines);
return retval;
-#endif
}
TotemPlParserResult
@@ -311,12 +283,11 @@
GFile *base_file,
gpointer data)
{
-#if 0
TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED;
char *contents;
- int size;
+ gsize size;
- 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;
if (size == 0) {
@@ -324,11 +295,10 @@
return TOTEM_PL_PARSER_RESULT_SUCCESS;
}
- retval = totem_pl_parser_add_pls_with_contents (parser, url, base, contents);
+ retval = totem_pl_parser_add_pls_with_contents (parser, file, base_file, contents);
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 Wed May 7 17:14:24 2008
@@ -34,7 +34,7 @@
gboolean totem_pl_parser_write_pls (TotemPlParser *parser,
GtkTreeModel *model,
TotemPlParserIterFunc func,
- const char *output,
+ GFile *file,
const char *title,
gpointer user_data,
GError **error);
Modified: trunk/plparse/totem-pl-parser-podcast.c
==============================================================================
--- trunk/plparse/totem-pl-parser-podcast.c (original)
+++ trunk/plparse/totem-pl-parser-podcast.c Wed May 7 17:14:24 2008
@@ -708,19 +708,32 @@
gboolean
totem_pl_parser_is_itms_feed (GFile *file)
{
-#if 0
- g_return_val_if_fail (url != NULL, FALSE);
+ char *url;
+
+ g_return_val_if_fail (file != NULL, FALSE);
+
+ url = g_file_get_uri (file);
if (g_file_has_uri_scheme (file, "itms:") != FALSE
&& strstr (url, "phobos.apple.com") != NULL
- && strstr (url, "viewPodcast") != NULL)
+ && strstr (url, "viewPodcast") != NULL) {
+ g_free (url);
return TRUE;
+ }
+
if (strstr (url, "phobos.apple.com/") != NULL
- && strstr (url, "viewPodcast") != NULL)
+ && strstr (url, "viewPodcast") != NULL) {
+ g_free (url);
return TRUE;
- if (strstr (url, "itunes.com/podcast") != NULL)
+ }
+
+ if (strstr (url, "itunes.com/podcast") != NULL) {
+ g_free (url);
return TRUE;
-#endif
+ }
+
+ g_free (url);
+
return FALSE;
}
Modified: trunk/plparse/totem-pl-parser-private.h
==============================================================================
--- trunk/plparse/totem-pl-parser-private.h (original)
+++ trunk/plparse/totem-pl-parser-private.h Wed May 7 17:14:24 2008
@@ -50,6 +50,7 @@
#define ASF_REF_MIME_TYPE "video/x-ms-asf"
#define TOTEM_PL_PARSER_FIELD_FILE "gfile-object"
+#define TOTEM_PL_PARSER_FIELD_BASE_FILE "gfile-object-base"
#ifndef TOTEM_PL_PARSER_MINI
#define DEBUG(file, x) { \
@@ -121,6 +122,7 @@
const char *first_property_name,
...);
gboolean totem_pl_parser_ignore (TotemPlParser *parser, const char *url);
+
#endif /* !TOTEM_PL_PARSER_MINI */
G_END_DECLS
Modified: trunk/plparse/totem-pl-parser-smil.c
==============================================================================
--- trunk/plparse/totem-pl-parser-smil.c (original)
+++ trunk/plparse/totem-pl-parser-smil.c Wed May 7 17:14:24 2008
@@ -38,7 +38,7 @@
#ifndef TOTEM_PL_PARSER_MINI
static TotemPlParserResult
parse_smil_entry (TotemPlParser *parser,
- char *base,
+ GFile *base_file,
xml_node_t *doc,
xml_node_t *parent,
const char *parent_title)
@@ -71,11 +71,11 @@
copyright = xml_parser_get_property (node, "copyright");
if (url != NULL) {
- char *fullpath;
+ GFile *resolved;
- fullpath = totem_pl_parser_resolve_url (base, url);
+ resolved = g_file_resolve_relative_path (base_file, url);
totem_pl_parser_add_url (parser,
- TOTEM_PL_PARSER_FIELD_URL, fullpath,
+ TOTEM_PL_PARSER_FIELD_FILE, resolved,
TOTEM_PL_PARSER_FIELD_TITLE, title ? title : parent_title,
TOTEM_PL_PARSER_FIELD_ABSTRACT, abstract,
TOTEM_PL_PARSER_FIELD_COPYRIGHT, copyright,
@@ -83,12 +83,12 @@
TOTEM_PL_PARSER_FIELD_STARTTIME, clip_begin,
TOTEM_PL_PARSER_FIELD_DURATION, dur,
NULL);
- g_free (fullpath);
+ g_object_unref (resolved);
retval = TOTEM_PL_PARSER_RESULT_SUCCESS;
}
} else {
if (parse_smil_entry (parser,
- base, doc, node, parent_title) != FALSE)
+ base_file, doc, node, parent_title) != FALSE)
retval = TOTEM_PL_PARSER_RESULT_SUCCESS;
}
}
@@ -120,7 +120,7 @@
}
static TotemPlParserResult
-parse_smil_entries (TotemPlParser *parser, char *base, xml_node_t *doc)
+parse_smil_entries (TotemPlParser *parser, GFile *base_file, xml_node_t *doc)
{
TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_ERROR;
const char *title;
@@ -133,7 +133,7 @@
continue;
if (g_ascii_strcasecmp (node->name, "body") == 0) {
- if (parse_smil_entry (parser, base,
+ if (parse_smil_entry (parser, base_file,
doc, node, title) != FALSE) {
retval = TOTEM_PL_PARSER_RESULT_SUCCESS;
}
@@ -148,10 +148,9 @@
static TotemPlParserResult
totem_pl_parser_add_smil_with_doc (TotemPlParser *parser, GFile *file,
- GFile *_base_file, xml_node_t *doc)
+ GFile *base_file, xml_node_t *doc)
{
TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED;
- char *base;
/* If the document has no root, or no name */
if(doc->name == NULL
@@ -159,11 +158,7 @@
return TOTEM_PL_PARSER_RESULT_ERROR;
}
- base = totem_pl_parser_base_url (file);
-
- retval = parse_smil_entries (parser, base, doc);
-
- g_free (base);
+ retval = parse_smil_entries (parser, base_file, doc);
return retval;
}
Modified: trunk/plparse/totem-pl-parser-wm.c
==============================================================================
--- trunk/plparse/totem-pl-parser-wm.c (original)
+++ trunk/plparse/totem-pl-parser-wm.c Wed May 7 17:14:24 2008
@@ -164,11 +164,10 @@
}
static gboolean
-parse_asx_entry (TotemPlParser *parser, const char *base, xml_node_t *parent)
+parse_asx_entry (TotemPlParser *parser, GFile *base_file, xml_node_t *parent)
{
xml_node_t *node;
TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_SUCCESS;
- char *fullpath;
GFile *resolved;
const char *url;
const char *title, *duration, *starttime, *author;
@@ -260,14 +259,14 @@
if (url == NULL)
return TOTEM_PL_PARSER_RESULT_ERROR;
- fullpath = totem_pl_parser_resolve_url (base, url);
- resolved = g_file_new_for_uri (fullpath);
+
+ resolved = g_file_resolve_relative_path (base_file, url);
/* .asx files can contain references to other .asx files */
retval = totem_pl_parser_parse_internal (parser, resolved, NULL);
if (retval != TOTEM_PL_PARSER_RESULT_SUCCESS) {
totem_pl_parser_add_url (parser,
- TOTEM_PL_PARSER_FIELD_URL, fullpath,
+ TOTEM_PL_PARSER_FIELD_FILE, resolved,
TOTEM_PL_PARSER_FIELD_TITLE, title,
TOTEM_PL_PARSER_FIELD_ABSTRACT, abstract,
TOTEM_PL_PARSER_FIELD_COPYRIGHT, copyright,
@@ -278,56 +277,49 @@
NULL);
retval = TOTEM_PL_PARSER_RESULT_SUCCESS;
}
- g_free (fullpath);
+ g_object_unref (resolved);
bail:
return retval;
}
static gboolean
-parse_asx_entryref (TotemPlParser *parser, const char *base, xml_node_t *node)
+parse_asx_entryref (TotemPlParser *parser, GFile *base_file, xml_node_t *node)
{
TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_SUCCESS;
const char *url;
- char *fullpath;
GFile *resolved;
- fullpath = NULL;
- url = NULL;
-
url = xml_parser_get_property (node, "href");
- if (url == NULL) {
+ if (url == NULL)
return TOTEM_PL_PARSER_RESULT_ERROR;
- }
- fullpath = totem_pl_parser_resolve_url (base, url);
- resolved = g_file_new_for_uri (fullpath);
+ resolved = g_file_resolve_relative_path (base_file, url);
/* .asx files can contain references to other .asx files */
retval = totem_pl_parser_parse_internal (parser, resolved, NULL);
- g_object_unref (resolved);
if (retval != TOTEM_PL_PARSER_RESULT_SUCCESS) {
totem_pl_parser_add_url (parser,
- TOTEM_PL_PARSER_FIELD_URL, fullpath,
+ TOTEM_PL_PARSER_FIELD_FILE, resolved,
NULL);
retval = TOTEM_PL_PARSER_RESULT_SUCCESS;
}
- g_free (fullpath);
+ g_object_unref (resolved);
return retval;
}
//FIXME the retval is completely wrong
static gboolean
-parse_asx_entries (TotemPlParser *parser, const char *url, const char *_base, xml_node_t *parent)
+parse_asx_entries (TotemPlParser *parser, const char *url, GFile *base_file, xml_node_t *parent)
{
char *title = NULL;
- const char *newbase = NULL, *base = NULL;
+ GFile *new_base;
xml_node_t *node;
TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_ERROR;
- base = _base;
+ new_base = NULL;
for (node = parent->child; node != NULL; node = node->next) {
if (node->name == NULL)
@@ -343,27 +335,33 @@
NULL);
}
if (g_ascii_strcasecmp (node->name, "base") == 0) {
- newbase = xml_parser_get_property (node, "href");
- if (newbase != NULL)
- base = newbase;
+ const char *str;
+ str = xml_parser_get_property (node, "href");
+ if (str != NULL) {
+ if (new_base != NULL)
+ g_object_unref (new_base);
+ new_base = g_file_new_for_uri (str);
+ }
}
if (g_ascii_strcasecmp (node->name, "entry") == 0) {
/* Whee! found an entry here, find the REF and TITLE */
- if (parse_asx_entry (parser, base, node) != FALSE)
+ if (parse_asx_entry (parser, new_base ? new_base : base_file, node) != FALSE)
retval = TOTEM_PL_PARSER_RESULT_SUCCESS;
}
if (g_ascii_strcasecmp (node->name, "entryref") == 0) {
/* Found an entryref, extract the REF attribute */
- if (parse_asx_entryref (parser, base, node) != FALSE)
+ if (parse_asx_entryref (parser, new_base ? new_base : base_file, node) != FALSE)
retval = TOTEM_PL_PARSER_RESULT_SUCCESS;
}
if (g_ascii_strcasecmp (node->name, "repeat") == 0) {
/* Repeat at the top-level */
- if (parse_asx_entries (parser, url, base, node) != FALSE)
+ if (parse_asx_entries (parser, url, new_base ? new_base : base_file, node) != FALSE)
retval = TOTEM_PL_PARSER_RESULT_SUCCESS;
}
}
+ if (new_base != NULL)
+ g_object_unref (new_base);
if (title != NULL)
totem_pl_parser_playlist_end (parser, url);
g_free (title);
@@ -378,7 +376,7 @@
gpointer data)
{
xml_node_t* doc;
- char *contents, *url, *base;
+ char *contents, *url;
gsize size;
TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED;
@@ -402,13 +400,11 @@
return TOTEM_PL_PARSER_RESULT_ERROR;
}
- base = g_file_get_uri (base_file);
url = g_file_get_uri (file);
- if (parse_asx_entries (parser, url, base, doc) != FALSE)
+ if (parse_asx_entries (parser, url, base_file, doc) != FALSE)
retval = TOTEM_PL_PARSER_RESULT_SUCCESS;
- g_free (base);
g_free (url);
g_free (contents);
xml_parser_free_tree (doc);
Modified: trunk/plparse/totem-pl-parser-xspf.c
==============================================================================
--- trunk/plparse/totem-pl-parser-xspf.c (original)
+++ trunk/plparse/totem-pl-parser-xspf.c Wed May 7 17:14:24 2008
@@ -43,13 +43,13 @@
#define SAFE_FREE(x) { if (x != NULL) xmlFree (x); }
static xmlDocPtr
-totem_pl_parser_parse_xml_file (const char *url)
+totem_pl_parser_parse_xml_file (GFile *file)
{
xmlDocPtr doc;
char *contents;
- int size;
+ gsize size;
- 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 NULL;
/* Try to remove HTML style comments */
@@ -77,11 +77,10 @@
gboolean
totem_pl_parser_write_xspf (TotemPlParser *parser, GtkTreeModel *model,
TotemPlParserIterFunc func,
- const char *output, const char *title,
+ GFile *output, const char *title,
gpointer user_data, GError **error)
{
- GnomeVFSHandle *handle;
- GnomeVFSResult res;
+ GFileOutputStream *stream;
int num_entries_total, num_entries, i;
char *buf;
gboolean success;
@@ -89,34 +88,17 @@
num_entries = totem_pl_parser_num_entries (parser, model, func, user_data);
num_entries_total = gtk_tree_model_iter_n_children (model, NULL);
- res = gnome_vfs_open (&handle, output, GNOME_VFS_OPEN_WRITE);
- if (res == GNOME_VFS_ERROR_NOT_FOUND) {
- res = gnome_vfs_create (&handle, output,
- GNOME_VFS_OPEN_WRITE, FALSE,
- GNOME_VFS_PERM_USER_WRITE
- | GNOME_VFS_PERM_USER_READ
- | GNOME_VFS_PERM_GROUP_READ);
- }
-
- if (res != GNOME_VFS_OK) {
- g_set_error(error,
- TOTEM_PL_PARSER_ERROR,
- TOTEM_PL_PARSER_ERROR_VFS_OPEN,
- _("Couldn't open file '%s': %s"),
- output, gnome_vfs_result_to_string (res));
+ stream = g_file_replace (output, NULL, FALSE, G_FILE_CREATE_NONE, NULL, error);
+ if (stream == NULL)
return FALSE;
- }
buf = g_strdup_printf ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\">\n"
" <trackList>\n");
- success = totem_pl_parser_write_string (handle, buf, error);
+ success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
g_free (buf);
if (success == FALSE)
- {
- gnome_vfs_close (handle);
return FALSE;
- }
for (i = 1; i <= num_entries_total; i++) {
GtkTreeIter iter;
@@ -139,14 +121,12 @@
url_escaped = g_markup_escape_text (relative ? relative : url, -1);
buf = g_strdup_printf (" <track>\n"
" <location>%s</location>\n", url_escaped);
- success = totem_pl_parser_write_string (handle, buf, error);
+ success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
g_free (url);
g_free (url_escaped);
g_free (relative);
g_free (buf);
- if (success == FALSE)
- {
- gnome_vfs_close (handle);
+ if (success == FALSE) {
g_free (title);
return FALSE;
}
@@ -157,36 +137,33 @@
else
buf = g_strdup_printf (" </track>\n");
- success = totem_pl_parser_write_string (handle, buf, error);
+ success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
g_free (buf);
g_free (title);
if (success == FALSE)
- {
- gnome_vfs_close (handle);
return FALSE;
- }
}
buf = g_strdup_printf (" </trackList>\n"
"</playlist>");
- success = totem_pl_parser_write_string (handle, buf, error);
+ success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
g_free (buf);
- gnome_vfs_close (handle);
+
+ g_output_stream_close (G_OUTPUT_STREAM (stream), NULL, NULL);
return success;
}
static gboolean
-parse_xspf_track (TotemPlParser *parser, char *base, xmlDocPtr doc,
+parse_xspf_track (TotemPlParser *parser, GFile *base_file, xmlDocPtr doc,
xmlNodePtr parent)
{
xmlNodePtr node;
xmlChar *title, *url, *image_url, *artist, *album, *duration, *moreinfo;
xmlChar *download_url, *id;
- char *fullpath;
+ GFile *resolved;
TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_ERROR;
- fullpath = NULL;
title = NULL;
url = NULL;
image_url = NULL;
@@ -238,9 +215,9 @@
goto bail;
}
- fullpath = totem_pl_parser_resolve_url (base, (char *)url);
+ resolved = g_file_resolve_relative_path (base_file, (const char *) url);
totem_pl_parser_add_url (parser,
- TOTEM_PL_PARSER_FIELD_URL, fullpath,
+ TOTEM_PL_PARSER_FIELD_FILE, resolved,
TOTEM_PL_PARSER_FIELD_TITLE, title,
TOTEM_PL_PARSER_FIELD_DURATION_MS, duration,
TOTEM_PL_PARSER_FIELD_IMAGE_URL, image_url,
@@ -250,6 +227,7 @@
TOTEM_PL_PARSER_FIELD_DOWNLOAD_URL, download_url,
TOTEM_PL_PARSER_FIELD_ID, id,
NULL);
+ g_object_unref (resolved);
retval = TOTEM_PL_PARSER_RESULT_SUCCESS;
@@ -261,13 +239,12 @@
SAFE_FREE (album);
SAFE_FREE (duration);
SAFE_FREE (moreinfo);
- g_free (fullpath);
return retval;
}
static gboolean
-parse_xspf_trackList (TotemPlParser *parser, char *base, xmlDocPtr doc,
+parse_xspf_trackList (TotemPlParser *parser, GFile *base_file, xmlDocPtr doc,
xmlNodePtr parent)
{
xmlNodePtr node;
@@ -279,7 +256,7 @@
continue;
if (g_ascii_strcasecmp ((char *)node->name, "track") == 0)
- if (parse_xspf_track (parser, base, doc, node) != FALSE)
+ if (parse_xspf_track (parser, base_file, doc, node) != FALSE)
retval = TOTEM_PL_PARSER_RESULT_SUCCESS;
}
@@ -287,7 +264,7 @@
}
static gboolean
-parse_xspf_entries (TotemPlParser *parser, char *base, xmlDocPtr doc,
+parse_xspf_entries (TotemPlParser *parser, GFile *base_file, xmlDocPtr doc,
xmlNodePtr parent)
{
xmlNodePtr node;
@@ -298,7 +275,7 @@
continue;
if (g_ascii_strcasecmp ((char *)node->name, "trackList") == 0)
- if (parse_xspf_trackList (parser, base, doc, node) != FALSE)
+ if (parse_xspf_trackList (parser, base_file, doc, node) != FALSE)
retval = TOTEM_PL_PARSER_RESULT_SUCCESS;
}
@@ -308,16 +285,14 @@
TotemPlParserResult
totem_pl_parser_add_xspf (TotemPlParser *parser,
GFile *file,
- GFile *_base_file,
+ GFile *base_file,
gpointer data)
{
-#if 0
xmlDocPtr doc;
xmlNodePtr node;
- char *base;
TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED;
- doc = totem_pl_parser_parse_xml_file (url);
+ doc = totem_pl_parser_parse_xml_file (file);
/* If the document has no root, or no name */
if(!doc || !doc->children
@@ -329,16 +304,13 @@
return TOTEM_PL_PARSER_RESULT_ERROR;
}
- base = totem_pl_parser_base_url (url);
-
- for (node = doc->children; node != NULL; node = node->next)
- if (parse_xspf_entries (parser, base, doc, node) != FALSE)
+ for (node = doc->children; node != NULL; node = node->next) {
+ if (parse_xspf_entries (parser, base_file, doc, node) != FALSE)
retval = TOTEM_PL_PARSER_RESULT_SUCCESS;
+ }
- 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 Wed May 7 17:14:24 2008
@@ -34,7 +34,7 @@
gboolean totem_pl_parser_write_xspf (TotemPlParser *parser,
GtkTreeModel *model,
TotemPlParserIterFunc func,
- const char *output,
+ GFile *output,
const char *title,
gpointer user_data,
GError **error);
Modified: trunk/plparse/totem-pl-parser.c
==============================================================================
--- trunk/plparse/totem-pl-parser.c (original)
+++ trunk/plparse/totem-pl-parser.c Wed May 7 17:14:24 2008
@@ -887,26 +887,32 @@
TotemPlParserType type,
gpointer user_data, GError **error)
{
+ GFile *file;
+
+ file = g_file_new_for_commandline_arg (output);
+
switch (type)
{
case TOTEM_PL_PARSER_PLS:
return totem_pl_parser_write_pls (parser, model, func,
- output, title, user_data, error);
+ file, title, user_data, error);
case TOTEM_PL_PARSER_M3U:
case TOTEM_PL_PARSER_M3U_DOS:
return totem_pl_parser_write_m3u (parser, model, func,
- output, (type == TOTEM_PL_PARSER_M3U_DOS),
+ file, (type == TOTEM_PL_PARSER_M3U_DOS),
user_data, error);
case TOTEM_PL_PARSER_XSPF:
return totem_pl_parser_write_xspf (parser, model, func,
- output, title, user_data, error);
+ file, title, user_data, error);
case TOTEM_PL_PARSER_IRIVER_PLA:
return totem_pl_parser_write_pla (parser, model, func,
- output, title, user_data, error);
+ file, title, user_data, error);
default:
g_assert_not_reached ();
}
+ g_object_unref (file);
+
return FALSE;
}
@@ -1133,6 +1139,21 @@
g_value_unset (&value);
name = va_arg (var_args, char*);
continue;
+ } else if (strcmp (name, TOTEM_PL_PARSER_FIELD_BASE_FILE) == 0) {
+ GFile *file;
+ char *base_url;
+
+ file = g_value_get_object (&value);
+ base_url = g_file_get_uri (file);
+ g_object_unref (file);
+
+ g_hash_table_insert (metadata,
+ g_strdup (TOTEM_PL_PARSER_FIELD_BASE),
+ base_url);
+
+ 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);
@@ -1241,120 +1262,6 @@
NULL);
}
-static char *
-totem_pl_parser_remove_filename (const char *url)
-{
- 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);
-
- /* Remove parameters */
- qmark = strrchr (no_frag, '?');
- 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;
-}
-
-static gboolean
-totem_pl_parser_might_be_file (const char *url)
-{
- char *content_type;
-
- 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, UNKNOWN_TYPE) == 0)
- return FALSE;
- return TRUE;
-}
-
-/**
- * totem_pl_parser_resolve_url:
- * @base: a base path and filename
- * @url: a URI
- *
- * Returns the absolute URI of @url, resolving any relative
- * paths with respect to @base.
- *
- * <emphasis>See totem_pl_parser_relative() to convert from absolute URLs
- * to relative URLs.</emphasis>
- *
- * Return value: a newly-allocated resolved URL
- **/
-char *
-totem_pl_parser_resolve_url (const char *base, const char *url)
-{
- //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));
-
- /* If the URI isn't relative, just leave */
- if (strstr (url, "://") != NULL)
- return g_strdup (url);
-
- /* Strip fragment and filename */
- base_no_frag = totem_pl_parser_remove_filename (base);
- 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) {
- GnomeVFSURI *new;
-
- new = gnome_vfs_uri_new (base_no_frag);
- base_uri = gnome_vfs_uri_get_parent (new);
- gnome_vfs_uri_unref (new);
- } else if (url[0] != '/') {
- char *newbase = g_strdup_printf ("%s/", base_no_frag);
- base_uri = gnome_vfs_uri_new (newbase);
- g_free (newbase);
- } else {
- base_uri = gnome_vfs_uri_new (base_no_frag);
- }
- g_free (base_no_frag);
-
- g_return_val_if_fail (base_uri != NULL, g_strdup (url));
-
- if (url[0] == '/')
- new = gnome_vfs_uri_resolve_symbolic_link (base_uri, url);
- else
- new = gnome_vfs_uri_append_path (base_uri, url);
-
- g_return_val_if_fail (new != NULL, g_strdup (url));
- gnome_vfs_uri_unref (base_uri);
- resolved = gnome_vfs_uri_to_string (new, GNOME_VFS_URI_HIDE_NONE);
- gnome_vfs_uri_unref (new);
-
- return resolved;
-#endif
-}
-
static PlaylistTypes ignore_types[] = {
PLAYLIST_TYPE3 ("image/*"),
PLAYLIST_TYPE3 ("text/plain"),
Modified: trunk/plparse/totem-pl-parser.h
==============================================================================
--- trunk/plparse/totem-pl-parser.h (original)
+++ trunk/plparse/totem-pl-parser.h Wed May 7 17:14:24 2008
@@ -326,7 +326,6 @@
gint64 totem_pl_parser_parse_duration (const char *duration, gboolean debug);
guint64 totem_pl_parser_parse_date (const char *date_str, gboolean debug);
-char *totem_pl_parser_resolve_url (const char *base, const char *url);
gboolean totem_pl_parser_write (TotemPlParser *parser, GtkTreeModel *model,
TotemPlParserIterFunc func,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]