From 0b12bc2e998c8c531f58228435ae2c716960964e Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Tue, 10 Jun 2008 21:21:58 +0200 Subject: Implement station renaming --- libpiano/main.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'libpiano') 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), "" + "station.setStationName" + "%li" + "%s" + "%s" + "%s" + "", 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; +} -- cgit v1.2.3