aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c
diff options
context:
space:
mode:
authorMarc Pavot <m.pavot@gmail.com>2008-11-22 13:26:21 +0100
committerMax Kellermann <max@duempel.org>2008-11-22 13:26:21 +0100
commit0bad84066bc12a370b8f1e54c37f705fad21929b (patch)
tree4d3b34b9e984aafd4389f98fa858d996e52df104 /src/command.c
parent976d5045c671700b1e16ed2b98e746a67fa91e8b (diff)
downloadmpd-0bad84066bc12a370b8f1e54c37f705fad21929b.tar.gz
mpd-0bad84066bc12a370b8f1e54c37f705fad21929b.tar.xz
mpd-0bad84066bc12a370b8f1e54c37f705fad21929b.zip
command: allow clients to subscribe to specific idle events
The client may provide the names of idle events as arguments to the "idle" command to inform MPD that it is only interested in these events.
Diffstat (limited to 'src/command.c')
-rw-r--r--src/command.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/command.c b/src/command.c
index dc71f1d1a..6a9489d92 100644
--- a/src/command.c
+++ b/src/command.c
@@ -39,6 +39,7 @@
#include "tag_print.h"
#include "path.h"
#include "os_compat.h"
+#include "idle.h"
#define COMMAND_STATUS_VOLUME "volume"
#define COMMAND_STATUS_STATE "state"
@@ -1253,8 +1254,28 @@ static enum command_return
handle_idle(struct client *client,
mpd_unused int argc, mpd_unused char *argv[])
{
+ unsigned flags = 0, j;
+ int i;
+ const char *const* idle_names;
+
+ idle_names = idle_get_names();
+ for (i = 1; i < argc; ++i) {
+ if (!argv[i])
+ continue;
+
+ for (j = 0; idle_names[j]; ++j) {
+ if (!strcasecmp(argv[i], idle_names[j])) {
+ flags |= (1 << j);
+ }
+ }
+ }
+
+ /* No argument means that the client wants to receive everything */
+ if (flags == 0)
+ flags = ~0;
+
/* enable "idle" mode on this client */
- client_idle_wait(client);
+ client_idle_wait(client, flags);
/* return value is "1" so the caller won't print "OK" */
return 1;
@@ -1280,7 +1301,7 @@ static const struct command commands[] = {
{ "disableoutput", PERMISSION_ADMIN, 1, 1, handle_disableoutput },
{ "enableoutput", PERMISSION_ADMIN, 1, 1, handle_enableoutput },
{ "find", PERMISSION_READ, 2, -1, handle_find },
- { "idle", PERMISSION_READ, 0, 0, handle_idle },
+ { "idle", PERMISSION_READ, 0, -1, handle_idle },
{ "kill", PERMISSION_ADMIN, -1, -1, handle_kill },
{ "list", PERMISSION_READ, 1, -1, handle_list },
{ "listall", PERMISSION_READ, 0, 1, handle_listall },