2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-22 20:24:36 +00:00

FB_CALLMONITOR: use mulitple-strict widget for reverse-search attribute; minor code make-up

git-svn-id: https://svn.fhem.de/fhem/trunk@6624 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
markusbloch 2014-09-27 13:47:52 +00:00
parent fe0b0307fe
commit a629decbea

View File

@ -31,60 +31,56 @@ package main;
use strict; use strict;
use warnings; use warnings;
use Time::HiRes qw(gettimeofday); use Time::HiRes qw(gettimeofday);
use DevIo;
use Digest::MD5; use Digest::MD5;
use HttpUtils; use HttpUtils;
use DevIo; use DevIo;
my %connection_type = ( my %connection_type = (
0 => "0", 0 => "0",
1 => "FON1", 1 => "FON1",
2 => "FON2", 2 => "FON2",
3 => "FON3", 3 => "FON3",
4 => "ISDN", 4 => "ISDN",
5 => "FAX", 5 => "FAX",
6 => "not_defined", 6 => "not_defined",
7 => "not_defined", 7 => "not_defined",
8 => "not_defined", 8 => "not_defined",
9 => "not_defined", 9 => "not_defined",
10 => "DECT_1", 10 => "DECT_1",
11 => "DECT_2", 11 => "DECT_2",
12 => "DECT_3", 12 => "DECT_3",
13 => "DECT_4", 13 => "DECT_4",
14 => "DECT_5", 14 => "DECT_5",
15 => "DECT_6", 15 => "DECT_6",
16 => "FRITZMini_1", 16 => "FRITZMini_1",
17 => "FRITZMini_2", 17 => "FRITZMini_2",
18 => "FRITZMini_3", 18 => "FRITZMini_3",
19 => "FRITZMini_4", 19 => "FRITZMini_4",
20 => "VoIP_1", 20 => "VoIP_1",
21 => "VoIP_2", 21 => "VoIP_2",
22 => "VoIP_3", 22 => "VoIP_3",
23 => "VoIP_4", 23 => "VoIP_4",
24 => "VoIP_5", 24 => "VoIP_5",
25 => "VoIP_6", 25 => "VoIP_6",
26 => "VoIP_7", 26 => "VoIP_7",
27 => "VoIP_8", 27 => "VoIP_8",
28 => "VoIP_9", 28 => "VoIP_9",
29 => "VoIP_10", 29 => "VoIP_10",
40 => "Answering_Machine_1", 40 => "Answering_Machine_1",
41 => "Answering_Machine_2", 41 => "Answering_Machine_2",
42 => "Answering_Machine_3", 42 => "Answering_Machine_3",
43 => "Answering_Machine_4", 43 => "Answering_Machine_4",
44 => "Answering_Machine_5" 44 => "Answering_Machine_5"
); );
#####################################
sub sub
FB_CALLMONITOR_Initialize($) FB_CALLMONITOR_Initialize($)
{ {
my ($hash) = @_; my ($hash) = @_;
require "$attr{global}{modpath}/FHEM/DevIo.pm"; # Provider
# Provider
$hash->{ReadFn} = "FB_CALLMONITOR_Read"; $hash->{ReadFn} = "FB_CALLMONITOR_Read";
$hash->{ReadyFn} = "FB_CALLMONITOR_Ready"; $hash->{ReadyFn} = "FB_CALLMONITOR_Ready";
$hash->{GetFn} = "FB_CALLMONITOR_Get"; $hash->{GetFn} = "FB_CALLMONITOR_Get";
@ -93,7 +89,7 @@ FB_CALLMONITOR_Initialize($)
$hash->{UndefFn} = "FB_CALLMONITOR_Undef"; $hash->{UndefFn} = "FB_CALLMONITOR_Undef";
$hash->{AttrFn} = "FB_CALLMONITOR_Attr"; $hash->{AttrFn} = "FB_CALLMONITOR_Attr";
$hash->{AttrList}= "do_not_notify:0,1 disable:0,1 unique-call-ids:0,1 local-area-code remove-leading-zero:0,1 reverse-search-cache-file reverse-search:multiple,phonebook,klicktel.de,dasoertliche.de,search.ch,dasschnelle.at reverse-search-cache:0,1 reverse-search-phonebook-file ". $hash->{AttrList}= "do_not_notify:0,1 disable:0,1 unique-call-ids:0,1 local-area-code remove-leading-zero:0,1 reverse-search-cache-file reverse-search:multiple-strict,phonebook,klicktel.de,dasoertliche.de,search.ch,dasschnelle.at reverse-search-cache:0,1 reverse-search-phonebook-file ".
$readingFnAttributes; $readingFnAttributes;
} }
@ -104,45 +100,41 @@ FB_CALLMONITOR_Define($$)
my ($hash, $def) = @_; my ($hash, $def) = @_;
my @a = split("[ \t][ \t]*", $def); my @a = split("[ \t][ \t]*", $def);
if(@a != 3) { if(@a != 3)
{
my $msg = "wrong syntax: define <name> FB_CALLMONITOR ip[:port]"; my $msg = "wrong syntax: define <name> FB_CALLMONITOR ip[:port]";
Log 2, $msg; Log 2, $msg;
return $msg; return $msg;
} }
DevIo_CloseDev($hash); DevIo_CloseDev($hash);
my $name = $a[0];
my $dev = $a[2]; my $dev = $a[2];
$dev .= ":1012" if($dev !~ m/:/ && $dev ne "none" && $dev !~ m/\@/); $dev .= ":1012" if($dev !~ m/:/ && $dev ne "none" && $dev !~ m/\@/);
$hash->{DeviceName} = $dev; $hash->{DeviceName} = $dev;
my $ret = DevIo_OpenDev($hash, 0, undef);
return DevIo_OpenDev($hash, 0, undef);
return $ret;
} }
##################################### #####################################
# closing the connection on undefinition (shutdown/delete)
sub sub
FB_CALLMONITOR_Undef($$) FB_CALLMONITOR_Undef($$)
{ {
my ($hash, $arg) = @_; my ($hash, $arg) = @_;
my $name = $hash->{NAME};
DevIo_CloseDev($hash); DevIo_CloseDev($hash);
return undef; return undef;
} }
##################################### #####################################
# No get commands possible, as we just receive the events from the FritzBox. # Get function for returning a reverse search name
sub sub
FB_CALLMONITOR_Get($@) FB_CALLMONITOR_Get($@)
{ {
@ -168,6 +160,8 @@ FB_CALLMONITOR_Get($@)
} }
#####################################
# Set function for executing a reread of the internal phonebook
sub sub
FB_CALLMONITOR_Set($@) FB_CALLMONITOR_Set($@)
{ {