diff options
Diffstat (limited to 'libpiano')
-rw-r--r-- | libpiano/main.c | 33 | ||||
-rw-r--r-- | libpiano/piano.h | 3 | ||||
-rw-r--r-- | libpiano/xml.c | 28 | ||||
-rw-r--r-- | libpiano/xml.h | 1 |
4 files changed, 65 insertions, 0 deletions
diff --git a/libpiano/main.c b/libpiano/main.c index cc4e65a..9754e73 100644 --- a/libpiano/main.c +++ b/libpiano/main.c @@ -456,3 +456,36 @@ void PianoSearchMusic (PianoHandle_t *ph, char *searchStr, free (retStr); free (requestStr); } + +/* create new station on server + * @author PromyLOPh + * @added 2008-06-14 + * @public yes + * @param piano handle + * @param music id from artist or track, you may obtain one by calling + * PianoSearchMusic + * @return nothing, yet + */ +void PianoCreateStation (PianoHandle_t *ph, char *musicId) { + char xmlSendBuf[10000], url[PIANO_URL_BUFFER_SIZE]; + char *requestStr, *retStr; + + snprintf (xmlSendBuf, sizeof (xmlSendBuf), "<?xml version=\"1.0\"?>" + "<methodCall><methodName>station.createStation</methodName>" + "<params><param><value><int>%li</int></value></param>" + "<param><value><string>%s</string></value></param>" + "<param><value><string>mi%s</string></value></param>" + "</params></methodCall>", time (NULL), ph->user.authToken, + musicId); + requestStr = PianoEncryptString (xmlSendBuf); + + snprintf (url, sizeof (url), PIANO_RPC_URL "rid=%s&lid=%s" + "&method=createStation&arg1=mi%s", ph->routeId, + ph->user.listenerId, musicId); + + PianoHttpPost (ph->curlHandle, url, requestStr, &retStr); + PianoXmlParseCreateStation (ph, retStr); + + free (requestStr); + free (retStr); +} diff --git a/libpiano/piano.h b/libpiano/piano.h index 9f2f7d7..0bffce5 100644 --- a/libpiano/piano.h +++ b/libpiano/piano.h @@ -157,5 +157,8 @@ PianoReturn_t PianoRateTrack (PianoHandle_t *ph, PianoStation_t *station, PianoReturn_t PianoRenameStation (PianoHandle_t *ph, PianoStation_t *station, char *newName); PianoReturn_t PianoDeleteStation (PianoHandle_t *ph, PianoStation_t *station); +void PianoSearchMusic (PianoHandle_t *ph, char *searchStr, + PianoSearchResult_t *searchResult); +void PianoCreateStation (PianoHandle_t *ph, char *musicId); #endif /* _PIANO_H */ diff --git a/libpiano/xml.c b/libpiano/xml.c index 6f8cb55..5ac8d97 100644 --- a/libpiano/xml.c +++ b/libpiano/xml.c @@ -245,6 +245,34 @@ void PianoXmlParseStations (PianoHandle_t *ph, char *xml) { xmlFreeDoc (doc); } +void PianoXmlParseCreateStation (PianoHandle_t *ph, char *xml) { + xmlNode *docRoot; + xmlDocPtr doc; + PianoStation_t *tmpStation; + + if (PianoXmlInitDoc (xml, &doc, &docRoot) != PIANO_RET_OK) { + return; + } + + /* get <struct> node */ + xmlNode *dataRoot = docRoot->children->children->children->children; + tmpStation = calloc (1, sizeof (*tmpStation)); + PianoXmlStructParser (dataRoot, PianoXmlParseStationsCb, tmpStation); + /* FIXME: copy & waste */ + /* start new linked list or append */ + if (ph->stations == NULL) { + ph->stations = tmpStation; + } else { + PianoStation_t *curStation = ph->stations; + while (curStation->next != NULL) { + curStation = curStation->next; + } + curStation->next = tmpStation; + } + + xmlFreeDoc (doc); +} + /* parses playlist; used when searching too * @author PromyLOPh * @added 2008-06-12 diff --git a/libpiano/xml.h b/libpiano/xml.h index 140d0ff..f8c9106 100644 --- a/libpiano/xml.h +++ b/libpiano/xml.h @@ -29,6 +29,7 @@ void PianoXmlParsePlaylist (PianoHandle_t *ph, char *xml); void PianoXmlParseSearch (char *searchXml, PianoSearchResult_t *searchResult); PianoReturn_t PianoXmlParseSimple (char *xml); +void PianoXmlParseCreateStation (PianoHandle_t *ph, char *xml); char *PianoXmlEncodeString (const char *s); |