diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-01-26 12:46:56 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-01-26 12:46:56 +0000 |
commit | 9eee1a81cf99d351d78bd6550dfa6646be364f3e (patch) | |
tree | a99b8aee871f0456e08e9c2e95c0f889aeb6e19c | |
parent | 2889b576eb32828df652505b90c8ea1d7d258509 (diff) | |
download | mpd-9eee1a81cf99d351d78bd6550dfa6646be364f3e.tar.gz mpd-9eee1a81cf99d351d78bd6550dfa6646be364f3e.tar.xz mpd-9eee1a81cf99d351d78bd6550dfa6646be364f3e.zip |
command: allow "addid" command to take an optional second argument, position
This will allow "addid \"song_url\" <pos>" to atomically insert a
song at any given playlist position.
If the add succeeds, but the actual movement fails (due to
invalid position), then the song_id will be deleted before
the command returns back to the client, and the client
will get an error response.
git-svn-id: https://svn.musicpd.org/mpd/trunk@7151 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/command.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/command.c b/src/command.c index 4411b2bd0..c621702b7 100644 --- a/src/command.c +++ b/src/command.c @@ -383,8 +383,20 @@ static int handleAddId(int fd, int *permission, int argc, char *argv[]) int added_id; int ret = addToPlaylist(fd, argv[1], &added_id); - if (!ret) + if (!ret) { + if (argc == 3) { + int to; + if (check_int(fd, &to, argv[2], + check_integer, argv[2]) < 0) + return -1; + ret = moveSongInPlaylistById(fd, added_id, to); + if (ret) { /* move failed */ + deleteFromPlaylistById(fd, added_id); + return ret; + } + } fdprintf(fd, "Id: %d\n", added_id); + } return ret; } @@ -1022,7 +1034,7 @@ void initCommands(void) addCommand(COMMAND_KILL, PERMISSION_ADMIN, -1, -1, handleKill, NULL); addCommand(COMMAND_CLOSE, PERMISSION_NONE, -1, -1, handleClose, NULL); addCommand(COMMAND_ADD, PERMISSION_ADD, 1, 1, handleAdd, NULL); - addCommand(COMMAND_ADDID, PERMISSION_ADD, 1, 1, handleAddId, NULL); + addCommand(COMMAND_ADDID, PERMISSION_ADD, 1, 2, handleAddId, NULL); addCommand(COMMAND_DELETE, PERMISSION_CONTROL, 1, 1, handleDelete, NULL); addCommand(COMMAND_DELETEID, PERMISSION_CONTROL, 1, 1, handleDeleteId, NULL); addCommand(COMMAND_PLAYLIST, PERMISSION_READ, 0, 0, handlePlaylist, NULL); |