|
/* Excute external event handler |
|
* @param settings containing the cmdline |
|
* @param event type |
|
* @param current station |
|
* @param current song |
|
* @param piano error-code (PIANO_RET_OK if not applicable) |
|
*/ |
|
void BarUiStartEventCmd (const BarSettings_t *settings, const char *type, |
|
const PianoStation_t *curStation, const PianoSong_t *curSong, |
|
const player2_t * const player, PianoStation_t *stations, |
|
PianoReturn_t pRet) { |
|
//pid_t chld; |
|
//int pipeFd[2]; |
|
|
|
//if (settings->eventCmd == NULL) { |
|
/* nothing to do... */ |
|
return; |
|
//} |
|
|
|
//if (pipe (pipeFd) == -1) { |
|
// BarUiMsg (settings, MSG_ERR, "Cannot create eventcmd pipe. (%s)\n", strerror (errno)); |
|
// return; |
|
//} |
|
|
|
//chld = fork (); |
|
//if (chld == 0) { |
|
// /* child */ |
|
// close (pipeFd[1]); |
|
// dup2 (pipeFd[0], fileno (stdin)); |
|
// execl (settings->eventCmd, settings->eventCmd, type, (char *) NULL); |
|
// BarUiMsg (settings, MSG_ERR, "Cannot start eventcmd. (%s)\n", strerror (errno)); |
|
// close (pipeFd[0]); |
|
// exit (1); |
|
//} else if (chld == -1) { |
|
// BarUiMsg (settings, MSG_ERR, "Cannot fork eventcmd. (%s)\n", strerror (errno)); |
|
//} else { |
|
// /* parent */ |
|
// int status; |
|
// PianoStation_t *songStation = NULL; |
|
// FILE *pipeWriteFd; |
|
|
|
// close (pipeFd[0]); |
|
|
|
// pipeWriteFd = fdopen (pipeFd[1], "w"); |
|
|
|
// if (curSong != NULL && stations != NULL && curStation != NULL && |
|
// curStation->isQuickMix) { |
|
// songStation = PianoFindStationById (stations, curSong->stationId); |
|
// } |
|
|
|
// fprintf (pipeWriteFd, |
|
// "artist=%s\n" |
|
// "title=%s\n" |
|
// "album=%s\n" |
|
// "coverArt=%s\n" |
|
// "stationName=%s\n" |
|
// "songStationName=%s\n" |
|
// "pRet=%i\n" |
|
// "pRetStr=%s\n" |
|
// "wRet=%i\n" |
|
// "wRetStr=%s\n" |
|
// "songDuration=%u\n" |
|
// "songPlayed=%u\n" |
|
// "rating=%i\n" |
|
// "detailUrl=%s\n", |
|
// curSong == NULL ? "" : curSong->artist, |
|
// curSong == NULL ? "" : curSong->title, |
|
// curSong == NULL ? "" : curSong->album, |
|
// curSong == NULL ? "" : curSong->coverArt, |
|
// curStation == NULL ? "" : curStation->name, |
|
// songStation == NULL ? "" : songStation->name, |
|
// pRet, |
|
// PianoErrorToStr (pRet), |
|
// wRet, |
|
// curl_easy_strerror (wRet), |
|
// player->songDuration, |
|
// player->songPlayed, |
|
// curSong == NULL ? PIANO_RATE_NONE : curSong->rating, |
|
// curSong == NULL ? "" : curSong->detailUrl |
|
// ); |
|
|
|
// if (stations != NULL) { |
|
// /* send station list */ |
|
// PianoStation_t **sortedStations = NULL; |
|
// size_t stationCount; |
|
// sortedStations = BarSortedStations (stations, &stationCount, |
|
// settings->sortOrder); |
|
// assert (sortedStations != NULL); |
|
|
|
// fprintf (pipeWriteFd, "stationCount=%zd\n", stationCount); |
|
|
|
// for (size_t i = 0; i < stationCount; i++) { |
|
// const PianoStation_t *currStation = sortedStations[i]; |
|
// fprintf (pipeWriteFd, "station%zd=%s\n", i, |
|
// currStation->name); |
|
// } |
|
// free (sortedStations); |
|
// } else { |
|
// const char * const msg = "stationCount=0\n"; |
|
// fwrite (msg, sizeof (*msg), strlen (msg), pipeWriteFd); |
|
// } |
|
// |
|
// /* closes pipeFd[1] as well */ |
|
// fclose (pipeWriteFd); |
|
// /* wait to get rid of the zombie */ |
|
// waitpid (chld, &status, 0); |
|
//} |
|
} |