It also removes some trailing spaces...
Signed-off-by: Romain Bignon <[email protected]>
---
doc/mpc-bashrc | 8 ++++----
doc/mpc.1 | 7 +++++--
src/command.c | 42 ++++++++++++++++++++++++++++++++----------
src/command.h | 3 ++-
src/libmpdclient.c | 14 +++++++++++++-
src/libmpdclient.h | 4 ++++
src/main.c | 3 ++-
src/status.c | 16 ++++++++++------
8 files changed, 72 insertions(+), 25 deletions(-)
diff --git a/doc/mpc-bashrc b/doc/mpc-bashrc
index 946c85a..07f2580 100644
--- a/doc/mpc-bashrc
+++ b/doc/mpc-bashrc
@@ -9,13 +9,13 @@
cur="${COMP_WORDS[COMP_CWORD]}"
first=${COMP_WORDS[1]}
hold="";
-
+
# add more escape stuff as it's needed
# because bash is a woman:
scrub="s/\([><()\";\`']\)/\\\1/g";
-
+
case "$first" in
- add)
+ add)
hold=`mpc tab ${cur} | sed "$scrub"`;
COMPREPLY=($(compgen -W "${hold}"))
return 0
@@ -57,7 +57,7 @@
COMPREPLY=($(compgen -W "${hold}" | sed "$scrub"))
return 0
;;
- repeat|random)
+ repeat|random|single)
COMPREPLY=($(compgen -W "0 1 true false yes no on off"
"${cur}"))
return 0
;;
diff --git a/doc/mpc.1 b/doc/mpc.1
index dd5d88b..77740a5 100644
--- a/doc/mpc.1
+++ b/doc/mpc.1
@@ -34,7 +34,7 @@ This command also takes the following defined escape
sequences:
.br
Prevents the current song status from being printed on completion of some of
the commands.
-.SH COMMANDS
+.SH COMMANDS
.TP
.B add <file>
Adds a song from the music database to the playlist. Can also read input from
pipes. Use "mpc ls | mpc add" to add all files to the playlist.
@@ -71,7 +71,7 @@ Lists all files/folders in <directory>. If no <directory> is
specified, lists al
.TP
.B lsplaylists
Lists available playlists.
-.TP
+.TP
.B move <from> <to>
Moves song at position <from> to the position <to> in the playlist.
.TP
@@ -99,6 +99,9 @@ Toggle random mode if state ("on" or "off") is not specified.
.B repeat <on|off>
Toggle repeat mode if state ("on" or "off") is not specified.
.TP
+.B single <on|off>
+Toggle single mode if state ("on" or "off") is not specified.
+.TP
.B rm <file>
Deletes a specific playlist.
.TP
diff --git a/src/command.c b/src/command.c
index 2f40aa6..1cdef39 100644
--- a/src/command.c
+++ b/src/command.c
@@ -4,7 +4,7 @@
Daniel Brown <[email protected]>
* Copyright (C) 2008-2009 Max Kellermann <[email protected]>
* Project homepage: http://musicpd.org
-
+
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -84,7 +84,7 @@ static mpd_Status * getStatus(mpd_Connection * conn) {
return ret;
}
-int cmd_add (int argc, char ** argv, mpd_Connection * conn )
+int cmd_add (int argc, char ** argv, mpd_Connection * conn )
{
int i;
@@ -136,7 +136,7 @@ cmd_crop(mpd_unused int argc, mpd_unused char **argv,
mpd_Connection *conn)
} else {
- mpd_freeStatus(status);
+ mpd_freeStatus(status);
DIE( "You need to be playing to crop the playlist\n" );
}
@@ -579,7 +579,7 @@ int cmd_listall ( int argc, char ** argv, mpd_Connection *
conn )
return 0;
}
-int cmd_update ( int argc, char ** argv, mpd_Connection * conn)
+int cmd_update ( int argc, char ** argv, mpd_Connection * conn)
{
const char * update = "";
int i = 0;
@@ -705,7 +705,7 @@ int cmd_load ( int argc, char ** argv, mpd_Connection *
conn )
return 0;
}
-static int do_search ( int argc, char ** argv, mpd_Connection * conn, int
exact )
+static int do_search ( int argc, char ** argv, mpd_Connection * conn, int
exact )
{
Constraint *constraints;
int numconstraints;
@@ -737,17 +737,17 @@ static int do_search ( int argc, char ** argv,
mpd_Connection * conn, int exact
return 0;
}
-int cmd_search ( int argc, char ** argv, mpd_Connection * conn )
+int cmd_search ( int argc, char ** argv, mpd_Connection * conn )
{
return do_search(argc, argv, conn, 0);
}
-int cmd_find ( int argc, char ** argv, mpd_Connection * conn )
+int cmd_find ( int argc, char ** argv, mpd_Connection * conn )
{
return do_search(argc, argv, conn, 1);
}
-int cmd_list ( int argc, char ** argv, mpd_Connection * conn )
+int cmd_list ( int argc, char ** argv, mpd_Connection * conn )
{
Constraint *constraints;
int numconstraints = 0;
@@ -798,7 +798,7 @@ int cmd_list ( int argc, char ** argv, mpd_Connection *
conn )
return 0;
}
-int cmd_volume ( int argc, char ** argv, mpd_Connection * conn )
+int cmd_volume ( int argc, char ** argv, mpd_Connection * conn )
{
struct int_value_change ch;
@@ -819,7 +819,7 @@ int cmd_volume ( int argc, char ** argv, mpd_Connection *
conn )
if (ch.is_relative)
mpd_sendVolumeCommand(conn,ch.value);
- else
+ else
mpd_sendSetvolCommand(conn,ch.value);
my_finishCommand(conn);
@@ -882,6 +882,28 @@ int cmd_random ( int argc, char ** argv, mpd_Connection *
conn )
return 1;
}
+int cmd_single ( int argc, char ** argv, mpd_Connection * conn )
+{
+ int mode;
+
+ if(argc==1) {
+ mode = get_boolean(argv[0]);
+ if (mode < 0)
+ return -1;
+ }
+ else {
+ mpd_Status * status;
+ status = getStatus(conn);
+ mode = !status->single;
+ mpd_freeStatus(status);
+ }
+
+ mpd_sendSingleCommand(conn,mode);
+ my_finishCommand(conn);
+
+ return 1;
+}
+
int cmd_crossfade ( int argc, char ** argv, mpd_Connection * conn )
{
int seconds;
diff --git a/src/command.h b/src/command.h
index 5a685d5..44ce035 100644
--- a/src/command.h
+++ b/src/command.h
@@ -4,7 +4,7 @@
Daniel Brown <[email protected]>
* Copyright (C) 2008-2009 Max Kellermann <[email protected]>
* Project homepage: http://musicpd.org
-
+
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -50,6 +50,7 @@ int cmd_rm ( int argc, char ** argv, mpd_Connection * conn );
int cmd_volume ( int argc, char ** argv, mpd_Connection * conn ) ;
int cmd_repeat ( int argc, char ** argv, mpd_Connection * conn );
int cmd_random ( int argc, char ** argv, mpd_Connection * conn );
+int cmd_single ( int argc, char ** argv, mpd_Connection * conn );
int cmd_crossfade ( int argc, char ** argv, mpd_Connection * conn );
int cmd_enable( int argc, char ** argv, mpd_Connection * conn );
int cmd_disable( int argc, char ** argv, mpd_Connection * conn );
diff --git a/src/libmpdclient.c b/src/libmpdclient.c
index 74f0abc..74b6a80 100644
--- a/src/libmpdclient.c
+++ b/src/libmpdclient.c
@@ -678,6 +678,7 @@ mpd_Status * mpd_getStatus(mpd_Connection * connection) {
status->volume = -1;
status->repeat = 0;
status->random = 0;
+ status->single = 0;
status->playlist = -1;
status->playlistLength = -1;
status->state = -1;
@@ -708,6 +709,9 @@ mpd_Status * mpd_getStatus(mpd_Connection * connection) {
else if(strcmp(re->name,"random")==0) {
status->random = atoi(re->value);
}
+ else if(strcmp(re->name,"single")==0) {
+ status->single = atoi(re->value);
+ }
else if(strcmp(re->name,"playlist")==0) {
status->playlist = strtol(re->value,NULL,10);
}
@@ -1315,7 +1319,7 @@ int mpd_sendAddIdCommand(mpd_Connection *connection,
const char *file)
retval = atoi(string);
free(string);
}
-
+
return retval;
}
@@ -1510,6 +1514,14 @@ void mpd_sendRandomCommand(mpd_Connection * connection,
int randomMode) {
free(string);
}
+void mpd_sendSingleCommand(mpd_Connection * connection, int singleMode) {
+ int len = strlen("single")+2+INTLEN+3;
+ char *string = malloc(len);
+ snprintf(string, len, "single \"%i\"\n", singleMode);
+ mpd_executeCommand(connection,string);
+ free(string);
+}
+
void mpd_sendSetvolCommand(mpd_Connection * connection, int volumeChange) {
int len = strlen("setvol")+2+INTLEN+3;
char *string = malloc(len);
diff --git a/src/libmpdclient.h b/src/libmpdclient.h
index 24b23df..ef09e4c 100644
--- a/src/libmpdclient.h
+++ b/src/libmpdclient.h
@@ -235,6 +235,8 @@ typedef struct mpd_Status {
int repeat;
/* 1 if random is on, 0 otherwise */
int random;
+ /* 1 if single is on, 0 otherwise */
+ int single;
/* playlist length */
int playlistLength;
/* playlist, use this to determine when the playlist has changed */
@@ -507,6 +509,8 @@ void mpd_sendRepeatCommand(mpd_Connection * connection, int
repeatMode);
void mpd_sendRandomCommand(mpd_Connection * connection, int randomMode);
+void mpd_sendSingleCommand(mpd_Connection * connection, int singleMode);
+
void mpd_sendSetvolCommand(mpd_Connection * connection, int volumeChange);
/* WARNING: don't use volume command, its depreacted */
diff --git a/src/main.c b/src/main.c
index 6db8111..417edeb 100644
--- a/src/main.c
+++ b/src/main.c
@@ -4,7 +4,7 @@
Daniel Brown <[email protected]>
* Copyright (C) 2008-2009 Max Kellermann <[email protected]>
* Project homepage: http://musicpd.org
-
+
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -82,6 +82,7 @@ static struct command {
{"volume", 0, 1, 0, cmd_volume, "[+-]<num>", "Sets
volume to <num> or adjusts by [+-]<num>"},
{"repeat", 0, 1, 0, cmd_repeat, "<on|off>", "Toggle
repeat mode, or specify state"},
{"random", 0, 1, 0, cmd_random, "<on|off>", "Toggle
random mode, or specify state"},
+ {"single", 0, 1, 0, cmd_single, "<on|off>", "Toggle
single mode, or specify state"},
{"search", 2, -1, 0, cmd_search, "<type> <query>",
"Search for a song"},
{"find", 2, -1, 0, cmd_find, "<type> <query>",
"Find a song (exact match)"},
{"list", 1, -1, 0, cmd_list, "<type> [<type>
<query>]", "Show all tags of <type>"},
diff --git a/src/status.c b/src/status.c
index 67e89b6..9da6942 100644
--- a/src/status.c
+++ b/src/status.c
@@ -4,7 +4,7 @@
Daniel Brown <[email protected]>
* Copyright (C) 2008-2009 Max Kellermann <[email protected]>
* Project homepage: http://musicpd.org
-
+
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -47,17 +47,17 @@ void print_status (mpd_Connection *conn)
status = mpd_getStatus(conn);
printErrorAndExit(conn);
- if(status->state == MPD_STATUS_STATE_PLAY ||
- status->state == MPD_STATUS_STATE_PAUSE)
+ if(status->state == MPD_STATUS_STATE_PLAY ||
+ status->state == MPD_STATUS_STATE_PAUSE)
{
float perc;
mpd_nextListOkCommand(conn);
printErrorAndExit(conn);
-
+
while((entity = mpd_getNextInfoEntity(conn))) {
struct mpd_song *song = entity->info.song;
-
+
if(entity->type!=MPD_INFO_ENTITY_TYPE_SONG) {
mpd_freeInfoEntity(entity);
continue;
@@ -112,7 +112,11 @@ void print_status (mpd_Connection *conn)
else printf("off ");
printf("random: ");
- if(status->random) printf("on \n");
+ if(status->random) printf("on ");
+ else printf("off ");
+
+ printf("single: ");
+ if(status->single) printf("on \n");
else printf("off\n");
if (status->error != NULL)
--
1.5.6.5
------------------------------------------------------------------------------
_______________________________________________
Musicpd-dev-team mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team