summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@lavabit.com>2009-03-04 17:20:39 +0100
committerLars-Dominik Braun <PromyLOPh@lavabit.com>2009-03-04 17:20:39 +0100
commit2e360ba0b308b233f94f3a4bb12e25d3d447aa07 (patch)
tree37a18be07394d63cd3113eceefddb34e3cbb0a6d
parenta17b0d5474bfd560ba5fea383b39cfeb1918dd72 (diff)
downloadpianobar-2e360ba0b308b233f94f3a4bb12e25d3d447aa07.tar.gz
pianobar-2e360ba0b308b233f94f3a4bb12e25d3d447aa07.tar.bz2
pianobar-2e360ba0b308b233f94f3a4bb12e25d3d447aa07.zip
Ui improvements
printf wrapper introduced, hopefully cleaned up ui
-rw-r--r--src/main.c40
-rw-r--r--src/pianobar.12
-rw-r--r--src/player.c12
-rw-r--r--src/settings.c4
-rw-r--r--src/ui.c83
-rw-r--r--src/ui.h7
-rw-r--r--src/ui_act.c64
-rw-r--r--src/ui_act.h1
8 files changed, 139 insertions, 74 deletions
diff --git a/src/main.c b/src/main.c
index ae0c643..d7589ed 100644
--- a/src/main.c
+++ b/src/main.c
@@ -67,7 +67,7 @@ int main (int argc, char **argv) {
char buf = '\0';
BarKeyShortcut_t *curShortcut = NULL;
- BarUiMsg ("Welcome to " PACKAGE "!\n");
+ BarUiMsg (MSG_NONE, "Welcome to " PACKAGE "!\n");
/* init some things */
curl_global_init (CURL_GLOBAL_SSL);
@@ -86,7 +86,7 @@ int main (int argc, char **argv) {
BarTermSetEcho (0);
settings.password = readline ("Password: ");
BarTermSetEcho (1);
- printf ("\n");
+ BarUiMsg (MSG_NONE, "\n");
}
if (settings.enableScrobbling) {
@@ -106,13 +106,13 @@ int main (int argc, char **argv) {
BarTermSetBuffer (0);
- BarUiMsg ("Login... ");
+ BarUiMsg (MSG_INFO, "Login... ");
if (BarUiPrintPianoStatus (PianoConnect (&ph, settings.username,
settings.password, !settings.disableSecureLogin)) !=
PIANO_RET_OK) {
return 0;
}
- BarUiMsg ("Get stations... ");
+ BarUiMsg (MSG_INFO, "Get stations... ");
if (BarUiPrintPianoStatus (PianoGetStations (&ph)) != PIANO_RET_OK) {
return 0;
}
@@ -122,7 +122,7 @@ int main (int argc, char **argv) {
curStation = PianoFindStationById (ph.stations,
settings.autostartStation);
if (curStation == NULL) {
- BarUiMsg ("Error: Autostart station not found.\n");
+ BarUiMsg (MSG_ERR, "Error: Autostart station not found.\n");
}
}
/* no autostart? ask the user */
@@ -130,7 +130,7 @@ int main (int argc, char **argv) {
curStation = BarUiSelectStation (&ph, "Select station: ");
}
if (curStation != NULL) {
- printf ("Playing station \"%s\"\n", curStation->name);
+ BarUiPrintStation (curStation);
}
/* little hack, needed to signal: hey! we need a playlist, but don't
@@ -148,12 +148,13 @@ int main (int argc, char **argv) {
scrobbleSong.length >= settings.lastfmScrobblePercent) {
WardrobeReturn_t wRet;
- BarUiMsg ("Scrobbling song... ");
+ BarUiMsg (MSG_INFO, "Scrobbling song... ");
if ((wRet = WardrobeSubmit (&wh, &scrobbleSong)) ==
WARDROBE_RET_OK) {
- BarUiMsg ("Ok.\n");
+ BarUiMsg (MSG_NONE, "Ok.\n");
} else {
- printf ("Error: %s\n", WardrobeErrorToString (wRet));
+ BarUiMsg (MSG_ERR, "Error: %s\n",
+ WardrobeErrorToString (wRet));
}
}
WardrobeSongDestroy (&scrobbleSong);
@@ -174,7 +175,7 @@ int main (int argc, char **argv) {
curSong = curSong->next;
}
if (curSong == NULL) {
- BarUiMsg ("Receiving new playlist... ");
+ BarUiMsg (MSG_INFO, "Receiving new playlist... ");
PianoDestroyPlaylist (&ph);
if (BarUiPrintPianoStatus (PianoGetPlaylist (&ph,
curStation->id, settings.audioFormat)) !=
@@ -183,23 +184,16 @@ int main (int argc, char **argv) {
} else {
curSong = ph.playlist;
if (curSong == NULL) {
- BarUiMsg ("No tracks left.\n");
+ BarUiMsg (MSG_INFO, "No tracks left.\n");
curStation = NULL;
}
}
}
/* song ready to play */
if (curSong != NULL) {
- PianoStation_t *realStation =
+ BarUiPrintSong (curSong, curStation->isQuickMix ?
PianoFindStationById (ph.stations,
- curSong->stationId);
- printf ("\"%s\" by \"%s\" on \"%s\"%s%s%s\n",
- curSong->title, curSong->artist,
- curSong->album, (curSong->rating ==
- PIANO_RATE_LOVE) ? " (Loved)" : "",
- curStation->isQuickMix ? " @ ": "",
- curStation->isQuickMix ? realStation->name :
- "");
+ curSong->stationId) : NULL);
/* setup artist and song name for scrobbling (curSong
* may be NULL later) */
WardrobeSongInit (&scrobbleSong);
@@ -226,6 +220,9 @@ int main (int argc, char **argv) {
if (poll (&polls, 1, 1000) > 0) {
read (fileno (stdin), &buf, sizeof (buf));
curShortcut = settings.keys;
+ /* don't show what the user enters here, we could disable
+ * echoing too... */
+ BarUiMsg (MSG_NONE, "\r");
while (curShortcut != NULL) {
if (curShortcut->key == buf) {
curShortcut->cmd (&ph, &player, &settings, &curSong,
@@ -240,12 +237,11 @@ int main (int argc, char **argv) {
if (player.mode >= PLAYER_SAMPLESIZE_INITIALIZED &&
player.mode < PLAYER_FINISHED_PLAYBACK) {
long int songRemaining = player.songDuration - player.songPlayed;
- printf ("-%02i:%02i/%02i:%02i\r",
+ BarUiMsg (MSG_TIME, "-%02i:%02i/%02i:%02i\r",
(int) songRemaining / BAR_PLAYER_MS_TO_S_FACTOR / 60,
(int) songRemaining / BAR_PLAYER_MS_TO_S_FACTOR % 60,
(int) player.songDuration / BAR_PLAYER_MS_TO_S_FACTOR / 60,
(int) player.songDuration / BAR_PLAYER_MS_TO_S_FACTOR % 60);
- fflush (stdout);
}
}
diff --git a/src/pianobar.1 b/src/pianobar.1
index b0a3194..0c236b6 100644
--- a/src/pianobar.1
+++ b/src/pianobar.1
@@ -64,7 +64,7 @@ Add genre station provided by pandora.
.TP
.B act_songinfo = i
-Print detailed information about currently played song.
+Print information about currently played song/station.
.TP
.B act_addshared = j
diff --git a/src/player.c b/src/player.c
index 92038d9..f701ff4 100644
--- a/src/player.c
+++ b/src/player.c
@@ -30,6 +30,7 @@ THE SOFTWARE.
#include "player.h"
#include "config.h"
+#include "ui.h"
#define byteswap32(x) (((x >> 24) & 0x000000ff) | ((x >> 8) & 0x0000ff00) | \
((x << 8) & 0x00ff0000) | ((x << 24) & 0xff000000))
@@ -85,7 +86,7 @@ inline int BarPlayerBufferFill (struct audioPlayer *player, char *data,
size_t dataSize) {
/* fill buffer */
if (player->bufferFilled + dataSize > sizeof (player->buffer)) {
- printf (PACKAGE ": Buffer overflow!\n");
+ BarUiMsg (MSG_ERR, PACKAGE ": Buffer overflow!\n");
return 0;
}
memcpy (player->buffer+player->bufferFilled, data, dataSize);
@@ -138,7 +139,7 @@ size_t BarPlayerAACCurlCb (void *ptr, size_t size, size_t nmemb, void *stream) {
player->buffer + player->bufferRead,
player->sampleSize[player->sampleSizeCurr]);
if (frameInfo.error != 0) {
- printf (PACKAGE ": Decoding error: %s\n\n",
+ BarUiMsg (MSG_ERR, PACKAGE ": Decoding error: %s\n",
NeAACDecGetErrorMessage (frameInfo.error));
break;
}
@@ -186,7 +187,8 @@ size_t BarPlayerAACCurlCb (void *ptr, size_t size, size_t nmemb, void *stream) {
&player->channels);
player->bufferRead += 5;
if (err != 0) {
- printf (PACKAGE ": Error while initializing audio decoder"
+ BarUiMsg (MSG_ERR, PACKAGE ": Error while "
+ "initializing audio decoder"
"(%i)\n", err);
return 0;
}
@@ -314,7 +316,7 @@ size_t BarPlayerMp3CurlCb (void *ptr, size_t size, size_t nmemb, void *stream) {
if (mad_frame_decode (&player->mp3Frame, &player->mp3Stream) != 0) {
if (player->mp3Stream.error != MAD_ERROR_BUFLEN) {
- printf (PACKAGE ": mp3 decoding error: %s.\n",
+ BarUiMsg (MSG_ERR, PACKAGE ": mp3 decoding error: %s\n",
mad_stream_errorstr (&player->mp3Stream));
return 0;
} else {
@@ -453,7 +455,7 @@ void *BarPlayerThread (void *data) {
#endif /* ENABLE_MAD */
default:
- printf (PACKAGE ": Unsupported audio format!\n");
+ BarUiMsg (MSG_ERR, PACKAGE ": Unsupported audio format!\n");
return NULL;
break;
}
diff --git a/src/settings.c b/src/settings.c
index cd82b7c..a0dabb5 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -147,7 +147,7 @@ void BarSettingsRead (BarSettings_t *settings) {
{'g', BarUiActStationFromGenre, "add genre station",
"act_stationaddbygenre", NULL},
{'i', BarUiActSongInfo,
- "print verbose information about current song",
+ "print information about current song/station",
"act_songinfo", NULL},
{'j', BarUiActAddSharedStation, "add shared station",
"act_addshared", NULL},
@@ -166,6 +166,8 @@ void BarSettingsRead (BarSettings_t *settings) {
NULL},
{'x', BarUiActSelectQuickMix, "select quickmix stations",
"act_stationselectquickmix", NULL},
+ {'$', BarUiActDebug, NULL,
+ "act_debug", NULL},
};
/* apply defaults */
diff --git a/src/ui.c b/src/ui.c
index 9b0024a..b0b3f1f 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -24,6 +24,7 @@ THE SOFTWARE.
/* everything that interacts with the user */
#include <stdio.h>
+#include <stdarg.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
@@ -34,8 +35,37 @@ THE SOFTWARE.
/* output message and flush stdout
* @param message
*/
-inline void BarUiMsg (const char *msg) {
- printf ("%s", msg);
+inline void BarUiMsg (uiMsg_t type, const char *format, ...) {
+ va_list fmtargs;
+
+ switch (type) {
+ case MSG_INFO:
+ printf ("i ");
+ break;
+
+ case MSG_PLAYING:
+ printf ("> ");
+ break;
+
+ case MSG_TIME:
+ printf ("# ");
+ break;
+
+ case MSG_ERR:
+ printf ("! ");
+ break;
+
+ case MSG_LIST:
+ printf ("\t");
+ break;
+
+ default:
+ break;
+ }
+ va_start (fmtargs, format);
+ vprintf (format, fmtargs);
+ va_end (fmtargs);
+
fflush (stdout);
}
@@ -44,9 +74,9 @@ inline void BarUiMsg (const char *msg) {
*/
inline PianoReturn_t BarUiPrintPianoStatus (PianoReturn_t ret) {
if (ret != PIANO_RET_OK) {
- printf ("Error: %s\n", PianoErrorToStr (ret));
+ BarUiMsg (MSG_NONE, "Error: %s\n", PianoErrorToStr (ret));
} else {
- printf ("Ok.\n");
+ BarUiMsg (MSG_NONE, "Ok.\n");
}
return ret;
}
@@ -151,7 +181,7 @@ PianoStation_t *BarUiSelectStation (PianoHandle_t *ph, const char *prompt) {
ss = BarSortedStations (ph->stations);
ssCurr = ss;
while (*ssCurr != NULL) {
- printf ("%2i) %c%c%c %s\n", i,
+ BarUiMsg (MSG_LIST, "%2i) %c%c%c %s\n", i,
(*ssCurr)->useQuickMix ? 'q' : ' ',
(*ssCurr)->isQuickMix ? 'Q' : ' ',
!(*ssCurr)->isCreator ? 'S' : ' ',
@@ -185,7 +215,8 @@ PianoSong_t *BarUiSelectSong (PianoSong_t *startSong) {
/* print all songs */
tmpSong = startSong;
while (tmpSong != NULL) {
- printf ("%2u) %s - %s\n", i, tmpSong->artist, tmpSong->title);
+ BarUiMsg (MSG_LIST, "%2u) %s - %s\n", i, tmpSong->artist,
+ tmpSong->title);
i++;
tmpSong = tmpSong->next;
}
@@ -211,7 +242,7 @@ PianoArtist_t *BarUiSelectArtist (PianoArtist_t *startArtist) {
/* print all artists */
tmpArtist = startArtist;
while (tmpArtist != NULL) {
- printf ("%2u) %s\n", i, tmpArtist->name);
+ BarUiMsg (MSG_LIST, "%2u) %s\n", i, tmpArtist->name);
i++;
tmpArtist = tmpArtist->next;
}
@@ -239,16 +270,17 @@ char *BarUiSelectMusicId (const PianoHandle_t *ph) {
lineBuf = readline ("Search for artist/title: ");
if (lineBuf != NULL && strlen (lineBuf) > 0) {
- BarUiMsg ("Searching... ");
+ BarUiMsg (MSG_INFO, "Searching... ");
if (BarUiPrintPianoStatus (PianoSearchMusic (ph, lineBuf,
&searchResult)) != PIANO_RET_OK) {
free (lineBuf);
return NULL;
}
- BarUiMsg ("\r");
+ BarUiMsg (MSG_NONE, "\r");
if (searchResult.songs != NULL && searchResult.artists != NULL) {
/* songs and artists found */
- BarUiMsg ("Is this an [a]rtist or [t]rack name? Press c to abort.\n");
+ BarUiMsg (MSG_QUESTION,
+ "Is this an [a]rtist or [t]rack name? Press c to abort.\n");
read (fileno (stdin), &yesnoBuf, sizeof (yesnoBuf));
if (yesnoBuf == 'a') {
tmpArtist = BarUiSelectArtist (searchResult.artists);
@@ -274,7 +306,7 @@ char *BarUiSelectMusicId (const PianoHandle_t *ph) {
musicId = strdup (tmpArtist->musicId);
}
} else {
- BarUiMsg ("Nothing found...\n");
+ BarUiMsg (MSG_INFO, "Nothing found...\n");
}
PianoDestroySearchResult (&searchResult);
}
@@ -295,7 +327,7 @@ void BarStationFromGenre (PianoHandle_t *ph) {
/* receive genre stations list if not yet available */
if (ph->genreStations == NULL) {
- BarUiMsg ("Receiving genre stations... ");
+ BarUiMsg (MSG_INFO, "Receiving genre stations... ");
if (BarUiPrintPianoStatus (PianoGetGenreStations (ph)) !=
PIANO_RET_OK) {
return;
@@ -306,13 +338,12 @@ void BarStationFromGenre (PianoHandle_t *ph) {
curCat = ph->genreStations;
i = 0;
while (curCat != NULL) {
- printf ("%2i) %s\n", i, curCat->name);
+ BarUiMsg (MSG_LIST, "%2i) %s\n", i, curCat->name);
i++;
curCat = curCat->next;
}
/* select category or exit */
if (!BarReadlineInt ("Select category: ", &i)) {
- BarUiMsg ("Aborted.\n");
return;
}
curCat = ph->genreStations;
@@ -325,12 +356,11 @@ void BarStationFromGenre (PianoHandle_t *ph) {
curStation = curCat->stations;
i = 0;
while (curStation != NULL) {
- printf ("%2i) %s\n", i, curStation->name);
+ BarUiMsg (MSG_LIST, "%2i) %s\n", i, curStation->name);
i++;
curStation = curStation->next;
}
if (!BarReadlineInt ("Select genre: ", &i)) {
- BarUiMsg ("Aborted.\n");
return;
}
curStation = curCat->stations;
@@ -339,8 +369,25 @@ void BarStationFromGenre (PianoHandle_t *ph) {
i--;
}
/* create station */
- printf ("Adding shared station \"%s\"... ", curStation->name);
- fflush (stdout);
+ BarUiMsg (MSG_INFO, "Adding shared station \"%s\"... ", curStation->name);
BarUiPrintPianoStatus (PianoCreateStation (ph, "sh", curStation->id));
}
+/* Print station infos (including station id)
+ * @param the station
+ */
+inline void BarUiPrintStation (PianoStation_t *station) {
+ BarUiMsg (MSG_PLAYING, "Station \"%s\" (%s)\n", station->name, station->id);
+}
+
+/* Print song infos (artist, title, album, loved)
+ * @param the song
+ * @param alternative station info (show real station for quickmix, e.g.)
+ */
+inline void BarUiPrintSong (PianoSong_t *song, PianoStation_t *station) {
+ BarUiMsg (MSG_PLAYING, "\"%s\" by \"%s\" on \"%s\"%s%s%s\n",
+ song->title, song->artist, song->album,
+ (song->rating == PIANO_RATE_LOVE) ? " <3" : "",
+ station != NULL ? " @ " : "",
+ station != NULL ? station->name : "");
+}
diff --git a/src/ui.h b/src/ui.h
index 9caa874..084bce0 100644
--- a/src/ui.h
+++ b/src/ui.h
@@ -26,12 +26,17 @@ THE SOFTWARE.
#include <piano.h>
-inline void BarUiMsg (const char *msg);
+typedef enum {MSG_NONE, MSG_INFO, MSG_PLAYING, MSG_TIME, MSG_ERR,
+ MSG_QUESTION, MSG_LIST} uiMsg_t;
+
+inline void BarUiMsg (uiMsg_t type, const char *format, ...);
inline PianoReturn_t BarUiPrintPianoStatus (PianoReturn_t ret);
PianoStation_t *BarUiSelectStation (PianoHandle_t *ph, const char *prompt);
PianoSong_t *BarUiSelectSong (PianoSong_t *startSong);
PianoArtist_t *BarUiSelectArtist (PianoArtist_t *startArtist);
char *BarUiSelectMusicId (const PianoHandle_t *ph);
void BarStationFromGenre (PianoHandle_t *ph);
+inline void BarUiPrintStation (PianoStation_t *);
+inline void BarUiPrintSong (PianoSong_t *, PianoStation_t *);
#endif /* _UI_H */
diff --git a/src/ui_act.c b/src/ui_act.c
index 1ba4277..5f0861d 100644
--- a/src/ui_act.c
+++ b/src/ui_act.c
@@ -34,11 +34,11 @@ THE SOFTWARE.
#include "ui_act.h"
#define RETURN_IF_NO_STATION if (*curStation == NULL) { \
- BarUiMsg ("No station selected.\n"); \
+ BarUiMsg (MSG_ERR, "No station selected.\n"); \
return; }
#define RETURN_IF_NO_SONG if (*curStation == NULL || *curSong == NULL) { \
- BarUiMsg ("No song playing.\n"); \
+ BarUiMsg (MSG_ERR, "No song playing.\n"); \
return; }
/* helper to _really_ skip a song (unlock mutex, quit player)
@@ -57,7 +57,7 @@ inline void BarUiDoSkipSong (struct audioPlayer *player) {
int BarTransformIfShared (PianoHandle_t *ph, PianoStation_t *station) {
/* shared stations must be transformed */
if (!station->isCreator) {
- BarUiMsg ("Transforming station... ");
+ BarUiMsg (MSG_INFO, "Transforming station... ");
if (BarUiPrintPianoStatus (PianoTransformShared (ph, station)) !=
PIANO_RET_OK) {
return 0;
@@ -71,10 +71,11 @@ int BarTransformIfShared (PianoHandle_t *ph, PianoStation_t *station) {
void BarUiActHelp (BAR_KS_ARGS) {
BarKeyShortcut_t *curShortcut = settings->keys;
- printf ("\r");
+ BarUiMsg (MSG_NONE, "\r");
while (curShortcut != NULL) {
if (curShortcut->description != NULL) {
- printf ("%c\t%s\n", curShortcut->key, curShortcut->description);
+ BarUiMsg (MSG_NONE, "%c\t%s\n", curShortcut->key,
+ curShortcut->description);
}
curShortcut = curShortcut->next;
}
@@ -92,7 +93,7 @@ void BarUiActAddMusic (BAR_KS_ARGS) {
if (!BarTransformIfShared (ph, *curStation)) {
return;
}
- BarUiMsg ("Adding music to station... ");
+ BarUiMsg (MSG_INFO, "Adding music to station... ");
BarUiPrintPianoStatus (PianoStationAddMusic (ph,
*curStation, musicId));
free (musicId);
@@ -107,7 +108,7 @@ void BarUiActBanSong (BAR_KS_ARGS) {
if (!BarTransformIfShared (ph, *curStation)) {
return;
}
- BarUiMsg ("Banning song... ");
+ BarUiMsg (MSG_INFO, "Banning song... ");
if (BarUiPrintPianoStatus (PianoRateTrack (ph, *curSong,
PIANO_RATE_BAN)) == PIANO_RET_OK) {
BarUiDoSkipSong (player);
@@ -120,7 +121,7 @@ void BarUiActCreateStation (BAR_KS_ARGS) {
char *musicId;
musicId = BarUiSelectMusicId (ph);
if (musicId != NULL) {
- BarUiMsg ("Creating station... ");
+ BarUiMsg (MSG_INFO, "Creating station... ");
BarUiPrintPianoStatus (PianoCreateStation (ph, "mi", musicId));
free (musicId);
}
@@ -133,7 +134,7 @@ void BarUiActAddSharedStation (BAR_KS_ARGS) {
if ((stationId = readline ("Station id: ")) != NULL &&
strlen (stationId) > 0) {
- BarUiMsg ("Adding shared station... ");
+ BarUiMsg (MSG_INFO, "Adding shared station... ");
BarUiPrintPianoStatus (PianoCreateStation (ph, "sh", stationId));
free (stationId);
}
@@ -146,10 +147,12 @@ void BarUiActDeleteStation (BAR_KS_ARGS) {
RETURN_IF_NO_STATION;
- printf ("Really delete \"%s\"? [yn]\n", (*curStation)->name);
+ BarUiMsg (MSG_QUESTION, "Really delete \"%s\"? [yn] ",
+ (*curStation)->name);
read (fileno (stdin), &yesNoBuf, sizeof (yesNoBuf));
+ BarUiMsg (MSG_NONE, "\n");
if (yesNoBuf == 'y') {
- BarUiMsg ("Deleting station... ");
+ BarUiMsg (MSG_INFO, "Deleting station... ");
if (BarUiPrintPianoStatus (PianoDeleteStation (ph,
*curStation)) == PIANO_RET_OK) {
BarUiDoSkipSong (player);
@@ -167,10 +170,10 @@ void BarUiActExplain (BAR_KS_ARGS) {
RETURN_IF_NO_STATION;
- BarUiMsg ("Receiving explanation... ");
+ BarUiMsg (MSG_INFO, "Receiving explanation... ");
if (BarUiPrintPianoStatus (PianoExplain (ph, *curSong,
&explanation)) == PIANO_RET_OK) {
- printf ("%s\n", explanation);
+ BarUiMsg (MSG_INFO, "%s\n", explanation);
free (explanation);
}
}
@@ -187,8 +190,19 @@ void BarUiActStationFromGenre (BAR_KS_ARGS) {
void BarUiActSongInfo (BAR_KS_ARGS) {
RETURN_IF_NO_SONG;
+ BarUiPrintStation ((*curStation));
+ /* print real station if quickmix */
+ BarUiPrintSong ((*curSong), (*curStation)->isQuickMix ?
+ PianoFindStationById (ph->stations, (*curSong)->stationId) : NULL);
+}
+
+/* print some debugging information
+ */
+void BarUiActDebug (BAR_KS_ARGS) {
+ RETURN_IF_NO_SONG;
+
/* print debug-alike infos */
- printf ("Song infos:\n"
+ BarUiMsg (MSG_NONE,
"album:\t%s\n"
"artist:\t%s\n"
"audioFormat:\t%i\n"
@@ -217,7 +231,7 @@ void BarUiActLoveSong (BAR_KS_ARGS) {
if (!BarTransformIfShared (ph, *curStation)) {
return;
}
- BarUiMsg ("Loving song... ");
+ BarUiMsg (MSG_INFO, "Loving song... ");
BarUiPrintPianoStatus (PianoRateTrack (ph, *curSong, PIANO_RATE_LOVE));
}
@@ -240,11 +254,10 @@ void BarUiActMoveSong (BAR_KS_ARGS) {
!BarTransformIfShared (ph, moveStation)) {
return;
}
- printf ("Moving song to \"%s\"... ", moveStation->name);
- fflush (stdout);
+ BarUiMsg (MSG_INFO, "Moving song to \"%s\"... ", moveStation->name);
fromStation = PianoFindStationById (ph->stations, (*curSong)->stationId);
if (fromStation == NULL) {
- BarUiMsg ("Station not found\n");
+ BarUiMsg (MSG_ERR, "Station not found\n");
return;
}
if (BarUiPrintPianoStatus (PianoMoveSong (ph, fromStation,
@@ -275,7 +288,7 @@ void BarUiActRenameStation (BAR_KS_ARGS) {
if (!BarTransformIfShared (ph, *curStation)) {
return;
}
- BarUiMsg ("Renaming station... ");
+ BarUiMsg (MSG_INFO, "Renaming station... ");
BarUiPrintPianoStatus (PianoRenameStation (ph, *curStation, lineBuf));
}
if (lineBuf != NULL) {
@@ -291,7 +304,7 @@ void BarUiActSelectStation (BAR_KS_ARGS) {
*curSong = NULL;
*curStation = BarUiSelectStation (ph, "Select station: ");
if (*curStation != NULL) {
- printf ("Changed station to %s\n", (*curStation)->name);
+ BarUiPrintStation ((*curStation));
}
}
@@ -300,7 +313,7 @@ void BarUiActSelectStation (BAR_KS_ARGS) {
void BarUiActTempBanSong (BAR_KS_ARGS) {
RETURN_IF_NO_SONG;
- BarUiMsg ("Putting song on shelf... ");
+ BarUiMsg (MSG_INFO, "Putting song on shelf... ");
if (BarUiPrintPianoStatus (PianoSongTired (ph, *curSong)) ==
PIANO_RET_OK) {
BarUiDoSkipSong (player);
@@ -315,15 +328,14 @@ void BarUiActPrintUpcoming (BAR_KS_ARGS) {
PianoSong_t *nextSong = (*curSong)->next;
if (nextSong != NULL) {
int i = 0;
- BarUiMsg ("Next songs:\n");
while (nextSong != NULL) {
- printf ("%2i) \"%s\" by \"%s\"\n", i, nextSong->title,
+ BarUiMsg (MSG_LIST, "%2i) \"%s\" by \"%s\"\n", i, nextSong->title,
nextSong->artist);
nextSong = nextSong->next;
i++;
}
} else {
- BarUiMsg ("No songs in queue.\n");
+ BarUiMsg (MSG_INFO, "No songs in queue.\n");
}
}
@@ -339,10 +351,10 @@ void BarUiActSelectQuickMix (BAR_KS_ARGS) {
"Toggle quickmix for station: ")) != NULL) {
selStation->useQuickMix = !selStation->useQuickMix;
}
- BarUiMsg ("Setting quickmix stations... ");
+ BarUiMsg (MSG_INFO, "Setting quickmix stations... ");
BarUiPrintPianoStatus (PianoSetQuickmix (ph));
} else {
- BarUiMsg ("Not a QuickMix station.\n");
+ BarUiMsg (MSG_ERR, "Not a QuickMix station.\n");
}
}
diff --git a/src/ui_act.h b/src/ui_act.h
index 4eaefbe..bbb5904 100644
--- a/src/ui_act.h
+++ b/src/ui_act.h
@@ -45,5 +45,6 @@ void BarUiActTempBanSong (BAR_KS_ARGS);
void BarUiActPrintUpcoming (BAR_KS_ARGS);
void BarUiActSelectQuickMix (BAR_KS_ARGS);
void BarUiActQuit (BAR_KS_ARGS);
+void BarUiActDebug (BAR_KS_ARGS);
#endif /* _UI_ACT_H */