2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 09:16:53 +00:00

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
This commit is contained in:
markusbloch 2015-01-24 12:08:09 +00:00
parent 535d479b7f
commit 06fe0dd5b6
2 changed files with 7 additions and 19 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # 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. # 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: SYSMON: non-blocking
- changed: 71_YAMAHA_NP.pm: Provide entire http link to Player AlbumArt. - changed: 71_YAMAHA_NP.pm: Provide entire http link to Player AlbumArt.
- changed: 71_YAMAHA_NP.pm: Minor code improvements. - changed: 71_YAMAHA_NP.pm: Minor code improvements.

View File

@ -144,17 +144,10 @@ FB_CALLMONITOR_Get($@)
return "argument missing" if(int(@arguments) < 2); return "argument missing" if(int(@arguments) < 2);
if($arguments[1] eq "search") if($arguments[1] eq "search")
{
if($arguments[2] =~ /^\d+$/)
{ {
return FB_CALLMONITOR_reverseSearch($hash, $arguments[2]); return FB_CALLMONITOR_reverseSearch($hash, $arguments[2]);
} }
else else
{
return "given argument is not a telephone number";
}
}
else
{ {
return "unknown argument ".$arguments[1].", choose one of search"; return "unknown argument ".$arguments[1].", choose one of search";
} }
@ -687,7 +680,6 @@ sub FB_CALLMONITOR_readPhonebook($;$$)
($err, @lines) = FileRead($phonebook_file); ($err, @lines) = FileRead($phonebook_file);
if(defined($err) && $err) if(defined($err) && $err)
{ {
Log3 $name, 2, "FB_CALLMONITOR ($name) - could not read FritzBox phonebook file - $err"; Log3 $name, 2, "FB_CALLMONITOR ($name) - could not read FritzBox phonebook file - $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"; Log3 $name, 2, "FB_CALLMONITOR ($name) - read $count_contacts contact".($count_contacts == 1 ? "" : "s")." from $phonebook_file";
} }
} }
else else
{ {
Log3 $name, 4, "FB_CALLMONITOR ($name) - skipping local phonebook file"; Log3 $name, 4, "FB_CALLMONITOR ($name) - skipping local phonebook file";
} }
} }
@ -746,7 +734,6 @@ sub FB_CALLMONITOR_parsePhonebook($$)
if($contact =~ m/<realName>(.+?)<\/realName>/) if($contact =~ m/<realName>(.+?)<\/realName>/)
{ {
$contact_name = $1; $contact_name = $1;
Log3 $name, 4, "FB_CALLMONITOR ($name) - found $contact_name";
while($contact =~ m/<number[^>]*?type="([^<>"]+?)"[^<>]*?>([^<>"]+?)<\/number>/gs) while($contact =~ m/<number[^>]*?type="([^<>"]+?)"[^<>]*?>([^<>"]+?)<\/number>/gs)
{ {
@ -754,7 +741,6 @@ sub FB_CALLMONITOR_parsePhonebook($$)
{ {
$number = $2; $number = $2;
$number =~ s/^\+\d\d/0/g; # quick'n'dirty fix in case of international number format. $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 =~ /@/); $number =~ s/\s//g if($number =~ /@/);
if(not $number =~ /^0/ and not $number =~ /@/ and $area_code ne "") if(not $number =~ /^0/ and not $number =~ /@/ and $area_code ne "")
@ -764,6 +750,7 @@ sub FB_CALLMONITOR_parsePhonebook($$)
} }
} }
$count_contacts++; $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})); $hash->{helper}{PHONEBOOK}{$number} = FB_CALLMONITOR_html2txt($contact_name) if(not defined($hash->{helper}{PHONEBOOK}{$number}));
undef $number; undef $number;
} }