aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/command.c10
-rw-r--r--src/directory.c2
-rw-r--r--src/playlist.c18
-rw-r--r--src/playlist.h4
4 files changed, 24 insertions, 10 deletions
diff --git a/src/command.c b/src/command.c
index d7d644cd0..6ccb51579 100644
--- a/src/command.c
+++ b/src/command.c
@@ -45,6 +45,7 @@
#define COMMAND_KILL "kill"
#define COMMAND_CLOSE "close"
#define COMMAND_ADD "add"
+#define COMMAND_ADDID "addid"
#define COMMAND_DELETE "delete"
#define COMMAND_DELETEID "deleteid"
#define COMMAND_PLAYLIST "playlist"
@@ -298,11 +299,17 @@ int handleAdd(FILE * fp, unsigned int * permission, int argArrayLength,
if(argArrayLength == 2) {
path = argArray[1];
- if(isRemoteUrl(path)) return addToPlaylist(fp,path);
+ if(isRemoteUrl(path)) return addToPlaylist(fp, path, 0);
}
return addAllIn(fp,path);
}
+int handleAddId(FILE * fp, unsigned int * permission, int argArrayLength,
+ char ** argArray)
+{
+ return addToPlaylist(fp, argArray[0], 1);
+}
+
int handleDelete(FILE * fp, unsigned int * permission, int argArrayLength,
char ** argArray)
{
@@ -811,6 +818,7 @@ void initCommands() {
addCommand(COMMAND_KILL ,PERMISSION_ADMIN, -1,-1,handleKill,NULL);
addCommand(COMMAND_CLOSE ,0, -1,-1,handleClose,NULL);
addCommand(COMMAND_ADD ,PERMISSION_ADD, 0, 1,handleAdd,NULL);
+ addCommand(COMMAND_ADDID ,PERMISSION_ADD, 0, 1,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);
diff --git a/src/directory.c b/src/directory.c
index 75b50720c..5caeb311d 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -1289,7 +1289,7 @@ int printAllIn(FILE * fp, char * name) {
}
int directoryAddSongToPlaylist(FILE * fp, Song * song, void * data) {
- return addSongToPlaylist(fp,song);
+ return addSongToPlaylist(fp, song, 0);
}
int addAllIn(FILE * fp, char * name) {
diff --git a/src/playlist.c b/src/playlist.c
index 71901b85a..ea88ef18e 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -315,7 +315,7 @@ void loadPlaylistFromStateFile(FILE * fp, char * buffer, int state, int current,
playlist_stateFile);
exit(EXIT_FAILURE);
}
- if(addToPlaylist(stderr,temp)==0 && current==song) {
+ if(addToPlaylist(stderr, temp, 0)==0 && current==song) {
if(state!=PLAYER_STATE_STOP) {
playPlaylist(stderr,playlist.length-1,0);
}
@@ -595,7 +595,7 @@ void clearPlayerQueue() {
}
}
-int addToPlaylist(FILE * fp, char * url) {
+int addToPlaylist(FILE * fp, char * url, int printId) {
Song * song;
DEBUG("add to playlist: %s\n",url);
@@ -613,10 +613,12 @@ int addToPlaylist(FILE * fp, char * url) {
return -1;
}
- return addSongToPlaylist(fp,song);
+ return addSongToPlaylist(fp,song, printId);
}
-int addSongToPlaylist(FILE * fp, Song * song) {
+int addSongToPlaylist(FILE * fp, Song * song, int printId) {
+ int id;
+
if(playlist.length==playlist_max_length) {
commandError(fp, ACK_ERROR_PLAYLIST_MAX,
"playlist is at the max size", NULL);
@@ -631,10 +633,12 @@ int addSongToPlaylist(FILE * fp, Song * song) {
}
}
+ id = getNextId();
+
playlist.songs[playlist.length] = song;
playlist.songMod[playlist.length] = playlist.version;
playlist.order[playlist.length] = playlist.length;
- playlist.positionToId[playlist.length] = getNextId();
+ playlist.positionToId[playlist.length] = id;
playlist.idToPosition[playlist.positionToId[playlist.length]] = playlist.length;
playlist.length++;
@@ -653,6 +657,8 @@ int addSongToPlaylist(FILE * fp, Song * song) {
incrPlaylistVersion();
+ if(printId) myfprintf(fp, "Id: %i\n", id);
+
return 0;
}
@@ -1400,7 +1406,7 @@ int loadPlaylist(FILE * fp, char * utf8file) {
free(temp);
continue;
}
- if((addToPlaylist(stderr,temp))<0) {
+ if((addToPlaylist(stderr, temp, 0))<0) {
if(!erroredFile) erroredFile = strdup(temp);
}
free(temp);
diff --git a/src/playlist.h b/src/playlist.h
index 2b6befd74..025e6445c 100644
--- a/src/playlist.h
+++ b/src/playlist.h
@@ -42,9 +42,9 @@ void savePlaylistState();
int clearPlaylist(FILE * fp);
-int addToPlaylist(FILE * fp, char * file);
+int addToPlaylist(FILE * fp, char * file, int printId);
-int addSongToPlaylist(FILE * fp, Song * song);
+int addSongToPlaylist(FILE * fp, Song * song, int printId);
int showPlaylist(FILE * fp);