From a2ec18be5ae44a3ec1d83b270133ff95e07bae97 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 26 Oct 2021 18:15:03 -0400 Subject: [PATCH] Implement Control() function to implement the Protocol Specific Control object --- scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm b/scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm index d01ef3455..899426164 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm @@ -36,6 +36,7 @@ require ZoneMinder::Server; require ZoneMinder::Memory; require ZoneMinder::Monitor_Status; require ZoneMinder::Zone; +use ZoneMinder::Logger qw(:all); #our @ISA = qw(Exporter ZoneMinder::Base); use parent qw(ZoneMinder::Object); @@ -313,6 +314,25 @@ sub resumeMotionDetection { return 1; } +sub Control { + my $self = shift; + if ( ! exists $$self{Control}) { + require ZoneMinder::Control; + my $Control = ZoneMinder::Control->find_one(Id=>$$self{ControlId}); + if ($Control) { + require Module::Load::Conditional; + if (!Module::Load::Conditional::can_load(modules => {'ZoneMinder::Control::'.$$Control{Protocol} => undef})) { + Error("Can't load ZoneMinder::Control::$$Control{Protocol}\n$Module::Load::Conditional::ERROR"); + return undef; + } + bless $Control, 'ZoneMinder::Control::'.$$Control{Protocol}; + $$Control{MonitorId} = $$self{Id}; + $$self{Control} = $Control; + } + } + return $$self{Control}; +} + 1; __END__