From 06fe0dd5b670cff68a354beff86befda347460b9 Mon Sep 17 00:00:00 2001 From: markusbloch <> Date: Sat, 24 Jan 2015 12:08:09 +0000 Subject: [PATCH] FB_CALLMONITOR: allow chars in phone numbers for reverse search (Forum #32646) git-svn-id: https://svn.fhem.de/fhem/trunk@7687 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/72_FB_CALLMONITOR.pm | 25 ++++++------------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 14f476f66..6c549ca57 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - changed: FB_CALLMONITOR: allow chars in phone numbers for reverse search - changed: SYSMON: non-blocking - changed: 71_YAMAHA_NP.pm: Provide entire http link to Player AlbumArt. - changed: 71_YAMAHA_NP.pm: Minor code improvements. diff --git a/fhem/FHEM/72_FB_CALLMONITOR.pm b/fhem/FHEM/72_FB_CALLMONITOR.pm index d6faf068f..fb896784d 100755 --- a/fhem/FHEM/72_FB_CALLMONITOR.pm +++ b/fhem/FHEM/72_FB_CALLMONITOR.pm @@ -145,18 +145,11 @@ FB_CALLMONITOR_Get($@) if($arguments[1] eq "search") { - if($arguments[2] =~ /^\d+$/) - { - return FB_CALLMONITOR_reverseSearch($hash, $arguments[2]); - } - else - { - return "given argument is not a telephone number"; - } + return FB_CALLMONITOR_reverseSearch($hash, $arguments[2]); } else { - return "unknown argument ".$arguments[1].", choose one of search"; + return "unknown argument ".$arguments[1].", choose one of search"; } } @@ -685,8 +678,7 @@ sub FB_CALLMONITOR_readPhonebook($;$$) { $phonebook_file = AttrVal($name, "reverse-search-phonebook-file", "/var/flash/phonebook") unless(defined($phonebook_file)); - ($err, @lines) = FileRead($phonebook_file); - + ($err, @lines) = FileRead($phonebook_file); if(defined($err) && $err) { @@ -709,15 +701,11 @@ sub FB_CALLMONITOR_readPhonebook($;$$) { Log3 $name, 2, "FB_CALLMONITOR ($name) - read $count_contacts contact".($count_contacts == 1 ? "" : "s")." from $phonebook_file"; } - } else { Log3 $name, 4, "FB_CALLMONITOR ($name) - skipping local phonebook file"; } - - - } @@ -738,7 +726,7 @@ sub FB_CALLMONITOR_parsePhonebook($$) if($phonebook =~ // and $phonebook =~ //) { - + while($phonebook =~ m/]*>(.+?)<\/contact>/gs) { $contact = $1; @@ -746,15 +734,13 @@ sub FB_CALLMONITOR_parsePhonebook($$) if($contact =~ m/(.+?)<\/realName>/) { $contact_name = $1; - Log3 $name, 4, "FB_CALLMONITOR ($name) - found $contact_name"; - + while($contact =~ m/]*?type="([^<>"]+?)"[^<>]*?>([^<>"]+?)<\/number>/gs) { if($1 ne "intern" and $1 ne "memo") { $number = $2; $number =~ s/^\+\d\d/0/g; # quick'n'dirty fix in case of international number format. - $number =~ s/\D//g unless($number =~ /@/); $number =~ s/\s//g if($number =~ /@/); if(not $number =~ /^0/ and not $number =~ /@/ and $area_code ne "") @@ -764,6 +750,7 @@ sub FB_CALLMONITOR_parsePhonebook($$) } } $count_contacts++; + Log3 $name, 4, "FB_CALLMONITOR ($name) - found $contact_name with number $number"; $hash->{helper}{PHONEBOOK}{$number} = FB_CALLMONITOR_html2txt($contact_name) if(not defined($hash->{helper}{PHONEBOOK}{$number})); undef $number; }