diff options
author | Lars-Dominik Braun <PromyLOPh@gmail.com> | 2008-07-17 15:53:01 +0200 |
---|---|---|
committer | Lars-Dominik Braun <PromyLOPh@gmail.com> | 2008-07-17 15:53:01 +0200 |
commit | 7c96aa41979b1c1b0b4c582c8ac31b7ff779b737 (patch) | |
tree | 125ea492c67f2bbf0d3e2b81e935de2c2376dc5d /libpiano/src/main.c | |
parent | 6b0824285abab829cf97de770c9051a60255106e (diff) | |
download | pianobar-7c96aa41979b1c1b0b4c582c8ac31b7ff779b737.tar.gz pianobar-7c96aa41979b1c1b0b4c582c8ac31b7ff779b737.tar.bz2 pianobar-7c96aa41979b1c1b0b4c582c8ac31b7ff779b737.zip |
piano: Initial global genre stations support
Pandora provides a xml list of genre stations. Read this list and insert its
data into our PianoHandle tree if requested.
Diffstat (limited to 'libpiano/src/main.c')
-rw-r--r-- | libpiano/src/main.c | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/libpiano/src/main.c b/libpiano/src/main.c index 4cd3aa3..3a16401 100644 --- a/libpiano/src/main.c +++ b/libpiano/src/main.c @@ -105,7 +105,6 @@ void PianoDestroySearchResult (PianoSearchResult_t *searchResult) { } /* free single station - * @public yes * @param station */ void PianoDestroyStation (PianoStation_t *station) { @@ -117,17 +116,16 @@ void PianoDestroyStation (PianoStation_t *station) { /* free complete station list * @param piano handle */ -void PianoDestroyStations (PianoHandle_t *ph) { +void PianoDestroyStations (PianoStation_t *stations) { PianoStation_t *curStation, *lastStation; - curStation = ph->stations; + curStation = stations; while (curStation != NULL) { lastStation = curStation; curStation = curStation->next; PianoDestroyStation (lastStation); PianoFree (lastStation, sizeof (*lastStation)); } - ph->stations = NULL; } /* FIXME: copy & waste */ @@ -169,7 +167,16 @@ void PianoDestroy (PianoHandle_t *ph) { PianoFree (ph->user.authToken, 0); PianoFree (ph->user.listenerId, 0); - PianoDestroyStations (ph); + PianoDestroyStations (ph->stations); + /* destroy genre stations */ + PianoGenreCategory_t *curGenreCat = ph->genreStations, *lastGenreCat; + while (curGenreCat != NULL) { + PianoDestroyStations (curGenreCat->stations); + PianoFree (curGenreCat->name, 0); + lastGenreCat = curGenreCat; + curGenreCat = curGenreCat->next; + PianoFree (lastGenreCat, sizeof (*lastGenreCat)); + } PianoDestroyPlaylist (ph); memset (ph, 0, sizeof (*ph)); } @@ -707,3 +714,24 @@ PianoStation_t *PianoFindStationById (PianoStation_t *stations, } return NULL; } + +/* receive genre stations + * @param piano handle + * @return _OK or error + */ +PianoReturn_t PianoGetGenreStations (PianoHandle_t *ph) { + char url[PIANO_URL_BUFFER_SIZE]; + char *retStr; + PianoReturn_t ret; + + snprintf (url, sizeof (url), "http://www.pandora.com/xml/genre?r=%li", + time (NULL)); + + if ((ret = PianoHttpGet (ph->curlHandle, url, &retStr)) == + PIANO_RET_OK) { + ret = PianoXmlParseGenreExplorer (ph, retStr); + PianoFree (retStr, 0); + } + + return ret; +} |