const char *share) {
char *owner;
- if(!playlist_parse_name(name, &owner, 0))
+ if(playlist_parse_name(name, &owner, 0))
return 0;
/* Anyone can read shared playlists */
if(!owner)
const char attribute((unused)) *share) {
char *owner;
- if(!playlist_parse_name(name, &owner, 0))
+ if(playlist_parse_name(name, &owner, 0))
return 0;
/* Anyone can modify shared playlists */
if(!owner)
char **sharep) {
int e;
- if(!playlist_parse_name(name, 0, 0)) {
+ if(playlist_parse_name(name, 0, 0)) {
error(0, "invalid playlist name '%s'", name);
return EINVAL;
}
int e;
char *owner;
- if(!playlist_parse_name(name, &owner, 0)) {
+ if(playlist_parse_name(name, &owner, 0)) {
error(0, "invalid playlist name '%s'", name);
return EINVAL;
}
return 0;
/* Set the new values */
if(share)
- kvp_set(&k, "share", share);
+ kvp_set(&k, "sharing", share);
if(tracks) {
char b[16];
int oldcount, n;
while(!(e = c->c_get(c, k, prepare_data(d), DB_NEXT))) {
char *name = xstrndup(k->data, k->size), *owner;
const char *share = kvp_get(kvp_urldecode(d->data, d->size),
- "share");
+ "sharing");
/* Extract owner; malformed names are skipped */
if(playlist_parse_name(name, &owner, 0)) {
error(0, "invalid playlist name '%s' found in database", name);
continue;
}
+ if(!share) {
+ error(0, "playlist '%s' has no 'sharing' key", name);
+ continue;
+ }
/* Always list public and shared playlists
* Only list private ones to their owner
* Don't list anything else
&& owner && !strcmp(owner, who)))
vector_append(v, name);
}
+ trackdb_closecursor(c);
switch(e) {
case DB_NOTFOUND:
break;
int e;
char *owner;
- if(!playlist_parse_name(name, &owner, 0)) {
+ if(playlist_parse_name(name, &owner, 0)) {
error(0, "invalid playlist name '%s'", name);
return EINVAL;
}
Arguments:
playlist -- Playlist to set
tracks -- Array of tracks"""
- self._simple_body("playlist-set", tracks, playlist)
+ self._simple_body(tracks, "playlist-set", playlist)
def playlist_set_share(self, playlist, share):
"""Set the sharing status of a playlist"""
return None
return _split(details)[0]
+ def playlists(self):
+ """Returns the list of visible playlists"""
+ self._simple("playlists")
+ return self._body()
+
########################################################################
# I/O infrastructure
const char *playlist = u;
int err;
+ if(!c->locked_playlist
+ || strcmp(playlist, c->locked_playlist)) {
+ sink_writes(ev_writer_sink(c->w), "550 Playlist is not locked\n");
+ return 1;
+ }
if(!(err = trackdb_playlist_set(playlist, c->who,
body, nbody, 0))) {
sink_printf(ev_writer_sink(c->w), "250 OK\n");
TESTS=cookie.py dbversion.py dump.py files.py play.py queue.py \
recode.py search.py user-upgrade.py user.py aliases.py \
- schedule.py
+ schedule.py playlists.py
TESTS_ENVIRONMENT=${PYTHON} -u
--- /dev/null
+#! /usr/bin/env python
+#
+# This file is part of DisOrder.
+# Copyright (C) 2008 Richard Kettlewell
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA
+#
+import dtest,disorder
+
+def test():
+ """Playlist testing"""
+ dtest.start_daemon()
+ dtest.create_user()
+ c = disorder.client()
+ c.random_disable()
+ print " checking initial playlist set is empty"
+ l = c.playlists()
+ assert l == [], "checking initial playlist set is empty"
+ print " creating a shared playlist"
+ c.playlist_lock("wibble")
+ c.playlist_set("wibble", ["one", "two", "three"])
+ c.playlist_unlock()
+ print " checking new playlist appears in list"
+ l = c.playlists()
+ assert l == ["wibble"], "checking new playlists"
+ print " checking new playlist contents is as assigned"
+ l = c.playlist_get("wibble")
+ assert l == ["one", "two", "three"], "checking playlist contents"
+
+if __name__ == '__main__':
+ dtest.run()