summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c9
-rw-r--r--src/ui.c30
-rw-r--r--src/ui.h2
-rw-r--r--src/ui_act.c12
4 files changed, 41 insertions, 12 deletions
diff --git a/src/main.c b/src/main.c
index 908fcee..d6da519 100644
--- a/src/main.c
+++ b/src/main.c
@@ -249,8 +249,8 @@ static void BarMainGetPlaylist (BarApp_t *app) {
}
}
BarUiStartEventCmd (&app->settings, "stationfetchplaylist",
- app->curStation, app->playlist, &app->player, pRet,
- wRet);
+ app->curStation, app->playlist, &app->player, app->ph.stations,
+ pRet, wRet);
}
/* start new player thread
@@ -286,7 +286,7 @@ static void BarMainStartPlayback (BarApp_t *app, pthread_t *playerThread) {
/* throw event */
BarUiStartEventCmd (&app->settings, "songstart",
- app->curStation, app->playlist, &app->player,
+ app->curStation, app->playlist, &app->player, app->ph.stations,
PIANO_RET_OK, WAITRESS_RET_OK);
/* prevent race condition, mode must _not_ be FREED if
@@ -304,7 +304,8 @@ static void BarMainPlayerCleanup (BarApp_t *app, pthread_t *playerThread) {
void *threadRet;
BarUiStartEventCmd (&app->settings, "songfinish", app->curStation,
- app->playlist, &app->player, PIANO_RET_OK, WAITRESS_RET_OK);
+ app->playlist, &app->player, app->ph.stations, PIANO_RET_OK,
+ WAITRESS_RET_OK);
/* FIXME: pthread_join blocks everything if network connection
* is hung up e.g. */
diff --git a/src/ui.c b/src/ui.c
index 8c8dc39..6166044 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -590,8 +590,8 @@ size_t BarUiListSongs (const BarSettings_t *settings,
*/
void BarUiStartEventCmd (const BarSettings_t *settings, const char *type,
const PianoStation_t *curStation, const PianoSong_t *curSong,
- const struct audioPlayer *player, PianoReturn_t pRet,
- WaitressReturn_t wRet) {
+ const struct audioPlayer *player, PianoStation_t *stations,
+ PianoReturn_t pRet, WaitressReturn_t wRet) {
pid_t chld;
char pipeBuf[1024];
int pipeFd[2];
@@ -629,7 +629,7 @@ void BarUiStartEventCmd (const BarSettings_t *settings, const char *type,
player->songPlayed,
curSong == NULL ? PIANO_RATE_NONE : curSong->rating
);
-
+
if (pipe (pipeFd) == -1) {
BarUiMsg (MSG_ERR, "Cannot create eventcmd pipe. (%s)\n", strerror (errno));
return;
@@ -651,6 +651,30 @@ void BarUiStartEventCmd (const BarSettings_t *settings, const char *type,
int status;
close (pipeFd[0]);
write (pipeFd[1], pipeBuf, strlen (pipeBuf));
+
+ if (stations != NULL) {
+ /* send station list */
+ PianoStation_t **sortedStations = NULL;
+ size_t stationCount;
+ sortedStations = BarSortedStations (stations, &stationCount,
+ settings->sortOrder);
+ assert (sortedStations != NULL);
+
+ snprintf (pipeBuf, sizeof (pipeBuf), "stationCount=%zd\n", stationCount);
+ write (pipeFd[1], pipeBuf, strlen (pipeBuf));
+
+ for (size_t i = 0; i < stationCount; i++) {
+ const PianoStation_t *currStation = sortedStations[i];
+ snprintf (pipeBuf, sizeof (pipeBuf), "station%zd=%s\n", i,
+ currStation->name);
+ write (pipeFd[1], pipeBuf, strlen (pipeBuf));
+ }
+ free (sortedStations);
+ } else {
+ const char *msg = "stationCount=0\n";
+ write (pipeFd[1], msg, strlen (msg));
+ }
+
close (pipeFd[1]);
/* wait to get rid of the zombie */
waitpid (chld, &status, 0);
diff --git a/src/ui.h b/src/ui.h
index 23457e0..6664f8e 100644
--- a/src/ui.h
+++ b/src/ui.h
@@ -48,7 +48,7 @@ void BarUiPrintSong (const BarSettings_t *, const PianoSong_t *,
size_t BarUiListSongs (const BarSettings_t *, const PianoSong_t *);
void BarUiStartEventCmd (const BarSettings_t *, const char *,
const PianoStation_t *, const PianoSong_t *, const struct audioPlayer *,
- PianoReturn_t, WaitressReturn_t);
+ PianoStation_t *, PianoReturn_t, WaitressReturn_t);
int BarUiPianoCall (BarApp_t * const, PianoRequestType_t,
void *, PianoReturn_t *, WaitressReturn_t *);
diff --git a/src/ui_act.c b/src/ui_act.c
index 4ea8b71..76f4fee 100644
--- a/src/ui_act.c
+++ b/src/ui_act.c
@@ -42,7 +42,8 @@ THE SOFTWARE.
/* standard eventcmd call
*/
#define BarUiActDefaultEventcmd(name) BarUiStartEventCmd (&app->settings, \
- name, app->curStation, app->playlist, &app->player, pRet, wRet)
+ name, app->curStation, app->playlist, &app->player, app->ph.stations, \
+ pRet, wRet)
/* standard piano call
*/
@@ -517,7 +518,8 @@ BarUiActCallback(BarUiActHistory) {
&reqData);
BarUiStartEventCmd (&app->settings, "songlove", songStation,
- selectedSong, &app->player, pRet, wRet);
+ selectedSong, &app->player, app->ph.stations,
+ pRet, wRet);
} else if (selectBuf[0] == app->settings.keys[BAR_KS_BAN]) {
PianoRequestDataRateSong_t reqData;
reqData.song = selectedSong;
@@ -527,13 +529,15 @@ BarUiActCallback(BarUiActHistory) {
BarUiActDefaultPianoCall (PIANO_REQUEST_RATE_SONG,
&reqData);
BarUiStartEventCmd (&app->settings, "songban", songStation,
- selectedSong, &app->player, pRet, wRet);
+ selectedSong, &app->player, app->ph.stations,
+ pRet, wRet);
} else if (selectBuf[0] == app->settings.keys[BAR_KS_TIRED]) {
BarUiMsg (MSG_INFO, "Putting song on shelf... ");
BarUiActDefaultPianoCall (PIANO_REQUEST_ADD_TIRED_SONG, selectedSong);
BarUiStartEventCmd (&app->settings, "songshelf", songStation,
- selectedSong, &app->player, pRet, wRet);
+ selectedSong, &app->player, app->ph.stations,
+ pRet, wRet);
} /* end if */
} /* end if selectBuf[0] */
} /* end if selectedSong != NULL */