diff --git a/fhem/FHEM/72_FB_CALLMONITOR.pm b/fhem/FHEM/72_FB_CALLMONITOR.pm index c43b6272a..d8b94914a 100755 --- a/fhem/FHEM/72_FB_CALLMONITOR.pm +++ b/fhem/FHEM/72_FB_CALLMONITOR.pm @@ -36,44 +36,6 @@ use HttpUtils; use DevIo; use FritzBoxUtils; -my %connection_type = ( - 0 => "0", - 1 => "FON1", - 2 => "FON2", - 3 => "FON3", - 4 => "ISDN", - 5 => "FAX", - 6 => "not_defined", - 7 => "not_defined", - 8 => "not_defined", - 9 => "not_defined", - 10 => "DECT_1", - 11 => "DECT_2", - 12 => "DECT_3", - 13 => "DECT_4", - 14 => "DECT_5", - 15 => "DECT_6", - 16 => "FRITZMini_1", - 17 => "FRITZMini_2", - 18 => "FRITZMini_3", - 19 => "FRITZMini_4", - 20 => "VoIP_1", - 21 => "VoIP_2", - 22 => "VoIP_3", - 23 => "VoIP_4", - 24 => "VoIP_5", - 25 => "VoIP_6", - 26 => "VoIP_7", - 27 => "VoIP_8", - 28 => "VoIP_9", - 29 => "VoIP_10", - 40 => "Answering_Machine_1", - 41 => "Answering_Machine_2", - 42 => "Answering_Machine_3", - 43 => "Answering_Machine_4", - 44 => "Answering_Machine_5" -); - ##################################### sub @@ -304,6 +266,44 @@ FB_CALLMONITOR_Read($) { my ($hash) = @_; + my %connection_type = ( + 0 => "0", + 1 => "FON1", + 2 => "FON2", + 3 => "FON3", + 4 => "ISDN", + 5 => "FAX", + 6 => "not_defined", + 7 => "not_defined", + 8 => "not_defined", + 9 => "not_defined", + 10 => "DECT_1", + 11 => "DECT_2", + 12 => "DECT_3", + 13 => "DECT_4", + 14 => "DECT_5", + 15 => "DECT_6", + 16 => "FRITZMini_1", + 17 => "FRITZMini_2", + 18 => "FRITZMini_3", + 19 => "FRITZMini_4", + 20 => "VoIP_1", + 21 => "VoIP_2", + 22 => "VoIP_3", + 23 => "VoIP_4", + 24 => "VoIP_5", + 25 => "VoIP_6", + 26 => "VoIP_7", + 27 => "VoIP_8", + 28 => "VoIP_9", + 29 => "VoIP_10", + 40 => "Answering_Machine_1", + 41 => "Answering_Machine_2", + 42 => "Answering_Machine_3", + 43 => "Answering_Machine_4", + 44 => "Answering_Machine_5" + ); + my $buf = DevIo_SimpleRead($hash); return "" if(!defined($buf) or IsDisabled($hash->{NAME})); @@ -610,7 +610,7 @@ FB_CALLMONITOR_reverseSearch($$) else { #Log 2, $result; - if($result =~ /(.+?)<\/span>/) + if($result =~ m,(.+?),) { $invert_match = $1; $invert_match = FB_CALLMONITOR_html2txt($invert_match); @@ -645,23 +645,23 @@ FB_CALLMONITOR_reverseSearch($$) else { #Log 2, $result; - if($result =~ /(.+?)<\/entry>/s) + if($result =~ m,(.+?),s) { my $xml = $1; $invert_match = ""; - if($xml =~ /(.+?)<\/tel:firstname>/) + if($xml =~ m,(.+?),) { $invert_match .= $1; } - if($xml =~ /(.+?)<\/tel:name>/) + if($xml =~ m,(.+?),) { $invert_match .= " $1"; } - if($xml =~ /(.+?)<\/tel:occupation>/) + if($xml =~ m,(.+?),) { $invert_match .= ", $1"; } @@ -859,8 +859,8 @@ sub FB_CALLMONITOR_readPhonebook($;$) if(defined($err)) { - Log3 $name, 2, "FB_CALLMONITOR ($name) - unable to retrieve phonebook \"".$hash->{helper}{PHONEBOOK_NAMES}{$phonebookId}."\" from FritzBox - $err"; - return "unable to retrieve phonebook \"".$hash->{helper}{PHONEBOOK_NAMES}{$phonebookId}."\" from FritzBox - $err"; + Log3 $name, 2, 'FB_CALLMONITOR ($name) - unable to retrieve phonebook "'.$hash->{helper}{PHONEBOOK_NAMES}{$phonebookId}.'" from FritzBox - '.$err; + return 'unable to retrieve phonebook "'.$hash->{helper}{PHONEBOOK_NAMES}{$phonebookId}.'" from FritzBox - $err'; } else { @@ -873,7 +873,7 @@ sub FB_CALLMONITOR_readPhonebook($;$) } else { - Log3 $name, 2, "FB_CALLMONITOR ($name) - read $count_contacts contact".($count_contacts == 1 ? "" : "s")." from remote phonebook \"".$hash->{helper}{PHONEBOOK_NAMES}{$phonebookId}."\""; + Log3 $name, 2, "FB_CALLMONITOR ($name) - read $count_contacts contact".($count_contacts == 1 ? "" : "s").' from remote phonebook "'.$hash->{helper}{PHONEBOOK_NAMES}{$phonebookId}.'"'; } } } @@ -934,18 +934,18 @@ sub FB_CALLMONITOR_parsePhonebook($$) my $count_contacts = 0; - if($phonebook =~ // and $phonebook =~ //) + if($phonebook =~ // and $phonebook =~ /,) { - while($phonebook =~ m/]*>(.+?)<\/contact>/gs) + while($phonebook =~ m,]*>(.+?),gs) { $contact = $1; - if($contact =~ m/(.+?)<\/realName>/) + if($contact =~ m,(.+?),) { $contact_name = $1; - while($contact =~ m/]*?type="([^<>"]+?)"[^<>]*?>([^<>"]+?)<\/number>/gs) + while($contact =~ m,]*?type="([^<>"]+?)"[^<>]*?>([^<>"]+?),gs) { if($1 ne "intern" and $1 ne "memo") { @@ -1049,7 +1049,7 @@ sub FB_CALLMONITOR_loadTextFile($;$) foreach my $line (@file) { $line =~ s/#.*$//g; - $line =~ s/\/\/.*$//g; + $line =~ s,//.*$,,g; if(not $line =~ /^\s*$/) @@ -1274,12 +1274,12 @@ EOD my ($nonce, $realm); - if($data =~ /(.+?)<\/Nonce>/i) + if($data =~ m,(.+?),i) { $nonce = $1; } - if($data =~ /(.+?)<\/Realm>/i) + if($data =~ m,(.+?),i) { $realm = $1; } @@ -1335,7 +1335,7 @@ EOD Log3 $name, 5, "FB_CALLMONITOR ($name) - received response:\n$data"; # if status is still "unauthenticated" => user/password combination is wrong - if($data =~ /Unauthenticated<\/Status>/i) + if($data =~ m,Unauthenticated,i) { $hash->{helper}{PWD_NEEDED} = 1; Log3 $name, 3, "FB_CALLMONITOR ($name) - unable to login via TR-064, wrong user/password"; @@ -1345,7 +1345,7 @@ EOD my @phonebooks; # read list response (TR-064 id's: "0,1,2,...") - if($data =~ m/(.+?)<\/NewPhonebookList>/si) + if($data =~ m,(.+?),si) { @phonebooks = split(",",$1); Log3 $name, 3, "FB_CALLMONITOR ($name) - found ".scalar @phonebooks." phonebooks"; @@ -1405,14 +1405,14 @@ EOD Log3 $name, 5, "FB_CALLMONITOR ($name) - received response with phonebook description for id $_:\n$data"; - if($data =~ m/(.+?)<\/NewPhonebookName>.*?.*?pbid=(\d+)\D*?<\/NewPhonebookURL>/si) + if($data =~ m,(.+?).*?.*?pbid=(\d+)\D*?,si) { $phb_id = $2; $hash->{helper}{PHONEBOOK_NAMES}{$phb_id} = $1; Log3 $name, 4, "FB_CALLMONITOR ($name) - found phonebook: $1 - $2"; } - if($data =~ m/(.*?)<\/NewPhonebookURL>/i) + if($data =~ m,(.*?),i) { $hash->{helper}{PHONEBOOK_URL}{$phb_id} = $1; $hash->{helper}{PHONEBOOK_URL}{$phb_id} =~ s/&/&/g; @@ -1519,14 +1519,14 @@ sub FB_CALLMONITOR_identifyPhoneBooksViaWeb($;$) Log3 $name, 4, "FB_CALLMONITOR ($name) - phonebooks successfully identified"; - if($data =~ m/]*name="mainform"[^>]*>(.+?)<\/form>/s) + if($data =~ m,]*name="mainform"[^>]*>(.+?),s) { $data = $1; } delete($hash->{helper}{PHONEBOOK_NAMES}) if(exists($hash->{helper}{PHONEBOOK_NAMES})); - while($data =~ /]*for="uiBookid:(\d+)"[^>]*>\s*(.+?)\s*<\/label>/gcs) + while($data =~ m,]*for="uiBookid:(\d+)"[^>]*>\s*(.+?)\s*,gcs) { $hash->{helper}{PHONEBOOK_NAMES}{$1} = $2; Log3 $name, 4, "FB_CALLMONITOR ($name) - found phonebook: $2";