2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-22 08:11:44 +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,7 +31,6 @@ 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;
@ -75,15 +74,12 @@ my %connection_type = (
); );
#####################################
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";
@ -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($@)
{ {