Mercurial > audlegacy-plugins
annotate src/xspf/xspf.c @ 2147:e49d9b0ee308
Change my mail.
author | Jonathan Schleifer <js@h3c.de> |
---|---|
date | Thu, 01 Nov 2007 15:37:43 +0100 |
parents | cf4fa45ffd80 |
children | fe479ddb4f4e |
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, |
1667 | 4 * Giacomo Lozito, Derek Pomery, Yoshiki Yazawa |
5 * and Matti Hämäläinen. | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
6 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
7 * 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
|
8 * 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
|
9 * 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
|
10 * (at your option) any later version. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
11 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
12 * 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
|
13 * 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
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
15 * GNU General Public License for more details. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
16 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
17 * 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
|
18 * 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
|
19 * 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
|
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 |
1962 | 33 #include <audacious/plugin.h> |
1950
2ebeb7816c5e
Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents:
1701
diff
changeset
|
34 #include <audacious/main.h> |
2ebeb7816c5e
Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents:
1701
diff
changeset
|
35 #include <audacious/util.h> |
2ebeb7816c5e
Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents:
1701
diff
changeset
|
36 #include <audacious/playlist.h> |
1952
17a6441c71b6
Some missed #include "" to <> changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1950
diff
changeset
|
37 #include <audacious/playlist_container.h> |
0
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 | 44 #include <libxml/uri.h> |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
45 |
641 | 46 #define XSPF_ROOT_NODE_NAME "playlist" |
47 #define XSPF_XMLNS "http://xspf.org/ns/0/" | |
47 | 48 |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
49 enum { |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
50 CMP_DEF = 0, |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
51 CMP_GT, |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
52 CMP_NULL |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
53 } xspf_compare; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
54 |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
55 typedef struct { |
1693 | 56 gint tupleField; |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
57 gchar *xspfName; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
58 TupleValueType type; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
59 gboolean isMeta; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
60 gint compare; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
61 } xspf_entry_t; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
62 |
47 | 63 |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
64 static const xspf_entry_t xspf_entries[] = { |
1693 | 65 { FIELD_TITLE, "title", TUPLE_STRING, FALSE, CMP_DEF }, |
66 { FIELD_ARTIST, "creator", TUPLE_STRING, FALSE, CMP_DEF }, | |
67 { FIELD_COMMENT, "annotation", TUPLE_STRING, FALSE, CMP_DEF }, | |
68 { FIELD_ALBUM, "album", TUPLE_STRING, FALSE, CMP_DEF }, | |
69 { FIELD_TRACK_NUMBER, "trackNum", TUPLE_INT, FALSE, CMP_DEF }, | |
70 { FIELD_LENGTH, "duration", TUPLE_INT, FALSE, CMP_GT }, | |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
71 |
1693 | 72 { FIELD_YEAR, "year", TUPLE_INT, TRUE, CMP_DEF }, |
73 { FIELD_DATE, "date", TUPLE_STRING, TRUE, CMP_DEF }, | |
74 { FIELD_GENRE, "genre", TUPLE_STRING, TRUE, CMP_DEF }, | |
75 { FIELD_FORMATTER, "formatter", TUPLE_STRING, TRUE, CMP_DEF }, | |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
76 }; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
77 |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
78 static const gint xspf_nentries = (sizeof(xspf_entries) / sizeof(xspf_entry_t)); |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
79 |
641 | 80 |
1963
b9b62802b072
Define a preprocessor macro XSDEBUG() for printing debugging messages, if DEBUG is defined.
Matti Hamalainen <ccr@tnsp.org>
parents:
1962
diff
changeset
|
81 #ifdef DEBUG |
b9b62802b072
Define a preprocessor macro XSDEBUG() for printing debugging messages, if DEBUG is defined.
Matti Hamalainen <ccr@tnsp.org>
parents:
1962
diff
changeset
|
82 # define XSDEBUG(...) { fprintf(stderr, "xspf[%s:%d]: ", __FUNCTION__, (int) __LINE__); fprintf(stderr, __VA_ARGS__); } |
b9b62802b072
Define a preprocessor macro XSDEBUG() for printing debugging messages, if DEBUG is defined.
Matti Hamalainen <ccr@tnsp.org>
parents:
1962
diff
changeset
|
83 #else |
b9b62802b072
Define a preprocessor macro XSDEBUG() for printing debugging messages, if DEBUG is defined.
Matti Hamalainen <ccr@tnsp.org>
parents:
1962
diff
changeset
|
84 # define XSDEBUG(...) /* stub */ |
b9b62802b072
Define a preprocessor macro XSDEBUG() for printing debugging messages, if DEBUG is defined.
Matti Hamalainen <ccr@tnsp.org>
parents:
1962
diff
changeset
|
85 #endif |
b9b62802b072
Define a preprocessor macro XSDEBUG() for printing debugging messages, if DEBUG is defined.
Matti Hamalainen <ccr@tnsp.org>
parents:
1962
diff
changeset
|
86 |
b9b62802b072
Define a preprocessor macro XSDEBUG() for printing debugging messages, if DEBUG is defined.
Matti Hamalainen <ccr@tnsp.org>
parents:
1962
diff
changeset
|
87 |
892 | 88 static gboolean is_uri(gchar *uri) |
89 { | |
1964
375950feec51
Cosmetic whitespace changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1963
diff
changeset
|
90 if (strstr(uri, "://")) |
892 | 91 return TRUE; |
92 else | |
93 return FALSE; | |
94 } | |
95 | |
1963
b9b62802b072
Define a preprocessor macro XSDEBUG() for printing debugging messages, if DEBUG is defined.
Matti Hamalainen <ccr@tnsp.org>
parents:
1962
diff
changeset
|
96 |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
97 /* This function is taken from libxml2-2.6.27. |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
98 */ |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
99 static xmlChar *xspf_path_to_uri(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
|
100 { |
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
|
101 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
|
102 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
|
103 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
|
104 |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
105 if (path == NULL) |
892 | 106 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
|
107 |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
108 if ((uri = xmlParseURI((const char *)path)) != 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
|
109 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
|
110 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
|
111 } |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
112 |
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
|
113 cal = xmlCanonicPath(path); |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
114 if (cal == NULL) |
892 | 115 return NULL; |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
116 |
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
|
117 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
|
118 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
|
119 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
|
120 xmlFree(cal); |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
121 |
892 | 122 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
|
123 } |
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
|
124 |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
125 |
1962 | 126 static void xspf_add_file(xmlNode *track, const gchar *filename, |
127 gint pos, const gchar *base) | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
128 { |
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
|
129 xmlNode *nptr; |
1444
3b1651d37b58
xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
130 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
|
131 gchar *location = NULL; |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2053
diff
changeset
|
132 Playlist *playlist = aud_playlist_get_active(); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
133 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
134 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1966
diff
changeset
|
135 tuple = aud_tuple_new(); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1966
diff
changeset
|
136 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1966
diff
changeset
|
137 aud_tuple_associate_int(tuple, FIELD_MTIME, NULL, -1); |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
138 |
641 | 139 |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
140 for (nptr = track->children; nptr != NULL; nptr = nptr->next) { |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
141 if (nptr->type == XML_ELEMENT_NODE) { |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
142 if (!xmlStrcmp(nptr->name, (xmlChar *)"location")) { |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
143 /* Location is a special case */ |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
144 gchar *str = (gchar *)xmlNodeGetContent(nptr); |
657 | 145 |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
146 location = g_strdup_printf("%s%s", base ? base : "", str); |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
147 xmlFree(str); |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
148 str = g_filename_from_uri(location, NULL, NULL); |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
149 if (str) { |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
150 g_free(location); |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
151 location = g_strdup_printf("file://%s", str); |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
152 } |
1594
78d8dd386d0b
Kludge xspf plugin to "work" better with playlist entries which have
Matti Hamalainen <ccr@tnsp.org>
parents:
1547
diff
changeset
|
153 |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
154 g_free(str); |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
155 } else { |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
156 /* Rest of the nodes are handled here */ |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
157 gint i; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
158 gboolean isMeta; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
159 xmlChar *findName; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
160 |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
161 if (!xmlStrcmp(nptr->name, (xmlChar *)"meta")) { |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
162 isMeta = TRUE; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
163 findName = xmlGetProp(nptr, (xmlChar *)"rel"); |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
164 } else { |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
165 isMeta = FALSE; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
166 findName = xmlStrdup(nptr->name); |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
167 } |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
168 |
1669 | 169 for (i = 0; i < xspf_nentries; i++) |
170 if ((xspf_entries[i].isMeta == isMeta) && | |
171 !xmlStrcmp(findName, (xmlChar *)xspf_entries[i].xspfName)) { | |
172 xmlChar *str = xmlNodeGetContent(nptr); | |
173 switch (xspf_entries[i].type) { | |
174 case TUPLE_STRING: | |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1966
diff
changeset
|
175 aud_tuple_associate_string(tuple, xspf_entries[i].tupleField, NULL, (gchar *)str); |
1669 | 176 break; |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
177 |
1669 | 178 case TUPLE_INT: |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1966
diff
changeset
|
179 aud_tuple_associate_int(tuple, xspf_entries[i].tupleField, NULL, atol((char *)str)); |
1669 | 180 break; |
181 | |
182 default: | |
183 break; | |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
184 } |
1669 | 185 xmlFree(str); |
186 break; | |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
187 } |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
188 |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
189 xmlFree(findName); |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
190 } |
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
|
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 } |
47 | 193 |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
194 if (location) { |
1278
d1c66f8ccf73
adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1271
diff
changeset
|
195 gchar *uri = NULL; |
1444
3b1651d37b58
xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
196 gchar *scratch; |
3b1651d37b58
xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
197 |
3b1651d37b58
xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
198 scratch = g_path_get_basename(location); |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1966
diff
changeset
|
199 aud_tuple_associate_string(tuple, FIELD_FILE_NAME, NULL, scratch); |
1444
3b1651d37b58
xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
200 g_free(scratch); |
3b1651d37b58
xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
201 |
3b1651d37b58
xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
202 scratch = g_path_get_dirname(location); |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1966
diff
changeset
|
203 aud_tuple_associate_string(tuple, FIELD_FILE_PATH, NULL, scratch); |
1444
3b1651d37b58
xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
204 g_free(scratch); |
3b1651d37b58
xspf: update to new API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
205 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1966
diff
changeset
|
206 aud_tuple_associate_string(tuple, FIELD_FILE_EXT, NULL, strrchr(location, '.')); |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
207 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1966
diff
changeset
|
208 XSDEBUG("tuple->file_name = %s\n", aud_tuple_get_string(tuple, FIELD_FILE_NAME, NULL)); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1966
diff
changeset
|
209 XSDEBUG("tuple->file_path = %s\n", aud_tuple_get_string(tuple, FIELD_FILE_PATH, NULL)); |
1963
b9b62802b072
Define a preprocessor macro XSDEBUG() for printing debugging messages, if DEBUG is defined.
Matti Hamalainen <ccr@tnsp.org>
parents:
1962
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 // add file to playlist |
1278
d1c66f8ccf73
adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1271
diff
changeset
|
212 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
|
213 // uri would be NULL if location is already uri. --yaz |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2053
diff
changeset
|
214 aud_playlist_load_ins_file_tuple(playlist, uri ? uri: location, filename, pos, tuple); |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
215 g_free(uri); |
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
|
216 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
|
217 } |
502222ed5dd4
[svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents:
884
diff
changeset
|
218 |
502222ed5dd4
[svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents:
884
diff
changeset
|
219 g_free(location); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
220 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
221 |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
222 |
1962 | 223 static void xspf_find_track(xmlNode *tracklist, const gchar *filename, |
224 gint pos, const gchar *base) | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
225 { |
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
|
226 xmlNode *nptr; |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
227 |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
228 for (nptr = tracklist->children; nptr != NULL; nptr = nptr->next) { |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
229 if (nptr->type == XML_ELEMENT_NODE && |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
230 !xmlStrcmp(nptr->name, (xmlChar *)"track")) { |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
231 xspf_add_file(nptr, filename, pos, base); |
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
|
232 } |
502222ed5dd4
[svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code 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 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
234 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
235 |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
236 |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
237 static void xspf_find_audoptions(xmlNode *tracklist, const gchar *filename, gint pos) |
641 | 238 { |
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
|
239 xmlNode *nptr; |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2053
diff
changeset
|
240 Playlist *playlist = aud_playlist_get_active(); |
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
|
241 |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
242 for (nptr = tracklist->children; nptr != NULL; nptr = nptr->next) { |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
243 if (nptr->type == XML_ELEMENT_NODE && |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
244 !xmlStrcmp(nptr->name, (xmlChar *)"options")) { |
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
|
245 xmlChar *opt = NULL; |
884 | 246 |
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
|
247 opt = xmlGetProp(nptr, (xmlChar *)"staticlist"); |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
248 if (!g_strcasecmp((char *)opt, "true")) |
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
|
249 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
|
250 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
|
251 playlist->attribute ^= PLAYLIST_STATIC; |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
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 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
|
254 } |
502222ed5dd4
[svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code 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 } |
641 | 256 } |
257 | |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
258 |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
259 static void xspf_playlist_load(const gchar *filename, gint pos) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
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 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
|
262 xmlNode *nptr, *nptr2; |
502222ed5dd4
[svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code 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 |
502222ed5dd4
[svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code 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 g_return_if_fail(filename != NULL); |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
265 |
1963
b9b62802b072
Define a preprocessor macro XSDEBUG() for printing debugging messages, if DEBUG is defined.
Matti Hamalainen <ccr@tnsp.org>
parents:
1962
diff
changeset
|
266 XSDEBUG("filename='%s', pos=%d\n", filename, pos); |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
267 |
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
|
268 doc = xmlRecoverFile(filename); |
1964
375950feec51
Cosmetic whitespace changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1963
diff
changeset
|
269 if (doc == 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
|
270 return; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
271 |
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
|
272 // find trackList |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
273 for (nptr = doc->children; nptr != NULL; nptr = nptr->next) { |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
274 if (nptr->type == XML_ELEMENT_NODE && |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
275 !xmlStrcmp(nptr->name, (xmlChar *)"playlist")) { |
1965
41d726acb915
Remove useless NULL assignations.
Matti Hamalainen <ccr@tnsp.org>
parents:
1964
diff
changeset
|
276 gchar *tmp, *base; |
41d726acb915
Remove useless NULL assignations.
Matti Hamalainen <ccr@tnsp.org>
parents:
1964
diff
changeset
|
277 |
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 base = (gchar *)xmlNodeGetBase(doc, nptr); |
1963
b9b62802b072
Define a preprocessor macro XSDEBUG() for printing debugging messages, if DEBUG is defined.
Matti Hamalainen <ccr@tnsp.org>
parents:
1962
diff
changeset
|
279 |
b9b62802b072
Define a preprocessor macro XSDEBUG() for printing debugging messages, if DEBUG is defined.
Matti Hamalainen <ccr@tnsp.org>
parents:
1962
diff
changeset
|
280 XSDEBUG("base @1 = %s\n", base); |
b9b62802b072
Define a preprocessor macro XSDEBUG() for printing debugging messages, if DEBUG is defined.
Matti Hamalainen <ccr@tnsp.org>
parents:
1962
diff
changeset
|
281 |
1278
d1c66f8ccf73
adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1271
diff
changeset
|
282 // 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
|
283 tmp = xmlURIUnescapeString(base, -1, NULL); |
1964
375950feec51
Cosmetic whitespace changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1963
diff
changeset
|
284 if (tmp) { |
375950feec51
Cosmetic whitespace changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1963
diff
changeset
|
285 if (!strcmp(tmp, filename)) { |
1278
d1c66f8ccf73
adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1271
diff
changeset
|
286 xmlFree(base); |
d1c66f8ccf73
adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1271
diff
changeset
|
287 base = NULL; |
892 | 288 } |
1278
d1c66f8ccf73
adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1271
diff
changeset
|
289 g_free(tmp); |
892 | 290 } |
1963
b9b62802b072
Define a preprocessor macro XSDEBUG() for printing debugging messages, if DEBUG is defined.
Matti Hamalainen <ccr@tnsp.org>
parents:
1962
diff
changeset
|
291 |
b9b62802b072
Define a preprocessor macro XSDEBUG() for printing debugging messages, if DEBUG is defined.
Matti Hamalainen <ccr@tnsp.org>
parents:
1962
diff
changeset
|
292 XSDEBUG("base @2 = %s\n", base); |
b9b62802b072
Define a preprocessor macro XSDEBUG() for printing debugging messages, if DEBUG is defined.
Matti Hamalainen <ccr@tnsp.org>
parents:
1962
diff
changeset
|
293 |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
294 for (nptr2 = nptr->children; nptr2 != NULL; nptr2 = nptr2->next) { |
641 | 295 |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
296 if (nptr2->type == XML_ELEMENT_NODE && |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
297 !xmlStrcmp(nptr2->name, (xmlChar *)"extension")) { |
641 | 298 //check if application is audacious |
299 xmlChar *app = NULL; | |
300 app = xmlGetProp(nptr2, (xmlChar *)"application"); | |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
301 if (!xmlStrcmp(app, (xmlChar *)"audacious")) |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
302 xspf_find_audoptions(nptr2, filename, pos); |
641 | 303 xmlFree(app); |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
304 } else |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
305 if (nptr2->type == XML_ELEMENT_NODE && |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
306 !xmlStrcmp(nptr2->name, (xmlChar *)"title")) { |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2053
diff
changeset
|
307 Playlist *plist = aud_playlist_get_active(); |
1528
8fddba1d94e4
xspf: When loading playlist, read title from xml if set
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1514
diff
changeset
|
308 xmlChar *title = xmlNodeGetContent(nptr2); |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
309 |
1528
8fddba1d94e4
xspf: When loading playlist, read title from xml if set
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1514
diff
changeset
|
310 if (title && *title) { |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2053
diff
changeset
|
311 aud_playlist_set_current_name(plist, (gchar*)title); |
1528
8fddba1d94e4
xspf: When loading playlist, read title from xml if set
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1514
diff
changeset
|
312 } |
8fddba1d94e4
xspf: When loading playlist, read title from xml if set
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1514
diff
changeset
|
313 xmlFree(title); |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
314 } else |
1964
375950feec51
Cosmetic whitespace changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1963
diff
changeset
|
315 if (nptr2->type == XML_ELEMENT_NODE && |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
316 !xmlStrcmp(nptr2->name, (xmlChar *)"trackList")) { |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
317 xspf_find_track(nptr2, filename, pos, base); |
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
|
318 } |
502222ed5dd4
[svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents:
884
diff
changeset
|
319 } |
502222ed5dd4
[svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents:
884
diff
changeset
|
320 } |
502222ed5dd4
[svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents:
884
diff
changeset
|
321 } |
502222ed5dd4
[svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code 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 xmlFreeDoc(doc); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
323 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
324 |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
325 |
1962 | 326 static void xspf_add_node(xmlNodePtr node, TupleValueType type, |
327 gboolean isMeta, const gchar *xspfName, const gchar *strVal, | |
328 const gint intVal) | |
1668 | 329 { |
330 gchar tmps[64]; | |
331 xmlNodePtr tmp; | |
332 | |
333 if (isMeta) { | |
334 tmp = xmlNewNode(NULL, (xmlChar *) "meta"); | |
335 xmlSetProp(tmp, (xmlChar *) "rel", (xmlChar *) xspfName); | |
336 } else | |
337 tmp = xmlNewNode(NULL, (xmlChar *) xspfName); | |
338 | |
339 switch (type) { | |
340 case TUPLE_STRING: | |
341 xmlAddChild(tmp, xmlNewText((xmlChar *) strVal)); | |
342 break; | |
343 | |
344 case TUPLE_INT: | |
345 g_snprintf(tmps, sizeof(tmps), "%d", intVal); | |
346 xmlAddChild(tmp, xmlNewText((xmlChar *) tmps)); | |
347 break; | |
348 | |
349 default: | |
350 break; | |
351 } | |
352 | |
353 xmlAddChild(node, tmp); | |
354 } | |
355 | |
356 | |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
357 static void xspf_playlist_save(const gchar *filename, gint pos) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
358 { |
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
|
359 xmlDocPtr doc; |
1669 | 360 xmlNodePtr rootnode, tracklist; |
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
|
361 GList *node; |
892 | 362 gint baselen = 0; |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
363 gchar *base = NULL; |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2053
diff
changeset
|
364 Playlist *playlist = aud_playlist_get_active(); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
365 |
1963
b9b62802b072
Define a preprocessor macro XSDEBUG() for printing debugging messages, if DEBUG is defined.
Matti Hamalainen <ccr@tnsp.org>
parents:
1962
diff
changeset
|
366 XSDEBUG("filename='%s', pos=%d\n", filename, pos); |
892 | 367 |
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
|
368 doc = xmlNewDoc((xmlChar *)"1.0"); |
502222ed5dd4
[svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents:
884
diff
changeset
|
369 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
|
370 doc->encoding = xmlStrdup((xmlChar *)"UTF-8"); |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
371 |
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
|
372 rootnode = xmlNewNode(NULL, (xmlChar *)XSPF_ROOT_NODE_NAME); |
892 | 373 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
|
374 xmlSetProp(rootnode, (xmlChar *)"xmlns", (xmlChar *)XSPF_XMLNS); |
892 | 375 |
1675
ae9b0327b620
Fix plugins to conform with PLAYLIST_{UN}LOCK() change.
Matti Hamalainen <ccr@tnsp.org>
parents:
1669
diff
changeset
|
376 PLAYLIST_LOCK(playlist); |
1278
d1c66f8ccf73
adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1271
diff
changeset
|
377 |
d1c66f8ccf73
adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1271
diff
changeset
|
378 /* relative */ |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
379 if (playlist->attribute & PLAYLIST_USE_RELATIVE) { |
892 | 380 /* prescan to determine base uri */ |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
381 for (node = playlist->entries; node != NULL; node = g_list_next(node)) { |
892 | 382 gchar *ptr1, *ptr2; |
383 PlaylistEntry *entry = PLAYLIST_ENTRY(node->data); | |
384 gchar *tmp; | |
385 gint tmplen = 0; | |
386 | |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
387 if (!is_uri(entry->filename)) { //obsolete |
1966 | 388 gchar *tmp2 = g_path_get_dirname(entry->filename); |
892 | 389 tmp = g_strdup_printf("%s/", tmp2); |
1669 | 390 g_free(tmp2); |
1966 | 391 } else |
892 | 392 tmp = g_strdup(entry->filename); |
393 | |
1964
375950feec51
Cosmetic whitespace changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1963
diff
changeset
|
394 if (!base) { |
892 | 395 base = strdup(tmp); |
396 baselen = strlen(base); | |
397 } | |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
398 |
892 | 399 ptr1 = base; |
400 ptr2 = tmp; | |
401 | |
402 while(ptr1 && ptr2 && *ptr1 && *ptr2 && *ptr1 == *ptr2) { | |
403 ptr1++; | |
404 ptr2++; | |
405 } | |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
406 |
892 | 407 *ptr2 = '\0'; //terminate |
408 tmplen = ptr2 - tmp; | |
409 | |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
410 if (tmplen <= baselen) { |
892 | 411 g_free(base); |
412 base = tmp; | |
413 baselen = tmplen; | |
1963
b9b62802b072
Define a preprocessor macro XSDEBUG() for printing debugging messages, if DEBUG is defined.
Matti Hamalainen <ccr@tnsp.org>
parents:
1962
diff
changeset
|
414 XSDEBUG("base='%s', baselen=%d\n", base, baselen); |
1966 | 415 } else |
892 | 416 g_free(tmp); |
417 } | |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
418 |
892 | 419 /* set base URI */ |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
420 if (base) { |
892 | 421 gchar *tmp; |
1964
375950feec51
Cosmetic whitespace changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1963
diff
changeset
|
422 if (!is_uri(base)) { |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
423 tmp = (gchar *) xspf_path_to_uri((xmlChar *)base); |
1964
375950feec51
Cosmetic whitespace changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1963
diff
changeset
|
424 if (tmp) { |
892 | 425 g_free(base); |
426 base = tmp; | |
427 } | |
428 } | |
429 | |
1964
375950feec51
Cosmetic whitespace changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1963
diff
changeset
|
430 if (!is_uri(base)) { |
1963
b9b62802b072
Define a preprocessor macro XSDEBUG() for printing debugging messages, if DEBUG is defined.
Matti Hamalainen <ccr@tnsp.org>
parents:
1962
diff
changeset
|
431 XSDEBUG("base is not uri. something is wrong.\n"); |
892 | 432 tmp = g_strdup_printf("file://%s", base); |
433 xmlSetProp(rootnode, (xmlChar *)"xml:base", (xmlChar *)tmp); | |
434 g_free(tmp); | |
1966 | 435 } else |
892 | 436 xmlSetProp(rootnode, (xmlChar *)"xml:base", (xmlChar *)base); |
437 } | |
438 } /* USE_RELATIVE */ | |
439 | |
1278
d1c66f8ccf73
adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1271
diff
changeset
|
440 /* 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
|
441 xmlDocSetRootElement(doc, rootnode); |
1669 | 442 xspf_add_node(rootnode, TUPLE_STRING, FALSE, "creator", PACKAGE "-" VERSION, 0); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
443 |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
444 /* add staticlist marker */ |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
445 if (playlist->attribute & PLAYLIST_STATIC) { |
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
|
446 xmlNodePtr extension, options; |
884 | 447 |
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
|
448 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
|
449 xmlSetProp(extension, (xmlChar *)"application", (xmlChar *)"audacious"); |
884 | 450 |
891
502222ed5dd4
[svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents:
884
diff
changeset
|
451 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
|
452 xmlSetProp(options, (xmlChar *)"staticlist", (xmlChar *)"true"); |
884 | 453 |
891
502222ed5dd4
[svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents:
884
diff
changeset
|
454 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
|
455 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
|
456 } |
884 | 457 |
1531
10cfa5b51bce
xspf: Store playlist title when saving playlist
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1528
diff
changeset
|
458 /* save playlist title */ |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
459 if (playlist->title && playlist->title[0] && |
1669 | 460 g_utf8_validate(playlist->title, -1, NULL)) |
461 xspf_add_node(rootnode, TUPLE_STRING, FALSE, "title", playlist->title, 0); | |
462 | |
1531
10cfa5b51bce
xspf: Store playlist title when saving playlist
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1528
diff
changeset
|
463 |
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
|
464 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
|
465 xmlAddChild(rootnode, tracklist); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
466 |
1964
375950feec51
Cosmetic whitespace changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1963
diff
changeset
|
467 for (node = playlist->entries; node != NULL; node = g_list_next(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
|
468 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
|
469 xmlNodePtr track, location; |
1668 | 470 gchar *filename = NULL; |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
471 const gchar *scratch = NULL; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
472 gint scratchi = 0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
473 |
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
|
474 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
|
475 location = xmlNewNode(NULL, (xmlChar *)"location"); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
476 |
1964
375950feec51
Cosmetic whitespace changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1963
diff
changeset
|
477 if (is_uri(entry->filename)) { /* uri */ |
1963
b9b62802b072
Define a preprocessor macro XSDEBUG() for printing debugging messages, if DEBUG is defined.
Matti Hamalainen <ccr@tnsp.org>
parents:
1962
diff
changeset
|
478 XSDEBUG("filename is uri\n"); |
1278
d1c66f8ccf73
adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1271
diff
changeset
|
479 filename = g_strdup(entry->filename + baselen); // entry->filename is always uri now. |
1966 | 480 } else { /* local file (obsolete) */ |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
481 gchar *tmp = (gchar *) xspf_path_to_uri((const xmlChar *)entry->filename + baselen); |
1964
375950feec51
Cosmetic whitespace changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1963
diff
changeset
|
482 if (base) { /* relative */ |
892 | 483 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
|
484 } else { |
1963
b9b62802b072
Define a preprocessor macro XSDEBUG() for printing debugging messages, if DEBUG is defined.
Matti Hamalainen <ccr@tnsp.org>
parents:
1962
diff
changeset
|
485 XSDEBUG("absolute and local (obsolete)\n"); |
1278
d1c66f8ccf73
adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1271
diff
changeset
|
486 filename = g_filename_to_uri(tmp, NULL, NULL); |
892 | 487 } |
1965
41d726acb915
Remove useless NULL assignations.
Matti Hamalainen <ccr@tnsp.org>
parents:
1964
diff
changeset
|
488 g_free(tmp); |
1278
d1c66f8ccf73
adapt xspf for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1271
diff
changeset
|
489 } /* obsolete */ |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
490 |
1964
375950feec51
Cosmetic whitespace changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1963
diff
changeset
|
491 if (!g_utf8_validate(filename, -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
|
492 continue; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
493 |
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
|
494 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
|
495 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
|
496 xmlAddChild(tracklist, track); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
497 |
1669 | 498 /* Do we have a tuple? */ |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
499 if (entry->tuple != NULL) { |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
500 gint i; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
501 for (i = 0; i < xspf_nentries; i++) { |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
502 const xspf_entry_t *xs = &xspf_entries[i]; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
503 gboolean isOK = FALSE; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
504 |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
505 switch (xs->type) { |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
506 case TUPLE_STRING: |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1966
diff
changeset
|
507 scratch = aud_tuple_get_string(entry->tuple, xs->tupleField, NULL); |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
508 switch (xs->compare) { |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
509 case CMP_DEF: isOK = (scratch != NULL); break; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
510 case CMP_NULL: isOK = (scratch == NULL); break; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
511 } |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
512 if (scratch != NULL && !g_utf8_validate(scratch, -1, NULL)) |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
513 isOK = FALSE; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
514 break; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
515 |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
516 case TUPLE_INT: |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1966
diff
changeset
|
517 scratchi = aud_tuple_get_int(entry->tuple, xs->tupleField, NULL); |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
518 switch (xs->compare) { |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
519 case CMP_DEF: isOK = (scratchi != 0); break; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
520 case CMP_GT: isOK = (scratchi > 0); break; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
521 } |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
522 break; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
523 |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
524 default: |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
525 break; |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
526 } |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
527 |
1668 | 528 if (isOK) |
529 xspf_add_node(track, xs->type, xs->isMeta, xs->xspfName, scratch, scratchi); | |
891
502222ed5dd4
[svn] justify indentation by gnu indent. current state is a mixture of some styles and very hard to maintain. the code is exactly same to previous revision. this is preparation for upcoming commit so that to make taking diff easier.
yaz
parents:
884
diff
changeset
|
530 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
531 |
1669 | 532 /* Write mtime unconditionally to support staticlist */ |
1693 | 533 xspf_add_node(track, TUPLE_INT, TRUE, "mtime", NULL, |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1966
diff
changeset
|
534 aud_tuple_get_int(entry->tuple, FIELD_MTIME, NULL)); |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
535 } else { |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
536 |
1668 | 537 if (entry->title != NULL && g_utf8_validate(entry->title, -1, NULL)) |
538 xspf_add_node(track, TUPLE_STRING, FALSE, "title", entry->title, 0); | |
892 | 539 |
1668 | 540 if (entry->length > 0) |
541 xspf_add_node(track, TUPLE_INT, FALSE, "duration", NULL, entry->length); | |
892 | 542 |
1669 | 543 /* Add mtime of -1 */ |
1668 | 544 xspf_add_node(track, TUPLE_INT, TRUE, "mtime", NULL, -1); |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
545 } |
892 | 546 |
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 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
|
548 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
549 |
1675
ae9b0327b620
Fix plugins to conform with PLAYLIST_{UN}LOCK() change.
Matti Hamalainen <ccr@tnsp.org>
parents:
1669
diff
changeset
|
550 PLAYLIST_UNLOCK(playlist); |
92
fadf346ddde3
[svn] - pls doesn't go along with PLAYLIST_LOCK in playlist_save().
yaz
parents:
87
diff
changeset
|
551 |
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
|
552 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
|
553 xmlFreeDoc(doc); |
892 | 554 xmlFree(base); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
555 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
556 |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
557 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
558 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
|
559 .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
|
560 .ext = "xspf", |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
561 .plc_read = xspf_playlist_load, |
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
562 .plc_write = xspf_playlist_save, |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
563 }; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
564 |
1962 | 565 |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
566 static void xspf_init(void) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
567 { |
2053
059bd21a0c80
PlaylistContainer API updates
William Pitcock <nenolod@atheme.org>
parents:
1976
diff
changeset
|
568 aud_playlist_container_register(&plc_xspf); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
569 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
570 |
1962 | 571 |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
572 static void xspf_cleanup(void) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
573 { |
2053
059bd21a0c80
PlaylistContainer API updates
William Pitcock <nenolod@atheme.org>
parents:
1976
diff
changeset
|
574 aud_playlist_container_unregister(&plc_xspf); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
575 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
576 |
1962 | 577 |
1661
927d341eecb8
Partial rewrite/sanitation of the xspf plugin.
Matti Hamalainen <ccr@tnsp.org>
parents:
1594
diff
changeset
|
578 DECLARE_PLUGIN(xspf, xspf_init, xspf_cleanup, NULL, NULL, NULL, NULL, NULL, NULL); |