diff options
-rw-r--r-- | dynamicdevice.c | 1 | ||||
-rw-r--r-- | dynamicdevice.h | 1 | ||||
-rw-r--r-- | dynamite.c | 29 |
3 files changed, 30 insertions, 1 deletions
diff --git a/dynamicdevice.c b/dynamicdevice.c index 349c944..c694313 100644 --- a/dynamicdevice.c +++ b/dynamicdevice.c @@ -10,6 +10,7 @@ int cDynamicDevice::defaultGetTSTimeout = 0; int cDynamicDevice::idleTimeoutMinutes = 0; int cDynamicDevice::idleWakeupHours = 0; cString *cDynamicDevice::idleHook = NULL; +cString *cDynamicDevice::attachHook = NULL; cDvbDeviceProbe *cDynamicDevice::dvbprobe = NULL; bool cDynamicDevice::enableOsdMessages = false; int cDynamicDevice::numDynamicDevices = 0; diff --git a/dynamicdevice.h b/dynamicdevice.h index ae0cb21..175d6e3 100644 --- a/dynamicdevice.h +++ b/dynamicdevice.h @@ -39,6 +39,7 @@ private: static int idleTimeoutMinutes; static int idleWakeupHours; static cString *idleHook; + static cString *attachHook; static int numDynamicDevices; static cMutex arrayMutex; @@ -118,6 +118,10 @@ cPluginDynamite::~cPluginDynamite() delete cDynamicDevice::idleHook; cDynamicDevice::idleHook = NULL; } + if (cDynamicDevice::attachHook != NULL) { + delete cDynamicDevice::attachHook; + cDynamicDevice::attachHook = NULL; + } if (cDynamicDevice::dvbprobe) { delete cDynamicDevice::dvbprobe; cDynamicDevice::dvbprobe = NULL; @@ -142,6 +146,8 @@ const char *cPluginDynamite::CommandLineHelp(void) " set program to be called on GetTS-timeout\n" " --free-device-slots=n\n" " leave n slots free for non-dynamic devices\n" + " --attach-hook=/path/to/program\n" + " set program to be called on device attach\n" " --idle-hook=/path/to/program\n" " set program to be called on SetIdle and reactivation\n" " --idle-timeout=m\n" @@ -159,6 +165,7 @@ bool cPluginDynamite::ProcessArgs(int argc, char *argv[]) {"GetTSTimeout", required_argument, 0, 't'}, {"GetTSTimeoutHandler", required_argument, 0, 'h'}, {"free-device-slots", required_argument, 0, 'f'}, + {"attach-hook", required_argument, 0, 'a'}, {"idle-hook", required_argument, 0, 'i'}, {"idle-timeout", required_argument, 0, 'I'}, {"idle-wakeup", required_argument, 0, 'W'}, @@ -167,7 +174,7 @@ bool cPluginDynamite::ProcessArgs(int argc, char *argv[]) while (true) { int option_index = 0; - int c = getopt_long(argc, argv, "udt:h:f:i:I:W:", options, &option_index); + int c = getopt_long(argc, argv, "udt:h:f:a:i:I:W:", options, &option_index); if (c == -1) break; switch (c) { @@ -211,6 +218,17 @@ bool cPluginDynamite::ProcessArgs(int argc, char *argv[]) } break; } + case 'a': + { + if (cDynamicDevice::attachHook != NULL) + delete cDynamicDevice::attachHook; + cDynamicDevice::attachHook = NULL; + if (optarg != NULL) { + cDynamicDevice::attachHook = new cString(optarg); + isyslog("dynamite: installing attach-hook %s", **cDynamicDevice::attachHook); + } + break; + } case 'i': { if (cDynamicDevice::idleHook != NULL) @@ -368,6 +386,15 @@ bool cPluginDynamite::SetupParse(const char *Name, const char *Value) else esyslog("dynamite: \"%d\" free device slots is out of range", tmp); } + else if (strcasecmp(Name, "AttachHook") == 0) { + if (cDynamicDevice::attachHook != NULL) + delete cDynamicDevice::attachHook; + cDynamicDevice::attachHook = NULL; + if (Value != NULL) { + cDynamicDevice::attachHook = new cString(Value); + isyslog("dynamite: installing attach-hook %s", **cDynamicDevice::attachHook); + } + } else if (strcasecmp(Name, "IdleHook") == 0) { if (cDynamicDevice::idleHook != NULL) delete cDynamicDevice::idleHook; |