From 31ff2f7dfd0b6eb98cb90d44d87044321def0f7a Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Wed, 11 Jun 2008 16:32:23 +0200 Subject: client: Station renaming implemented --- INSTALL | 1 + configure.in | 3 +++ src/Makefile.am | 2 +- src/main.c | 17 +++++++++++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/INSTALL b/INSTALL index d6458ab..590758a 100644 --- a/INSTALL +++ b/INSTALL @@ -12,6 +12,7 @@ libao http://www.xiph.org/ao/ (pianobar) libcurl http://curl.haxx.se/ (libpiano, pianobar) libfaad2 http://www.audiocoding.com/downloads.html (pianobar) libxml2 http://xmlsoft.org/ (libpiano) +readline (pianobar) Build ----- diff --git a/configure.in b/configure.in index 2206af2..db07cf7 100644 --- a/configure.in +++ b/configure.in @@ -24,6 +24,9 @@ AC_SUBST(LIBAO_LIBS) AC_CHECK_LIB([faad], [NeAACDecOpen], [LIBFAAD_LIBS=-lfaad], AC_MSG_ERROR([libfaad2 is required. See INSTALL])) AC_SUBST(LIBFAAD_LIBS) +AC_CHECK_LIB([readline], [readline], [LIBREADLINE_LIBS=-lreadline], AC_MSG_ERROR([readline is required. See INSTALL])) +AC_SUBST(LIBREADLINE_LIBS) + # FIXME: check for pthread AC_CHECK_HEADERS([stdlib.h string.h]) diff --git a/src/Makefile.am b/src/Makefile.am index 8f88440..fbd184c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,5 +2,5 @@ bin_PROGRAMS = pianobar pianobar_SOURCES = main.c pianobar_CPPFLAGS = ${LIBCURL_CFLAGS} ${LIBAO_CFLAGS} -I../libpiano -pianobar_LDADD = ${LIBCURL_LIBS} ${LIBAO_LIBS} ${LIBFAAD_LIBS} -lpthread ../libpiano/libpiano.la +pianobar_LDADD = ${LIBCURL_LIBS} ${LIBAO_LIBS} ${LIBFAAD_LIBS} ${LIBREADLINE_LIBS} -lpthread ../libpiano/libpiano.la diff --git a/src/main.c b/src/main.c index 84457df..8b06ed6 100644 --- a/src/main.c +++ b/src/main.c @@ -31,6 +31,7 @@ THE SOFTWARE. #include #include #include +#include struct aacPlayer { /* buffer */ @@ -274,6 +275,7 @@ int main (int argc, char **argv) { while (!player.finishedPlayback) { struct pollfd polls = {fileno (stdin), POLLIN, POLLIN}; char buf; + char *lineBuf; if (poll (&polls, 1, 1000) > 0) { read (fileno (stdin), &buf, sizeof (buf)); @@ -316,6 +318,21 @@ int main (int argc, char **argv) { player.doQuit = 1; break; + case 'r': + lineBuf = readline ("New name?\n"); + if (lineBuf != NULL && strlen (lineBuf) > 0) { + if (PianoRenameStation (&ph, curStation, lineBuf) == + PIANO_RET_OK) { + printf ("Renamed.\n"); + } else { + printf ("Error while renaming station.\n"); + } + } + if (lineBuf != NULL) { + free (lineBuf); + } + break; + case 's': player.doQuit = 1; PianoDestroyPlaylist (&ph); -- cgit v1.2.3