diff options
author | Lars-Dominik Braun <PromyLOPh@gmail.com> | 2008-06-10 21:21:58 +0200 |
---|---|---|
committer | Lars-Dominik Braun <PromyLOPh@gmail.com> | 2008-06-10 21:21:58 +0200 |
commit | 0b12bc2e998c8c531f58228435ae2c716960964e (patch) | |
tree | 3ef5eca9c37814f2b97a49414fd4b5375599ffc6 /libpiano | |
parent | fc349af94466fbfa95c2f4d1c3435eecc11c3f2b (diff) | |
download | pianobar-0b12bc2e998c8c531f58228435ae2c716960964e.tar.gz pianobar-0b12bc2e998c8c531f58228435ae2c716960964e.tar.bz2 pianobar-0b12bc2e998c8c531f58228435ae2c716960964e.zip |
Implement station renaming
Diffstat (limited to 'libpiano')
-rw-r--r-- | libpiano/main.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libpiano/main.c b/libpiano/main.c index 746e8d9..b933bb7 100644 --- a/libpiano/main.c +++ b/libpiano/main.c @@ -267,3 +267,33 @@ PianoReturn_t PianoRateTrack (PianoHandle_t *ph, PianoStation_t *station, return ret; } + +PianoReturn_t PianoRenameStation (PianoHandle_t *ph, PianoStation_t *station, + char *newName) { + char xmlSendBuf[10000], url[PIANO_URL_BUFFER_SIZE]; + char *requestStr, *retStr, *urlencodedNewName; + PianoReturn_t ret = PIANO_RET_ERR; + + snprintf (xmlSendBuf, sizeof (xmlSendBuf), "<?xml version=\"1.0\"?>" + "<methodCall><methodName>station.setStationName</methodName>" + "<params><param><value><int>%li</int></value></param>" + "<param><value><string>%s</string></value></param>" + "<param><value><string>%s</string></value></param>" + "<param><value><string>%s</string></value></param>" + "</params></methodCall>", time (NULL), ph->user.authToken, + station->id, /* FIXME: xml-encode this */ newName); + requestStr = PianoEncryptString (xmlSendBuf); + + urlencodedNewName = curl_easy_escape (ph->curlHandle, newName, 0); + snprintf (url, sizeof (url), PIANO_RPC_URL "rid=%s&lid=%s" + "&method=setStationName&arg1=%s&arg2=%s", ph->routeId, + ph->user.listenerId, station->id, urlencodedNewName); + PianoHttpPost (ph->curlHandle, url, requestStr, &retStr); + ret = PianoXmlParseSimple (retStr); + + curl_free (urlencodedNewName); + free (requestStr); + free (retStr); + + return ret; +} |