mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
FB_CALLMONITOR: use standard file read/write function to support use of configDb
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@7456 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
20924a8102
commit
60c9be5edb
1
CHANGED
1
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.
|
||||
- change: FB_CALLMONITOR: use standard file read/write function to support use of configDb
|
||||
- bugfix: FB_CALLMONITOR: fix phonebook file read when using configDb (Forum #30244)
|
||||
- feature: 70_XBMC: added commands: openmovieid, openepisodeid, addon, jsonraw (thanks to siggi85)
|
||||
- fix: 70_XBMC: made fork attribute to close file handles correctly
|
||||
|
@ -600,6 +600,8 @@ sub FB_CALLMONITOR_writeToCache($$$)
|
||||
my ($hash, $number, $txt) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
my $file = AttrVal($name, "reverse-search-cache-file", "");
|
||||
my $err;
|
||||
my @cachefile;
|
||||
|
||||
$file =~ s/(^\s+|\s+$)//g;
|
||||
|
||||
@ -608,14 +610,17 @@ sub FB_CALLMONITOR_writeToCache($$$)
|
||||
if($file ne "")
|
||||
{
|
||||
Log3 $name, 4, "FB_CALLMONITOR ($name) - opening cache file $file for writing $number ($txt)";
|
||||
if(open(CACHEFILE, ">>$file"))
|
||||
|
||||
foreach my $key (keys %{$hash->{helper}{CACHE}})
|
||||
{
|
||||
print CACHEFILE "$number|$txt\n";
|
||||
close(CACHEFILE);
|
||||
push @cachefile, "$key|".$hash->{helper}{CACHE}{$key};
|
||||
}
|
||||
else
|
||||
|
||||
$err = FileWrite($file,@cachefile);
|
||||
|
||||
if(defined($err) && $err)
|
||||
{
|
||||
Log3 $name, 2, "FB_CALLMONITOR ($name) - could not open cache file for writing";
|
||||
Log3 $name, 2, "FB_CALLMONITOR ($name) - could not write cache file: $err";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -676,8 +681,6 @@ sub FB_CALLMONITOR_readPhonebook($;$$)
|
||||
return "Could not read FritzBox phonebook file - $err";
|
||||
}
|
||||
|
||||
|
||||
|
||||
$phonebook = join("", @lines);
|
||||
|
||||
Log3 $name, 2, "FB_CALLMONITOR ($name) - found FritzBox phonebook $phonebook_file";
|
||||
@ -776,7 +779,7 @@ sub FB_CALLMONITOR_loadCacheFile($;$)
|
||||
my @tmpline;
|
||||
my $count_contacts;
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
my $err;
|
||||
$file = AttrVal($hash->{NAME}, "reverse-search-cache-file", "") unless(defined($file));
|
||||
$file =~ s/(^\s+|\s+$)//g;
|
||||
|
||||
@ -785,11 +788,11 @@ sub FB_CALLMONITOR_loadCacheFile($;$)
|
||||
delete($hash->{helper}{CACHE}) if(defined($hash->{helper}{CACHE}));
|
||||
|
||||
Log3 $hash->{NAME}, 3, "FB_CALLMONITOR ($name) - loading cache file $file";
|
||||
if(open(CACHEFILE, "$file"))
|
||||
{
|
||||
@cachefile = <CACHEFILE>;
|
||||
close(CACHEFILE);
|
||||
|
||||
($err, @cachefile) = FileRead($file);
|
||||
|
||||
unless(defined($err) and $err)
|
||||
{
|
||||
foreach my $line (@cachefile)
|
||||
{
|
||||
if(not $line =~ /^\s*$/)
|
||||
@ -809,7 +812,7 @@ sub FB_CALLMONITOR_loadCacheFile($;$)
|
||||
}
|
||||
else
|
||||
{
|
||||
Log3 $name, 3, "FB_CALLMONITOR ($name) - could not open cache file";
|
||||
Log3 $name, 3, "FB_CALLMONITOR ($name) - could not open cache file: $err";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user