aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/command.c134
-rw-r--r--src/playlist.c10
-rw-r--r--src/playlist.h16
3 files changed, 155 insertions, 5 deletions
diff --git a/src/command.c b/src/command.c
index 1ab3b789a..b3d2acbcd 100644
--- a/src/command.c
+++ b/src/command.c
@@ -38,6 +38,7 @@
#include <unistd.h>
#define COMMAND_PLAY "play"
+#define COMMAND_PLAYID "playid"
#define COMMAND_STOP "stop"
#define COMMAND_PAUSE "pause"
#define COMMAND_STATUS "status"
@@ -45,6 +46,7 @@
#define COMMAND_CLOSE "close"
#define COMMAND_ADD "add"
#define COMMAND_DELETE "delete"
+#define COMMAND_DELETEID "deleteid"
#define COMMAND_PLAYLIST "playlist"
#define COMMAND_SHUFFLE "shuffle"
#define COMMAND_CLEAR "clear"
@@ -53,6 +55,7 @@
#define COMMAND_LSINFO "lsinfo"
#define COMMAND_RM "rm"
#define COMMAND_PLAYLISTINFO "playlistinfo"
+#define COMMAND_PLAYLISTID "playlistid"
#define COMMAND_FIND "find"
#define COMMAND_SEARCH "search"
#define COMMAND_UPDATE "update"
@@ -66,8 +69,11 @@
#define COMMAND_CLEAR_ERROR "clearerror"
#define COMMAND_LIST "list"
#define COMMAND_MOVE "move"
+#define COMMAND_MOVEID "moveid"
#define COMMAND_SWAP "swap"
+#define COMMAND_SWAPID "swapid"
#define COMMAND_SEEK "seek"
+#define COMMAND_SEEKID "seekid"
#define COMMAND_LISTALLINFO "listallinfo"
#define COMMAND_PING "ping"
#define COMMAND_SETVOL "setvol"
@@ -83,6 +89,7 @@
#define COMMAND_STATUS_PLAYLIST "playlist"
#define COMMAND_STATUS_PLAYLIST_LENGTH "playlistlength"
#define COMMAND_STATUS_SONG "song"
+#define COMMAND_STATUS_SONGID "songid"
#define COMMAND_STATUS_TIME "time"
#define COMMAND_STATUS_BITRATE "bitrate"
#define COMMAND_STATUS_ERROR "error"
@@ -163,6 +170,23 @@ int handlePlay(FILE * fp, unsigned int * permission, int argArrayLength,
return playPlaylist(fp,song,0);
}
+int handlePlayId(FILE * fp, unsigned int * permission, int argArrayLength,
+ char ** argArray)
+{
+ int id = -1;
+ char * test;
+
+ if(argArrayLength==2) {
+ id = strtol(argArray[1],&test,10);
+ if(*test!='\0') {
+ commandError(fp, ACK_ERROR_ARG,
+ "need a positive integer");
+ return -1;
+ }
+ }
+ return playPlaylist(fp, id, 0);
+}
+
int handleStop(FILE * fp, unsigned int * permission, int argArrayLength,
char ** argArray)
{
@@ -216,7 +240,11 @@ int commandStatus(FILE * fp, unsigned int * permission, int argArrayLength,
myfprintf(fp,"%s: %s\n",COMMAND_STATUS_STATE,state);
song = getPlaylistCurrentSong();
- if(song >= 0) myfprintf(fp,"%s: %i\n",COMMAND_STATUS_SONG,song);
+ if(song >= 0) {
+ myfprintf(fp,"%s: %i\n", COMMAND_STATUS_SONG, song);
+ myfprintf(fp,"%s: %i\n", COMMAND_STATUS_SONGID,
+ getPlaylistSongId(song));
+ }
if(getPlayerState()!=PLAYER_STATE_STOP) {
myfprintf(fp,"%s: %i:%i\n",COMMAND_STATUS_TIME,getPlayerElapsedTime(),getPlayerTotalTime());
myfprintf(fp,"%s: %li\n",COMMAND_STATUS_BITRATE,getPlayerBitRate(),getPlayerTotalTime());
@@ -275,6 +303,21 @@ int handleDelete(FILE * fp, unsigned int * permission, int argArrayLength,
return deleteFromPlaylist(fp,song);
}
+int handleDeleteId(FILE * fp, unsigned int * permission, int argArrayLength,
+ char ** argArray)
+{
+ int id;
+ char * test;
+
+ id = strtol(argArray[1],&test,10);
+ if(*test!='\0') {
+ commandError(fp, ACK_ERROR_ARG,
+ "need a positive integer");
+ return -1;
+ }
+ return deleteFromPlaylist(fp, id);
+}
+
int handlePlaylist(FILE * fp, unsigned int * permission, int argArrayLength,
char ** argArray)
{
@@ -355,6 +398,23 @@ int handlePlaylistInfo(FILE * fp, unsigned int * permission,
return playlistInfo(fp,song);
}
+int handlePlaylistId(FILE * fp, unsigned int * permission,
+ int argArrayLength, char ** argArray)
+{
+ int id = -1;
+ char * test;
+
+ if(argArrayLength == 2) {
+ id = strtol(argArray[1],&test,10);
+ if(*test!='\0') {
+ commandError(fp, ACK_ERROR_ARG,
+ "%s need a positive integer");
+ return -1;
+ }
+ }
+ return playlistId(fp, id);
+}
+
int handleFind(FILE * fp, unsigned int * permission, int argArrayLength,
char ** argArray)
{
@@ -529,6 +589,28 @@ int handleMove(FILE * fp, unsigned int * permission, int argArrayLength,
return moveSongInPlaylist(fp,from,to);
}
+int handleMoveId(FILE * fp, unsigned int * permission, int argArrayLength,
+ char ** argArray)
+{
+ int id;
+ int to;
+ char * test;
+
+ id = strtol(argArray[1],&test,10);
+ if(*test!='\0') {
+ commandError(fp, ACK_ERROR_ARG,
+ "\"%s\" is not a integer", argArray[1]);
+ return -1;
+ }
+ to = strtol(argArray[2],&test,10);
+ if(*test!='\0') {
+ commandError(fp, ACK_ERROR_ARG,
+ "\"%s\" is not a integer", argArray[2]);
+ return -1;
+ }
+ return moveSongInPlaylistById(fp, id, to);
+}
+
int handleSwap(FILE * fp, unsigned int * permission, int argArrayLength,
char ** argArray)
{
@@ -551,6 +633,28 @@ int handleSwap(FILE * fp, unsigned int * permission, int argArrayLength,
return swapSongsInPlaylist(fp,song1,song2);
}
+int handleSwapId(FILE * fp, unsigned int * permission, int argArrayLength,
+ char ** argArray)
+{
+ int id1;
+ int id2;
+ char * test;
+
+ id1 = strtol(argArray[1],&test,10);
+ if(*test!='\0') {
+ commandError(fp, ACK_ERROR_ARG,
+ "\"%s\" is not a integer", argArray[1]);
+ return -1;
+ }
+ id2 = strtol(argArray[2],&test,10);
+ if(*test!='\0') {
+ commandError(fp, ACK_ERROR_ARG, "\"%s\" is not a integer",
+ argArray[2]);
+ return -1;
+ }
+ return swapSongsInPlaylist(fp, id1, id2);
+}
+
int handleSeek(FILE * fp, unsigned int * permission, int argArrayLength,
char ** argArray)
{
@@ -573,6 +677,28 @@ int handleSeek(FILE * fp, unsigned int * permission, int argArrayLength,
return seekSongInPlaylist(fp,song,time);
}
+int handleSeekId(FILE * fp, unsigned int * permission, int argArrayLength,
+ char ** argArray)
+{
+ int id;
+ int time;
+ char * test;
+
+ id = strtol(argArray[1],&test,10);
+ if(*test!='\0') {
+ commandError(fp, ACK_ERROR_ARG,
+ "\"%s\" is not a integer", argArray[1]);
+ return -1;
+ }
+ time = strtol(argArray[2],&test,10);
+ if(*test!='\0') {
+ commandError(fp, ACK_ERROR_ARG,
+ "\"%s\" is not a integer", argArray[2]);
+ return -1;
+ }
+ return seekSongInPlaylist(fp, id, time);
+}
+
int handleListAllInfo(FILE * fp, unsigned int * permission, int argArrayLength,
char ** argArray)
{
@@ -621,6 +747,7 @@ void initCommands() {
commandList = makeList(free);
addCommand(COMMAND_PLAY ,PERMISSION_CONTROL, 0, 1,handlePlay,NULL);
+ addCommand(COMMAND_PLAYID ,PERMISSION_CONTROL, 0, 1,handlePlayId,NULL);
addCommand(COMMAND_STOP ,PERMISSION_CONTROL, 0, 0,handleStop,NULL);
addCommand(COMMAND_PAUSE ,PERMISSION_CONTROL, 0, 1,handlePause,NULL);
addCommand(COMMAND_STATUS ,PERMISSION_READ, 0, 0,commandStatus,NULL);
@@ -628,7 +755,9 @@ void initCommands() {
addCommand(COMMAND_CLOSE ,0, -1,-1,handleClose,NULL);
addCommand(COMMAND_ADD ,PERMISSION_ADD, 0, 1,handleAdd,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);
+ addCommand(COMMAND_PLAYLISTID ,PERMISSION_READ, 0, 0,handlePlaylistId,NULL);
addCommand(COMMAND_SHUFFLE ,PERMISSION_CONTROL, 0, 0,handleShuffle,NULL);
addCommand(COMMAND_CLEAR ,PERMISSION_CONTROL, 0, 0,handleClear,NULL);
addCommand(COMMAND_SAVE ,PERMISSION_CONTROL, 1, 1,handleSave,NULL);
@@ -649,8 +778,11 @@ void initCommands() {
addCommand(COMMAND_CLEAR_ERROR ,PERMISSION_CONTROL, 0, 0,handleClearError,NULL);
addCommand(COMMAND_LIST ,PERMISSION_READ, 1, 2,handleList,NULL);
addCommand(COMMAND_MOVE ,PERMISSION_CONTROL, 2, 2,handleMove,NULL);
+ addCommand(COMMAND_MOVEID ,PERMISSION_CONTROL, 2, 2,handleMoveId,NULL);
addCommand(COMMAND_SWAP ,PERMISSION_CONTROL, 2, 2,handleSwap,NULL);
+ addCommand(COMMAND_SWAPID ,PERMISSION_CONTROL, 2, 2,handleSwapId,NULL);
addCommand(COMMAND_SEEK ,PERMISSION_CONTROL, 2, 2,handleSeek,NULL);
+ addCommand(COMMAND_SEEKID ,PERMISSION_CONTROL, 2, 2,handleSeekId,NULL);
addCommand(COMMAND_LISTALLINFO ,PERMISSION_READ, 0, 1,handleListAllInfo,NULL);
addCommand(COMMAND_PING ,0, 0, 0,handlePing,NULL);
addCommand(COMMAND_SETVOL ,PERMISSION_CONTROL, 1, 1,handleSetVol,NULL);
diff --git a/src/playlist.c b/src/playlist.c
index e7eb1827d..31dc31fc5 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -1081,12 +1081,10 @@ int moveSongInPlaylist(FILE * fp, int from, int to) {
return 0;
}
-int moveSongInPlaylistById(FILE * fp, int id1, int id2) {
+int moveSongInPlaylistById(FILE * fp, int id1, int to) {
checkSongId(id1);
- checkSongId(id2);
- return moveSongInPlaylist(fp, playlist.idToNum[id1],
- playlist.idToNum[id2]);
+ return moveSongInPlaylist(fp, playlist.idToNum[id1], to);
}
void orderPlaylist() {
@@ -1461,3 +1459,7 @@ int seekSongInPlaylistById(FILE * fp, int id, float time) {
return seekSongInPlaylist(fp, playlist.idToNum[id], time);
}
+
+int getPlaylistSongId(int song) {
+ return playlist.numToId[song];
+}
diff --git a/src/playlist.h b/src/playlist.h
index 0281b6bfe..2b6befd74 100644
--- a/src/playlist.h
+++ b/src/playlist.h
@@ -50,12 +50,18 @@ int showPlaylist(FILE * fp);
int deleteFromPlaylist(FILE * fp, int song);
+int deleteFromPlaylistById(FILE * fp, int song);
+
int playlistInfo(FILE * fp, int song);
+int playlistId(FILE * fp, int song);
+
int stopPlaylist(FILE * fp);
int playPlaylist(FILE * fp, int song, int stopOnError);
+int playPlaylistById(FILE * fp, int song, int stopOnError);
+
int nextSongInPlaylist(FILE * fp);
void syncPlayerAndPlaylist();
@@ -68,12 +74,18 @@ int savePlaylist(FILE * fp, char * utf8file);
int deletePlaylist(FILE * fp, char * utf8file);
+int deletePlaylistById(FILE * fp, char * utf8file);
+
void deleteASongFromPlaylist(Song * song);
int moveSongInPlaylist(FILE * fp, int from, int to);
+int moveSongInPlaylistById(FILE * fp, int id, int to);
+
int swapSongsInPlaylist(FILE * fp, int song1, int song2);
+int swapSongsInPlaylistById(FILE * fp, int id1, int id2);
+
int loadPlaylist(FILE * fp, char * utf8file);
int getPlaylistRepeatStatus();
@@ -86,6 +98,8 @@ int setPlaylistRandomStatus(FILE * fp, int status);
int getPlaylistCurrentSong();
+int getPlaylistSongId(int song);
+
int getPlaylistLength();
unsigned long getPlaylistVersion();
@@ -94,6 +108,8 @@ void playPlaylistIfPlayerStopped();
int seekSongInPlaylist(FILE * fp, int song, float time);
+int seekSongInPlaylistById(FILE * fp, int id, float time);
+
void playlistVersionChange();
int playlistChanges(FILE * fp, mpd_uint32 version);