diff options
Diffstat (limited to '')
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | Makefile.am | 24 | ||||
-rwxr-xr-x | autogen.sh | 162 | ||||
-rw-r--r-- | configure.ac | 10 | ||||
-rw-r--r-- | src/Makefile.am | 20 | ||||
-rw-r--r-- | src/colors.c (renamed from colors.c) | 0 | ||||
-rw-r--r-- | src/colors.h (renamed from colors.h) | 0 | ||||
-rw-r--r-- | src/command.c (renamed from command.c) | 0 | ||||
-rw-r--r-- | src/command.h (renamed from command.h) | 0 | ||||
-rw-r--r-- | src/conf.c (renamed from conf.c) | 0 | ||||
-rw-r--r-- | src/conf.h (renamed from conf.h) | 0 | ||||
-rw-r--r-- | src/libmpdclient.c (renamed from libmpdclient.c) | 41 | ||||
-rw-r--r-- | src/libmpdclient.h (renamed from libmpdclient.h) | 8 | ||||
-rw-r--r-- | src/list_window.c (renamed from list_window.c) | 0 | ||||
-rw-r--r-- | src/list_window.h (renamed from list_window.h) | 0 | ||||
-rw-r--r-- | src/main.c (renamed from main.c) | 0 | ||||
-rw-r--r-- | src/mpc.c (renamed from mpc.c) | 0 | ||||
-rw-r--r-- | src/mpc.h (renamed from mpc.h) | 0 | ||||
-rw-r--r-- | src/options.c (renamed from options.c) | 0 | ||||
-rw-r--r-- | src/options.h (renamed from options.h) | 0 | ||||
-rw-r--r-- | src/screen.c (renamed from screen.c) | 48 | ||||
-rw-r--r-- | src/screen.h (renamed from screen.h) | 0 | ||||
-rw-r--r-- | src/screen_file.c (renamed from screen_file.c) | 0 | ||||
-rw-r--r-- | src/screen_file.h (renamed from screen_file.h) | 0 | ||||
-rw-r--r-- | src/screen_help.c (renamed from screen_help.c) | 0 | ||||
-rw-r--r-- | src/screen_help.h (renamed from screen_help.h) | 0 | ||||
-rw-r--r-- | src/screen_keydef.c (renamed from screen_keydef.c) | 0 | ||||
-rw-r--r-- | src/screen_play.c (renamed from screen_play.c) | 0 | ||||
-rw-r--r-- | src/screen_play.h (renamed from screen_play.h) | 0 | ||||
-rw-r--r-- | src/screen_search.c (renamed from screen_search.c) | 0 | ||||
-rw-r--r-- | src/screen_search.h (renamed from screen_search.h) | 0 | ||||
-rw-r--r-- | src/screen_utils.c (renamed from screen_utils.c) | 0 | ||||
-rw-r--r-- | src/screen_utils.h (renamed from screen_utils.h) | 0 | ||||
-rw-r--r-- | src/support.c (renamed from support.c) | 0 | ||||
-rw-r--r-- | src/support.h (renamed from support.h) | 0 |
35 files changed, 231 insertions, 89 deletions
@@ -1,3 +1,10 @@ +2004-06-05 Kalle Wallin <kaw@linux.se> + * Changed directory layout to suit future use of gettext + * screen.c: Added mpd update flag [U] and display a status message + when a update has finished + * screen.c: Display bit rate instead of time when the total time + is zero and display local time when mpd is stopped. + 2004-05-07 Kalle Wallin <kaw@linux.se> * Redesigned ncmpc's color support - view the manual for details! * Added support for moving songs in a playlist (move-up, move-down) diff --git a/Makefile.am b/Makefile.am index 8ac5da7de..8bf3267ee 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,27 +1,15 @@ # -# $Id: Makefile.am,v 1.5 2004/03/16 23:49:14 kalle Exp $ +# $Id$ # -bin_PROGRAMS = ncmpc +AUTOMAKE_OPTIONS = foreign 1.6 + +SUBDIRS = doc src pkgdata_DATA = docdir = $(prefix)/share/doc/$(PACKAGE) -doc_DATA = AUTHORS README ChangeLog -EXTRA_DIST = COPYING $(pkgdata_DATA) $(doc_DATA) - -SUBDIRS = doc - -#EXTRA_ncmpc_SOURCES = -#ncmpc_LDADD = -#ncmpc_DEPENDENCIES = - -ncmpc_headers = libmpdclient.h mpc.h options.h conf.h command.h screen.h \ - screen_utils.h screen_play.h screen_file.h screen_search.h \ - screen_help.h list_window.h colors.h support.h +doc_DATA = AUTHORS README +EXTRA_DIST = ChangeLog COPYING $(pkgdata_DATA) $(doc_DATA) -ncmpc_SOURCES = libmpdclient.c main.c mpc.c options.c conf.c command.c \ - screen.c screen_utils.c screen_play.c screen_file.c \ - screen_search.c screen_help.c screen_keydef.c \ - list_window.c colors.c support.c $(ncmpc_headers) diff --git a/autogen.sh b/autogen.sh index 72a235234..22e7897d7 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,54 +1,122 @@ -#! /bin/sh -# Check Autoconf version -if [ -x `which autoconf` ]; then - AC_VER=`autoconf --version | head -n 1 | sed 's/^[^0-9]*//'` - AC_VER_MAJOR=`echo $AC_VER | cut -f1 -d'.'` - AC_VER_MINOR=`echo $AC_VER | cut -f2 -d'.' | sed 's/[^0-9]*$//'` - - if [ "$AC_VER_MAJOR" -lt "2" ]; then - echo "Autoconf 2.13 or greater needed to build configure." - exit 1 - fi - - if [ "$AC_VER_MINOR" -lt "13" ]; then - echo "Autoconf 2.13 or greater needed to build configure." - exit 1 - fi - - if [ "$AC_VER_MINOR" -lt "50" ]; then - if [ ! -e configure.in ]; then - ln -s configure.ac configure.in - fi - echo "If you see some warnings about cross-compiling, don't worry; this is normal." - else - echo "rm -f configure.in ?" - fi -else - echo Autoconf not found. AlsaPlayer CVS requires autoconf to bootstrap itself. - exit 1 -fi +#!/bin/sh +# Run this to set up the build system: configure, makefiles, etc. +# (based on the version in enlightenment's cvs) + +package="ncmpc" + +olddir=`pwd` +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +cd "$srcdir" +DIE=0 + +echo "checking for autoconf... " +(autoconf --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have autoconf installed to compile $package." + echo "Download the appropriate package for your distribution," + echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" + DIE=1 +} + +VERSIONGREP="sed -e s/.*[^0-9\.]\([0-9]\.[0-9]\).*/\1/" +VERSIONMKINT="sed -e s/[^0-9]//" -run_cmd() { - echo running $* ... - if ! $*; then - echo failed! - exit 1 +# do we need automake? +if test -r Makefile.am; then + AM_NEEDED=`fgrep AUTOMAKE_OPTIONS Makefile.am | $VERSIONGREP` + if test -z $AM_NEEDED; then + echo -n "checking for automake... " + AUTOMAKE=automake + ACLOCAL=aclocal + if ($AUTOMAKE --version < /dev/null > /dev/null 2>&1); then + echo "no" + AUTOMAKE= + else + echo "yes" fi + else + echo -n "checking for automake $AM_NEEDED or later... " + for am in automake-$AM_NEEDED automake$AM_NEEDED automake; do + ($am --version < /dev/null > /dev/null 2>&1) || continue + ver=`$am --version < /dev/null | head -n 1 | $VERSIONGREP | $VERSIONMKINT` + verneeded=`echo $AM_NEEDED | $VERSIONMKINT` + if test $ver -ge $verneeded; then + AUTOMAKE=$am + echo $AUTOMAKE + break + fi + done + test -z $AUTOMAKE && echo "no" + echo -n "checking for aclocal $AM_NEEDED or later... " + for ac in aclocal-$AM_NEEDED aclocal$AM_NEEDED aclocal; do + ($ac --version < /dev/null > /dev/null 2>&1) || continue + ver=`$ac --version < /dev/null | head -n 1 | $VERSIONGREP | $VERSIONMKINT` + verneeded=`echo $AM_NEEDED | $VERSIONMKINT` + if test $ver -ge $verneeded; then + ACLOCAL=$ac + echo $ACLOCAL + break + fi + done + test -z $ACLOCAL && echo "no" + fi + test -z $AUTOMAKE || test -z $ACLOCAL && { + echo + echo "You must have automake installed to compile $package." + echo "Download the appropriate package for your distribution," + echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" + exit 1 + } +fi + +echo -n "checking for libtool... " +for LIBTOOLIZE in libtoolize glibtoolize nope; do + (which $LIBTOOLIZE) > /dev/null 2>&1 && break +done +if test x$LIBTOOLIZE = xnope; then + echo "nope." + LIBTOOLIZE=libtoolize +else + echo $LIBTOOLIZE +fi +($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have libtool installed to compile $package." + echo "Download the appropriate package for your system," + echo "or get the source from one of the GNU ftp sites" + echo "listed in http://www.gnu.org/order/ftp.html" + DIE=1 } -# Check if /usr/local/share/aclocal exists -if [ -d /usr/local/share/aclocal ]; then - ACLOCAL_INCLUDE="$ACLOCAL_INCLUDE -I /usr/local/share/aclocal" -fi +if test "$DIE" -eq 1; then + exit 1 +fi + +echo "Generating configuration files for $package, please wait...." if [ -d m4 ] ; then - run_cmd cat m4/*.m4 > acinclude.m4 + cat m4/*.m4 > acinclude.m4 +fi + +if [ -d /usr/local/share/aclocal ]; then + ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I /usr/local/share/aclocal" fi -run_cmd aclocal $ACLOCAL_INCLUDE -run_cmd autoheader -run_cmd libtoolize --automake -run_cmd automake --add-missing -run_cmd autoconf -echo -echo "Now run './configure'" -echo +echo " $ACLOCAL $ACLOCAL_FLAGS" +$ACLOCAL $ACLOCAL_FLAGS + +echo " autoheader" +autoheader + +echo " $LIBTOOLIZE --automake" +$LIBTOOLIZE --automake + +echo " $AUTOMAKE --add-missing $AUTOMAKE_FLAGS" +$AUTOMAKE --add-missing $AUTOMAKE_FLAGS + +echo " autoconf" +autoconf + +cd $olddir +$srcdir/configure "$@" && echo diff --git a/configure.ac b/configure.ac index 87dbc6a52..d1601f9c8 100644 --- a/configure.ac +++ b/configure.ac @@ -3,8 +3,8 @@ dnl $Id$ dnl AC_INIT -AC_CONFIG_SRCDIR([main.c]) -AM_INIT_AUTOMAKE(ncmpc, 0.10.2-svn) +AC_CONFIG_SRCDIR([src/main.c]) +AM_INIT_AUTOMAKE(ncmpc, 0.11.0-svn) dnl Check for programs AC_PROG_CC @@ -96,9 +96,9 @@ AC_ARG_WITH(default-host, dnl Default port AC_ARG_WITH(default-port, - AC_HELP_STRING(--with-default-port=ARG,Default port (2100)), + AC_HELP_STRING(--with-default-port=ARG,Default port (6600)), DEFAULT_PORT="$withval", - DEFAULT_PORT="2100") + DEFAULT_PORT="6600") CFLAGS="$CFLAGS $GLIB_CFLAGS -DSYSCONFDIR=\\\"\$(sysconfdir)\\\"" @@ -112,7 +112,7 @@ AC_DEFINE_UNQUOTED(DEFAULT_HOST, "$DEFAULT_HOST", Default MPD host) AM_CONFIG_HEADER(config.h) -AC_CONFIG_FILES([doc/Makefile Makefile]) +AC_CONFIG_FILES([doc/Makefile src/Makefile Makefile]) AC_OUTPUT echo " diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 000000000..abf121cb2 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,20 @@ +# +# $Id$ +# + +bin_PROGRAMS = ncmpc + +ncmpc_headers = libmpdclient.h mpc.h options.h conf.h command.h screen.h \ + screen_utils.h screen_play.h screen_file.h screen_search.h \ + screen_help.h list_window.h colors.h support.h + +ncmpc_SOURCES = libmpdclient.c main.c mpc.c options.c conf.c command.c \ + screen.c screen_utils.c screen_play.c screen_file.c \ + screen_search.c screen_help.c screen_keydef.c \ + list_window.c colors.c support.c $(ncmpc_headers) + + + + + + diff --git a/colors.c b/src/colors.c index f70969390..f70969390 100644 --- a/colors.c +++ b/src/colors.c diff --git a/colors.h b/src/colors.h index a66d693cc..a66d693cc 100644 --- a/colors.h +++ b/src/colors.h diff --git a/command.c b/src/command.c index 1e9edcd0d..1e9edcd0d 100644 --- a/command.c +++ b/src/command.c diff --git a/command.h b/src/command.h index 1ce67e894..1ce67e894 100644 --- a/command.h +++ b/src/command.h diff --git a/libmpdclient.c b/src/libmpdclient.c index aa7b75725..2e8b579da 100644 --- a/libmpdclient.c +++ b/src/libmpdclient.c @@ -38,6 +38,7 @@ typedef SOCKLEN_T socklen_t; #endif #endif + #ifndef MPD_NO_IPV6 #ifdef AF_INET6 #define MPD_HAVE_IPV6 @@ -515,6 +516,7 @@ mpd_Status * mpd_getStatus(mpd_Connection * connection) { status->channels = 0; status->crossfade = -1; status->error = NULL; + status->updatingDb = 0; mpd_getNextReturnElement(connection); if(connection->error) { @@ -561,9 +563,14 @@ mpd_Status * mpd_getStatus(mpd_Connection * connection) { else if(strcmp(re->name,"time")==0) { char * tok; char * copy; + char * temp; copy = strdup(re->value); - status->elapsedTime = atoi(strtok_r(copy,":",&tok)); - status->totalTime = atoi(strtok_r(NULL,"",&tok)); + temp = strtok_r(copy,":",&tok); + if(temp) { + status->elapsedTime = atoi(temp); + temp = strtok_r(NULL,"",&tok); + if(temp) status->totalTime = atoi(temp); + } free(copy); } else if(strcmp(re->name,"error")==0) { @@ -572,13 +579,24 @@ mpd_Status * mpd_getStatus(mpd_Connection * connection) { else if(strcmp(re->name,"xfade")==0) { status->crossfade = atoi(re->value); } + else if(strcmp(re->name,"updating_db")==0) { + status->updatingDb = atoi(re->value); + } else if(strcmp(re->name,"audio")==0) { char * tok; char * copy; + char * temp; copy = strdup(re->value); - status->sampleRate = atoi(strtok_r(copy,":",&tok)); - status->bits = atoi(strtok_r(NULL,":",&tok)); - status->channels = atoi(strtok_r(NULL,"",&tok)); + temp = strtok_r(copy,":",&tok); + if(temp) { + status->sampleRate = atoi(temp); + temp = strtok_r(NULL,":",&tok); + if(temp) { + status->bits = atoi(temp); + temp = strtok_r(NULL,"",&tok); + if(temp) status->channels = atoi(temp); + } + } free(copy); } @@ -1111,6 +1129,19 @@ void mpd_sendUpdateCommand(mpd_Connection * connection) { mpd_executeCommand(connection,"update\n"); } +int mpd_getUpdateId(mpd_Connection * connection) { + char * jobid; + int ret = 0; + + jobid = mpd_getNextReturnElementNamed(connection,"updating_db"); + if(jobid) { + ret = atoi(jobid); + free(jobid); + } + + return ret; +} + void mpd_sendPrevCommand(mpd_Connection * connection) { mpd_executeCommand(connection,"previous\n"); } diff --git a/libmpdclient.h b/src/libmpdclient.h index 6d749fbd2..e5e58791c 100644 --- a/libmpdclient.h +++ b/src/libmpdclient.h @@ -135,6 +135,8 @@ typedef struct mpd_Status { int bits; /* audio channels */ int channels; + /* 1 if mpd is updating, 0 otherwise */ + int updatingDb; /* error */ char * error; } mpd_Status; @@ -327,9 +329,6 @@ char * mpd_getNextAlbum(mpd_Connection * connection); void mpd_sendListCommand(mpd_Connection * connection, int table, const char * arg1); -void mpd_sendListAlbumsCommand(mpd_Connection * connection, - const char * artist); - /* SIMPLE COMMANDS */ void mpd_sendAddCommand(mpd_Connection * connection, const char * file); @@ -378,6 +377,9 @@ void mpd_sendCrossfadeCommand(mpd_Connection * connection, int seconds); void mpd_sendUpdateCommand(mpd_Connection * connection); +/* returns the update job id, call this after a update command*/ +int mpd_getUpdateId(mpd_Connection * connection); + void mpd_sendPasswordCommand(mpd_Connection * connection, const char * pass); /* after executing a command, when your done with it to get its status diff --git a/list_window.c b/src/list_window.c index 6b4a41f0c..6b4a41f0c 100644 --- a/list_window.c +++ b/src/list_window.c diff --git a/list_window.h b/src/list_window.h index 9e9170382..9e9170382 100644 --- a/list_window.h +++ b/src/list_window.h diff --git a/options.c b/src/options.c index 416727ad3..416727ad3 100644 --- a/options.c +++ b/src/options.c diff --git a/options.h b/src/options.h index 2a6681e2a..2a6681e2a 100644 --- a/options.h +++ b/src/options.h diff --git a/screen.c b/src/screen.c index 20ece65ff..d846f3df5 100644 --- a/screen.c +++ b/src/screen.c @@ -21,7 +21,8 @@ #include <stdarg.h> #include <string.h> #include <time.h> -#include <signal.h> +//#include <signal.h> +#include <locale.h> #include <glib.h> #include <ncurses.h> @@ -115,7 +116,7 @@ paint_top_window(char *header, mpd_client_t *c, int clear) if(prev_volume!=c->status->volume || clear) { - char buf[12]; + char buf[32]; if( header[0] ) { @@ -139,14 +140,14 @@ paint_top_window(char *header, mpd_client_t *c, int clear) } if( c->status->volume==MPD_STATUS_NO_VOLUME ) { - snprintf(buf, 12, "Volume n/a "); + snprintf(buf, 32, "Volume n/a "); } else { - snprintf(buf, 12, "Volume %3d%%", c->status->volume); + snprintf(buf, 32, " Volume %d%%", c->status->volume); } colors_use(w, COLOR_TITLE); - mvwaddstr(w, 0, screen->top_window.cols-12, buf); + mvwaddstr(w, 0, screen->top_window.cols-strlen(buf), buf); flags[0] = 0; if( c->status->repeat ) @@ -155,6 +156,8 @@ paint_top_window(char *header, mpd_client_t *c, int clear) strcat(flags, "z"); if( c->status->crossfade ) strcat(flags, "x"); + if( c->status->updatingDb ) + strcat(flags, "U"); colors_use(w, COLOR_LINE); mvwhline(w, 1, 0, ACS_HLINE, screen->top_window.cols); if( flags[0] ) @@ -275,13 +278,31 @@ paint_status_window(mpd_client_t *c) /* create time string */ memset(screen->buf, 0, screen->buf_size); - if( c->seek_song_id == c->song_id ) - elapsedTime = c->seek_target_time; if( IS_PLAYING(status->state) || IS_PAUSED(status->state) ) - snprintf(screen->buf, screen->buf_size, - " [%i:%02i/%i:%02i] ", - elapsedTime/60, elapsedTime%60, - status->totalTime/60, status->totalTime%60 ); + { + if( status->totalTime > 0 ) + { + if( c->seek_song_id == c->song_id ) + elapsedTime = c->seek_target_time; + snprintf(screen->buf, screen->buf_size, + " [%i:%02i/%i:%02i]", + elapsedTime/60, elapsedTime%60, + status->totalTime/60, status->totalTime%60 ); + } + else + { + snprintf(screen->buf, screen->buf_size, " [%d kbps]", status->bitRate ); + } + } + else + { + time_t timep; + + time(&timep); + /* Note: setlocale(LC_TIME,"") should be used first */ + //strftime(screen->buf, screen->buf_size, "%X ", localtime(&timep)); + strftime(screen->buf, screen->buf_size, " %k:%M", localtime(&timep)); + } /* display song */ if( (IS_PLAYING(status->state) || IS_PAUSED(status->state)) && song ) @@ -600,6 +621,7 @@ screen_update(mpd_client_t *c) static int repeat = -1; static int random = -1; static int crossfade = -1; + static int dbupdate = -1; static int welcome = 1; list_window_t *lw = NULL; @@ -612,6 +634,7 @@ screen_update(mpd_client_t *c) repeat = c->status->repeat; random = c->status->random; crossfade = c->status->crossfade; + dbupdate = c->status->updatingDb; } if( repeat != c->status->repeat ) screen_status_printf("Repeat is %s", @@ -621,10 +644,13 @@ screen_update(mpd_client_t *c) c->status->random ? "On" : "Off"); if( crossfade != c->status->crossfade ) screen_status_printf("Crossfade %d seconds", c->status->crossfade); + if( dbupdate && dbupdate != c->status->updatingDb ) + screen_status_printf("Database updated!"); repeat = c->status->repeat; random = c->status->random; crossfade = c->status->crossfade; + dbupdate = c->status->updatingDb; /* update title/header window */ if( welcome && screen->last_cmd==CMD_NONE && diff --git a/screen.h b/src/screen.h index a7e6b7250..a7e6b7250 100644 --- a/screen.h +++ b/src/screen.h diff --git a/screen_file.c b/src/screen_file.c index d2b1f7844..d2b1f7844 100644 --- a/screen_file.c +++ b/src/screen_file.c diff --git a/screen_file.h b/src/screen_file.h index a7199a62e..a7199a62e 100644 --- a/screen_file.h +++ b/src/screen_file.h diff --git a/screen_help.c b/src/screen_help.c index c55c96380..c55c96380 100644 --- a/screen_help.c +++ b/src/screen_help.c diff --git a/screen_help.h b/src/screen_help.h index ba2c57c8e..ba2c57c8e 100644 --- a/screen_help.h +++ b/src/screen_help.h diff --git a/screen_keydef.c b/src/screen_keydef.c index 4bda6ea21..4bda6ea21 100644 --- a/screen_keydef.c +++ b/src/screen_keydef.c diff --git a/screen_play.c b/src/screen_play.c index cdec4f77e..cdec4f77e 100644 --- a/screen_play.c +++ b/src/screen_play.c diff --git a/screen_play.h b/src/screen_play.h index 2155ae593..2155ae593 100644 --- a/screen_play.h +++ b/src/screen_play.h diff --git a/screen_search.c b/src/screen_search.c index 6b6719e30..6b6719e30 100644 --- a/screen_search.c +++ b/src/screen_search.c diff --git a/screen_search.h b/src/screen_search.h index e69de29bb..e69de29bb 100644 --- a/screen_search.h +++ b/src/screen_search.h diff --git a/screen_utils.c b/src/screen_utils.c index f8dfa4c1d..f8dfa4c1d 100644 --- a/screen_utils.c +++ b/src/screen_utils.c diff --git a/screen_utils.h b/src/screen_utils.h index 30c58bfca..30c58bfca 100644 --- a/screen_utils.h +++ b/src/screen_utils.h diff --git a/support.c b/src/support.c index d292e8462..d292e8462 100644 --- a/support.c +++ b/src/support.c diff --git a/support.h b/src/support.h index 1f3aca160..1f3aca160 100644 --- a/support.h +++ b/src/support.h |