annotate src/xspf/xspf.c @ 1444:3b1651d37b58

xspf: update to new API
author William Pitcock <nenolod@atheme-project.org>
date Fri, 10 Aug 2007 10:27:13 -0500
parents 761e17b23e0c
children 6edbd225b100
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
1 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
2 * Audacious: A cross-platform multimedia player
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
3 * Copyright (c) 2006 William Pitcock, Tony Vroon, George Averill,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
4 * Giacomo Lozito, Derek Pomery and Yoshiki Yazawa.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
5 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
9 * (at your option) any later version.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
10 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
14 * GNU General Public License for more details.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
15 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
19 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
20
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
21 #include <config.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
22
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
23 #include <glib.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
24 #include <string.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
25 #include <stdlib.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
26 #include <time.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
27
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
28 #include <unistd.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
29 #include <sys/types.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
30 #include <sys/stat.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
31 #include <sys/errno.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
32
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
33 #include "audacious/main.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
34 #include "audacious/util.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
35 #include "audacious/playlist.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
36 #include "audacious/playlist_container.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
37 #include "audacious/plugin.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
38
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
39 #include <libxml/tree.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
40 #include <libxml/parser.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
41 #include <libxml/xmlreader.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
42 #include <libxml/xpath.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
43 #include <libxml/xpathInternals.h>
641
3f0a3c24f2b9 [svn] libxspf improvements:
yaz
parents: 585
diff changeset
44 #include <libxml/uri.h>
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
45
641
3f0a3c24f2b9 [svn] libxspf improvements:
yaz
parents: 585
diff changeset
46 #define XSPF_ROOT_NODE_NAME "playlist"
3f0a3c24f2b9 [svn] libxspf improvements:
yaz
parents: 585
diff changeset
47 #define XSPF_XMLNS "http://xspf.org/ns/0/"
47
85d7e55b29d2 [svn] - redundant metadata has been removed.
yaz
parents: 12
diff changeset
48
85d7e55b29d2 [svn] - redundant metadata has been removed.
yaz
parents: 12
diff changeset
49 #define TMP_BUF_LEN 128
85d7e55b29d2 [svn] - redundant metadata has been removed.
yaz
parents: 12
diff changeset
50
641
3f0a3c24f2b9 [svn] libxspf improvements:
yaz
parents: 585
diff changeset
51 gchar *base = NULL;
3f0a3c24f2b9 [svn] libxspf improvements:
yaz
parents: 585
diff changeset
52
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
53 static gboolean is_uri(gchar *uri)
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
54 {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
55 if(strstr(uri, "://"))
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
56 return TRUE;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
57 else
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
58 return FALSE;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
59 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
60
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
61 #if 0
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
62 static gboolean is_remote(gchar *uri)
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
63 {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
64 if(strstr(uri, "file://"))
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
65 return FALSE;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
66
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
67 if(strstr(uri, "://"))
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
68 return TRUE;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
69 else
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
70 return FALSE;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
71 }
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
72 #endif
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
73
652
7f865e3cd285 [svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents: 647
diff changeset
74 // this function is taken from libxml2-2.6.27.
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
75 static xmlChar *audPathToURI(const xmlChar *path)
652
7f865e3cd285 [svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents: 647
diff changeset
76 {
7f865e3cd285 [svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents: 647
diff changeset
77 xmlURIPtr uri;
7f865e3cd285 [svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents: 647
diff changeset
78 xmlURI temp;
7f865e3cd285 [svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents: 647
diff changeset
79 xmlChar *ret, *cal;
7f865e3cd285 [svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents: 647
diff changeset
80
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
81 if(path == NULL)
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
82 return NULL;
652
7f865e3cd285 [svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents: 647
diff changeset
83
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
84 if((uri = xmlParseURI((const char *)path)) != NULL) {
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
85 xmlFreeURI(uri);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
86 return xmlStrdup(path);
652
7f865e3cd285 [svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents: 647
diff changeset
87 }
7f865e3cd285 [svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents: 647
diff changeset
88 cal = xmlCanonicPath(path);
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
89 if(cal == NULL)
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
90 return NULL;
652
7f865e3cd285 [svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents: 647
diff changeset
91 memset(&temp, 0, sizeof(temp));
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
92 temp.path = (char *)cal;
652
7f865e3cd285 [svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents: 647
diff changeset
93 ret = xmlSaveUri(&temp);
7f865e3cd285 [svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents: 647
diff changeset
94 xmlFree(cal);
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
95 return ret;
652
7f865e3cd285 [svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents: 647
diff changeset
96 }
7f865e3cd285 [svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents: 647
diff changeset
97
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
98 static void add_file(xmlNode *track, const gchar *filename, gint pos)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
99 {
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
100 xmlNode *nptr;
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
101 Tuple *tuple;
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
102 gchar *location = NULL;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
103 Playlist *playlist = playlist_get_active();
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
104
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
105 tuple = tuple_new();
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
106
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
107 tuple_associate_int(tuple, "length", -1);
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
108 tuple_associate_int(tuple, "mtime", -1); // mark as uninitialized.
641
3f0a3c24f2b9 [svn] libxspf improvements:
yaz
parents: 585
diff changeset
109
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
110 // creator, album, title, duration, trackNum, annotation, image,
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
111 for(nptr = track->children; nptr != NULL; nptr = nptr->next) {
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
112 if(nptr->type == XML_ELEMENT_NODE
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
113 && !xmlStrcmp(nptr->name, (xmlChar *)"location")) {
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
114 gchar *str = (gchar *)xmlNodeGetContent(nptr);
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
115 gchar *tmp = NULL;
657
f46c9abe09d4 [svn] - do not unescape streaming uri.
yaz
parents: 652
diff changeset
116
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
117 // tmp is escaped uri or a part of escaped uri.
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
118 tmp = g_strdup_printf("%s%s", base ? base : "", str);
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
119 location = g_filename_from_uri(tmp, NULL, NULL);
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
120 if(!location) // http:// or something.
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
121 location = g_strdup(tmp);
1211
38b9c5765929 Remove workarounds for non-VFS compliant plugins. URIs are now mandatory.
William Pitcock <nenolod@atheme-project.org>
parents: 1145
diff changeset
122
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
123 xmlFree(str); str = NULL;
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
124 g_free(tmp); tmp = NULL;
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
125 }
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
126 else if(nptr->type == XML_ELEMENT_NODE
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
127 && !xmlStrcmp(nptr->name, (xmlChar *)"title")) {
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
128 xmlChar *str = xmlNodeGetContent(nptr);
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
129 tuple_associate_string(tuple, "title", (gchar *) str);
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
130 xmlFree(str);
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
131 }
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
132 else if(nptr->type == XML_ELEMENT_NODE
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
133 && !xmlStrcmp(nptr->name, (xmlChar *)"creator")) {
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
134 xmlChar *str = xmlNodeGetContent(nptr);
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
135 tuple_associate_string(tuple, "artist", (gchar *) str);
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
136 xmlFree(str);
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
137 }
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
138 else if(nptr->type == XML_ELEMENT_NODE
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
139 && !xmlStrcmp(nptr->name, (xmlChar *)"annotation")) {
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
140 xmlChar *str = xmlNodeGetContent(nptr);
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
141 tuple_associate_string(tuple, "comment", (gchar *) str);
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
142 xmlFree(str);
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
143 }
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
144 else if(nptr->type == XML_ELEMENT_NODE
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
145 && !xmlStrcmp(nptr->name, (xmlChar *)"album")) {
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
146 xmlChar *str = xmlNodeGetContent(nptr);
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
147 tuple_associate_string(tuple, "album", (gchar *) str);
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
148 xmlFree(str);
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
149 }
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
150 else if(nptr->type == XML_ELEMENT_NODE
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
151 && !xmlStrcmp(nptr->name, (xmlChar *)"trackNum")) {
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
152 xmlChar *str = xmlNodeGetContent(nptr);
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
153 tuple_associate_int(tuple, "track-number", atol((char *)str));
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
154 xmlFree(str);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
155 }
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
156 else if(nptr->type == XML_ELEMENT_NODE
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
157 && !xmlStrcmp(nptr->name, (xmlChar *)"duration")) {
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
158 xmlChar *str = xmlNodeGetContent(nptr);
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
159 tuple_associate_int(tuple, "length", atol((char *)str));
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
160 xmlFree(str);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
161 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
162
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
163 //
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
164 // additional metadata
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
165 //
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
166 // year, date, genre, formatter, mtime
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
167 //
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
168 else if(nptr->type == XML_ELEMENT_NODE
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
169 && !xmlStrcmp(nptr->name, (xmlChar *)"meta")) {
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
170 xmlChar *rel = NULL;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
171
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
172 rel = xmlGetProp(nptr, (xmlChar *)"rel");
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
173
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
174 if(!xmlStrcmp(rel, (xmlChar *)"year")) {
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
175 xmlChar *cont = xmlNodeGetContent(nptr);
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
176 tuple_associate_int(tuple, "year", atol((char *)cont));
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
177 xmlFree(cont);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
178 continue;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
179 }
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
180 else if(!xmlStrcmp(rel, (xmlChar *)"date")) {
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
181 xmlChar *cont = xmlNodeGetContent(nptr);
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
182 tuple_associate_string(tuple, "date", (gchar *) cont);
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
183 xmlFree(cont);
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
184 continue;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
185 }
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
186 else if(!xmlStrcmp(rel, (xmlChar *)"genre")) {
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
187 xmlChar *cont = xmlNodeGetContent(nptr);
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
188 tuple_associate_string(tuple, "genre", (gchar *) cont);
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
189 xmlFree(cont);
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
190 continue;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
191 }
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
192 else if(!xmlStrcmp(rel, (xmlChar *)"formatter")) {
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
193 xmlChar *cont = xmlNodeGetContent(nptr);
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
194 tuple_associate_string(tuple, "formatter", (gchar *) cont);
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
195 xmlFree(cont);
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
196 continue;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
197 }
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
198 else if(!xmlStrcmp(rel, (xmlChar *)"mtime")) {
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
199 xmlChar *str = NULL;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
200 str = xmlNodeGetContent(nptr);
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
201 tuple_associate_int(tuple, "mtime", atoll((char *)str));
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
202 xmlFree(str);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
203 continue;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
204 }
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
205 xmlFree(rel);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
206 rel = NULL;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
207 }
87
fabe64e89949 [svn] - mtime=-1 has been introduced to represent "uninitialized".
yaz
parents: 47
diff changeset
208
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
209 }
47
85d7e55b29d2 [svn] - redundant metadata has been removed.
yaz
parents: 12
diff changeset
210
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
211 if(location) {
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
212 gchar *uri = NULL;
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
213 gchar *scratch;
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
214
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
215 scratch = g_path_get_basename(location);
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
216 tuple_associate_string(tuple, "file-name", scratch);
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
217 g_free(scratch);
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
218
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
219 scratch = g_path_get_dirname(location);
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
220 tuple_associate_string(tuple, "file-path", scratch);
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
221 g_free(scratch);
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
222
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
223 #ifdef DEBUG
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
224 printf("xspf: tuple->file_name = %s\n", tuple_get_string(tuple, "file-name"));
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
225 printf("xspf: tuple->file_path = %s\n", tuple_get_string(tuple, "file-path"));
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
226 #endif
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
227 tuple_associate_string(tuple, "file-ext", strrchr(location, '.'));
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
228 // add file to playlist
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
229 uri = g_filename_to_uri(location, NULL, NULL);
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
230 // uri would be NULL if location is already uri. --yaz
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
231 playlist_load_ins_file_tuple(playlist, uri ? uri: location, filename, pos, tuple);
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
232 g_free(uri); uri = NULL;
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
233 pos++;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
234 }
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
235
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
236 g_free(location);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
237 location = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
238 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
239
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
240 static void find_track(xmlNode *tracklist, const gchar *filename, gint pos)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
241 {
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
242 xmlNode *nptr;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
243 for(nptr = tracklist->children; nptr != NULL; nptr = nptr->next) {
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
244 if(nptr->type == XML_ELEMENT_NODE
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
245 && !xmlStrcmp(nptr->name, (xmlChar *)"track")) {
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
246 add_file(nptr, filename, pos);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
247 }
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
248 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
249 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
250
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
251 static void find_audoptions(xmlNode *tracklist, const gchar *filename, gint pos)
641
3f0a3c24f2b9 [svn] libxspf improvements:
yaz
parents: 585
diff changeset
252 {
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
253 xmlNode *nptr;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
254 Playlist *playlist = playlist_get_active();
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
255
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
256 for(nptr = tracklist->children; nptr != NULL; nptr = nptr->next) {
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
257 if(nptr->type == XML_ELEMENT_NODE
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
258 && !xmlStrcmp(nptr->name, (xmlChar *)"options")) {
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
259 xmlChar *opt = NULL;
884
4fd90f2d1832 [svn] improve support for static playlist:
yaz
parents: 657
diff changeset
260
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
261 opt = xmlGetProp(nptr, (xmlChar *)"staticlist");
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
262 if(!strcasecmp((char *)opt, "true")) {
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
263 playlist->attribute |= PLAYLIST_STATIC;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
264 }
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
265 else
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
266 playlist->attribute ^= PLAYLIST_STATIC;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
267 xmlFree(opt);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
268 opt = NULL;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
269 }
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
270 }
641
3f0a3c24f2b9 [svn] libxspf improvements:
yaz
parents: 585
diff changeset
271 }
3f0a3c24f2b9 [svn] libxspf improvements:
yaz
parents: 585
diff changeset
272
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
273 static void playlist_load_xspf(const gchar *filename, gint pos)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
274 {
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
275 xmlDocPtr doc;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
276 xmlNode *nptr, *nptr2;
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
277 gchar *tmp = NULL;
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
278
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
279 g_return_if_fail(filename != NULL);
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
280 #ifdef DEBUG
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
281 printf("playlist_load_xspf: filename = %s\n", filename);
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
282 #endif
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
283 doc = xmlParseFile(filename);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
284 if(doc == NULL)
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
285 return;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
286
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
287 xmlFree(base);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
288 base = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
289
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
290 // find trackList
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
291 for(nptr = doc->children; nptr != NULL; nptr = nptr->next) {
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
292 if(nptr->type == XML_ELEMENT_NODE
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
293 && !xmlStrcmp(nptr->name, (xmlChar *)"playlist")) {
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
294 base = (gchar *)xmlNodeGetBase(doc, nptr);
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
295 #ifdef DEBUG
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
296 printf("playlist_load_xspf: base @1 = %s\n", base);
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
297 #endif
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
298 // if filename is specified as a base, ignore it.
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
299 tmp = xmlURIUnescapeString(base, -1, NULL);
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
300 if(tmp) {
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
301 if(!strcmp(tmp, filename)) {
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
302 xmlFree(base);
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
303 base = NULL;
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
304 }
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
305 g_free(tmp);
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
306 tmp = NULL;
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
307 }
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
308 #ifdef DEBUG
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
309 printf("playlist_load_xspf: base @2 = %s\n", base);
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
310 #endif
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
311 for(nptr2 = nptr->children; nptr2 != NULL; nptr2 = nptr2->next) {
641
3f0a3c24f2b9 [svn] libxspf improvements:
yaz
parents: 585
diff changeset
312
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
313 if(nptr2->type == XML_ELEMENT_NODE
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
314 && !xmlStrcmp(nptr2->name, (xmlChar *)"extension")) {
641
3f0a3c24f2b9 [svn] libxspf improvements:
yaz
parents: 585
diff changeset
315 //check if application is audacious
3f0a3c24f2b9 [svn] libxspf improvements:
yaz
parents: 585
diff changeset
316 xmlChar *app = NULL;
3f0a3c24f2b9 [svn] libxspf improvements:
yaz
parents: 585
diff changeset
317 app = xmlGetProp(nptr2, (xmlChar *)"application");
3f0a3c24f2b9 [svn] libxspf improvements:
yaz
parents: 585
diff changeset
318 if(!xmlStrcmp(app, (xmlChar *)"audacious")) {
3f0a3c24f2b9 [svn] libxspf improvements:
yaz
parents: 585
diff changeset
319 find_audoptions(nptr2, filename, pos);
3f0a3c24f2b9 [svn] libxspf improvements:
yaz
parents: 585
diff changeset
320 }
3f0a3c24f2b9 [svn] libxspf improvements:
yaz
parents: 585
diff changeset
321 xmlFree(app);
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
322 }
641
3f0a3c24f2b9 [svn] libxspf improvements:
yaz
parents: 585
diff changeset
323
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
324 if(nptr2->type == XML_ELEMENT_NODE
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
325 && !xmlStrcmp(nptr2->name, (xmlChar *)"trackList")) {
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
326 find_track(nptr2, filename, pos);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
327 }
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
328 }
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
329 }
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
330 }
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
331 xmlFreeDoc(doc);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
332 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
333
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
334 static void playlist_save_xspf(const gchar *filename, gint pos)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
335 {
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
336 xmlDocPtr doc;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
337 xmlNodePtr rootnode, tmp, tracklist;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
338 GList *node;
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
339 gint baselen = 0;
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
340 Playlist *playlist = playlist_get_active();
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
341
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
342 #ifdef DEBUG
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
343 printf("playlist_save_xspf: filename = %s\n", filename);
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
344 #endif
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
345 xmlFree(base);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
346 base = NULL;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
347
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
348 doc = xmlNewDoc((xmlChar *)"1.0");
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
349
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
350 doc->charset = XML_CHAR_ENCODING_UTF8;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
351 doc->encoding = xmlStrdup((xmlChar *)"UTF-8");
585
2d20bc58a290 [svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents: 577
diff changeset
352
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
353 rootnode = xmlNewNode(NULL, (xmlChar *)XSPF_ROOT_NODE_NAME);
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
354 xmlSetProp(rootnode, (xmlChar *)"version", (xmlChar *)"1");
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
355 xmlSetProp(rootnode, (xmlChar *)"xmlns", (xmlChar *)XSPF_XMLNS);
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
356
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
357 PLAYLIST_LOCK(playlist->mutex);
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
358
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
359 /* relative */
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
360 if(playlist->attribute & PLAYLIST_USE_RELATIVE) {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
361 /* prescan to determine base uri */
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
362 for(node = playlist->entries; node != NULL; node = g_list_next(node)) {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
363 gchar *ptr1, *ptr2;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
364 PlaylistEntry *entry = PLAYLIST_ENTRY(node->data);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
365 gchar *tmp;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
366 gint tmplen = 0;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
367
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
368 if(!is_uri(entry->filename)) { //obsolete
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
369 gchar *tmp2;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
370 tmp2 = g_path_get_dirname(entry->filename);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
371 tmp = g_strdup_printf("%s/", tmp2);
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
372 g_free(tmp2); tmp2 = NULL;
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
373 }
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
374 else { //uri
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
375 tmp = g_strdup(entry->filename);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
376 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
377
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
378 if(!base) {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
379 base = strdup(tmp);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
380 baselen = strlen(base);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
381 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
382 ptr1 = base;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
383 ptr2 = tmp;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
384
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
385 while(ptr1 && ptr2 && *ptr1 && *ptr2 && *ptr1 == *ptr2) {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
386 ptr1++;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
387 ptr2++;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
388 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
389 *ptr2 = '\0'; //terminate
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
390 tmplen = ptr2 - tmp;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
391
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
392 if(tmplen <= baselen) {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
393 g_free(base);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
394 base = tmp;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
395 baselen = tmplen;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
396 #ifdef DEBUG
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
397 printf("base = \"%s\" baselen = %d\n", base, baselen);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
398 #endif
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
399 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
400 else {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
401 g_free(tmp);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
402 tmp = NULL;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
403 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
404 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
405 /* set base URI */
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
406 if(base) {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
407 gchar *tmp;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
408 if(!is_uri(base)) {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
409 tmp = (gchar *)audPathToURI((xmlChar *)base);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
410 if(tmp) {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
411 g_free(base);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
412 base = tmp;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
413 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
414 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
415
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
416 if(!is_uri(base)) {
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
417 #ifdef DEBUG
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
418 printf("base is not uri. something is wrong.\n");
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
419 #endif
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
420 tmp = g_strdup_printf("file://%s", base);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
421 xmlSetProp(rootnode, (xmlChar *)"xml:base", (xmlChar *)tmp);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
422 g_free(tmp);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
423 tmp = NULL;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
424 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
425 else
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
426 xmlSetProp(rootnode, (xmlChar *)"xml:base", (xmlChar *)base);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
427 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
428 } /* USE_RELATIVE */
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
429
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
430 /* common */
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
431 xmlDocSetRootElement(doc, rootnode);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
432
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
433 tmp = xmlNewNode(NULL, (xmlChar *)"creator");
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
434 xmlAddChild(tmp, xmlNewText((xmlChar *)PACKAGE "-" VERSION));
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
435 xmlAddChild(rootnode, tmp);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
436
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
437 // add staticlist marker
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
438 if(playlist->attribute & PLAYLIST_STATIC) {
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
439 xmlNodePtr extension, options;
884
4fd90f2d1832 [svn] improve support for static playlist:
yaz
parents: 657
diff changeset
440
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
441 extension = xmlNewNode(NULL, (xmlChar *)"extension");
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
442 xmlSetProp(extension, (xmlChar *)"application", (xmlChar *)"audacious");
884
4fd90f2d1832 [svn] improve support for static playlist:
yaz
parents: 657
diff changeset
443
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
444 options = xmlNewNode(NULL, (xmlChar *)"options");
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
445 xmlSetProp(options, (xmlChar *)"staticlist", (xmlChar *)"true");
884
4fd90f2d1832 [svn] improve support for static playlist:
yaz
parents: 657
diff changeset
446
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
447 xmlAddChild(extension, options);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
448 xmlAddChild(rootnode, extension);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
449 }
884
4fd90f2d1832 [svn] improve support for static playlist:
yaz
parents: 657
diff changeset
450
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
451 tracklist = xmlNewNode(NULL, (xmlChar *)"trackList");
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
452 xmlAddChild(rootnode, tracklist);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
453
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
454 for(node = playlist->entries; node != NULL; node = g_list_next(node)) {
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
455 PlaylistEntry *entry = PLAYLIST_ENTRY(node->data);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
456 xmlNodePtr track, location;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
457 gchar *filename = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
458
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
459 track = xmlNewNode(NULL, (xmlChar *)"track");
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
460 location = xmlNewNode(NULL, (xmlChar *)"location");
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
461
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
462 if(is_uri(entry->filename)) { /* uri */
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
463 #ifdef DEBUG
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
464 printf("filename is uri\n");
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
465 #endif
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
466 filename = g_strdup(entry->filename + baselen); // entry->filename is always uri now.
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
467 }
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
468 else { /* local file (obsolete) */
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
469 gchar *tmp =
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
470 (gchar *)audPathToURI((const xmlChar *)entry->filename + baselen);
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
471 if(base) { /* relative */
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
472 filename = g_strdup_printf("%s", tmp);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
473 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
474 else {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
475 #ifdef DEBUG
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
476 printf("absolute and local (obsolete)\n");
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
477 #endif
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
478 filename = g_filename_to_uri(tmp, NULL, NULL);
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
479 }
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
480 g_free(tmp); tmp = NULL;
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
481 } /* obsolete */
585
2d20bc58a290 [svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents: 577
diff changeset
482
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
483 if(!g_utf8_validate(filename, -1, NULL))
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
484 continue;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
485
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
486 xmlAddChild(location, xmlNewText((xmlChar *)filename));
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
487 xmlAddChild(track, location);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
488 xmlAddChild(tracklist, track);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
489
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
490 /* do we have a tuple? */
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
491 if(entry->tuple != NULL) {
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
492 const gchar *scratch;
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
493
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
494 if((scratch = tuple_get_string(entry->tuple, "track-name")) != NULL &&
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
495 g_utf8_validate(scratch, -1, NULL)) {
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
496 tmp = xmlNewNode(NULL, (xmlChar *)"title");
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
497 xmlAddChild(tmp, xmlNewText((xmlChar *) scratch));
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
498 xmlAddChild(track, tmp);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
499 }
585
2d20bc58a290 [svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents: 577
diff changeset
500
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
501 if((scratch = tuple_get_string(entry->tuple, "artist")) != NULL &&
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
502 g_utf8_validate(scratch, -1, NULL)) {
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
503 tmp = xmlNewNode(NULL, (xmlChar *)"creator");
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
504 xmlAddChild(tmp, xmlNewText((xmlChar *) scratch));
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
505 xmlAddChild(track, tmp);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
506 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
507
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
508 if((scratch = tuple_get_string(entry->tuple, "comment")) != NULL &&
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
509 g_utf8_validate(scratch, -1, NULL)) {
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
510 tmp = xmlNewNode(NULL, (xmlChar *)"annotation");
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
511 xmlAddChild(tmp, xmlNewText((xmlChar *) scratch));
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
512 xmlAddChild(track, tmp);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
513 }
585
2d20bc58a290 [svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents: 577
diff changeset
514
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
515 if((scratch = tuple_get_string(entry->tuple, "album")) != NULL &&
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
516 g_utf8_validate(scratch, -1, NULL)) {
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
517 tmp = xmlNewNode(NULL, (xmlChar *)"album");
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
518 xmlAddChild(tmp, xmlNewText((xmlChar *) scratch));
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
519 xmlAddChild(track, tmp);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
520 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
521
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
522 if(tuple_get_int(entry->tuple, "track-number") != 0) {
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
523 gchar *str;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
524 str = g_malloc(TMP_BUF_LEN);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
525 tmp = xmlNewNode(NULL, (xmlChar *)"trackNum");
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
526 sprintf(str, "%d", tuple_get_int(entry->tuple, "track-number"));
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
527 xmlAddChild(tmp, xmlNewText((xmlChar *)str));
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
528 g_free(str);
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
529 str = NULL;
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
530 xmlAddChild(track, tmp);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
531 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
532
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
533 if(tuple_get_int(entry->tuple, "length") > 0) {
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
534 gchar *str;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
535 str = g_malloc(TMP_BUF_LEN);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
536 tmp = xmlNewNode(NULL, (xmlChar *)"duration");
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
537 sprintf(str, "%d", tuple_get_int(entry->tuple, "length"));
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
538 xmlAddChild(tmp, xmlNewText((xmlChar *) str));
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
539 g_free(str);
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
540 str = NULL;
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
541 xmlAddChild(track, tmp);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
542 }
47
85d7e55b29d2 [svn] - redundant metadata has been removed.
yaz
parents: 12
diff changeset
543
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
544 //
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
545 // additional metadata
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
546 //
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
547 // year, date, genre, formatter, mtime
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
548 //
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
549
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
550 if(tuple_get_int(entry->tuple, "year") != 0) {
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
551 gchar *str;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
552 str = g_malloc(TMP_BUF_LEN);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
553 tmp = xmlNewNode(NULL, (xmlChar *)"meta");
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
554 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"year");
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
555 sprintf(str, "%d", tuple_get_int(entry->tuple, "year"));
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
556 xmlAddChild(tmp, xmlNewText((xmlChar *)str));
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
557 xmlAddChild(track, tmp);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
558 g_free(str);
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
559 str = NULL;
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
560 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
561
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
562 if((scratch = tuple_get_string(entry->tuple, "date")) != NULL &&
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
563 g_utf8_validate(scratch, -1, NULL)) {
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
564 tmp = xmlNewNode(NULL, (xmlChar *)"meta");
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
565 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"date");
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
566 xmlAddChild(tmp, xmlNewText((xmlChar *) scratch));
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
567 xmlAddChild(track, tmp);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
568 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
569
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
570 if((scratch = tuple_get_string(entry->tuple, "genre")) != NULL &&
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
571 g_utf8_validate(scratch, -1, NULL)) {
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
572 tmp = xmlNewNode(NULL, (xmlChar *)"meta");
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
573 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"genre");
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
574 xmlAddChild(tmp, xmlNewText((xmlChar *) scratch));
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
575 xmlAddChild(track, tmp);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
576 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
577
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
578 if((scratch = tuple_get_string(entry->tuple, "formatter")) != NULL &&
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
579 g_utf8_validate(scratch, -1, NULL)) {
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
580 tmp = xmlNewNode(NULL, (xmlChar *)"meta");
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
581 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"formatter");
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
582 xmlAddChild(tmp, xmlNewText((xmlChar *) scratch));
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
583 xmlAddChild(track, tmp);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
584 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
585
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
586 // mtime: write mtime unconditionally to support staticlist.
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
587 {
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
588 gchar *str = g_malloc(TMP_BUF_LEN);
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
589 tmp = xmlNewNode(NULL, (xmlChar *)"meta");
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
590 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"mtime");
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
591 sprintf(str, "%ld", (long) tuple_get_int(entry->tuple, "mtime"));
884
4fd90f2d1832 [svn] improve support for static playlist:
yaz
parents: 657
diff changeset
592
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
593 xmlAddChild(tmp, xmlNewText((xmlChar *)str));
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
594 xmlAddChild(track, tmp);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
595 g_free(str);
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
596 str = NULL;
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
597 }
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
598
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
599 } /* tuple */
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
600 else {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
601
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
602 if(entry->title != NULL && g_utf8_validate(entry->title, -1, NULL)) {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
603 tmp = xmlNewNode(NULL, (xmlChar *)"title");
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
604 xmlAddChild(tmp, xmlNewText((xmlChar *)entry->title));
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
605 xmlAddChild(track, tmp);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
606 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
607
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
608 if(entry->length > 0) {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
609 gchar *str;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
610 str = g_malloc(TMP_BUF_LEN);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
611 tmp = xmlNewNode(NULL, (xmlChar *)"duration");
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
612 sprintf(str, "%d", entry->length);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
613 xmlAddChild(tmp, xmlNewText((xmlChar *)str));
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
614 g_free(str);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
615 str = NULL;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
616 xmlAddChild(track, tmp);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
617 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
618
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
619 /* add mtime of -1 */
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
620 {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
621 gchar *str = g_malloc(TMP_BUF_LEN);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
622 tmp = xmlNewNode(NULL, (xmlChar *)"meta");
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
623 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"mtime");
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
624 sprintf(str, "%ld", -1L);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
625
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
626 xmlAddChild(tmp, xmlNewText((xmlChar *)str));
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
627 xmlAddChild(track, tmp);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
628 g_free(str);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
629 str = NULL;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
630 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
631
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
632 } /* no tuple */
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
633
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
634 g_free(filename);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
635 filename = NULL;
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
636 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
637
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
638 PLAYLIST_UNLOCK(playlist->mutex);
92
fadf346ddde3 [svn] - pls doesn't go along with PLAYLIST_LOCK in playlist_save().
yaz
parents: 87
diff changeset
639
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
640 xmlSaveFormatFile(filename, doc, 1);
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
641 xmlFreeDoc(doc);
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
642 doc = NULL;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
643
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
644 xmlFree(base);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
645 base = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
646 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
647
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
648 PlaylistContainer plc_xspf = {
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
649 .name = "XSPF Playlist Format",
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
650 .ext = "xspf",
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
651 .plc_read = playlist_load_xspf,
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
652 .plc_write = playlist_save_xspf,
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
653 };
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
654
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
655 static void init(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
656 {
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
657 playlist_container_register(&plc_xspf);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
658 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
659
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
660 static void cleanup(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
661 {
891
502222ed5dd4 [svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents: 884
diff changeset
662 playlist_container_unregister(&plc_xspf);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
663 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
664
1395
761e17b23e0c added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents: 1278
diff changeset
665 DECLARE_PLUGIN(xspf, init, cleanup, NULL, NULL, NULL, NULL, NULL, NULL);