From f55a67b3f882641abe5a9b14b045d7ce71964af7 Mon Sep 17 00:00:00 2001 From: Kalle Wallin Date: Sat, 5 Jun 2004 11:21:43 +0000 Subject: [PATCH] Changed directory layout (for future use of gettext) git-svn-id: https://svn.musicpd.org/ncmpc/trunk@1342 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- ChangeLog | 7 ++ Makefile.am | 24 +--- autogen.sh | 162 ++++++++++++++++++------- configure.ac | 10 +- src/Makefile.am | 20 +++ colors.c => src/colors.c | 0 colors.h => src/colors.h | 0 command.c => src/command.c | 0 command.h => src/command.h | 0 conf.c => src/conf.c | 0 conf.h => src/conf.h | 0 libmpdclient.c => src/libmpdclient.c | 41 ++++++- libmpdclient.h => src/libmpdclient.h | 8 +- list_window.c => src/list_window.c | 0 list_window.h => src/list_window.h | 0 main.c => src/main.c | 0 mpc.c => src/mpc.c | 0 mpc.h => src/mpc.h | 0 options.c => src/options.c | 0 options.h => src/options.h | 0 screen.c => src/screen.c | 48 ++++++-- screen.h => src/screen.h | 0 screen_file.c => src/screen_file.c | 0 screen_file.h => src/screen_file.h | 0 screen_help.c => src/screen_help.c | 0 screen_help.h => src/screen_help.h | 0 screen_keydef.c => src/screen_keydef.c | 0 screen_play.c => src/screen_play.c | 0 screen_play.h => src/screen_play.h | 0 screen_search.c => src/screen_search.c | 0 screen_search.h => src/screen_search.h | 0 screen_utils.c => src/screen_utils.c | 0 screen_utils.h => src/screen_utils.h | 0 support.c => src/support.c | 0 support.h => src/support.h | 0 35 files changed, 231 insertions(+), 89 deletions(-) create mode 100644 src/Makefile.am rename colors.c => src/colors.c (100%) rename colors.h => src/colors.h (100%) rename command.c => src/command.c (100%) rename command.h => src/command.h (100%) rename conf.c => src/conf.c (100%) rename conf.h => src/conf.h (100%) rename libmpdclient.c => src/libmpdclient.c (97%) rename libmpdclient.h => src/libmpdclient.h (98%) rename list_window.c => src/list_window.c (100%) rename list_window.h => src/list_window.h (100%) rename main.c => src/main.c (100%) rename mpc.c => src/mpc.c (100%) rename mpc.h => src/mpc.h (100%) rename options.c => src/options.c (100%) rename options.h => src/options.h (100%) rename screen.c => src/screen.c (94%) rename screen.h => src/screen.h (100%) rename screen_file.c => src/screen_file.c (100%) rename screen_file.h => src/screen_file.h (100%) rename screen_help.c => src/screen_help.c (100%) rename screen_help.h => src/screen_help.h (100%) rename screen_keydef.c => src/screen_keydef.c (100%) rename screen_play.c => src/screen_play.c (100%) rename screen_play.h => src/screen_play.h (100%) rename screen_search.c => src/screen_search.c (100%) rename screen_search.h => src/screen_search.h (100%) rename screen_utils.c => src/screen_utils.c (100%) rename screen_utils.h => src/screen_utils.h (100%) rename support.c => src/support.c (100%) rename support.h => src/support.h (100%) diff --git a/ChangeLog b/ChangeLog index e43c8a0..2a4de61 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-06-05 Kalle Wallin + * 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 * 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 8ac5da7..8bf3267 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 72a2352..22e7897 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 87dbc6a..d1601f9 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 0000000..abf121c --- /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 similarity index 100% rename from colors.c rename to src/colors.c diff --git a/colors.h b/src/colors.h similarity index 100% rename from colors.h rename to src/colors.h diff --git a/command.c b/src/command.c similarity index 100% rename from command.c rename to src/command.c diff --git a/command.h b/src/command.h similarity index 100% rename from command.h rename to src/command.h diff --git a/conf.c b/src/conf.c similarity index 100% rename from conf.c rename to src/conf.c diff --git a/conf.h b/src/conf.h similarity index 100% rename from conf.h rename to src/conf.h diff --git a/libmpdclient.c b/src/libmpdclient.c similarity index 97% rename from libmpdclient.c rename to src/libmpdclient.c index aa7b757..2e8b579 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 similarity index 98% rename from libmpdclient.h rename to src/libmpdclient.h index 6d749fb..e5e5879 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 similarity index 100% rename from list_window.c rename to src/list_window.c diff --git a/list_window.h b/src/list_window.h similarity index 100% rename from list_window.h rename to src/list_window.h diff --git a/main.c b/src/main.c similarity index 100% rename from main.c rename to src/main.c diff --git a/mpc.c b/src/mpc.c similarity index 100% rename from mpc.c rename to src/mpc.c diff --git a/mpc.h b/src/mpc.h similarity index 100% rename from mpc.h rename to src/mpc.h diff --git a/options.c b/src/options.c similarity index 100% rename from options.c rename to src/options.c diff --git a/options.h b/src/options.h similarity index 100% rename from options.h rename to src/options.h diff --git a/screen.c b/src/screen.c similarity index 94% rename from screen.c rename to src/screen.c index 20ece65..d846f3d 100644 --- a/screen.c +++ b/src/screen.c @@ -21,7 +21,8 @@ #include #include #include -#include +//#include +#include #include #include @@ -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 similarity index 100% rename from screen.h rename to src/screen.h diff --git a/screen_file.c b/src/screen_file.c similarity index 100% rename from screen_file.c rename to src/screen_file.c diff --git a/screen_file.h b/src/screen_file.h similarity index 100% rename from screen_file.h rename to src/screen_file.h diff --git a/screen_help.c b/src/screen_help.c similarity index 100% rename from screen_help.c rename to src/screen_help.c diff --git a/screen_help.h b/src/screen_help.h similarity index 100% rename from screen_help.h rename to src/screen_help.h diff --git a/screen_keydef.c b/src/screen_keydef.c similarity index 100% rename from screen_keydef.c rename to src/screen_keydef.c diff --git a/screen_play.c b/src/screen_play.c similarity index 100% rename from screen_play.c rename to src/screen_play.c diff --git a/screen_play.h b/src/screen_play.h similarity index 100% rename from screen_play.h rename to src/screen_play.h diff --git a/screen_search.c b/src/screen_search.c similarity index 100% rename from screen_search.c rename to src/screen_search.c diff --git a/screen_search.h b/src/screen_search.h similarity index 100% rename from screen_search.h rename to src/screen_search.h diff --git a/screen_utils.c b/src/screen_utils.c similarity index 100% rename from screen_utils.c rename to src/screen_utils.c diff --git a/screen_utils.h b/src/screen_utils.h similarity index 100% rename from screen_utils.h rename to src/screen_utils.h diff --git a/support.c b/src/support.c similarity index 100% rename from support.c rename to src/support.c diff --git a/support.h b/src/support.h similarity index 100% rename from support.h rename to src/support.h -- 2.30.2