summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/main.c b/src/main.c
index 6886afc..3fcb2da 100644
--- a/src/main.c
+++ b/src/main.c
@@ -85,7 +85,7 @@ static bool BarMainLoginUser (BarApp_t *app) {
reqData.password = app->settings.password;
reqData.step = 0;
- BarUiMsg (MSG_INFO, "Login... ");
+ BarUiMsg (&app->settings, MSG_INFO, "Login... ");
ret = BarUiPianoCall (app, PIANO_REQUEST_LOGIN, &reqData, &pRet, &wRet);
BarUiStartEventCmd (&app->settings, "userlogin", NULL, NULL, &app->player,
NULL, pRet, wRet);
@@ -98,13 +98,13 @@ static void BarMainGetLoginCredentials (BarSettings_t *settings,
BarReadlineFds_t *input) {
if (settings->username == NULL) {
char nameBuf[100];
- BarUiMsg (MSG_QUESTION, "Username: ");
+ BarUiMsg (settings, MSG_QUESTION, "Username: ");
BarReadlineStr (nameBuf, sizeof (nameBuf), input, BAR_RL_DEFAULT);
settings->username = strdup (nameBuf);
}
if (settings->password == NULL) {
char passBuf[100];
- BarUiMsg (MSG_QUESTION, "Password: ");
+ BarUiMsg (settings, MSG_QUESTION, "Password: ");
BarReadlineStr (passBuf, sizeof (passBuf), input, BAR_RL_NOECHO);
write (STDIN_FILENO, "\n", 1);
settings->password = strdup (passBuf);
@@ -118,7 +118,7 @@ static bool BarMainGetStations (BarApp_t *app) {
WaitressReturn_t wRet;
bool ret;
- BarUiMsg (MSG_INFO, "Get stations... ");
+ BarUiMsg (&app->settings, MSG_INFO, "Get stations... ");
ret = BarUiPianoCall (app, PIANO_REQUEST_GET_STATIONS, NULL, &pRet, &wRet);
BarUiStartEventCmd (&app->settings, "usergetstations", NULL, NULL, &app->player,
app->ph.stations, pRet, wRet);
@@ -133,16 +133,16 @@ static void BarMainGetInitialStation (BarApp_t *app) {
app->curStation = PianoFindStationById (app->ph.stations,
app->settings.autostartStation);
if (app->curStation == NULL) {
- BarUiMsg (MSG_ERR, "Error: Autostart station not found.\n");
+ BarUiMsg (&app->settings, MSG_ERR,
+ "Error: Autostart station not found.\n");
}
}
/* no autostart? ask the user */
if (app->curStation == NULL) {
- app->curStation = BarUiSelectStation (&app->ph, "Select station: ",
- app->settings.sortOrder, &app->input);
+ app->curStation = BarUiSelectStation (app, "Select station: ");
}
if (app->curStation != NULL) {
- BarUiPrintStation (app->curStation);
+ BarUiPrintStation (&app->settings, app->curStation);
}
}
@@ -166,14 +166,14 @@ static void BarMainGetPlaylist (BarApp_t *app) {
reqData.station = app->curStation;
reqData.format = app->settings.audioFormat;
- BarUiMsg (MSG_INFO, "Receiving new playlist... ");
+ BarUiMsg (&app->settings, MSG_INFO, "Receiving new playlist... ");
if (!BarUiPianoCall (app, PIANO_REQUEST_GET_PLAYLIST,
&reqData, &pRet, &wRet)) {
app->curStation = NULL;
} else {
app->playlist = reqData.retPlaylist;
if (app->playlist == NULL) {
- BarUiMsg (MSG_INFO, "No tracks left.\n");
+ BarUiMsg (&app->settings, MSG_INFO, "No tracks left.\n");
app->curStation = NULL;
}
}
@@ -190,7 +190,7 @@ static void BarMainStartPlayback (BarApp_t *app, pthread_t *playerThread) {
app->playlist->stationId) : NULL);
if (app->playlist->audioUrl == NULL) {
- BarUiMsg (MSG_ERR, "Invalid song url.\n");
+ BarUiMsg (&app->settings, MSG_ERR, "Invalid song url.\n");
} else {
/* setup player */
memset (&app->player, 0, sizeof (app->player));
@@ -212,6 +212,7 @@ static void BarMainStartPlayback (BarApp_t *app, pthread_t *playerThread) {
app->player.gain = app->playlist->fileGain;
app->player.scale = BarPlayerCalcScale (app->player.gain + app->settings.volume);
app->player.audioFormat = app->playlist->audioFormat;
+ app->player.settings = &app->settings;
/* throw event */
BarUiStartEventCmd (&app->settings, "songstart",
@@ -261,7 +262,7 @@ static void BarMainPrintTime (BarApp_t *app) {
sign = POSITIVE;
songRemaining = -songRemaining;
}
- BarUiMsg (MSG_TIME, "%c%02i:%02i/%02i:%02i\r",
+ BarUiMsg (&app->settings, MSG_TIME, "%c%02i:%02i/%02i:%02i\r",
(sign == POSITIVE ? '+' : '-'),
songRemaining / 60, songRemaining % 60,
app->player.songDuration / BAR_PLAYER_MS_TO_S_FACTOR / 60,
@@ -356,11 +357,13 @@ int main (int argc, char **argv) {
BarSettingsInit (&app.settings);
BarSettingsRead (&app.settings);
- BarUiMsg (MSG_NONE, "Welcome to " PACKAGE " (" VERSION ")! ");
+ BarUiMsg (&app.settings, MSG_NONE,
+ "Welcome to " PACKAGE " (" VERSION ")! ");
if (app.settings.keys[BAR_KS_HELP] == BAR_KS_DISABLED) {
- BarUiMsg (MSG_NONE, "\n");
+ BarUiMsg (&app.settings, MSG_NONE, "\n");
} else {
- BarUiMsg (MSG_NONE, "Press %c for a list of commands.\n",
+ BarUiMsg (&app.settings, MSG_NONE,
+ "Press %c for a list of commands.\n",
app.settings.keys[BAR_KS_HELP]);
}
@@ -375,7 +378,8 @@ int main (int argc, char **argv) {
app.input.fds[1] = open (ctlPath, O_RDWR);
if (app.input.fds[1] != -1) {
FD_SET(app.input.fds[1], &app.input.set);
- BarUiMsg (MSG_INFO, "Control fifo at %s opened\n", ctlPath);
+ BarUiMsg (&app.settings, MSG_INFO, "Control fifo at %s opened\n",
+ ctlPath);
}
app.input.maxfd = app.input.fds[0] > app.input.fds[1] ? app.input.fds[0] :
app.input.fds[1];