aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c
diff options
context:
space:
mode:
authorJ. Alexander Treuman <jat@spatialrift.net>2007-05-16 12:02:10 +0000
committerJ. Alexander Treuman <jat@spatialrift.net>2007-05-16 12:02:10 +0000
commit6cfe421cd64278f85310a258ab42c372c8a847b3 (patch)
treec1e8be35035dea1001ad8ad67c62ea13353aa09c /src/command.c
parent6f68587ad59a2e5f606a332b96e55f57a0f9a5fc (diff)
downloadmpd-6cfe421cd64278f85310a258ab42c372c8a847b3.tar.gz
mpd-6cfe421cd64278f85310a258ab42c372c8a847b3.tar.xz
mpd-6cfe421cd64278f85310a258ab42c372c8a847b3.zip
Committing pat's rewrite of the stored playlist code. This also adds two
new commands: playlistmove and playlistdelete. git-svn-id: https://svn.musicpd.org/mpd/trunk@6116 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/command.c')
-rw-r--r--src/command.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/command.c b/src/command.c
index 519f6ff19..107df3275 100644
--- a/src/command.c
+++ b/src/command.c
@@ -30,6 +30,7 @@
#include "log.h"
#include "tag.h"
#include "utils.h"
+#include "storedPlaylist.h"
#include <assert.h>
#include <stdarg.h>
@@ -95,6 +96,8 @@
#define COMMAND_PLAYLISTADD "playlistadd"
#define COMMAND_PLAYLISTFIND "playlistfind"
#define COMMAND_PLAYLISTSEARCH "playlistsearch"
+#define COMMAND_PLAYLISTMOVE "playlistmove"
+#define COMMAND_PLAYLISTDELETE "playlistdelete"
#define COMMAND_TAGTYPES "tagtypes"
#define COMMAND_COUNT "count"
@@ -578,6 +581,43 @@ static int handlePlaylistSearch(int fd, int *permission, int argc, char *argv[])
return 0;
}
+static int handlePlaylistDelete(int fd, int *permission, int argc, char *argv[]) {
+ char *playlist = argv[1];
+ int from;
+ char *test;
+
+ from = strtol(argv[2], &test, 10);
+ if (*test != '\0') {
+ commandError(fd, ACK_ERROR_ARG,
+ "\"%s\" is not a integer", argv[2]);
+ return -1;
+ }
+
+ return removeOneSongFromStoredPlaylistByPath(fd, playlist, from);
+}
+
+static int handlePlaylistMove(int fd, int *permission, int argc, char *argv[])
+{
+ char *playlist = argv[1];
+ int from, to;
+ char *test;
+
+ from = strtol(argv[2], &test, 10);
+ if (*test != '\0') {
+ commandError(fd, ACK_ERROR_ARG,
+ "\"%s\" is not a integer", argv[2]);
+ return -1;
+ }
+ to = strtol(argv[3], &test, 10);
+ if (*test != '\0') {
+ commandError(fd, ACK_ERROR_ARG,
+ "\"%s\" is not a integer", argv[3]);
+ return -1;
+ }
+
+ return moveSongInStoredPlaylistByPath(fd, playlist, from, to);
+}
+
static int listHandleUpdate(int fd,
int *permission,
int argc,
@@ -1072,6 +1112,8 @@ void initCommands(void)
addCommand(COMMAND_PLAYLISTADD, PERMISSION_CONTROL, 2, 2, handlePlaylistAdd, NULL);
addCommand(COMMAND_PLAYLISTFIND, PERMISSION_READ, 2, -1, handlePlaylistFind, NULL);
addCommand(COMMAND_PLAYLISTSEARCH, PERMISSION_READ, 2, -1, handlePlaylistSearch, NULL);
+ addCommand(COMMAND_PLAYLISTMOVE, PERMISSION_CONTROL, 3, 3, handlePlaylistMove, NULL);
+ addCommand(COMMAND_PLAYLISTDELETE, PERMISSION_CONTROL, 2, 2, handlePlaylistDelete, NULL);
addCommand(COMMAND_TAGTYPES, PERMISSION_READ, 0, 0, handleTagTypes, NULL);
addCommand(COMMAND_COUNT, PERMISSION_READ, 2, -1, handleCount, NULL);