summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Hanisch <dvb@flensrocker.de>2011-03-18 00:08:18 +0100
committerLars Hanisch <dvb@flensrocker.de>2011-03-18 00:08:18 +0100
commit064797c1d6bdf08dcc0bc9c1195cb765431cca6b (patch)
tree32a6fb5822fff734eba34c9c2491945fa15a6b4c
parent346ebc85cd43fbf778a200e912bcb6079b611e64 (diff)
downloadvdr-plugin-dynamite-064797c1d6bdf08dcc0bc9c1195cb765431cca6b.tar.gz
vdr-plugin-dynamite-064797c1d6bdf08dcc0bc9c1195cb765431cca6b.tar.bz2
add new command ForceDetachDevice, the device will be detached regardless of any receivers or locks
-rw-r--r--HISTORY5
-rw-r--r--README8
-rw-r--r--dynamicdevice.c30
-rw-r--r--dynamicdevice.h2
-rw-r--r--dynamite.c18
5 files changed, 47 insertions, 16 deletions
diff --git a/HISTORY b/HISTORY
index 613eb5e..a07f6dd 100644
--- a/HISTORY
+++ b/HISTORY
@@ -120,3 +120,8 @@ VDR Plugin 'dynamite' Revision History
- 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")
+
+2011-03-18: Version 0.0.5n
+
+- add new command "ForceDetachDevice", the device will be detached regardless of any receivers
+ or locks
diff --git a/README b/README
index 50617f6..746c7a9 100644
--- a/README
+++ b/README
@@ -88,6 +88,14 @@ DETD devicepath
Any timeouts or locks set to this slot will be reset to its defaults.
alternate command: DetachDevice
+"dynamite-ForceDetachDevice-v0.1"
+FDTD devpath
+ Looks through its remembered devicepaths and deletes the attached
+ device if found. Case is important!
+ The device will be detached regardless of recordings or other locks!
+ This is useful for unplugged usb-sticks etc.
+ alternate command: ForceDetachDevice
+
"dynamite-DetachAllDevices-v0.1"
DTAD [force]
detachs all attached devices
diff --git a/dynamicdevice.c b/dynamicdevice.c
index bfd06af..ba74193 100644
--- a/dynamicdevice.c
+++ b/dynamicdevice.c
@@ -39,7 +39,7 @@ bool cDynamicDevice::ProcessQueuedCommands(void)
}
case ddpcDetach:
{
- DetachDevice(*dev->devpath);
+ DetachDevice(*dev->devpath, false);
break;
}
case ddpcService:
@@ -165,7 +165,7 @@ attach:
return ddrcSuccess;
}
-eDynamicDeviceReturnCode cDynamicDevice::DetachDevice(const char *DevPath)
+eDynamicDeviceReturnCode cDynamicDevice::DetachDevice(const char *DevPath, bool Force)
{
if (!DevPath)
return ddrcNotSupported;
@@ -183,23 +183,25 @@ eDynamicDeviceReturnCode cDynamicDevice::DetachDevice(const char *DevPath)
return ddrcNotFound;
}
- if (!dynamicdevice[index]->isDetachable) {
- esyslog("dynamite: detaching of device %s is not allowed", DevPath);
- return ddrcNotAllowed;
- }
+ if (!Force) {
+ if (!dynamicdevice[index]->isDetachable) {
+ esyslog("dynamite: detaching of device %s is not allowed", DevPath);
+ return ddrcNotAllowed;
+ }
- if (dynamicdevice[index] == PrimaryDevice()) {
- esyslog("dynamite: detaching of primary device %s is not supported", DevPath);
- return ddrcIsPrimaryDevice;
- }
+ if (dynamicdevice[index] == PrimaryDevice()) {
+ esyslog("dynamite: detaching of primary device %s is not supported", DevPath);
+ return ddrcIsPrimaryDevice;
+ }
- if (dynamicdevice[index]->Receiving(false)) {
- esyslog("dynamite: can't detach device %s, it's receiving something important", DevPath);
- return ddrcIsReceiving;
+ if (dynamicdevice[index]->Receiving(false)) {
+ esyslog("dynamite: can't detach device %s, it's receiving something important", DevPath);
+ return ddrcIsReceiving;
+ }
}
dynamicdevice[index]->DeleteSubDevice();
- isyslog("dynamite: detached device %s", DevPath);
+ isyslog("dynamite: detached device %s%s", DevPath, (Force ? " (forced)" : ""));
return ddrcSuccess;
}
diff --git a/dynamicdevice.h b/dynamicdevice.h
index d45adaa..e76a842 100644
--- a/dynamicdevice.h
+++ b/dynamicdevice.h
@@ -33,7 +33,7 @@ public:
static cString ListAllDevices(int &ReplyCode); // for SVDRP command LSTD
static cString AttachDevicePattern(const char *Pattern);
static eDynamicDeviceReturnCode AttachDevice(const char *DevPath);
- static eDynamicDeviceReturnCode DetachDevice(const char *DevPath);
+ static eDynamicDeviceReturnCode DetachDevice(const char *DevPath, bool Force);
static eDynamicDeviceReturnCode SetLockDevice(const char *DevPath, bool Lock);
static eDynamicDeviceReturnCode SetIdle(const char *DevPath, bool Idle);
static eDynamicDeviceReturnCode SetGetTSTimeout(const char *DevPath, int Seconds);
diff --git a/dynamite.c b/dynamite.c
index 60f0180..49a814e 100644
--- a/dynamite.c
+++ b/dynamite.c
@@ -9,7 +9,7 @@
#include "dynamicdevice.h"
#include "monitor.h"
-static const char *VERSION = "0.0.5m";
+static const char *VERSION = "0.0.5n";
static const char *DESCRIPTION = "attach/detach devices on the fly";
static const char *MAINMENUENTRY = NULL;
@@ -268,6 +268,11 @@ bool cPluginDynamite::Service(const char *Id, void *Data)
cDynamicDeviceProbe::QueueDynamicDeviceCommand(ddpcDetach, (const char*)Data);
return true;
}
+ if (strcmp(Id, "dynamite-ForceDetachDevice-v0.1") == 0) {
+ if (Data != NULL)
+ cDynamicDevice::DetachDevice((const char*)Data, true);
+ return true;
+ }
if (strcmp(Id, "dynamite-DetachAllDevices-v0.1") == 0) {
if (Data != NULL)
cDynamicDevice::DetachAllDevices((strcasecmp((const char*)Data, "force") == 0));
@@ -345,6 +350,12 @@ 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",
+ "FDTD devpath\n"
+ " Looks through its remembered devicepaths and deletes the attached\n"
+ " device if found. Case is important!\n"
+ " The device will be detached regardless of recordings or other locks!\n"
+ " This is useful for unplugged usb-sticks etc.\n"
+ " alternate command: ForceDetachDevice",
"DTAD [force]\n"
" detachs all attached devices\n"
" \"force\" will ignore recordings and other receivers\n"
@@ -410,6 +421,11 @@ cString cPluginDynamite::SVDRPCommand(const char *Command, const char *Option, i
return cString::sprintf("queued command for detaching %s", Option);
}
+ if ((strcasecmp(Command, "FDTD") == 0) || (strcasecmp(Command, "ForceDetachDevice") == 0)) {
+ cDynamicDevice::DetachDevice(Option, true);
+ return cString::sprintf("forced detaching of %s", Option);
+ }
+
if ((strcasecmp(Command, "DTAD") == 0) || (strcasecmp(Command, "DetachAllDevices") == 0)) {
bool force = false;
if (Option && (strcasecmp(Option, "force") == 0))