summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Hanisch <dvb@flensrocker.de>2011-02-26 17:15:41 +0100
committerLars Hanisch <dvb@flensrocker.de>2011-02-26 17:15:41 +0100
commit730ff56de4b4cd4aea74535fba347b8d1f4a09bd (patch)
treec7b55acc9fb6511aea17bc3a0c1714191f06ba2a
parente92b0f7b6c3c02b5d903eab398682bcbf6ae6d65 (diff)
downloadvdr-plugin-dynamite-730ff56de4b4cd4aea74535fba347b8d1f4a09bd.tar.gz
vdr-plugin-dynamite-730ff56de4b4cd4aea74535fba347b8d1f4a09bd.tar.bz2
add new command DTAD for detaching all devices
-rw-r--r--HISTORY4
-rw-r--r--README15
-rw-r--r--dynamicdevice.c12
-rw-r--r--dynamicdevice.h2
-rw-r--r--dynamite.c41
5 files changed, 62 insertions, 12 deletions
diff --git a/HISTORY b/HISTORY
index 3ade3e3..f479cd7 100644
--- a/HISTORY
+++ b/HISTORY
@@ -104,7 +104,9 @@ VDR Plugin 'dynamite' Revision History
- move reading of udev properties from the monitor to the attacher,
so that they are recognized on devices present at startup.
-2011-02-26: Version 0.0.5k-rc1
+2011-02-26: Version 0.0.5k
- while in cDvbDeviceProbe create only as much cDynamicDevice-objects as needed
- 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
diff --git a/README b/README
index a417076..d47bf22 100644
--- a/README
+++ b/README
@@ -88,6 +88,12 @@ DETD devicepath
Any timeouts or locks set to this slot will be reset to its defaults.
alternate command: DetachDevice
+"dynamite-DetachAllDevices-v0.1"
+DTAD [force]
+ detachs all attached devices
+ "force" will ignore recordings and other receivers
+ alternate command: DetachAllDevices
+
"dynamite-ScanDevices-v0.1"
SCND '/dev/path/glob*/pattern*'
Scan filesystem with pattern and try to attach each found device
@@ -159,12 +165,15 @@ Don't forget to prefix them with "plug dynamite"...
Parameters in setup.conf
------------------------
dynamite.DefaultGetTSTimeout = 0
-dynamite.GetTSTimeoutHandler = /path/to/program
Commandline Arguments
---------------------
---log-udev log all udev events to syslog (useful for diagnostics)
---dummy-probe start dummy-device probe (useful for experiments)
+--log-udev
+ log all udev events to syslog (useful for diagnostics)
+--dummy-probe
+ start dummy-device probe (useful for experiments)
+--GetTSTimeoutHandler /path/to/program
+ set program to be called on GetTS-timeout
"GetTS" watchdog
----------------
diff --git a/dynamicdevice.c b/dynamicdevice.c
index e7f5b1e..bf675e7 100644
--- a/dynamicdevice.c
+++ b/dynamicdevice.c
@@ -63,11 +63,16 @@ bool cDynamicDevice::ProcessQueuedCommands(void)
return true;
}
-void cDynamicDevice::DetachAllDevices(void)
+void cDynamicDevice::DetachAllDevices(bool Force)
{
cMutexLock lock(&arrayMutex);
- for (int i = 0; i < numDynamicDevices; i++)
- dynamicdevice[i]->DeleteSubDevice();
+ isyslog("dynamite: %sdetaching all devices", (Force ? "force " : ""));
+ for (int i = 0; i < numDynamicDevices; i++) {
+ if (Force)
+ dynamicdevice[i]->DeleteSubDevice();
+ else if (dynamicdevice[i]->devpath)
+ cDynamicDeviceProbe::QueueDynamicDeviceCommand(ddpcDetach, (**dynamicdevice[i]->devpath));
+ }
}
cString cDynamicDevice::ListAllDevices(int &ReplyCode)
@@ -380,6 +385,7 @@ void cDynamicDevice::DeleteSubDevice()
subDevice->StopSectionHandler();
delete subDevice;
subDevice = NULL;
+ isyslog("dynamite: deleted device for %s", (devpath ? **devpath : "(unknown)"));
}
if (devpath) {
delete devpath;
diff --git a/dynamicdevice.h b/dynamicdevice.h
index 36fb12d..d45adaa 100644
--- a/dynamicdevice.h
+++ b/dynamicdevice.h
@@ -29,7 +29,7 @@ public:
static int NumDynamicDevices(void) { return numDynamicDevices; }
///< Returns the total number of dynamic devices.
static bool ProcessQueuedCommands(void);
- static void DetachAllDevices(void);
+ static void DetachAllDevices(bool Force);
static cString ListAllDevices(int &ReplyCode); // for SVDRP command LSTD
static cString AttachDevicePattern(const char *Pattern);
static eDynamicDeviceReturnCode AttachDevice(const char *DevPath);
diff --git a/dynamite.c b/dynamite.c
index c3c80c1..eaa1dce 100644
--- a/dynamite.c
+++ b/dynamite.c
@@ -8,7 +8,7 @@
#include "dynamicdevice.h"
#include "monitor.h"
-static const char *VERSION = "0.0.5k-rc1";
+static const char *VERSION = "0.0.5k";
static const char *DESCRIPTION = "attach/detach devices on the fly";
static const char *MAINMENUENTRY = NULL;
@@ -108,8 +108,12 @@ cPluginDynamite::~cPluginDynamite()
const char *cPluginDynamite::CommandLineHelp(void)
{
- return " --log-udev log all udev events to syslog (useful for diagnostics)\n"
- " --dummy-probe start dummy-device probe";
+ return " --log-udev\n"
+ " log all udev events to syslog (useful for diagnostics)\n"
+ " --dummy-probe\n"
+ " start dummy-device probe\n"
+ " --GetTSTimeoutHandler /path/to/program\n"
+ " set program to be called on GetTS-timeout";
}
bool cPluginDynamite::ProcessArgs(int argc, char *argv[])
@@ -117,8 +121,20 @@ 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);
+ }
+ }
}
return true;
}
@@ -145,7 +161,7 @@ bool cPluginDynamite::Start(void)
void cPluginDynamite::Stop(void)
{
- cDynamicDevice::DetachAllDevices();
+ cDynamicDevice::DetachAllDevices(true);
}
void cPluginDynamite::Housekeeping(void)
@@ -221,6 +237,11 @@ bool cPluginDynamite::Service(const char *Id, void *Data)
cDynamicDeviceProbe::QueueDynamicDeviceCommand(ddpcDetach, (const char*)Data);
return true;
}
+ if (strcmp(Id, "dynamite-DetachAllDevices-v0.1") == 0) {
+ if (Data != NULL)
+ cDynamicDevice::DetachAllDevices((strcasecmp((const char*)Data, "force") == 0));
+ return true;
+ }
if (strcmp(Id, "dynamite-LockDevice-v0.1") == 0) {
if (Data != NULL)
cDynamicDevice::SetLockDevice((const char*)Data, true);
@@ -293,6 +314,10 @@ const char **cPluginDynamite::SVDRPHelpPages(void)
" device if found. Case is important!\n"
" Any timeouts or locks set to this slot will be reset to its defaults\n"
" alternate command: DetachDevice",
+ "DTAD [force]\n"
+ " detachs all attached devices\n"
+ " \"force\" will ignore recordings and other receivers\n"
+ " alternate command: DetachAllDevices",
"SCND '/dev/path/glob*/pattern*'\n"
" Scan filesystem with pattern and try to attach each found device\n"
" don't forget to enclose the pattern with single quotes\n"
@@ -354,6 +379,14 @@ cString cPluginDynamite::SVDRPCommand(const char *Command, const char *Option, i
return cString::sprintf("queued command for detaching %s", Option);
}
+ if ((strcasecmp(Command, "DTAD") == 0) || (strcasecmp(Command, "DetachAllDevices") == 0)) {
+ bool force = false;
+ if (Option && (strcasecmp(Option, "force") == 0))
+ force = true;
+ cDynamicDevice::DetachAllDevices(force);
+ return cString::sprintf("detaching all devices...");
+ }
+
if ((strcasecmp(Command, "SCND") == 0) || (strcasecmp(Command, "ScanDevices") == 0))
return cDynamicDevice::AttachDevicePattern(Option);