From 00cfc5e626abc51df4b728a064697616cf7aae02 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sat, 19 Jul 2008 12:11:12 +0200 Subject: Rate "shared stations" correctly by transforming them to private stations --- libpiano/src/main.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'libpiano/src/main.c') diff --git a/libpiano/src/main.c b/libpiano/src/main.c index d5fa0e7..a4beefd 100644 --- a/libpiano/src/main.c +++ b/libpiano/src/main.c @@ -734,3 +734,44 @@ PianoReturn_t PianoGetGenreStations (PianoHandle_t *ph) { return ret; } + +/* make shared stations private, needed to rate songs played on shared + * stations + * @param piano handle + * @param station to transform + * @return _OK or error + */ +PianoReturn_t PianoTransformShared (PianoHandle_t *ph, + PianoStation_t *station) { + char xmlSendBuf[PIANO_SEND_BUFFER_SIZE], url[PIANO_URL_BUFFER_SIZE]; + char *requestStr, *retStr; + PianoReturn_t ret; + + snprintf (xmlSendBuf, sizeof (xmlSendBuf), "" + "station.transformShared" + "%li" + "%s" + "%s" + "", time (NULL), ph->user.authToken, + station->id); + requestStr = PianoEncryptString (xmlSendBuf); + + snprintf (url, sizeof (url), PIANO_RPC_URL "rid=%s&lid=%s&" + "method=transformShared&arg1=%s", ph->routeId, ph->user.listenerId, + station->id); + + if ((ret = PianoHttpPost (ph->curlHandle, url, requestStr, &retStr)) == + PIANO_RET_OK) { + ret = PianoXmlParseTranformStation (retStr); + /* though this call returns a bunch of "new" data only this one is + * changed and important (at the moment) */ + if (ret == PIANO_RET_OK) { + station->isCreator = 1; + } + PianoFree (retStr, 0); + } + + PianoFree (requestStr, 0); + + return ret; +} -- cgit v1.2.3