summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c12
-rw-r--r--src/ui.c35
-rw-r--r--src/ui.h7
-rw-r--r--src/ui_act.c32
4 files changed, 41 insertions, 45 deletions
diff --git a/src/main.c b/src/main.c
index 40bd64a..d401e65 100644
--- a/src/main.c
+++ b/src/main.c
@@ -142,8 +142,8 @@ int main (int argc, char **argv) {
reqData.step = 0;
BarUiMsg (MSG_INFO, "Login... ");
- if (!BarUiPianoCall (&app.ph, PIANO_REQUEST_LOGIN, &app.waith,
- &reqData, &pRet, &wRet)) {
+ if (!BarUiPianoCall (&app, PIANO_REQUEST_LOGIN, &reqData, &pRet,
+ &wRet)) {
BarTermRestore (&termOrig);
return 0;
}
@@ -154,8 +154,8 @@ int main (int argc, char **argv) {
WaitressReturn_t wRet;
BarUiMsg (MSG_INFO, "Get stations... ");
- if (!BarUiPianoCall (&app.ph, PIANO_REQUEST_GET_STATIONS, &app.waith,
- NULL, &pRet, &wRet)) {
+ if (!BarUiPianoCall (&app, PIANO_REQUEST_GET_STATIONS, NULL, &pRet,
+ &wRet)) {
BarTermRestore (&termOrig);
return 0;
}
@@ -243,8 +243,8 @@ int main (int argc, char **argv) {
reqData.format = app.settings.audioFormat;
BarUiMsg (MSG_INFO, "Receiving new playlist... ");
- if (!BarUiPianoCall (&app.ph, PIANO_REQUEST_GET_PLAYLIST,
- &app.waith, &reqData, &pRet, &wRet)) {
+ if (!BarUiPianoCall (&app, PIANO_REQUEST_GET_PLAYLIST,
+ &reqData, &pRet, &wRet)) {
app.curStation = NULL;
} else {
app.playlist = reqData.retPlaylist;
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)
diff --git a/src/ui.h b/src/ui.h
index eed0b07..9a4dcb5 100644
--- a/src/ui.h
+++ b/src/ui.h
@@ -29,6 +29,7 @@ THE SOFTWARE.
#include "settings.h"
#include "player.h"
+#include "main.h"
typedef enum {MSG_NONE, MSG_INFO, MSG_PLAYING, MSG_TIME, MSG_ERR,
MSG_QUESTION, MSG_LIST} uiMsg_t;
@@ -39,14 +40,14 @@ PianoStation_t *BarUiSelectStation (PianoHandle_t *, const char *,
BarStationSorting_t, FILE *);
PianoSong_t *BarUiSelectSong (PianoSong_t *startSong, FILE *curFd);
PianoArtist_t *BarUiSelectArtist (PianoArtist_t *startArtist, FILE *curFd);
-char *BarUiSelectMusicId (PianoHandle_t *ph, WaitressHandle_t *, FILE *curFd, char *);
-void BarStationFromGenre (PianoHandle_t *ph, WaitressHandle_t *, FILE *curFd);
+char *BarUiSelectMusicId (BarApp_t *, FILE *, char *);
+void BarStationFromGenre (BarApp_t *, FILE *);
void BarUiPrintStation (PianoStation_t *);
void BarUiPrintSong (PianoSong_t *, PianoStation_t *);
void BarUiStartEventCmd (const BarSettings_t *, const char *,
const PianoStation_t *, const PianoSong_t *, const struct audioPlayer *,
PianoReturn_t, WaitressReturn_t);
-int BarUiPianoCall (PianoHandle_t *, PianoRequestType_t, WaitressHandle_t *,
+int BarUiPianoCall (BarApp_t * const, PianoRequestType_t,
void *, PianoReturn_t *, WaitressReturn_t *);
#endif /* _UI_H */
diff --git a/src/ui_act.c b/src/ui_act.c
index 664c966..0910ae9 100644
--- a/src/ui_act.c
+++ b/src/ui_act.c
@@ -46,8 +46,8 @@ THE SOFTWARE.
/* standard piano call
*/
-#define BarUiActDefaultPianoCall(call, arg) BarUiPianoCall (&app->ph, \
- call, &app->waith, arg, &pRet, &wRet)
+#define BarUiActDefaultPianoCall(call, arg) BarUiPianoCall (app, \
+ call, arg, &pRet, &wRet)
/* helper to _really_ skip a song (unlock mutex, quit player)
* @param player handle
@@ -62,16 +62,15 @@ static inline void BarUiDoSkipSong (struct audioPlayer *player) {
* @param transform this station
* @return 0 = error, 1 = everything went well
*/
-static int BarTransformIfShared (PianoHandle_t *ph, WaitressHandle_t *waith,
- PianoStation_t *station) {
+static int BarTransformIfShared (BarApp_t *app, PianoStation_t *station) {
PianoReturn_t pRet;
WaitressReturn_t wRet;
/* shared stations must be transformed */
if (!station->isCreator) {
BarUiMsg (MSG_INFO, "Transforming station... ");
- if (!BarUiPianoCall (ph, PIANO_REQUEST_TRANSFORM_STATION, waith,
- station, &pRet, &wRet)) {
+ if (!BarUiPianoCall (app, PIANO_REQUEST_TRANSFORM_STATION, station,
+ &pRet, &wRet)) {
return 0;
}
}
@@ -124,10 +123,9 @@ BarUiActCallback(BarUiActAddMusic) {
RETURN_IF_NO_STATION;
- reqData.musicId = BarUiSelectMusicId (&app->ph, &app->waith, curFd,
- app->playlist->musicId);
+ reqData.musicId = BarUiSelectMusicId (app, curFd, app->playlist->musicId);
if (reqData.musicId != NULL) {
- if (!BarTransformIfShared (&app->ph, &app->waith, app->curStation)) {
+ if (!BarTransformIfShared (app, app->curStation)) {
return;
}
reqData.station = app->curStation;
@@ -149,7 +147,7 @@ BarUiActCallback(BarUiActBanSong) {
RETURN_IF_NO_SONG;
- if (!BarTransformIfShared (&app->ph, &app->waith, app->curStation)) {
+ if (!BarTransformIfShared (app, app->curStation)) {
return;
}
@@ -171,7 +169,7 @@ BarUiActCallback(BarUiActCreateStation) {
WaitressReturn_t wRet;
PianoRequestDataCreateStation_t reqData;
- reqData.id = BarUiSelectMusicId (&app->ph, &app->waith, curFd, NULL);
+ reqData.id = BarUiSelectMusicId (app, curFd, NULL);
if (reqData.id != NULL) {
reqData.type = "mi";
BarUiMsg (MSG_INFO, "Creating station... ");
@@ -246,7 +244,7 @@ BarUiActCallback(BarUiActExplain) {
*/
BarUiActCallback(BarUiActStationFromGenre) {
/* use genre station */
- BarStationFromGenre (&app->ph, &app->waith, curFd);
+ BarStationFromGenre (app, curFd);
}
/* print verbose song information
@@ -298,7 +296,7 @@ BarUiActCallback(BarUiActLoveSong) {
RETURN_IF_NO_SONG;
- if (!BarTransformIfShared (&app->ph, &app->waith, app->curStation)) {
+ if (!BarTransformIfShared (app, app->curStation)) {
return;
}
@@ -340,8 +338,8 @@ BarUiActCallback(BarUiActMoveSong) {
return;
}
- if (!BarTransformIfShared (&app->ph, &app->waith, reqData.from) ||
- !BarTransformIfShared (&app->ph, &app->waith, reqData.to)) {
+ if (!BarTransformIfShared (app, reqData.from) ||
+ !BarTransformIfShared (app, reqData.to)) {
return;
}
BarUiMsg (MSG_INFO, "Moving song to \"%s\"... ", reqData.to->name);
@@ -374,7 +372,7 @@ BarUiActCallback(BarUiActRenameStation) {
BarUiMsg (MSG_QUESTION, "New name: ");
if (BarReadlineStr (lineBuf, sizeof (lineBuf), 0, curFd) > 0) {
PianoRequestDataRenameStation_t reqData;
- if (!BarTransformIfShared (&app->ph, &app->waith, app->curStation)) {
+ if (!BarTransformIfShared (app, app->curStation)) {
return;
}
@@ -501,7 +499,7 @@ BarUiActCallback(BarUiActHistory) {
return;
}
- if (!BarTransformIfShared (&app->ph, &app->waith, songStation)) {
+ if (!BarTransformIfShared (app, songStation)) {
return;
}