Created
January 2, 2014 14:42
-
-
Save anonymous/8220159 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/libpiano/piano.h b/src/libpiano/piano.h | |
| index ce66171..faa1e47 100644 | |
| --- a/src/libpiano/piano.h | |
| +++ b/src/libpiano/piano.h | |
| @@ -169,6 +169,7 @@ typedef enum { | |
| PIANO_REQUEST_GET_STATION_INFO = 20, | |
| PIANO_REQUEST_DELETE_FEEDBACK = 21, | |
| PIANO_REQUEST_DELETE_SEED = 22, | |
| + PIANO_REQUEST_GET_AD_METADATA = 23, | |
| } PianoRequestType_t; | |
| typedef struct PianoRequest { | |
| @@ -244,6 +245,10 @@ typedef struct { | |
| PianoStation_t *station; | |
| } PianoRequestDataDeleteSeed_t; | |
| +typedef struct { | |
| + char *token; | |
| +} PianoRequestDataGetAdMetadata_t; | |
| + | |
| /* pandora error code offset */ | |
| #define PIANO_RET_OFFSET 1024 | |
| typedef enum { | |
| diff --git a/src/libpiano/request.c b/src/libpiano/request.c | |
| index 82bf350..1949340 100644 | |
| --- a/src/libpiano/request.c | |
| +++ b/src/libpiano/request.c | |
| @@ -398,6 +398,23 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, | |
| break; | |
| } | |
| + case PIANO_REQUEST_GET_AD_METADATA: { | |
| + PianoRequestDataGetAdMetadata_t *reqData = req->data; | |
| + | |
| + assert (reqData != NULL); | |
| + assert (reqData->token != NULL); | |
| + | |
| + json_object_object_add (j, "adToken", | |
| + json_object_new_string (reqData->token)); | |
| + json_object_object_add (j, "supportAudioAds", | |
| + json_object_new_boolean (true)); | |
| + json_object_object_add (j, "includeBannerAd", | |
| + json_object_new_boolean (false)); | |
| + | |
| + method = "ad.getAdMetadata"; | |
| + break; | |
| + } | |
| + | |
| /* "high-level" wrapper */ | |
| case PIANO_REQUEST_RATE_SONG: { | |
| /* love/ban song */ | |
| diff --git a/src/libpiano/response.c b/src/libpiano/response.c | |
| index 41bbfd3..e16f1f5 100644 | |
| --- a/src/libpiano/response.c | |
| +++ b/src/libpiano/response.c | |
| @@ -591,6 +591,11 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) { | |
| } | |
| break; | |
| } | |
| + | |
| + case PIANO_REQUEST_GET_AD_METADATA: { | |
| + printf ("ad.getAdMetadata returned: %s\n", req->responseData); | |
| + break; | |
| + } | |
| } | |
| cleanup: | |
| diff --git a/src/main.c b/src/main.c | |
| index 4cca654..7b5f207 100644 | |
| --- a/src/main.c | |
| +++ b/src/main.c | |
| @@ -224,6 +224,7 @@ static void BarMainGetPlaylist (BarApp_t *app) { | |
| PianoReturn_t pRet; | |
| WaitressReturn_t wRet; | |
| PianoRequestDataGetPlaylist_t reqData; | |
| + | |
| reqData.station = app->curStation; | |
| reqData.quality = app->settings.audioQuality; | |
| @@ -246,6 +247,18 @@ static void BarMainGetPlaylist (BarApp_t *app) { | |
| /* start new player thread | |
| */ | |
| static void BarMainStartPlayback (BarApp_t *app, pthread_t *playerThread) { | |
| + PianoReturn_t pRet; | |
| + WaitressReturn_t wRet; | |
| + PianoRequestDataGetAdMetadata_t adReqData; | |
| + char token[100]; | |
| + snprintf (token, sizeof (token)-1, "%s-none", app->curStation->id); | |
| + | |
| + adReqData.token = strdup (token); | |
| + BarUiMsg (&app->settings, MSG_INFO, "Fetching ads... "); | |
| + BarUiPianoCall (app, PIANO_REQUEST_GET_AD_METADATA, | |
| + &adReqData, &pRet, &wRet); | |
| + free (adReqData.token); | |
| + | |
| BarUiPrintSong (&app->settings, app->playlist, app->curStation->isQuickMix ? | |
| PianoFindStationById (app->ph.stations, | |
| app->playlist->stationId) : NULL); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment