diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2012-07-05 22:00:22 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2012-07-06 17:29:04 +0200 |
commit | 24ed240c865837b8c9d7c9240f6ef3ba9065b162 (patch) | |
tree | a6e0d2e26877ab899d451865fa4995f0b8bf382b /src/libpiano | |
parent | bf13c962d2db93bd09d7dd50a26978e44fb0e860 (diff) | |
download | pianobar-windows-24ed240c865837b8c9d7c9240f6ef3ba9065b162.tar.gz pianobar-windows-24ed240c865837b8c9d7c9240f6ef3ba9065b162.tar.bz2 pianobar-windows-24ed240c865837b8c9d7c9240f6ef3ba9065b162.zip |
Add feature: Create new station from selected song
New keybinding āvā, new setting act_createstationfromsong.
Diffstat (limited to 'src/libpiano')
-rw-r--r-- | src/libpiano/piano.h | 9 | ||||
-rw-r--r-- | src/libpiano/request.c | 31 |
2 files changed, 35 insertions, 5 deletions
diff --git a/src/libpiano/piano.h b/src/libpiano/piano.h index e881621..00bc744 100644 --- a/src/libpiano/piano.h +++ b/src/libpiano/piano.h @@ -208,6 +208,15 @@ typedef struct { } PianoRequestDataSearch_t; typedef struct { + char *token; + enum { + PIANO_MUSICTYPE_INVALID = 0, + PIANO_MUSICTYPE_SONG, + PIANO_MUSICTYPE_ARTIST, + } type; +} PianoRequestDataCreateStation_t; + +typedef struct { PianoStation_t *station; char *musicId; } PianoRequestDataAddSeed_t; diff --git a/src/libpiano/request.c b/src/libpiano/request.c index cb1b30a..85d6286 100644 --- a/src/libpiano/request.c +++ b/src/libpiano/request.c @@ -204,12 +204,33 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, case PIANO_REQUEST_CREATE_STATION: { /* create new station from specified musicToken or station number */ - char *token = req->data; + PianoRequestDataCreateStation_t *reqData = req->data; - assert (token != NULL); - - json_object_object_add (j, "musicToken", - json_object_new_string (token)); + assert (reqData != NULL); + assert (reqData->token != NULL); + + if (reqData->type == PIANO_MUSICTYPE_INVALID) { + json_object_object_add (j, "musicToken", + json_object_new_string (reqData->token)); + } else { + json_object_object_add (j, "trackToken", + json_object_new_string (reqData->token)); + switch (reqData->type) { + case PIANO_MUSICTYPE_SONG: + json_object_object_add (j, "musicType", + json_object_new_string ("song")); + break; + + case PIANO_MUSICTYPE_ARTIST: + json_object_object_add (j, "musicType", + json_object_new_string ("artist")); + break; + + default: + assert (0); + break; + } + } method = "station.createStation"; break; |