diff options
author | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2009-12-15 17:08:19 +0100 |
---|---|---|
committer | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2009-12-15 17:08:19 +0100 |
commit | 6a62ae4231c2ce10b6623e32198f40f0a2a8e777 (patch) | |
tree | 524e9322520bdbee06cdc20f1b8d636147d7aa9f /libpiano | |
parent | 927a878f171580c1fdeb4d01caf0a2c9c32f8b42 (diff) | |
download | pianobar-6a62ae4231c2ce10b6623e32198f40f0a2a8e777.tar.gz pianobar-6a62ae4231c2ce10b6623e32198f40f0a2a8e777.tar.bz2 pianobar-6a62ae4231c2ce10b6623e32198f40f0a2a8e777.zip |
New history feature
Default key is 'h', playlists are no longer part of PianoHandle_t now
(=> libpiano's api changed)
Diffstat (limited to 'libpiano')
-rw-r--r-- | libpiano/src/main.c | 12 | ||||
-rw-r--r-- | libpiano/src/piano.h | 5 | ||||
-rw-r--r-- | libpiano/src/xml.c | 10 | ||||
-rw-r--r-- | libpiano/src/xml.h | 3 |
4 files changed, 16 insertions, 14 deletions
diff --git a/libpiano/src/main.c b/libpiano/src/main.c index 16d30d7..2bf8426 100644 --- a/libpiano/src/main.c +++ b/libpiano/src/main.c @@ -133,10 +133,10 @@ void PianoDestroyStations (PianoStation_t *stations) { * @param piano handle * @return nothing */ -void PianoDestroyPlaylist (PianoHandle_t *ph) { +void PianoDestroyPlaylist (PianoSong_t *playlist) { PianoSong_t *curSong, *lastSong; - curSong = ph->playlist; + curSong = playlist; while (curSong != NULL) { PianoFree (curSong->audioUrl, 0); PianoFree (curSong->artist, 0); @@ -152,7 +152,6 @@ void PianoDestroyPlaylist (PianoHandle_t *ph) { curSong = curSong->next; PianoFree (lastSong, sizeof (*lastSong)); } - ph->playlist = NULL; } /* frees the whole piano handle structure @@ -176,7 +175,6 @@ void PianoDestroy (PianoHandle_t *ph) { curGenreCat = curGenreCat->next; PianoFree (lastGenreCat, sizeof (*lastGenreCat)); } - PianoDestroyPlaylist (ph); memset (ph, 0, sizeof (*ph)); } @@ -255,9 +253,11 @@ PianoReturn_t PianoGetStations (PianoHandle_t *ph) { /* get next songs for station (usually four tracks) * @param piano handle * @param station id + * @param audio format + * @param return value: playlist */ PianoReturn_t PianoGetPlaylist (PianoHandle_t *ph, const char *stationId, - PianoAudioFormat_t format) { + PianoAudioFormat_t format, PianoSong_t **retPlaylist) { char xmlSendBuf[PIANO_SEND_BUFFER_SIZE], *retStr; PianoReturn_t ret; @@ -283,7 +283,7 @@ PianoReturn_t PianoGetPlaylist (PianoHandle_t *ph, const char *stationId, if ((ret = PianoHttpPost (&ph->waith, xmlSendBuf, &retStr)) == PIANO_RET_OK) { - ret = PianoXmlParsePlaylist (ph, retStr); + ret = PianoXmlParsePlaylist (ph, retStr, retPlaylist); PianoFree (retStr, 0); } diff --git a/libpiano/src/piano.h b/libpiano/src/piano.h index 3bb9108..cd3e8ca 100644 --- a/libpiano/src/piano.h +++ b/libpiano/src/piano.h @@ -90,7 +90,6 @@ typedef struct PianoHandle { PianoUserInfo_t user; /* linked lists */ PianoStation_t *stations; - PianoSong_t *playlist; PianoGenreCategory_t *genreStations; } PianoHandle_t; @@ -109,13 +108,13 @@ typedef enum {PIANO_RET_OK, PIANO_RET_ERR, PIANO_RET_XML_INVALID, void PianoInit (PianoHandle_t *); void PianoDestroy (PianoHandle_t *); -void PianoDestroyPlaylist (PianoHandle_t *); +void PianoDestroyPlaylist (PianoSong_t *); void PianoDestroySearchResult (PianoSearchResult_t *); PianoReturn_t PianoConnect (PianoHandle_t *, const char *, const char *); PianoReturn_t PianoGetStations (PianoHandle_t *); PianoReturn_t PianoGetPlaylist (PianoHandle_t *, const char *, - PianoAudioFormat_t); + PianoAudioFormat_t, PianoSong_t **); PianoReturn_t PianoRateTrack (PianoHandle_t *, PianoSong_t *, PianoSongRating_t); diff --git a/libpiano/src/xml.c b/libpiano/src/xml.c index 8e8fb2a..8d34a32 100644 --- a/libpiano/src/xml.c +++ b/libpiano/src/xml.c @@ -484,8 +484,10 @@ PianoReturn_t PianoXmlParseAddSeed (PianoHandle_t *ph, char *xml, /* parses playlist; used when searching too * @param piano handle * @param xml document + * @param return: playlist */ -PianoReturn_t PianoXmlParsePlaylist (PianoHandle_t *ph, char *xml) { +PianoReturn_t PianoXmlParsePlaylist (PianoHandle_t *ph, char *xml, + PianoSong_t **retPlaylist) { ezxml_t xmlDoc, dataNode; PianoReturn_t ret; @@ -508,10 +510,10 @@ PianoReturn_t PianoXmlParsePlaylist (PianoHandle_t *ph, char *xml) { PianoXmlStructParser (ezxml_child (dataNode, "struct"), PianoXmlParsePlaylistCb, tmpSong); /* begin linked list or append */ - if (ph->playlist == NULL) { - ph->playlist = tmpSong; + if (*retPlaylist == NULL) { + *retPlaylist = tmpSong; } else { - PianoSong_t *curSong = ph->playlist; + PianoSong_t *curSong = *retPlaylist; while (curSong->next != NULL) { curSong = curSong->next; } diff --git a/libpiano/src/xml.h b/libpiano/src/xml.h index 5c0e5c2..7d1f1b2 100644 --- a/libpiano/src/xml.h +++ b/libpiano/src/xml.h @@ -28,7 +28,8 @@ THE SOFTWARE. PianoReturn_t PianoXmlParseUserinfo (PianoHandle_t *ph, const char *xml); PianoReturn_t PianoXmlParseStations (PianoHandle_t *ph, const char *xml); -PianoReturn_t PianoXmlParsePlaylist (PianoHandle_t *ph, const char *xml); +PianoReturn_t PianoXmlParsePlaylist (PianoHandle_t *ph, const char *xml, + PianoSong_t **); PianoReturn_t PianoXmlParseSearch (const char *searchXml, PianoSearchResult_t *searchResult); PianoReturn_t PianoXmlParseSimple (const char *xml); |