Permalink
Browse files

add new skin interface with QueueMessage to display a message on the …

…OSD (thanks to Holger Schvestka)
  • Loading branch information...
1 parent 7d3ff76 commit f679536291be7be90dc4b735c7ceb2b0b0dfd31e @flensrocker flensrocker committed May 13, 2011
Showing with 145 additions and 3 deletions.
  1. +5 −0 HISTORY
  2. +1 −1 Makefile
  3. +3 −0 README
  4. +1 −1 bin/vdr-dbus-send.sh
  5. +1 −0 common.h
  6. +3 −1 dbus2vdr.c
  7. +94 −0 skin.c
  8. +37 −0 skin.h
View
@@ -45,3 +45,8 @@ VDR Plugin 'dbus2vdr' Revision History
- add new recording interface, for now only an update of the
recording list can be triggered
+
+2011-05-13: Version 0.0.2h
+
+- add new skin interface with "QueueMessage" to display a message
+ on the OSD (thanks to Holger Schvestka)
View
@@ -53,7 +53,7 @@ DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
### The object files (add further files here):
-OBJS = $(PLUGIN).o epg.o helper.o message.o monitor.o plugin.o recording.o remote.o timer.o
+OBJS = $(PLUGIN).o epg.o helper.o message.o monitor.o plugin.o recording.o remote.o skin.o timer.o
### The main target:
View
3 README
@@ -71,6 +71,9 @@ If the SVDRP command doesn't take a parameter you can ommit it or pass an empty
- trigger an update of the list of recordings
vdr-dbus-send.sh /Recording recording.Update
+- display a message at the OSD
+ vdr-dbus-send.sh /Skin skin.QueueMessage string:'message text'
+
Using the Python binding
------------------------
First, I don't know Python at all, I just copy code fragments from the Python Binding Tutorial [1]
View
@@ -12,4 +12,4 @@ shift
INTERFACE=$1
shift
-dbus-send --system --type=method_call --dest=$DEST --print-reply $OBJECT $DEST.$INTERFACE $*
+dbus-send --system --type=method_call --dest=$DEST --print-reply $OBJECT $DEST.$INTERFACE "$@"
View
@@ -6,6 +6,7 @@
#define DBUS_VDR_EPG_INTERFACE DBUS_VDR_BUSNAME".epg"
#define DBUS_VDR_RECORDING_INTERFACE DBUS_VDR_BUSNAME".recording"
#define DBUS_VDR_REMOTE_INTERFACE DBUS_VDR_BUSNAME".remote"
+#define DBUS_VDR_SKIN_INTERFACE DBUS_VDR_BUSNAME".skin"
#define DBUS_VDR_TIMER_INTERFACE DBUS_VDR_BUSNAME".timer"
#endif
View
@@ -11,11 +11,12 @@
#include "monitor.h"
#include "recording.h"
#include "remote.h"
+#include "skin.h"
#include "timer.h"
#include <vdr/plugin.h>
-static const char *VERSION = "0.0.2g";
+static const char *VERSION = "0.0.2h";
static const char *DESCRIPTION = "expose methods for controlling vdr via DBus";
static const char *MAINMENUENTRY = NULL;
@@ -82,6 +83,7 @@ bool cPluginDbus2vdr::Start(void)
new cDBusDispatcherPlugin;
new cDBusDispatcherRecording;
new cDBusDispatcherRemote;
+ new cDBusDispatcherSkin;
new cDBusDispatcherTimer;
cDBusMonitor::StartMonitor();
return true;
View
94 skin.c
@@ -0,0 +1,94 @@
+#include "skin.h"
+#include "common.h"
+#include "helper.h"
+
+#include <vdr/skins.h>
+
+
+cDBusMessageSkin::cDBusMessageSkin(cDBusMessageSkin::eAction action, DBusConnection* conn, DBusMessage* msg)
+:cDBusMessage(conn, msg)
+,_action(action)
+{
+}
+
+cDBusMessageSkin::~cDBusMessageSkin(void)
+{
+}
+
+void cDBusMessageSkin::Process(void)
+{
+ switch (_action) {
+ case dmsQueueMessage:
+ QueueMessage();
+ break;
+ }
+}
+
+void cDBusMessageSkin::QueueMessage(void)
+{
+ const char *messageText = NULL;
+ DBusMessageIter args;
+ if (!dbus_message_iter_init(_msg, &args))
+ esyslog("dbus2vdr: %s.QueueMessage: message misses an argument for the message text", DBUS_VDR_SKIN_INTERFACE);
+ else {
+ int rc = cDBusHelper::GetNextArg(args, DBUS_TYPE_STRING, &messageText);
+ if (rc < 0)
+ esyslog("dbus2vdr: %s.QueueMessage: 'messageText' argument is not a string", DBUS_VDR_SKIN_INTERFACE);
+ }
+
+ dbus_int32_t replyCode = 501;
+ cString replyMessage;
+ if (messageText != NULL) {
+ Skins.QueueMessage(mtInfo, messageText);
+ replyCode = 250;
+ replyMessage = "Message queued";
+ }
+ else
+ replyMessage = "Missing message";
+
+ cDBusHelper::SendReply(_conn, _msg, replyCode, replyMessage);
+}
+
+
+cDBusDispatcherSkin::cDBusDispatcherSkin(void)
+:cDBusMessageDispatcher(DBUS_VDR_SKIN_INTERFACE)
+{
+}
+
+cDBusDispatcherSkin::~cDBusDispatcherSkin(void)
+{
+}
+
+cDBusMessage *cDBusDispatcherSkin::CreateMessage(DBusConnection* conn, DBusMessage* msg)
+{
+ if ((conn == NULL) || (msg == NULL))
+ return NULL;
+
+ const char *object = dbus_message_get_path(msg);
+ if ((object == NULL) || (strcmp(object, "/Skin") != 0))
+ return NULL;
+
+ if (dbus_message_is_method_call(msg, DBUS_VDR_SKIN_INTERFACE, "QueueMessage"))
+ return new cDBusMessageSkin(cDBusMessageSkin::dmsQueueMessage, conn, msg);
+
+ return NULL;
+}
+
+bool cDBusDispatcherSkin::OnIntrospect(DBusMessage *msg, cString &Data)
+{
+ if (strcmp(dbus_message_get_path(msg), "/Skin") != 0)
+ return false;
+ Data =
+ "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
+ " \"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
+ "<node>\n"
+ " <interface name=\""DBUS_VDR_SKIN_INTERFACE"\">\n"
+ " <method name=\"QueueMessage\">\n"
+ " <arg name=\"messageText\" type=\"s\" direction=\"in\"/>\n"
+ " <arg name=\"replycode\" type=\"i\" direction=\"out\"/>\n"
+ " <arg name=\"message\" type=\"s\" direction=\"out\"/>\n"
+ " </method>\n"
+ " </interface>\n"
+ "</node>\n";
+ return true;
+}
View
37 skin.h
@@ -0,0 +1,37 @@
+#ifndef __DBUS2VDR_SKIN_H
+#define __DBUS2VDR_SKIN_H
+
+#include "message.h"
+
+
+class cDBusMessageSkin : public cDBusMessage
+{
+friend class cDBusDispatcherSkin;
+
+public:
+ enum eAction { dmsQueueMessage };
+
+ virtual ~cDBusMessageSkin(void);
+
+protected:
+ virtual void Process(void);
+
+private:
+ cDBusMessageSkin(eAction action, DBusConnection* conn, DBusMessage* msg);
+ void QueueMessage(void);
+
+ eAction _action;
+};
+
+class cDBusDispatcherSkin : public cDBusMessageDispatcher
+{
+public:
+ cDBusDispatcherSkin(void);
+ virtual ~cDBusDispatcherSkin(void);
+
+protected:
+ virtual cDBusMessage *CreateMessage(DBusConnection* conn, DBusMessage* msg);
+ virtual bool OnIntrospect(DBusMessage *msg, cString &Data);
+};
+
+#endif

0 comments on commit f679536

Please sign in to comment.