diff options
Diffstat (limited to '')
-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 |
31 files changed, 98 insertions, 19 deletions
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 |