summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Hanisch <dvb@flensrocker.de>2011-03-17 18:37:24 +0100
committerLars Hanisch <dvb@flensrocker.de>2011-03-17 18:37:24 +0100
commit346ebc85cd43fbf778a200e912bcb6079b611e64 (patch)
treeaabc62f576036d308a70afb59de7244c6d99cd19
parentc2b418c56d5f6e179bd6a62a45a186c70d2b14e2 (diff)
downloadvdr-plugin-dynamite-346ebc85cd43fbf778a200e912bcb6079b611e64.tar.gz
vdr-plugin-dynamite-346ebc85cd43fbf778a200e912bcb6079b611e64.tar.bz2
- use getopt_long on commandline argument processing, look at README for new arguments
- raise event via cPlugin::Service if a device is attached/detached so other plugins can react on it ("dynamite-event-DeviceAttached-v0.1", "dynamite-event-DeviceDetached-v0.1")
-rw-r--r--HISTORY10
-rw-r--r--README20
-rw-r--r--dynamicdevice.c5
-rw-r--r--dynamite.c69
4 files changed, 80 insertions, 24 deletions
diff --git a/HISTORY b/HISTORY
index f479cd7..613eb5e 100644
--- a/HISTORY
+++ b/HISTORY
@@ -110,3 +110,13 @@ VDR Plugin 'dynamite' Revision History
- create dummy-device-probe only if specified on command line option "--dummy-probe"
- add commandline arg --GetTSTimeoutHandler /path/to/program
- add new command "DTAD" for detaching all devices
+
+2011-03-09: Version 0.0.5l
+
+- bugfix on logging error message
+
+2011-03-17: Version 0.0.5m
+
+- use getopt_long on commandline argument processing, look at README for new arguments
+- raise event via cPlugin::Service if a device is attached/detached so other plugins
+ can react on it ("dynamite-event-DeviceAttached-v0.1", "dynamite-event-DeviceDetached-v0.1")
diff --git a/README b/README
index d47bf22..50617f6 100644
--- a/README
+++ b/README
@@ -162,17 +162,31 @@ CallGetTSTimeoutHandler arg
Don't forget to prefix them with "plug dynamite"...
+Signals emitted via cPluginManager::CallAllServices
+---------------------------------------------------
+On some actions dynamite calls the Service interface of every plugin
+so other plugins can react on these.
+
+On attaching a device:
+"dynamite-event-DeviceAttached-v0.1" /dev/path/to/device
+
+On detaching a device:
+"dynamite-event-DeviceDetached-v0.1" /dev/path/to/device
+
Parameters in setup.conf
------------------------
dynamite.DefaultGetTSTimeout = 0
+dynamite.GetTSTimeoutHandler = /path/to/program
Commandline Arguments
---------------------
---log-udev
+-u, --log-udev
log all udev events to syslog (useful for diagnostics)
---dummy-probe
+-d, --dummy-probe
start dummy-device probe (useful for experiments)
---GetTSTimeoutHandler /path/to/program
+-t, --GetTSTimeout=n
+ set default GetTS-timeout to n seconds
+-h, --GetTSTimeoutHandler=/path/to/program
set program to be called on GetTS-timeout
"GetTS" watchdog
diff --git a/dynamicdevice.c b/dynamicdevice.c
index bf675e7..bfd06af 100644
--- a/dynamicdevice.c
+++ b/dynamicdevice.c
@@ -161,6 +161,7 @@ attach:
dynamicdevice[freeIndex]->devpath = new cString(DevPath);
isyslog("dynamite: attached device %s to dynamic device slot %d", DevPath, freeIndex + 1);
dynamicdevice[freeIndex]->ReadUdevProperties();
+ cPluginManager::CallAllServices("dynamite-event-DeviceAttached-v0.1", (void*)DevPath);
return ddrcSuccess;
}
@@ -267,7 +268,7 @@ void cDynamicDevice::SetDefaultGetTSTimeout(int Seconds)
{
if (Seconds >= 0) {
defaultGetTSTimeout = Seconds;
- isyslog("dynamite: set default GetTSTimeout to %d seconds", Seconds);
+ isyslog("dynamite: set default GetTS-Timeout to %d seconds", Seconds);
cMutexLock lock(&arrayMutex);
for (int i = 0; i < numDynamicDevices; i++)
dynamicdevice[i]->InternSetGetTSTimeout(Seconds);
@@ -386,6 +387,8 @@ void cDynamicDevice::DeleteSubDevice()
delete subDevice;
subDevice = NULL;
isyslog("dynamite: deleted device for %s", (devpath ? **devpath : "(unknown)"));
+ if (devpath)
+ cPluginManager::CallAllServices("dynamite-event-DeviceDetached-v0.1", (void*)**devpath);
}
if (devpath) {
delete devpath;
diff --git a/dynamite.c b/dynamite.c
index 9c57d71..60f0180 100644
--- a/dynamite.c
+++ b/dynamite.c
@@ -4,11 +4,12 @@
* See the README file for copyright information and how to reach the author.
*/
+#include <getopt.h>
#include <vdr/plugin.h>
#include "dynamicdevice.h"
#include "monitor.h"
-static const char *VERSION = "0.0.5l";
+static const char *VERSION = "0.0.5m";
static const char *DESCRIPTION = "attach/detach devices on the fly";
static const char *MAINMENUENTRY = NULL;
@@ -120,24 +121,52 @@ const char *cPluginDynamite::CommandLineHelp(void)
bool cPluginDynamite::ProcessArgs(int argc, char *argv[])
{
- for (int i = 0; i < argc; i++) {
- if (strcmp(argv[i], "--log-udev") == 0)
- cUdevMonitor::AddFilter(NULL, new cUdevLogFilter());
-
- if ((strcmp(argv[i], "--dummy-probe") == 0) && (probe == NULL))
- probe = new cDynamiteDeviceProbe;
-
- if ((strcasecmp(argv[i], "--GetTSTimeoutHandler") == 0) && ((i + 1) < argc)) {
- if (getTSTimeoutHandler != NULL)
- delete getTSTimeoutHandler;
- getTSTimeoutHandler = NULL;
- i++;
- if (argv[i] != NULL) {
- getTSTimeoutHandler = new cString(argv[i]);
- isyslog("dynamite: installing GetTSTimeoutHandler %s", **getTSTimeoutHandler);
- }
- }
- }
+ static struct option options[] =
+ {
+ {"log-udev", no_argument, 0, 'u'},
+ {"dummy-probe", no_argument, 0, 'd'},
+ {"GetTSTimeout", required_argument, 0, 't'},
+ {"GetTSTimeoutHandler", required_argument, 0, 'h'},
+ {0, 0, 0, 0}
+ };
+
+ while (true) {
+ int option_index = 0;
+ int c = getopt_long(argc, argv, "udt:h:", options, &option_index);
+ if (c == -1)
+ break;
+ switch (c) {
+ case 'u':
+ {
+ isyslog("dynamite: activate udev-logging");
+ cUdevMonitor::AddFilter(NULL, new cUdevLogFilter());
+ break;
+ }
+ case 'd':
+ {
+ isyslog("dynamite: activate dummy-device-probe");
+ probe = new cDynamiteDeviceProbe;
+ break;
+ }
+ case 't':
+ {
+ if ((optarg != NULL) && isnumber(optarg))
+ cDynamicDevice::SetDefaultGetTSTimeout(strtol(optarg, NULL, 10));
+ break;
+ }
+ case 'h':
+ {
+ if (getTSTimeoutHandler != NULL)
+ delete getTSTimeoutHandler;
+ getTSTimeoutHandler = NULL;
+ if (optarg != NULL) {
+ getTSTimeoutHandler = new cString(optarg);
+ isyslog("dynamite: installing GetTS-Timeout-Handler %s", **getTSTimeoutHandler);
+ }
+ break;
+ }
+ }
+ }
return true;
}
@@ -214,7 +243,7 @@ bool cPluginDynamite::SetupParse(const char *Name, const char *Value)
getTSTimeoutHandler = NULL;
if (Value != NULL) {
getTSTimeoutHandler = new cString(Value);
- isyslog("dynamite: installing GetTSTimeoutHandler %s", **getTSTimeoutHandler);
+ isyslog("dynamite: installing GetTS-Timeout-Handler %s", **getTSTimeoutHandler);
}
}
else