summaryrefslogtreecommitdiff
path: root/plparse/totem-pl-parser-wm.c
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2008-05-07 17:14:24 +0000
committerBastien Nocera <hadess@src.gnome.org>2008-05-07 17:14:24 +0000
commitb5336dc92cc2906c7da7d0138009de857d34f7a6 (patch)
treeb52e900d969c6437f33bfe265174a61baf593792 /plparse/totem-pl-parser-wm.c
parent3a796d57c5c011c51815e377d1d694826809e84b (diff)
downloadtotem-pl-parser-b5336dc92cc2906c7da7d0138009de857d34f7a6.tar.gz
Port playlist writers to GIO, removed totem_pl_parser_resolve_url and
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 svn path=/trunk/; revision=114
Diffstat (limited to 'plparse/totem-pl-parser-wm.c')
-rw-r--r--plparse/totem-pl-parser-wm.c58
1 files changed, 27 insertions, 31 deletions
diff --git a/plparse/totem-pl-parser-wm.c b/plparse/totem-pl-parser-wm.c
index 1aad8de..6c9ad7e 100644
--- a/plparse/totem-pl-parser-wm.c
+++ b/plparse/totem-pl-parser-wm.c
@@ -164,11 +164,10 @@ totem_pl_parser_add_asf_parser (TotemPlParser *parser,
}
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 @@ parse_asx_entry (TotemPlParser *parser, const char *base, xml_node_t *parent)
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 @@ parse_asx_entry (TotemPlParser *parser, const char *base, xml_node_t *parent)
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 @@ parse_asx_entries (TotemPlParser *parser, const char *url, const char *_base, xm
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 @@ totem_pl_parser_add_asx (TotemPlParser *parser,
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 @@ totem_pl_parser_add_asx (TotemPlParser *parser,
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);