annotate src/xspf/xspf.c @ 1547:b63e772ee21d

Useless use of if() with g_free().
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 01 Sep 2007 06:01:34 +0300
parents a8436c6e3753
children 78d8dd386d0b
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);
1546
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
141 tuple_associate_string(tuple, "comment", (gchar *) str);
1444
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
1512
7b1b24af319f now xspf plugin try to load non well formed xspf file. closes #969.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1462
diff changeset
283 doc = xmlRecoverFile(filename);
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
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
1528
8fddba1d94e4 xspf: When loading playlist, read title from xml if set
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1514
diff changeset
325 && !xmlStrcmp(nptr2->name, (xmlChar *)"title")) {
8fddba1d94e4 xspf: When loading playlist, read title from xml if set
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1514
diff changeset
326 Playlist *plist = playlist_get_active();
8fddba1d94e4 xspf: When loading playlist, read title from xml if set
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1514
diff changeset
327 xmlChar *title = xmlNodeGetContent(nptr2);
8fddba1d94e4 xspf: When loading playlist, read title from xml if set
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1514
diff changeset
328 if (title && *title) {
8fddba1d94e4 xspf: When loading playlist, read title from xml if set
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1514
diff changeset
329 gchar *old = plist->title;
8fddba1d94e4 xspf: When loading playlist, read title from xml if set
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1514
diff changeset
330 plist->title = g_strdup((gchar*)title);
1547
b63e772ee21d Useless use of if() with g_free().
Matti Hamalainen <ccr@tnsp.org>
parents: 1546
diff changeset
331 g_free(old);
1528
8fddba1d94e4 xspf: When loading playlist, read title from xml if set
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1514
diff changeset
332 }
8fddba1d94e4 xspf: When loading playlist, read title from xml if set
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1514
diff changeset
333 xmlFree(title);
8fddba1d94e4 xspf: When loading playlist, read title from xml if set
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1514
diff changeset
334 }
8fddba1d94e4 xspf: When loading playlist, read title from xml if set
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1514
diff changeset
335
8fddba1d94e4 xspf: When loading playlist, read title from xml if set
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1514
diff changeset
336 if(nptr2->type == XML_ELEMENT_NODE
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
337 && !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
338 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
339 }
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 }
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
341 }
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
342 }
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
343 xmlFreeDoc(doc);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
344 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
345
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
346 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
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 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
349 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
350 GList *node;
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
351 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
352 Playlist *playlist = playlist_get_active();
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
353
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
354 #ifdef DEBUG
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
355 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
356 #endif
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
357 xmlFree(base);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
358 base = NULL;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
359
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
360 doc = xmlNewDoc((xmlChar *)"1.0");
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
361
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
362 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
363 doc->encoding = xmlStrdup((xmlChar *)"UTF-8");
585
2d20bc58a290 [svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents: 577
diff changeset
364
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
365 rootnode = xmlNewNode(NULL, (xmlChar *)XSPF_ROOT_NODE_NAME);
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
366 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
367 xmlSetProp(rootnode, (xmlChar *)"xmlns", (xmlChar *)XSPF_XMLNS);
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
368
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
369 PLAYLIST_LOCK(playlist->mutex);
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
370
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
371 /* relative */
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
372 if(playlist->attribute & PLAYLIST_USE_RELATIVE) {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
373 /* prescan to determine base uri */
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
374 for(node = playlist->entries; node != NULL; node = g_list_next(node)) {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
375 gchar *ptr1, *ptr2;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
376 PlaylistEntry *entry = PLAYLIST_ENTRY(node->data);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
377 gchar *tmp;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
378 gint tmplen = 0;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
379
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
380 if(!is_uri(entry->filename)) { //obsolete
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
381 gchar *tmp2;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
382 tmp2 = g_path_get_dirname(entry->filename);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
383 tmp = g_strdup_printf("%s/", tmp2);
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
384 g_free(tmp2); tmp2 = NULL;
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
385 }
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
386 else { //uri
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
387 tmp = g_strdup(entry->filename);
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
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
390 if(!base) {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
391 base = strdup(tmp);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
392 baselen = strlen(base);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
393 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
394 ptr1 = base;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
395 ptr2 = tmp;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
396
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
397 while(ptr1 && ptr2 && *ptr1 && *ptr2 && *ptr1 == *ptr2) {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
398 ptr1++;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
399 ptr2++;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
400 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
401 *ptr2 = '\0'; //terminate
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
402 tmplen = ptr2 - tmp;
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 if(tmplen <= baselen) {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
405 g_free(base);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
406 base = tmp;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
407 baselen = tmplen;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
408 #ifdef DEBUG
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
409 printf("base = \"%s\" baselen = %d\n", base, baselen);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
410 #endif
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
411 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
412 else {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
413 g_free(tmp);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
414 tmp = NULL;
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 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
417 /* set base URI */
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
418 if(base) {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
419 gchar *tmp;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
420 if(!is_uri(base)) {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
421 tmp = (gchar *)audPathToURI((xmlChar *)base);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
422 if(tmp) {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
423 g_free(base);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
424 base = tmp;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
425 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
426 }
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 if(!is_uri(base)) {
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
429 #ifdef DEBUG
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
430 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
431 #endif
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
432 tmp = g_strdup_printf("file://%s", base);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
433 xmlSetProp(rootnode, (xmlChar *)"xml:base", (xmlChar *)tmp);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
434 g_free(tmp);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
435 tmp = NULL;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
436 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
437 else
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
438 xmlSetProp(rootnode, (xmlChar *)"xml:base", (xmlChar *)base);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
439 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
440 } /* USE_RELATIVE */
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
441
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
442 /* 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
443 xmlDocSetRootElement(doc, rootnode);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
444
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
445 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
446 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
447 xmlAddChild(rootnode, tmp);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
448
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
449 // 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
450 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
451 xmlNodePtr extension, options;
884
4fd90f2d1832 [svn] improve support for static playlist:
yaz
parents: 657
diff changeset
452
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
453 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
454 xmlSetProp(extension, (xmlChar *)"application", (xmlChar *)"audacious");
884
4fd90f2d1832 [svn] improve support for static playlist:
yaz
parents: 657
diff changeset
455
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
456 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
457 xmlSetProp(options, (xmlChar *)"staticlist", (xmlChar *)"true");
884
4fd90f2d1832 [svn] improve support for static playlist:
yaz
parents: 657
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 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
460 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
461 }
884
4fd90f2d1832 [svn] improve support for static playlist:
yaz
parents: 657
diff changeset
462
1531
10cfa5b51bce xspf: Store playlist title when saving playlist
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1528
diff changeset
463 /* save playlist title */
10cfa5b51bce xspf: Store playlist title when saving playlist
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1528
diff changeset
464 if(playlist->title && playlist->title[0]
10cfa5b51bce xspf: Store playlist title when saving playlist
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1528
diff changeset
465 && g_utf8_validate(playlist->title, -1, NULL)) {
10cfa5b51bce xspf: Store playlist title when saving playlist
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1528
diff changeset
466 xmlNodePtr title;
10cfa5b51bce xspf: Store playlist title when saving playlist
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1528
diff changeset
467 title = xmlNewNode(NULL, (xmlChar *)"title");
10cfa5b51bce xspf: Store playlist title when saving playlist
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1528
diff changeset
468 xmlAddChild(title, xmlNewText((xmlChar *)playlist->title));
10cfa5b51bce xspf: Store playlist title when saving playlist
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1528
diff changeset
469 xmlAddChild(rootnode, title);
10cfa5b51bce xspf: Store playlist title when saving playlist
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1528
diff changeset
470 }
10cfa5b51bce xspf: Store playlist title when saving playlist
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1528
diff changeset
471
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
472 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
473 xmlAddChild(rootnode, tracklist);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
474
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
475 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
476 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
477 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
478 gchar *filename = NULL;
1546
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
479 const gchar *scratch;
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
480 gchar tmps[64];
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
481 gint tmpi;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
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 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
484 location = xmlNewNode(NULL, (xmlChar *)"location");
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
485
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
486 if(is_uri(entry->filename)) { /* uri */
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
487 #ifdef DEBUG
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
488 printf("filename is uri\n");
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
489 #endif
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
490 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
491 }
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
492 else { /* local file (obsolete) */
1546
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
493 gchar *tmp = (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
494 if(base) { /* relative */
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
495 filename = g_strdup_printf("%s", tmp);
1546
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
496 } else {
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
497 #ifdef DEBUG
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
498 printf("absolute and local (obsolete)\n");
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
499 #endif
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
500 filename = g_filename_to_uri(tmp, NULL, NULL);
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
501 }
1278
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
502 g_free(tmp); tmp = NULL;
d1c66f8ccf73 adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1271
diff changeset
503 } /* obsolete */
585
2d20bc58a290 [svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents: 577
diff changeset
504
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 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
506 continue;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
507
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
508 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
509 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
510 xmlAddChild(tracklist, track);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
511
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 /* 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
513 if(entry->tuple != NULL) {
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
514
1462
6edbd225b100 playlist entry doesn't have "track-name".
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1444
diff changeset
515 if((scratch = tuple_get_string(entry->tuple, "title")) != NULL &&
1546
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
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 *)"title");
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 }
585
2d20bc58a290 [svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents: 577
diff changeset
521
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
522 if((scratch = tuple_get_string(entry->tuple, "artist")) != NULL &&
1546
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
523 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
524 tmp = xmlNewNode(NULL, (xmlChar *)"creator");
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
525 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
526 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
527 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
528
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
529 if((scratch = tuple_get_string(entry->tuple, "comment")) != NULL &&
1546
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
530 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
531 tmp = xmlNewNode(NULL, (xmlChar *)"annotation");
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
532 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
533 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
534 }
585
2d20bc58a290 [svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents: 577
diff changeset
535
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
536 if((scratch = tuple_get_string(entry->tuple, "album")) != NULL &&
1546
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
537 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
538 tmp = xmlNewNode(NULL, (xmlChar *)"album");
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
539 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
540 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
541 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
542
1546
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
543 if((tmpi = 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
544 tmp = xmlNewNode(NULL, (xmlChar *)"trackNum");
1546
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
545 g_snprintf(tmps, sizeof(tmps), "%d", tmpi);
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
546 xmlAddChild(tmp, xmlNewText((xmlChar *) tmps));
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
547 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
548 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
549
1546
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
550 if((tmpi = 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
551 tmp = xmlNewNode(NULL, (xmlChar *)"duration");
1546
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
552 g_snprintf(tmps, sizeof(tmps), "%d", tmpi);
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
553 xmlAddChild(tmp, xmlNewText((xmlChar *) tmps));
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
554 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
555 }
47
85d7e55b29d2 [svn] - redundant metadata has been removed.
yaz
parents: 12
diff changeset
556
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
557 //
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 // 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
559 //
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 // 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
561 //
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
562
1546
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
563 if((tmpi = 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
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 *)"year");
1546
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
566 g_snprintf(tmps, sizeof(tmps), "%d", tmpi);
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
567 xmlAddChild(tmp, xmlNewText((xmlChar *) tmps));
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
568 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
569 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
570
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
571 if((scratch = tuple_get_string(entry->tuple, "date")) != NULL &&
1546
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
572 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
573 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
574 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"date");
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
575 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
576 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
577 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
578
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
579 if((scratch = tuple_get_string(entry->tuple, "genre")) != NULL &&
1546
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
580 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
581 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
582 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"genre");
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
583 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
584 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
585 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
586
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
587 if((scratch = tuple_get_string(entry->tuple, "formatter")) != NULL &&
1546
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
588 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
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 *)"formatter");
1444
3b1651d37b58 xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
591 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
592 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
593 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
594
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
595 // mtime: write mtime unconditionally to support staticlist.
1546
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
596 tmp = xmlNewNode(NULL, (xmlChar *)"meta");
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
597 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"mtime");
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
598 g_snprintf(tmps, sizeof(tmps), "%ld", (long) tuple_get_int(entry->tuple, "mtime"));
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
599 xmlAddChild(tmp, xmlNewText((xmlChar *) tmps));
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
600 xmlAddChild(track, tmp);
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
601 } /* tuple */
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
602 else {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
603
1514
a8430f6ea7a2 reverted a local change on xspf that wasn't supposed to be committed
Giacomo Lozito <james@develia.org>
parents: 1513
diff changeset
604 if(entry->title != NULL && g_utf8_validate(entry->title, -1, NULL)) {
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
605 tmp = xmlNewNode(NULL, (xmlChar *)"title");
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
606 xmlAddChild(tmp, xmlNewText((xmlChar *)entry->title));
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
607 xmlAddChild(track, tmp);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
608 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
609
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
610 if(entry->length > 0) {
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
611 tmp = xmlNewNode(NULL, (xmlChar *)"duration");
1546
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
612 g_snprintf(tmps, sizeof(tmps), "%d", entry->length);
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
613 xmlAddChild(tmp, xmlNewText((xmlChar *) tmps));
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
614 xmlAddChild(track, tmp);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
615 }
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
616
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
617 /* add mtime of -1 */
1546
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
618 tmp = xmlNewNode(NULL, (xmlChar *)"meta");
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
619 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"mtime");
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
620 g_snprintf(tmps, sizeof(tmps), "%ld", -1L);
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
621 xmlAddChild(tmp, xmlNewText((xmlChar *) tmps));
a8436c6e3753 Some cleanups; Removed useless heap allocations, use a small static buffer
Matti Hamalainen <ccr@tnsp.org>
parents: 1531
diff changeset
622 xmlAddChild(track, tmp);
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
623 } /* no tuple */
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
624
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
625 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
626 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
627 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
628
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
629 PLAYLIST_UNLOCK(playlist->mutex);
92
fadf346ddde3 [svn] - pls doesn't go along with PLAYLIST_LOCK in playlist_save().
yaz
parents: 87
diff changeset
630
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
631 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
632 xmlFreeDoc(doc);
892
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
633 doc = NULL;
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
634
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
635 xmlFree(base);
d0b558bcf704 [svn] - initial support for writing relative path.
yaz
parents: 891
diff changeset
636 base = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
637 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
638
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
639 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
640 .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
641 .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
642 .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
643 .plc_write = playlist_save_xspf,
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
644 };
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
645
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
646 static void init(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
647 {
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
648 playlist_container_register(&plc_xspf);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
649 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
650
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
651 static void cleanup(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
652 {
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
653 playlist_container_unregister(&plc_xspf);
0
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
1395
761e17b23e0c added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents: 1278
diff changeset
656 DECLARE_PLUGIN(xspf, init, cleanup, NULL, NULL, NULL, NULL, NULL, NULL);