summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzmike <michael.blumenkrantz@gmail.com>2014-02-06 17:19:29 -0500
committerzmike <michael.blumenkrantz@gmail.com>2014-02-06 17:19:29 -0500
commit019357e12c984b6aa2ace826cb547e38884ea121 (patch)
tree10202e593476ca3b59cc985daad836fb737dfec0
parenta77401ce6f0d696403c10015eb2193aecd5dc634 (diff)
add methods for toggling play modes
-rw-r--r--src/bin/empdd.c80
-rw-r--r--src/bin/empdd.xml16
2 files changed, 94 insertions, 2 deletions
diff --git a/src/bin/empdd.c b/src/bin/empdd.c
index b8693cf..f365bc9 100644
--- a/src/bin/empdd.c
+++ b/src/bin/empdd.c
@@ -54,6 +54,10 @@ typedef enum
54 EMPD_COMMAND_PLAY_ID, 54 EMPD_COMMAND_PLAY_ID,
55 EMPD_COMMAND_QUEUE_LIST, 55 EMPD_COMMAND_QUEUE_LIST,
56 EMPD_COMMAND_DELETE_LIST, 56 EMPD_COMMAND_DELETE_LIST,
57 EMPD_COMMAND_REPEAT,
58 EMPD_COMMAND_RANDOM,
59 EMPD_COMMAND_SINGLE,
60 EMPD_COMMAND_CONSUME,
57} EMPD_Command; 61} EMPD_Command;
58 62
59static const char *cmd_txt[] = 63static const char *cmd_txt[] =
@@ -74,6 +78,10 @@ static const char *cmd_txt[] =
74 CMD_TXT(EMPD_COMMAND_PLAY_ID) 78 CMD_TXT(EMPD_COMMAND_PLAY_ID)
75 CMD_TXT(EMPD_COMMAND_QUEUE_LIST) 79 CMD_TXT(EMPD_COMMAND_QUEUE_LIST)
76 CMD_TXT(EMPD_COMMAND_DELETE_LIST) 80 CMD_TXT(EMPD_COMMAND_DELETE_LIST)
81 CMD_TXT(EMPD_COMMAND_REPEAT)
82 CMD_TXT(EMPD_COMMAND_RANDOM)
83 CMD_TXT(EMPD_COMMAND_SINGLE)
84 CMD_TXT(EMPD_COMMAND_CONSUME)
77}; 85};
78 86
79typedef enum 87typedef enum
@@ -474,8 +482,8 @@ static Eldbus_Message * \
474_dbus_##name##_cb(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg) \ 482_dbus_##name##_cb(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg) \
475{ \ 483{ \
476 mpd_async_send_command(empd->async, S(name), NULL); \ 484 mpd_async_send_command(empd->async, S(name), NULL); \
477 fdh_update(); \
478 cmd_append(EMPD_COMMAND_##CMD); \ 485 cmd_append(EMPD_COMMAND_##CMD); \
486 pinger_cb(NULL); \
479 return eldbus_message_method_return_new(msg); \ 487 return eldbus_message_method_return_new(msg); \
480} 488}
481 489
@@ -499,7 +507,71 @@ _dbus_pause_cb(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_M
499 mpd_async_send_command(empd->async, "pause", NULL); 507 mpd_async_send_command(empd->async, "pause", NULL);
500 cmd_append(EMPD_COMMAND_TOGGLE_PAUSE); 508 cmd_append(EMPD_COMMAND_TOGGLE_PAUSE);
501 } 509 }
502 fdh_update(); 510 pinger_cb(NULL);
511 return eldbus_message_method_return_new(msg);
512}
513
514static Eldbus_Message *
515_dbus_repeat_cb(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
516{
517 Eina_Bool mode;
518 const char *sig;
519
520 sig = eldbus_message_signature_get(msg);
521 if (sig && (!strcmp(sig, "b")) && eldbus_message_arguments_get(msg, "b", &mode))
522 {
523 mpd_async_send_command(empd->async, "repeat", mode ? "1" : "0", NULL);
524 cmd_append(EMPD_COMMAND_REPEAT);
525 pinger_cb(NULL);
526 }
527 return eldbus_message_method_return_new(msg);
528}
529
530static Eldbus_Message *
531_dbus_shuffle_cb(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
532{
533 Eina_Bool mode;
534 const char *sig;
535
536 sig = eldbus_message_signature_get(msg);
537 if (sig && (!strcmp(sig, "b")) && eldbus_message_arguments_get(msg, "b", &mode))
538 {
539 mpd_async_send_command(empd->async, "random", mode ? "1" : "0", NULL);
540 cmd_append(EMPD_COMMAND_RANDOM);
541 pinger_cb(NULL);
542 }
543 return eldbus_message_method_return_new(msg);
544}
545
546static Eldbus_Message *
547_dbus_single_cb(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
548{
549 Eina_Bool mode;
550 const char *sig;
551
552 sig = eldbus_message_signature_get(msg);
553 if (sig && (!strcmp(sig, "b")) && eldbus_message_arguments_get(msg, "b", &mode))
554 {
555 mpd_async_send_command(empd->async, "single", mode ? "1" : "0", NULL);
556 cmd_append(EMPD_COMMAND_SINGLE);
557 pinger_cb(NULL);
558 }
559 return eldbus_message_method_return_new(msg);
560}
561
562static Eldbus_Message *
563_dbus_consume_cb(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
564{
565 Eina_Bool mode;
566 const char *sig;
567
568 sig = eldbus_message_signature_get(msg);
569 if (sig && (!strcmp(sig, "b")) && eldbus_message_arguments_get(msg, "b", &mode))
570 {
571 mpd_async_send_command(empd->async, "consume", mode ? "1" : "0", NULL);
572 cmd_append(EMPD_COMMAND_CONSUME);
573 pinger_cb(NULL);
574 }
503 return eldbus_message_method_return_new(msg); 575 return eldbus_message_method_return_new(msg);
504} 576}
505 577
@@ -627,6 +699,10 @@ static const Eldbus_Method empd_methods[] =
627 { "QueueListRange", ELDBUS_ARGS({"i", "start"}, {"i", "num"}), NULL, _dbus_queue_list_cb, 0}, 699 { "QueueListRange", ELDBUS_ARGS({"i", "start"}, {"i", "num"}), NULL, _dbus_queue_list_cb, 0},
628 { "QueueListCachedRange", ELDBUS_ARGS({"i", "start"}, {"i", "num"}), NULL, _dbus_queue_list_cached_cb, 0}, 700 { "QueueListCachedRange", ELDBUS_ARGS({"i", "start"}, {"i", "num"}), NULL, _dbus_queue_list_cached_cb, 0},
629 { "DeleteListRange", ELDBUS_ARGS({"i", "start"}, {"i", "num"}), NULL, _dbus_delete_list_cb, 0}, 701 { "DeleteListRange", ELDBUS_ARGS({"i", "start"}, {"i", "num"}), NULL, _dbus_delete_list_cb, 0},
702 { "Repeat", ELDBUS_ARGS({"b", "mode"}), NULL, _dbus_repeat_cb, 0},
703 { "Shuffle", ELDBUS_ARGS({"b", "mode"}), NULL, _dbus_shuffle_cb, 0},
704 { "Single", ELDBUS_ARGS({"b", "mode"}), NULL, _dbus_single_cb, 0},
705 { "Consume", ELDBUS_ARGS({"b", "mode"}), NULL, _dbus_consume_cb, 0},
630 {NULL, NULL, NULL, NULL, 0} 706 {NULL, NULL, NULL, NULL, 0}
631}; 707};
632 708
diff --git a/src/bin/empdd.xml b/src/bin/empdd.xml
index 0f49cbb..8a41399 100644
--- a/src/bin/empdd.xml
+++ b/src/bin/empdd.xml
@@ -79,6 +79,22 @@
79 <arg type="i" name="num" direction="in" /> 79 <arg type="i" name="num" direction="in" />
80 <annotation name="org.freedesktop.DBus.Method.NoReply" value="true" /> 80 <annotation name="org.freedesktop.DBus.Method.NoReply" value="true" />
81 </method> 81 </method>
82 <method name="Repeat">
83 <arg type="b" name="mode" direction="in" />
84 <annotation name="org.freedesktop.DBus.Method.NoReply" value="true" />
85 </method>
86 <method name="Shuffle">
87 <arg type="b" name="mode" direction="in" />
88 <annotation name="org.freedesktop.DBus.Method.NoReply" value="true" />
89 </method>
90 <method name="Single">
91 <arg type="b" name="mode" direction="in" />
92 <annotation name="org.freedesktop.DBus.Method.NoReply" value="true" />
93 </method>
94 <method name="Consume">
95 <arg type="b" name="mode" direction="in" />
96 <annotation name="org.freedesktop.DBus.Method.NoReply" value="true" />
97 </method>
82 <signal name="Status"> 98 <signal name="Status">
83 <arg type="i" name="volume" direction="out" /><!-- volume % --> 99 <arg type="i" name="volume" direction="out" /><!-- volume % -->
84 <arg type="b" name="repeat" direction="out" /> 100 <arg type="b" name="repeat" direction="out" />