diff options
author | Lars Hanisch <dvb@flensrocker.de> | 2011-12-21 21:14:53 +0100 |
---|---|---|
committer | Lars Hanisch <dvb@flensrocker.de> | 2011-12-21 21:17:36 +0100 |
commit | f526ab07bcdfe659a2f05a18f3367b09becc3156 (patch) | |
tree | 2f4a3dbe410e95eaf37f61d61ab0d7d3d537ce3f | |
parent | 660c47ab44cef67a2b2bb6d3e8daa276129797f7 (diff) | |
download | vdr-plugin-dynamite-f526ab07bcdfe659a2f05a18f3367b09becc3156.tar.gz vdr-plugin-dynamite-f526ab07bcdfe659a2f05a18f3367b09becc3156.tar.bz2 |
call attach-hook on detach, too, argument is --action=detach --device=/dev/path
-rw-r--r-- | HISTORY | 5 | ||||
-rw-r--r-- | README | 8 | ||||
-rw-r--r-- | dynamicdevice.c | 22 | ||||
-rw-r--r-- | dynamite.c | 2 |
4 files changed, 25 insertions, 12 deletions
@@ -231,3 +231,8 @@ VDR Plugin 'dynamite' Revision History 2011-12-15: Version 0.0.8j - add attach-hook, argument is --device=/dev/path + +2011-12-21: Version 0.0.8k + +- call attach-hook on detach, too, argument is --action=detach --device=/dev/path + arguments for call on attach has changed to --action=attach --device=/dev/path @@ -235,7 +235,7 @@ Commandline Arguments leave n slots free for non-dynamic devices of incompatible plugins -a, --attach-hook=/path/to/program - set program to be called on device attach + set program to be called on device attach/detach -i, --idle-hook=/path/to/program set program to be called on SetIdle and reactivation -I, --idle-timeout=m @@ -245,11 +245,11 @@ Commandline Arguments Attach hook ----------- -If you want 'special action' taken after a device is attached to vdr -you can specify a program either with the commandline parameter +If you want 'special action' taken after a device is attached or detached +to vdr you can specify a program either with the commandline parameter "--attach-hook=/path/to/program" or with an entry in the setup.conf dynamite.AttachHook = /path/to/program -It will be called with the parameter "--device=/dev/path". +It will be called with the parameter "--action=[attach|detach] --device=/dev/path". Idle mode --------- diff --git a/dynamicdevice.c b/dynamicdevice.c index 0567a57..1395bbd 100644 --- a/dynamicdevice.c +++ b/dynamicdevice.c @@ -285,8 +285,8 @@ attach: } cDynamiteStatus::SetStartupChannel(); if (attachHook != NULL) { - cString hookCmd = cString::sprintf("%s --device=%s", **attachHook, DevPath); - isyslog("dynamite: calling attach hook %s", *hookCmd); + cString hookCmd = cString::sprintf("%s --action=attach --device=%s", **attachHook, DevPath); + isyslog("dynamite: calling hook %s", *hookCmd); int status = SystemExec(*hookCmd, true); if (!WIFEXITED(status) || WEXITSTATUS(status)) esyslog("SystemExec() failed with status %d", status); @@ -312,29 +312,37 @@ eDynamicDeviceReturnCode cDynamicDevice::DetachDevice(const char *DevPath, bool return ddrcNotFound; } + cString realDevPath(dynamicdevice[index]->GetDevPath()); if (!Force) { if (!dynamicdevice[index]->isDetachable) { - esyslog("dynamite: detaching of device %s is not allowed", DevPath); + esyslog("dynamite: detaching of device %s is not allowed", *realDevPath); return ddrcNotAllowed; } if (dynamicdevice[index] == PrimaryDevice()) { - esyslog("dynamite: detaching of primary device %s is not supported", DevPath); + esyslog("dynamite: detaching of primary device %s is not supported", *realDevPath); return ddrcIsPrimaryDevice; } if (dynamicdevice[index]->Receiving(false)) { - esyslog("dynamite: can't detach device %s, it's receiving something important", DevPath); + esyslog("dynamite: can't detach device %s, it's receiving something important", *realDevPath); return ddrcIsReceiving; } } dynamicdevice[index]->DeleteSubDevice(); - isyslog("dynamite: detached device %s%s", DevPath, (Force ? " (forced)" : "")); + isyslog("dynamite: detached device %s%s", *realDevPath, (Force ? " (forced)" : "")); if (enableOsdMessages) { - cString osdMsg = cString::sprintf(tr("detached %s"), DevPath); + cString osdMsg = cString::sprintf(tr("detached %s"), *realDevPath); Skins.QueueMessage(mtInfo, *osdMsg); } + if (attachHook != NULL) { + cString hookCmd = cString::sprintf("%s --action=detach --device=%s", **attachHook, *realDevPath); + isyslog("dynamite: calling hook %s", *hookCmd); + int status = SystemExec(*hookCmd, true); + if (!WIFEXITED(status) || WEXITSTATUS(status)) + esyslog("SystemExec() failed with status %d", status); + } return ddrcSuccess; } @@ -11,7 +11,7 @@ #include "monitor.h" #include "status.h" -static const char *VERSION = "0.0.8j"; +static const char *VERSION = "0.0.8k"; static const char *DESCRIPTION = tr("attach/detach devices on the fly"); static const char *MAINMENUENTRY = NULL; |