From 1c44f089383538a113fc46e49a842bb5b3cc66fc Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Mon, 25 Oct 2010 11:51:15 +0200 Subject: Use BarApp_t in BarUiPianoCall Required for automatic reauthentication --- src/ui.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'src/ui.c') diff --git a/src/ui.c b/src/ui.c index 4329a4e..fb20f0a 100644 --- a/src/ui.c +++ b/src/ui.c @@ -119,9 +119,8 @@ static WaitressReturn_t BarPianoHttpRequest (WaitressHandle_t *waith, * @param data pointer (used as request data) * @return 1 on success, 0 otherwise */ -int BarUiPianoCall (PianoHandle_t *ph, PianoRequestType_t type, - WaitressHandle_t *waith, void *data, PianoReturn_t *pRet, - WaitressReturn_t *wRet) { +int BarUiPianoCall (BarApp_t * const app, PianoRequestType_t type, + void *data, PianoReturn_t *pRet, WaitressReturn_t *wRet) { PianoRequest_t req; memset (&req, 0, sizeof (req)); @@ -130,14 +129,14 @@ int BarUiPianoCall (PianoHandle_t *ph, PianoRequestType_t type, do { req.data = data; - *pRet = PianoRequest (ph, &req, type); + *pRet = PianoRequest (&app->ph, &req, type); if (*pRet != PIANO_RET_OK) { BarUiMsg (MSG_NONE, "Error: %s\n", PianoErrorToStr (*pRet)); PianoDestroyRequest (&req); return 0; } - *wRet = BarPianoHttpRequest (waith, &req); + *wRet = BarPianoHttpRequest (&app->waith, &req); if (*wRet != WAITRESS_RET_OK) { BarUiMsg (MSG_NONE, "Network error: %s\n", WaitressErrorToStr (*wRet)); PianoDestroyRequest (&req); @@ -147,7 +146,7 @@ int BarUiPianoCall (PianoHandle_t *ph, PianoRequestType_t type, return 0; } - *pRet = PianoResponse (ph, &req); + *pRet = PianoResponse (&app->ph, &req); if (*pRet != PIANO_RET_CONTINUE_REQUEST) { if (*pRet != PIANO_RET_OK) { BarUiMsg (MSG_NONE, "Error: %s\n", PianoErrorToStr (*pRet)); @@ -362,8 +361,7 @@ PianoArtist_t *BarUiSelectArtist (PianoArtist_t *startArtist, FILE *curFd) { * @param allow seed suggestions if != NULL * @return musicId or NULL on abort/error */ -char *BarUiSelectMusicId (PianoHandle_t *ph, WaitressHandle_t *waith, - FILE *curFd, char *similarToId) { +char *BarUiSelectMusicId (BarApp_t *app, FILE *curFd, char *similarToId) { char *musicId = NULL; char lineBuf[100], selectBuf[2]; PianoSearchResult_t searchResult; @@ -381,8 +379,8 @@ char *BarUiSelectMusicId (PianoHandle_t *ph, WaitressHandle_t *waith, reqData.max = 20; BarUiMsg (MSG_INFO, "Receiving suggestions... "); - if (!BarUiPianoCall (ph, PIANO_REQUEST_GET_SEED_SUGGESTIONS, - waith, &reqData, &pRet, &wRet)) { + if (!BarUiPianoCall (app, PIANO_REQUEST_GET_SEED_SUGGESTIONS, + &reqData, &pRet, &wRet)) { return NULL; } memcpy (&searchResult, &reqData.searchResult, sizeof (searchResult)); @@ -394,8 +392,8 @@ char *BarUiSelectMusicId (PianoHandle_t *ph, WaitressHandle_t *waith, reqData.searchStr = lineBuf; BarUiMsg (MSG_INFO, "Searching... "); - if (!BarUiPianoCall (ph, PIANO_REQUEST_SEARCH, waith, &reqData, - &pRet, &wRet)) { + if (!BarUiPianoCall (app, PIANO_REQUEST_SEARCH, &reqData, &pRet, + &wRet)) { return NULL; } memcpy (&searchResult, &reqData.searchResult, sizeof (searchResult)); @@ -441,7 +439,7 @@ char *BarUiSelectMusicId (PianoHandle_t *ph, WaitressHandle_t *waith, /* browse genre stations and create shared station * @param piano handle */ -void BarStationFromGenre (PianoHandle_t *ph, WaitressHandle_t *waith, FILE *curFd) { +void BarStationFromGenre (BarApp_t *app, FILE *curFd) { PianoReturn_t pRet; WaitressReturn_t wRet; PianoGenreCategory_t *curCat; @@ -450,19 +448,19 @@ void BarStationFromGenre (PianoHandle_t *ph, WaitressHandle_t *waith, FILE *curF int i; /* receive genre stations list if not yet available */ - if (ph->genreStations == NULL) { + if (app->ph.genreStations == NULL) { PianoReturn_t pRet; WaitressReturn_t wRet; BarUiMsg (MSG_INFO, "Receiving genre stations... "); - if (!BarUiPianoCall (ph, PIANO_REQUEST_GET_GENRE_STATIONS, waith, NULL, + if (!BarUiPianoCall (app, PIANO_REQUEST_GET_GENRE_STATIONS, NULL, &pRet, &wRet)) { return; } } /* print all available categories */ - curCat = ph->genreStations; + curCat = app->ph.genreStations; i = 0; while (curCat != NULL) { BarUiMsg (MSG_LIST, "%2i) %s\n", i, curCat->name); @@ -474,7 +472,7 @@ void BarStationFromGenre (PianoHandle_t *ph, WaitressHandle_t *waith, FILE *curF if (BarReadlineInt (&i, curFd) == 0) { return; } - curCat = ph->genreStations; + curCat = app->ph.genreStations; while (curCat != NULL && i > 0) { curCat = curCat->next; i--; @@ -501,8 +499,7 @@ void BarStationFromGenre (PianoHandle_t *ph, WaitressHandle_t *waith, FILE *curF BarUiMsg (MSG_INFO, "Adding shared station \"%s\"... ", curGenre->name); reqData.id = curGenre->musicId; reqData.type = "mi"; - BarUiPianoCall (ph, PIANO_REQUEST_CREATE_STATION, waith, &reqData, &pRet, - &wRet); + BarUiPianoCall (app, PIANO_REQUEST_CREATE_STATION, &reqData, &pRet, &wRet); } /* Print station infos (including station id) -- cgit v1.2.3