If no protocol defined, fall back to the name of the Control
This commit is contained in:
parent
2529765df3
commit
40e7f607f5
|
@ -326,17 +326,23 @@ sub resumeMotionDetection {
|
||||||
|
|
||||||
sub Control {
|
sub Control {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
if ( ! exists $$self{Control}) {
|
if (!exists $$self{Control}) {
|
||||||
if ($$self{ControlId}) {
|
if ($$self{ControlId}) {
|
||||||
require ZoneMinder::Control;
|
require ZoneMinder::Control;
|
||||||
my $Control = ZoneMinder::Control->find_one(Id=>$$self{ControlId});
|
my $Control = ZoneMinder::Control->find_one(Id=>$$self{ControlId});
|
||||||
if ($Control) {
|
if ($Control) {
|
||||||
|
my $Protocol = $$Control{Protocol};
|
||||||
|
|
||||||
|
if (!$Protocol) {
|
||||||
|
Error("No protocol set in control $$Control{Id}, trying Name $$Control{Name}");
|
||||||
|
$Protocol = $$Control{Name};
|
||||||
|
}
|
||||||
require Module::Load::Conditional;
|
require Module::Load::Conditional;
|
||||||
if (!Module::Load::Conditional::can_load(modules => {'ZoneMinder::Control::'.$$Control{Protocol} => undef})) {
|
if (!Module::Load::Conditional::can_load(modules => {'ZoneMinder::Control::'.$Protocol => undef})) {
|
||||||
Error("Can't load ZoneMinder::Control::$$Control{Protocol}\n$Module::Load::Conditional::ERROR");
|
Error("Can't load ZoneMinder::Control::$Protocol\n$Module::Load::Conditional::ERROR");
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
bless $Control, 'ZoneMinder::Control::'.$$Control{Protocol};
|
bless $Control, 'ZoneMinder::Control::'.$Protocol;
|
||||||
$$Control{MonitorId} = $$self{Id};
|
$$Control{MonitorId} = $$self{Id};
|
||||||
$$self{Control} = $Control;
|
$$self{Control} = $Control;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue