static int scrobbler_send_tracks ( char *  key,
const char *  url,
const char *  poststr 
) [static]

Submit an amount of tracks to the AudioScrobbler server. Also make sure whether the tracks are submitted properly.

Definition at line 422 of file scrobbler.c.

00423 {
00424         CURL *con;
00425         GString *response;
00426         char *lines[1];
00427         int ret;
00428 
00429         con = curl_easy_init();
00430         if (con == NULL)
00431                 return (-1);
00432         
00433         curl_easy_setopt(con, CURLOPT_URL, url);
00434         curl_easy_setopt(con, CURLOPT_POSTFIELDS, poststr);
00435         curl_easy_setopt(con, CURLOPT_USERAGENT, APP_NAME "/" APP_VERSION);
00436 
00437         /* Callback function */
00438         response = g_string_sized_new(128);
00439         curl_easy_setopt(con, CURLOPT_WRITEFUNCTION, scrobbler_curl_concat);
00440         curl_easy_setopt(con, CURLOPT_WRITEDATA, response);
00441 
00442         ret = curl_easy_perform(con);
00443         curl_easy_cleanup(con);
00444 
00445         /* Connection error */
00446         if (ret != 0)
00447                 goto done;
00448 
00449         ret = -1;
00450         scrobbler_split_lines(response->str, lines, 1);
00451 
00452         /* Response string handling */
00453         if (lines[0] != NULL) {
00454                 if (strcmp(lines[0], "OK") == 0)
00455                         ret = 0;
00456                 else if (strcmp(lines[0], "BADSESSION") == 0)
00457                         /* Invalidate the session */
00458                         key[0] = '\0';
00459         }
00460 done:
00461         g_string_free(response, TRUE);
00462         return (ret);
00463 }

Here is the call graph for this function:

Here is the caller graph for this function:

 All Data Structures Files Functions Variables Defines
Generated on Mon Mar 15 04:45:47 2010 for herrie by  doxygen 1.6.3