From bbd317d85069dee9c9cffff609d1d1fd086cbcb7 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Mon, 21 Mar 2011 12:46:21 +0100 Subject: piano: Add getStation support Response contains artist/song seeds and feedback data. --- src/libpiano/piano.c | 69 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 15 deletions(-) (limited to 'src/libpiano/piano.c') diff --git a/src/libpiano/piano.c b/src/libpiano/piano.c index a53c102..e475799 100644 --- a/src/libpiano/piano.c +++ b/src/libpiano/piano.c @@ -57,32 +57,29 @@ void PianoInit (PianoHandle_t *ph) { (unsigned long) time (NULL) % 10000000); } -/* free complete search result - * @public yes - * @param search result +/* destroy artist linked list */ -void PianoDestroySearchResult (PianoSearchResult_t *searchResult) { +void PianoDestroyArtists (PianoArtist_t *artists) { PianoArtist_t *curArtist, *lastArtist; - PianoSong_t *curSong, *lastSong; - curArtist = searchResult->artists; + curArtist = artists; while (curArtist != NULL) { free (curArtist->name); free (curArtist->musicId); + free (curArtist->seedId); lastArtist = curArtist; curArtist = curArtist->next; free (lastArtist); } +} - curSong = searchResult->songs; - while (curSong != NULL) { - free (curSong->title); - free (curSong->artist); - free (curSong->musicId); - lastSong = curSong; - curSong = curSong->next; - free (lastSong); - } +/* free complete search result + * @public yes + * @param search result + */ +void PianoDestroySearchResult (PianoSearchResult_t *searchResult) { + PianoDestroyArtists (searchResult->artists); + PianoDestroyPlaylist (searchResult->songs); } /* free single station @@ -128,12 +125,20 @@ void PianoDestroyPlaylist (PianoSong_t *playlist) { free (curSong->stationId); free (curSong->album); free (curSong->artistMusicId); + free (curSong->feedbackId); + free (curSong->seedId); lastSong = curSong; curSong = curSong->next; free (lastSong); } } +void PianoDestroyStationInfo (PianoStationInfo_t *info) { + PianoDestroyPlaylist (info->feedback); + PianoDestroyPlaylist (info->songSeeds); + PianoDestroyArtists (info->artistSeeds); +} + /* destroy genre linked list */ void PianoDestroyGenres (PianoGenre_t *genres) { @@ -708,6 +713,28 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, break; } + case PIANO_REQUEST_GET_STATION_INFO: { + /* get station information (seeds and feedback) */ + PianoRequestDataGetStationInfo_t *reqData = req->data; + + assert (reqData != NULL); + assert (reqData->station != NULL); + + snprintf (xmlSendBuf, sizeof (xmlSendBuf), "" + "station.getStation" + "%lu" + /* auth token */ + "%s" + /* station id */ + "%s" + "", (unsigned long) timestamp, + ph->user.authToken, reqData->station->id); + snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH + "rid=%s&lid=%s&method=getStation&arg1=%s", + ph->routeId, ph->user.listenerId, reqData->station->id); + break; + } + /* "high-level" wrapper */ case PIANO_REQUEST_RATE_SONG: { /* love/ban song */ @@ -1029,6 +1056,18 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) { &reqData->searchResult); break; } + + case PIANO_REQUEST_GET_STATION_INFO: { + /* get station information (seeds and feedback) */ + PianoRequestDataGetStationInfo_t *reqData = req->data; + + assert (req->responseData != NULL); + assert (reqData != NULL); + + ret = PianoXmlParseGetStationInfo (req->responseData, + &reqData->info); + break; + } } return ret; -- cgit v1.2.3