summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@lavabit.com>2010-03-05 12:38:03 +0100
committerLars-Dominik Braun <PromyLOPh@lavabit.com>2010-03-06 10:55:52 +0100
commited2240e0990236bf50d795ac86a2dfad05e1a086 (patch)
tree040a468f74d9389716101ac9cbd9b2159a4999bb
parent064db905c761df7e9e4e3b5d99807d4c44c4a86b (diff)
downloadpianobar-ed2240e0990236bf50d795ac86a2dfad05e1a086.tar.gz
pianobar-ed2240e0990236bf50d795ac86a2dfad05e1a086.tar.bz2
pianobar-ed2240e0990236bf50d795ac86a2dfad05e1a086.zip
Added song length and rating to eventcmd, new songfinish event
-rw-r--r--src/main.c6
-rw-r--r--src/ui.c13
-rw-r--r--src/ui.h7
-rw-r--r--src/ui_act.c42
4 files changed, 45 insertions, 23 deletions
diff --git a/src/main.c b/src/main.c
index b7f6235..82ed674 100644
--- a/src/main.c
+++ b/src/main.c
@@ -159,6 +159,8 @@ int main (int argc, char **argv) {
while (!doQuit) {
/* song finished playing, clean up things/scrobble song */
if (player.mode == PLAYER_FINISHED_PLAYBACK) {
+ BarUiStartEventCmd (&settings, "songfinish", curStation, playlist,
+ &player, PIANO_RET_OK);
/* FIXME: pthread_join blocks everything if network connection
* is hung up e.g. */
void *threadRet;
@@ -222,7 +224,7 @@ int main (int argc, char **argv) {
}
}
BarUiStartEventCmd (&settings, "stationfetchplaylist",
- curStation, playlist, pRet);
+ curStation, playlist, &player, pRet);
}
/* song ready to play */
if (playlist != NULL) {
@@ -244,7 +246,7 @@ int main (int argc, char **argv) {
/* throw event */
BarUiStartEventCmd (&settings, "songstart", curStation,
- playlist, PIANO_RET_OK);
+ playlist, &player, PIANO_RET_OK);
/* start player */
pthread_create (&playerThread, NULL, BarPlayerThread,
diff --git a/src/ui.c b/src/ui.c
index 7fd4bba..53fea6c 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -377,7 +377,7 @@ inline void BarUiPrintSong (PianoSong_t *song, PianoStation_t *station) {
*/
void BarUiStartEventCmd (const BarSettings_t *settings, const char *type,
const PianoStation_t *curStation, const PianoSong_t *curSong,
- PianoReturn_t pRet) {
+ const struct audioPlayer *player, PianoReturn_t pRet) {
pid_t chld;
char pipeBuf[1024];
int pipeFd[2];
@@ -395,13 +395,20 @@ void BarUiStartEventCmd (const BarSettings_t *settings, const char *type,
"album=%s\n"
"stationName=%s\n"
"pRet=%i\n"
- "pRetStr=%s\n",
+ "pRetStr=%s\n"
+ "songDuration=%lu\n"
+ "songPlayed=%lu\n"
+ "rating=%i\n",
curSong == NULL ? "" : curSong->artist,
curSong == NULL ? "" : curSong->title,
curSong == NULL ? "" : curSong->album,
curStation == NULL ? "" : curStation->name,
pRet,
- PianoErrorToStr (pRet));
+ PianoErrorToStr (pRet),
+ player->songDuration,
+ player->songPlayed,
+ curSong == NULL ? PIANO_RATE_NONE : curSong->rating
+ );
if (pipe (pipeFd) == -1) {
BarUiMsg (MSG_ERR, "Cannot create eventcmd pipe. (%s)\n", strerror (errno));
diff --git a/src/ui.h b/src/ui.h
index 83df72b..46cdbe8 100644
--- a/src/ui.h
+++ b/src/ui.h
@@ -27,6 +27,7 @@ THE SOFTWARE.
#include <piano.h>
#include "settings.h"
+#include "player.h"
typedef enum {MSG_NONE, MSG_INFO, MSG_PLAYING, MSG_TIME, MSG_ERR,
MSG_QUESTION, MSG_LIST} uiMsg_t;
@@ -41,8 +42,8 @@ char *BarUiSelectMusicId (PianoHandle_t *ph, FILE *curFd, char *);
void BarStationFromGenre (PianoHandle_t *ph, FILE *curFd);
void BarUiPrintStation (PianoStation_t *);
void BarUiPrintSong (PianoSong_t *, PianoStation_t *);
-void BarUiStartEventCmd (const BarSettings_t *settings, const char *type,
- const PianoStation_t *curStation, const PianoSong_t *curSong,
- PianoReturn_t);
+void BarUiStartEventCmd (const BarSettings_t *, const char *,
+ const PianoStation_t *, const PianoSong_t *,
+ const struct audioPlayer *, PianoReturn_t);
#endif /* _UI_H */
diff --git a/src/ui_act.c b/src/ui_act.c
index 5a3ee5a..23b0f34 100644
--- a/src/ui_act.c
+++ b/src/ui_act.c
@@ -118,7 +118,8 @@ void BarUiActAddMusic (BAR_KS_ARGS) {
pRet = BarUiPrintPianoStatus (PianoStationAddMusic (ph, *curStation, musicId));
free (musicId);
- BarUiStartEventCmd (settings, "stationaddmusic", *curStation, *curSong, pRet);
+ BarUiStartEventCmd (settings, "stationaddmusic", *curStation, *curSong,
+ player, pRet);
}
}
@@ -137,7 +138,8 @@ void BarUiActBanSong (BAR_KS_ARGS) {
PIANO_RATE_BAN))) == PIANO_RET_OK) {
BarUiDoSkipSong (player);
}
- BarUiStartEventCmd (settings, "songban", *curStation, *curSong, pRet);
+ BarUiStartEventCmd (settings, "songban", *curStation, *curSong, player,
+ pRet);
}
/* create new station
@@ -151,7 +153,8 @@ void BarUiActCreateStation (BAR_KS_ARGS) {
BarUiMsg (MSG_INFO, "Creating station... ");
pRet = BarUiPrintPianoStatus (PianoCreateStation (ph, "mi", musicId));
free (musicId);
- BarUiStartEventCmd (settings, "stationcreate", *curStation, *curSong, pRet);
+ BarUiStartEventCmd (settings, "stationcreate", *curStation, *curSong,
+ player, pRet);
}
}
@@ -167,7 +170,8 @@ void BarUiActAddSharedStation (BAR_KS_ARGS) {
BarUiMsg (MSG_INFO, "Adding shared station... ");
pRet = BarUiPrintPianoStatus (PianoCreateStation (ph, "sh",
(char *) stationId));
- BarUiStartEventCmd (settings, "stationaddshared", *curStation, *curSong, pRet);
+ BarUiStartEventCmd (settings, "stationaddshared", *curStation,
+ *curSong, player, pRet);
}
}
@@ -189,7 +193,8 @@ void BarUiActDeleteStation (BAR_KS_ARGS) {
*curSong = NULL;
*curStation = NULL;
}
- BarUiStartEventCmd (settings, "stationdelete", *curStation, *curSong, pRet);
+ BarUiStartEventCmd (settings, "stationdelete", *curStation, *curSong,
+ player, pRet);
}
}
@@ -207,7 +212,8 @@ void BarUiActExplain (BAR_KS_ARGS) {
BarUiMsg (MSG_INFO, "%s\n", explanation);
free (explanation);
}
- BarUiStartEventCmd (settings, "songexplain", *curStation, *curSong, pRet);
+ BarUiStartEventCmd (settings, "songexplain", *curStation, *curSong, player,
+ pRet);
}
/* choose genre station and add it as shared station
@@ -267,7 +273,8 @@ void BarUiActLoveSong (BAR_KS_ARGS) {
}
BarUiMsg (MSG_INFO, "Loving song... ");
pRet = BarUiPrintPianoStatus (PianoRateTrack (ph, *curSong, PIANO_RATE_LOVE));
- BarUiStartEventCmd (settings, "songlove", *curStation, *curSong, pRet);
+ BarUiStartEventCmd (settings, "songlove", *curStation, *curSong, player,
+ pRet);
}
/* skip song
@@ -300,7 +307,8 @@ void BarUiActMoveSong (BAR_KS_ARGS) {
moveStation, *curSong))) == PIANO_RET_OK) {
BarUiDoSkipSong (player);
}
- BarUiStartEventCmd (settings, "songmove", *curStation, *curSong, pRet);
+ BarUiStartEventCmd (settings, "songmove", *curStation, *curSong,
+ player, pRet);
}
}
@@ -329,7 +337,8 @@ void BarUiActRenameStation (BAR_KS_ARGS) {
BarUiMsg (MSG_INFO, "Renaming station... ");
pRet = BarUiPrintPianoStatus (PianoRenameStation (ph, *curStation,
(char *) lineBuf));
- BarUiStartEventCmd (settings, "stationrename", *curStation, *curSong, pRet);
+ BarUiStartEventCmd (settings, "stationrename", *curStation, *curSong,
+ player, pRet);
}
}
@@ -357,7 +366,8 @@ void BarUiActTempBanSong (BAR_KS_ARGS) {
PIANO_RET_OK) {
BarUiDoSkipSong (player);
}
- BarUiStartEventCmd (settings, "songshelf", *curStation, *curSong, pRet);
+ BarUiStartEventCmd (settings, "songshelf", *curStation, *curSong, player,
+ pRet);
}
/* print upcoming songs
@@ -396,7 +406,7 @@ void BarUiActSelectQuickMix (BAR_KS_ARGS) {
BarUiMsg (MSG_INFO, "Setting quickmix stations... ");
pRet = BarUiPrintPianoStatus (PianoSetQuickmix (ph));
BarUiStartEventCmd (settings, "stationquickmixtoggle", *curStation,
- *curSong, pRet);
+ *curSong, player, pRet);
} else {
BarUiMsg (MSG_ERR, "Not a QuickMix station.\n");
}
@@ -452,13 +462,13 @@ void BarUiActHistory (BAR_KS_ARGS) {
pRet = BarUiPrintPianoStatus (PianoRateTrack (ph,
selectedSong, PIANO_RATE_LOVE));
BarUiStartEventCmd (settings, "songlove", songStation,
- selectedSong, pRet);
+ selectedSong, player, pRet);
} else if (selectBuf[0] == settings->keys[BAR_KS_BAN]) {
BarUiMsg (MSG_INFO, "Banning song... ");
pRet = BarUiPrintPianoStatus (PianoRateTrack (ph,
selectedSong, PIANO_RATE_BAN));
BarUiStartEventCmd (settings, "songban", songStation,
- selectedSong, pRet);
+ selectedSong, player, pRet);
} /* end if */
} /* end if selectBuf[0] */
} /* end if selectedSong != NULL */
@@ -481,11 +491,13 @@ void BarUiActBookmark (BAR_KS_ARGS) {
if (selectBuf[0] == 's') {
BarUiMsg (MSG_INFO, "Bookmarking song... ");
pRet = BarUiPrintPianoStatus (PianoBookmarkSong (ph, *curSong));
- BarUiStartEventCmd (settings, "songbookmark", *curStation, *curSong, pRet);
+ BarUiStartEventCmd (settings, "songbookmark", *curStation, *curSong,
+ player, pRet);
} else if (selectBuf[0] == 'a') {
BarUiMsg (MSG_INFO, "Bookmarking artist... ");
pRet = BarUiPrintPianoStatus (PianoBookmarkArtist (ph, *curSong));
- BarUiStartEventCmd (settings, "artistbookmark", *curStation, *curSong, pRet);
+ BarUiStartEventCmd (settings, "artistbookmark", *curStation, *curSong,
+ player, pRet);
}
}