summaryrefslogtreecommitdiff
path: root/libpiano/main.c
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@gmail.com>2008-06-17 12:13:56 +0200
committerLars-Dominik Braun <PromyLOPh@gmail.com>2008-06-17 12:13:56 +0200
commit56432d661e34de9aa0d1727fb7b06f19aa18723e (patch)
tree11cd9f4272afae4867496dc942f35866718d2a7c /libpiano/main.c
parentdddcf192c7c9d3a4cb19e7523d81ed2b11d560ad (diff)
downloadpianobar-56432d661e34de9aa0d1727fb7b06f19aa18723e.tar.gz
pianobar-56432d661e34de9aa0d1727fb7b06f19aa18723e.tar.bz2
pianobar-56432d661e34de9aa0d1727fb7b06f19aa18723e.zip
More error handling.
Now we can parse and handle pandora's <fault> messages and abort the parsing process. Some more fault type should be added, as well as more client support for those errors.
Diffstat (limited to 'libpiano/main.c')
-rw-r--r--libpiano/main.c14
1 files changed, 10 insertions, 4 deletions
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 ("<?xml version=\"1.0\"?>"
"<methodCall><methodName>misc.sync</methodName>"
"<params></params></methodCall>");
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), "<?xml version=\"1.0\"?>"
"<methodCall><methodName>station.getStations</methodName>"
@@ -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)