From 6a62ae4231c2ce10b6623e32198f40f0a2a8e777 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Tue, 15 Dec 2009 17:08:19 +0100 Subject: New history feature Default key is 'h', playlists are no longer part of PianoHandle_t now (=> libpiano's api changed) --- src/ui_act.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) (limited to 'src/ui_act.c') diff --git a/src/ui_act.c b/src/ui_act.c index a3d33ed..5510b2f 100644 --- a/src/ui_act.c +++ b/src/ui_act.c @@ -163,7 +163,7 @@ void BarUiActDeleteStation (BAR_KS_ARGS) { if ((pRet = BarUiPrintPianoStatus (PianoDeleteStation (ph, *curStation))) == PIANO_RET_OK) { BarUiDoSkipSong (player); - PianoDestroyPlaylist (ph); + PianoDestroyPlaylist (*curSong); *curSong = NULL; *curStation = NULL; } @@ -315,7 +315,7 @@ void BarUiActRenameStation (BAR_KS_ARGS) { */ void BarUiActSelectStation (BAR_KS_ARGS) { BarUiDoSkipSong (player); - PianoDestroyPlaylist (ph); + PianoDestroyPlaylist (*curSong); *curSong = NULL; *curStation = BarUiSelectStation (ph, "Select station: ", curFd); if (*curStation != NULL) { @@ -386,3 +386,60 @@ void BarUiActQuit (BAR_KS_ARGS) { *doQuit = 1; BarUiDoSkipSong (player); } + +/* song history + */ +void BarUiActHistory (BAR_KS_ARGS) { + char selectBuf[2]; + PianoSong_t *selectedSong; + + if (*songHistory != NULL) { + selectedSong = BarUiSelectSong (*songHistory, curFd); + if (selectedSong != NULL) { + BarUiMsg (MSG_QUESTION, "%s - %s: [l]ove or [b]an? ", + selectedSong->artist, selectedSong->title); + BarReadline (selectBuf, sizeof (selectBuf), "lbs", 1, 0, curFd); + if (selectBuf[0] == 'l' || selectBuf[0] == 'b') { + PianoReturn_t pRet = PIANO_RET_ERR; + /* make sure we're transforming the _original_ station (not + * curStation) */ + PianoStation_t *songStation = + PianoFindStationById (ph->stations, + selectedSong->stationId); + + if (songStation == NULL) { + BarUiMsg (MSG_ERR, "Station does not exist any more.\n"); + return; + } + + if (!BarTransformIfShared (ph, songStation)) { + return; + } + + switch (selectBuf[0]) { + case 'l': + /* love */ + /* FIXME: copy&waste */ + BarUiMsg (MSG_INFO, "Loving song... "); + pRet = BarUiPrintPianoStatus (PianoRateTrack (ph, + selectedSong, PIANO_RATE_LOVE)); + BarUiStartEventCmd (settings, "songlove", songStation, + selectedSong, pRet); + break; + + case 'b': + /* ban */ + BarUiMsg (MSG_INFO, "Banning song... "); + pRet = BarUiPrintPianoStatus (PianoRateTrack (ph, + selectedSong, PIANO_RATE_BAN)); + BarUiStartEventCmd (settings, "songban", songStation, + selectedSong, pRet); + break; + } /* end switch */ + } /* end if selectBuf[0] */ + } /* end if selectedSong != NULL */ + } else { + BarUiMsg (MSG_INFO, (settings->history == 0) ? "History disabled.\n" : + "No history yet.\n"); + } +} -- cgit v1.2.3