diff options
author | Lars-Dominik Braun <PromyLOPh@gmail.com> | 2008-06-14 16:08:35 +0200 |
---|---|---|
committer | Lars-Dominik Braun <PromyLOPh@gmail.com> | 2008-06-14 16:08:35 +0200 |
commit | e22869ebdd98ecc3f870cb1d6c5c31fd1b5d61ee (patch) | |
tree | b2e54f4e5c95f73fa96f88a624dd358a5477cd0f /src | |
parent | b1ea463843add37874f9768b606825504cdc8eb2 (diff) | |
download | pianobar-windows-e22869ebdd98ecc3f870cb1d6c5c31fd1b5d61ee.tar.gz pianobar-windows-e22869ebdd98ecc3f870cb1d6c5c31fd1b5d61ee.tar.bz2 pianobar-windows-e22869ebdd98ecc3f870cb1d6c5c31fd1b5d61ee.zip |
Finally implemented "create station"
This may be a bit buggy, because no return values are checked or returned. A
big cleanup session is waiting...
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 79 |
1 files changed, 79 insertions, 0 deletions
@@ -232,6 +232,46 @@ PianoStation_t *selectStation (PianoHandle_t *ph) { return curStation; } +PianoSong_t *selectSong (PianoSong_t *startSong) { + PianoSong_t *tmpSong; + size_t i; + + tmpSong = startSong; + i = 0; + while (tmpSong != NULL) { + printf ("%2u) %s - %s\n", i, tmpSong->artist, tmpSong->title); + i++; + tmpSong = tmpSong->next; + } + scanf ("%i", &i); + tmpSong = startSong; + while (tmpSong != NULL && i > 0) { + tmpSong = tmpSong->next; + i--; + } + return tmpSong; +} + +PianoArtist_t *selectArtist (PianoArtist_t *startArtist) { + PianoArtist_t *tmpArtist; + size_t i; + + tmpArtist = startArtist; + i = 0; + while (tmpArtist != NULL) { + printf ("%2u) %s\n", i, tmpArtist->name); + i++; + tmpArtist = tmpArtist->next; + } + scanf ("%i", &i); + tmpArtist = startArtist; + while (tmpArtist != NULL && i > 0) { + tmpArtist = tmpArtist->next; + i--; + } + return tmpArtist; +} + int main (int argc, char **argv) { PianoHandle_t ph; struct aacPlayer player; @@ -278,6 +318,9 @@ int main (int argc, char **argv) { struct pollfd polls = {fileno (stdin), POLLIN, POLLIN}; char buf, yesnoBuf; char *lineBuf; + PianoSearchResult_t searchResult; + PianoArtist_t *tmpArtist; + PianoSong_t *tmpSong; if (poll (&polls, 1, 1000) > 0) { read (fileno (stdin), &buf, sizeof (buf)); @@ -299,6 +342,42 @@ int main (int argc, char **argv) { curSong = NULL; break; + case 'c': + lineBuf = readline ("Search for artist/title\n"); + if (lineBuf != NULL && strlen (lineBuf) > 0) { + PianoSearchMusic (&ph, lineBuf, &searchResult); + if (searchResult.songs != NULL && searchResult.artists != NULL) { + printf ("Is this an [a]rtist or [t]rack name?\n"); + read (fileno (stdin), &yesnoBuf, sizeof (yesnoBuf)); + if (yesnoBuf == 'a') { + tmpArtist = selectArtist (searchResult.artists); + PianoCreateStation (&ph, tmpArtist->musicId); + printf ("Ok.\n"); + } else if (yesnoBuf == 't') { + tmpSong = selectSong (searchResult.songs); + PianoCreateStation (&ph, tmpSong->musicId); + printf ("Ok.\n"); + } + } else if (searchResult.songs != NULL) { + printf ("Select song\n"); + tmpSong = selectSong (searchResult.songs); + PianoCreateStation (&ph, tmpSong->musicId); + printf ("Ok.\n"); + } else if (searchResult.artists != NULL) { + printf ("Select artist\n"); + tmpArtist = selectArtist (searchResult.artists); + PianoCreateStation (&ph, tmpArtist->musicId); + printf ("Ok.\n"); + } else { + printf ("Nothing found...\n"); + } + PianoDestroySearchResult (&searchResult); + } + if (lineBuf != NULL) { + free (lineBuf); + } + break; + case 'd': printf ("Really delete \"%s\"? [yn]\n", curStation->name); |