Skip to content

Commit

Permalink
accept multiple keys with HitKey
Browse files Browse the repository at this point in the history
  • Loading branch information
flensrocker committed Apr 4, 2012
1 parent a75d93d commit 89e0b04
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 21 deletions.
4 changes: 4 additions & 0 deletions HISTORY
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -128,3 +128,7 @@ VDR Plugin 'dbus2vdr' Revision History
2012-03-11: Version 0.0.4b 2012-03-11: Version 0.0.4b


- adapt to vdr 1.7.26 and add missing symbol - adapt to vdr 1.7.26 and add missing symbol

2012-04-04: Version 0.0.4c

- accept multiple keys with "HitKey"
4 changes: 2 additions & 2 deletions README
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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.Disable
vdr-dbus-send.sh /Remote remote.Status vdr-dbus-send.sh /Remote remote.Status


- hit a key - hit a key, you may specify more than one key
vdr-dbus-send.sh /Remote remote.HitKey string:'Menu' 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 - 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' ... vdr-dbus-send.sh /Remote remote.AskUser string:'title' string:'item 1' string:'item 2' ...
Expand Down
2 changes: 1 addition & 1 deletion dbus2vdr.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <vdr/osdbase.h> #include <vdr/osdbase.h>
#include <vdr/plugin.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 *DESCRIPTION = trNOOP("control vdr via D-Bus");
static const char *MAINMENUENTRY = NULL; static const char *MAINMENUENTRY = NULL;


Expand Down
45 changes: 27 additions & 18 deletions remote.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -174,31 +174,40 @@ void cDBusMessageRemote::Status(void)


void cDBusMessageRemote::HitKey(void) void cDBusMessageRemote::HitKey(void)
{ {
const char *keyName = NULL; cVector<eKeys> keys;
DBusMessageIter args; 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); esyslog("dbus2vdr: %s.HitKey: message misses an argument for the keyName", DBUS_VDR_REMOTE_INTERFACE);
else { cDBusHelper::SendReply(_conn, _msg, replyCode, replyMessage);
int rc = cDBusHelper::GetNextArg(args, DBUS_TYPE_STRING, &keyName); return;
if (rc < 0)
esyslog("dbus2vdr: %s.HitKey: 'keyName' argument is not a string", DBUS_VDR_REMOTE_INTERFACE);
} }


dbus_int32_t replyCode = 500; const char *keyName = NULL;
cString replyMessage; while (cDBusHelper::GetNextArg(args, DBUS_TYPE_STRING, &keyName) >= 0) {
if (keyName != NULL) { eKeys k = cKey::FromString(keyName);
eKeys k = cKey::FromString(keyName); if (k == kNone) {
if (k != kNone) { replyCode = 504;
cRemote::Put(k); replyMessage = cString::sprintf("Unknown key: \"%s\"", keyName);
replyCode = 250; keys.Clear();
replyMessage = cString::sprintf("Key \"%s\" accepted", keyName); break; // just get the keys until first error
} }
else { isyslog("dbus2vdr: %s.HitKey: get key '%s'", DBUS_VDR_REMOTE_INTERFACE, keyName);
replyCode = 504; keys.Append(k);
replyMessage = cString::sprintf("Unknown key: \"%s\"", keyName);
} }

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); cDBusHelper::SendReply(_conn, _msg, replyCode, replyMessage);
} }


Expand Down

0 comments on commit 89e0b04

Please sign in to comment.