From 56432d661e34de9aa0d1727fb7b06f19aa18723e Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Tue, 17 Jun 2008 12:13:56 +0200 Subject: More error handling. Now we can parse and handle pandora's messages and abort the parsing process. Some more fault type should be added, as well as more client support for those errors. --- libpiano/main.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'libpiano/main.c') diff --git a/libpiano/main.c b/libpiano/main.c index faf5317..be97737 100644 --- a/libpiano/main.c +++ b/libpiano/main.c @@ -166,12 +166,13 @@ void PianoDestroy (PianoHandle_t *ph) { * @param password (plaintext, utf-8 encoded) * @return nothing */ -void PianoConnect (PianoHandle_t *ph, char *user, char *password) { +PianoReturn_t PianoConnect (PianoHandle_t *ph, char *user, char *password) { char url[PIANO_URL_BUFFER_SIZE]; char *requestStr = PianoEncryptString ("" "misc.sync" ""); char *retStr, requestStrPlain[10000]; + PianoReturn_t ret; /* sync (is the return value used by pandora? for now: ignore result) */ snprintf (url, sizeof (url), PIANO_RPC_URL "rid=%s&method=sync", @@ -192,10 +193,12 @@ void PianoConnect (PianoHandle_t *ph, char *user, char *password) { snprintf (url, sizeof (url), PIANO_SECURE_RPC_URL "rid=%s" "&method=authenticateListener", ph->routeId); PianoHttpPost (ph->curlHandle, url, requestStr, &retStr); - PianoXmlParseUserinfo (ph, retStr); + ret = PianoXmlParseUserinfo (ph, retStr); free (requestStr); free (retStr); + + return ret; } /* get all stations for authenticated user (so: PianoConnect needs to @@ -205,9 +208,10 @@ void PianoConnect (PianoHandle_t *ph, char *user, char *password) { * @param piano handle filled with some authentication data by PianoConnect * @return nothing */ -void PianoGetStations (PianoHandle_t *ph) { +PianoReturn_t PianoGetStations (PianoHandle_t *ph) { char xmlSendBuf[10000], url[PIANO_URL_BUFFER_SIZE]; char *requestStr, *retStr; + PianoReturn_t ret; snprintf (xmlSendBuf, sizeof (xmlSendBuf), "" "station.getStations" @@ -219,9 +223,11 @@ void PianoGetStations (PianoHandle_t *ph) { "rid=%s&lid=%s&method=getStations", ph->routeId, ph->user.listenerId); PianoHttpPost (ph->curlHandle, url, requestStr, &retStr); - PianoXmlParseStations (ph, retStr); + ret = PianoXmlParseStations (ph, retStr); free (retStr); free (requestStr); + + return ret; } /* get next songs for station (usually four tracks) -- cgit v1.2.3