diff options
author | Lars Hanisch <dvb@flensrocker.de> | 2011-03-18 00:08:18 +0100 |
---|---|---|
committer | Lars Hanisch <dvb@flensrocker.de> | 2011-03-18 00:08:18 +0100 |
commit | 064797c1d6bdf08dcc0bc9c1195cb765431cca6b (patch) | |
tree | 32a6fb5822fff734eba34c9c2491945fa15a6b4c | |
parent | 346ebc85cd43fbf778a200e912bcb6079b611e64 (diff) | |
download | vdr-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-- | HISTORY | 5 | ||||
-rw-r--r-- | README | 8 | ||||
-rw-r--r-- | dynamicdevice.c | 30 | ||||
-rw-r--r-- | dynamicdevice.h | 2 | ||||
-rw-r--r-- | dynamite.c | 18 |
5 files changed, 47 insertions, 16 deletions
@@ -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 @@ -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); @@ -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)) |