Permalink
Browse files

accept multiple keys with HitKey

  • Loading branch information...
1 parent a75d93d commit 89e0b044bac3708dc03b38e10dc3f8163226eaad @flensrocker committed Apr 4, 2012
Showing with 34 additions and 21 deletions.
  1. +4 −0 HISTORY
  2. +2 −2 README
  3. +1 −1 dbus2vdr.c
  4. +27 −18 remote.c
View
@@ -128,3 +128,7 @@ VDR Plugin 'dbus2vdr' Revision History
2012-03-11: Version 0.0.4b
- adapt to vdr 1.7.26 and add missing symbol
+
+2012-04-04: Version 0.0.4c
+
+- accept multiple keys with "HitKey"
View
4 README
@@ -115,8 +115,8 @@ If the SVDRP command doesn't take a parameter you can ommit it or pass an empty
vdr-dbus-send.sh /Remote remote.Disable
vdr-dbus-send.sh /Remote remote.Status
-- hit a key
- vdr-dbus-send.sh /Remote remote.HitKey string:'Menu'
+- hit a key, you may specify more than one key
+ vdr-dbus-send.sh /Remote remote.HitKey string:'Menu' string:'Down' string:'Down' ...
- display list of strings on the osd and let the user select one
vdr-dbus-send.sh /Remote remote.AskUser string:'title' string:'item 1' string:'item 2' ...
View
@@ -22,7 +22,7 @@
#include <vdr/osdbase.h>
#include <vdr/plugin.h>
-static const char *VERSION = "0.0.4b";
+static const char *VERSION = "0.0.4c";
static const char *DESCRIPTION = trNOOP("control vdr via D-Bus");
static const char *MAINMENUENTRY = NULL;
View
@@ -174,31 +174,40 @@ void cDBusMessageRemote::Status(void)
void cDBusMessageRemote::HitKey(void)
{
- const char *keyName = NULL;
+ cVector<eKeys> keys;
DBusMessageIter args;
- if (!dbus_message_iter_init(_msg, &args))
+ dbus_int32_t replyCode = 500;
+ cString replyMessage;
+ if (!dbus_message_iter_init(_msg, &args)) {
esyslog("dbus2vdr: %s.HitKey: message misses an argument for the keyName", DBUS_VDR_REMOTE_INTERFACE);
- else {
- int rc = cDBusHelper::GetNextArg(args, DBUS_TYPE_STRING, &keyName);
- if (rc < 0)
- esyslog("dbus2vdr: %s.HitKey: 'keyName' argument is not a string", DBUS_VDR_REMOTE_INTERFACE);
+ cDBusHelper::SendReply(_conn, _msg, replyCode, replyMessage);
+ return;
}
- dbus_int32_t replyCode = 500;
- cString replyMessage;
- if (keyName != NULL) {
- eKeys k = cKey::FromString(keyName);
- if (k != kNone) {
- cRemote::Put(k);
- replyCode = 250;
- replyMessage = cString::sprintf("Key \"%s\" accepted", keyName);
- }
- else {
- replyCode = 504;
- replyMessage = cString::sprintf("Unknown key: \"%s\"", keyName);
+ const char *keyName = NULL;
+ while (cDBusHelper::GetNextArg(args, DBUS_TYPE_STRING, &keyName) >= 0) {
+ eKeys k = cKey::FromString(keyName);
+ if (k == kNone) {
+ replyCode = 504;
+ replyMessage = cString::sprintf("Unknown key: \"%s\"", keyName);
+ keys.Clear();
+ break; // just get the keys until first error
+ }
+ isyslog("dbus2vdr: %s.HitKey: get key '%s'", DBUS_VDR_REMOTE_INTERFACE, keyName);
+ keys.Append(k);
}
+
+ if (keys.Size() == 0) {
+ esyslog("dbus2vdr: %s.HitKey: no valid 'keyName' given", DBUS_VDR_REMOTE_INTERFACE);
+ cDBusHelper::SendReply(_conn, _msg, replyCode, replyMessage);
+ return;
}
+ for (int i = 0; i < keys.Size(); i++)
+ cRemote::Put(keys.At(i));
+
+ replyCode = 250;
+ replyMessage = cString::sprintf("Key%s accepted", keys.Size() > 1 ? "s" : "");
cDBusHelper::SendReply(_conn, _msg, replyCode, replyMessage);
}

0 comments on commit 89e0b04

Please sign in to comment.