summaryrefslogtreecommitdiff
path: root/src/libpiano
diff options
context:
space:
mode:
Diffstat (limited to 'src/libpiano')
-rw-r--r--src/libpiano/piano.c7
-rw-r--r--src/libpiano/piano.h3
-rw-r--r--src/libpiano/xml.c32
3 files changed, 38 insertions, 4 deletions
diff --git a/src/libpiano/piano.c b/src/libpiano/piano.c
index d6071f2..9a7e8d3 100644
--- a/src/libpiano/piano.c
+++ b/src/libpiano/piano.c
@@ -91,6 +91,7 @@ void PianoDestroySearchResult (PianoSearchResult_t *searchResult) {
void PianoDestroyStation (PianoStation_t *station) {
free (station->name);
free (station->id);
+ free (station->seedId);
memset (station, 0, sizeof (station));
}
@@ -141,6 +142,7 @@ void PianoDestroyStationInfo (PianoStationInfo_t *info) {
PianoDestroyPlaylist (info->feedback);
PianoDestroyPlaylist (info->songSeeds);
PianoDestroyArtists (info->artistSeeds);
+ PianoDestroyStations (info->stationSeeds);
}
/* destroy genre linked list
@@ -769,12 +771,15 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
char *seedId = NULL;
assert (reqData != NULL);
- assert (reqData->song != NULL || reqData->artist != NULL);
+ assert (reqData->song != NULL || reqData->artist != NULL ||
+ reqData->station != NULL);
if (reqData->song != NULL) {
seedId = reqData->song->seedId;
} else if (reqData->artist != NULL) {
seedId = reqData->artist->seedId;
+ } else if (reqData->station != NULL) {
+ seedId = reqData->station->seedId;
}
assert (seedId != NULL);
diff --git a/src/libpiano/piano.h b/src/libpiano/piano.h
index 7b692c6..b692a47 100644
--- a/src/libpiano/piano.h
+++ b/src/libpiano/piano.h
@@ -43,6 +43,7 @@ typedef struct PianoStation {
char useQuickMix; /* station will be included in quickmix */
char *name;
char *id;
+ char *seedId;
struct PianoStation *next;
} PianoStation_t;
@@ -119,6 +120,7 @@ typedef struct PianoSearchResult {
typedef struct {
PianoSong_t *songSeeds;
PianoArtist_t *artistSeeds;
+ PianoStation_t *stationSeeds;
PianoSong_t *feedback;
} PianoStationInfo_t;
@@ -230,6 +232,7 @@ typedef struct {
typedef struct {
PianoSong_t *song;
PianoArtist_t *artist;
+ PianoStation_t *station;
} PianoRequestDataDeleteSeed_t;
typedef enum {
diff --git a/src/libpiano/xml.c b/src/libpiano/xml.c
index 7f21f8d..1dd2a24 100644
--- a/src/libpiano/xml.c
+++ b/src/libpiano/xml.c
@@ -831,6 +831,7 @@ struct PianoXmlParseSeedBag {
char *seedId;
PianoSong_t *song;
PianoArtist_t *artist;
+ PianoStation_t *station;
};
/* parse seed struct
@@ -853,6 +854,14 @@ static void PianoXmlParseSeedCb (const char *key, const ezxml_t value,
PianoXmlStructParser (ezxml_child (value, "struct"),
PianoXmlParseSearchArtistCb, bag->artist);
+ } else if (strcmp ("nonGenomeStation", key) == 0) {
+ /* genre stations are "non genome" station seeds */
+ if ((bag->station = calloc (1, sizeof (*bag->station))) == NULL) {
+ return;
+ }
+
+ PianoXmlStructParser (ezxml_child (value, "struct"),
+ PianoXmlParseStationsCb, bag->station);
} else if (strcmp ("seedId", key) == 0) {
char *valueStr = PianoXmlGetNodeText (value);
bag->seedId = strdup (valueStr);
@@ -875,10 +884,15 @@ static void PianoXmlParseGetStationInfoCb (const char *key, const ezxml_t value,
PianoXmlStructParser (ezxml_child (seedNode, "struct"),
PianoXmlParseSeedCb, &bag);
- /* FIXME: use if-clause */
- assert (bag.seedId != NULL);
- assert (bag.song != NULL || bag.artist != NULL);
+ assert (bag.song != NULL || bag.artist != NULL ||
+ bag.station != NULL);
+
+ if (bag.seedId == NULL) {
+ /* seeds without id are useless */
+ continue;
+ }
+ /* FIXME: copy&waste */
if (bag.song != NULL) {
bag.song->seedId = bag.seedId;
@@ -903,6 +917,18 @@ static void PianoXmlParseGetStationInfoCb (const char *key, const ezxml_t value,
}
curSong->next = bag.artist;
}
+ } else if (bag.station != NULL) {
+ bag.station->seedId = bag.seedId;
+
+ if (info->stationSeeds == NULL) {
+ info->stationSeeds = bag.station;
+ } else {
+ PianoStation_t *curStation = info->stationSeeds;
+ while (curStation->next != NULL) {
+ curStation = curStation->next;
+ }
+ curStation->next = bag.station;
+ }
} else {
free (bag.seedId);
}