diff --git a/fhem/configDB.pm b/fhem/configDB.pm index 0b6e006dd..7f4eed775 100644 --- a/fhem/configDB.pm +++ b/fhem/configDB.pm @@ -1,4 +1,4 @@ -# $Id$ +# $Id: configDB.pm 7696 2015-01-24 18:16:54Z betateilchen $ ############################################################################## # @@ -140,7 +140,7 @@ sub __cfgDB_Diff($$$$); sub _cfgDB_InsertLine($$$$); sub _cfgDB_Execute($@); sub _cfgDB_Filedelete($); -sub _cfgDB_Fileexport($); +sub _cfgDB_Fileexport($;$); sub _cfgDB_Filelist(;$); sub _cfgDB_Info(); sub _cfgDB_Migrate(); @@ -568,7 +568,7 @@ sub cfgDB_MigrationImport() { # return SVN Id, called by fhem's CommandVersion sub cfgDB_svnId() { - return "# ".'$Id$' + return "# ".'$Id: configDB.pm 7696 2015-01-24 18:16:54Z betateilchen $' } # return filelist depending on directory and regexp @@ -975,8 +975,8 @@ sub _cfgDB_Filedelete($) { } # export file from database to filesystem -sub _cfgDB_Fileexport($) { - my ($filename) = @_; +sub _cfgDB_Fileexport($;$) { + my ($filename,$raw) = @_; my $fhem_dbh = _cfgDB_Connect; my $sth = $fhem_dbh->prepare( "SELECT content FROM fhembinfilesave WHERE filename = '$filename'" ); $sth->execute(); @@ -991,7 +991,8 @@ sub _cfgDB_Fileexport($) { $sth->finish(); $fhem_dbh->disconnect(); - return "$counter bytes written from database into file $filename"; + return "$counter bytes written from database into file $filename" unless $raw; + return ($blobContent,$counter); } # import file into database diff --git a/fhem/contrib/InfoPanel/55_InfoPanel.pm b/fhem/contrib/InfoPanel/55_InfoPanel.pm index ab31c9490..fd1ea6163 100644 --- a/fhem/contrib/InfoPanel/55_InfoPanel.pm +++ b/fhem/contrib/InfoPanel/55_InfoPanel.pm @@ -80,7 +80,7 @@ sub InfoPanel_Initialize($) { $hash->{DefFn} = "btIP_Define"; $hash->{UndefFn} = "btIP_Undef"; #$hash->{AttrFn} = "btIP_Attr"; - $hash->{AttrList} = "autoreload:1,0 bg bgcolor refresh size title tmin"; + $hash->{AttrList} = "disable:0,1,toggle autoreload:1,0 bg bgcolor refresh size title tmin"; $hash->{SetFn} = "btIP_Set"; $hash->{NotifyFn} = "btIP_Notify"; @@ -272,24 +272,24 @@ sub btIP_itemImg { $id = ($id eq '-') ? createUniqueId() : $id; return unless(defined($arg)); return if($arg eq ""); - my ($data,$info,$width,$height,$mimetype,$output); + my ($counter,$data,$info,$width,$height,$mimetype,$output); if($srctype eq 'file') { - my (@d,$err); - $err = ""; - - Log3(undef,4,"InfoPanel img name: $arg"); - ($err,@d) = FileRead($arg); - if($err && configDBUsed()) { - # not found in database, try to read from filesystem - Log3(undef,4,"Infopanel forced read $arg"); - $err = undef; - ($err,@d) = FileRead({FileName => $arg, ForceType =>'file'}); - Log3(undef,4,"Infopanel: forced read error file: $arg") if $err; - Log3(undef,4,"Infopanel: forced read found: $arg") if !$err; - } - $data = join("",@d) unless $err; + Log3(undef,4,"InfoPanel: looking for img $arg"); + if(configDBUsed()){ + Log3(undef,4,"InfoPanel: reading from configDB"); + ($data,$counter) = _cfgDB_Fileexport($arg,1); + } + + if(!$counter) { + Log3(undef,4,"InfoPanel: reading from filesystem"); + my $length = -s "$arg"; + open(GRAFIK, "<", $arg) or die("File not found $!"); + binmode(GRAFIK); + $counter = read(GRAFIK, $data, $length); + close(GRAFIK); + } } elsif ($srctype eq "url" || $srctype eq "urlq") { if($srctype eq "url") { $data= GetFileFromURL($arg,3,undef,1); @@ -303,8 +303,9 @@ sub btIP_itemImg { return ""; } - ($width,$height,$data) = _btIP_imgData($data,$scale); - $output = "\n"; + ($width,$height,$mimetype,$data) = _btIP_imgData($data,$scale); + $output = "\n"; + $output .= "\n"; return $output; } @@ -316,7 +317,7 @@ sub _btIP_imgData { ($width,$height)= _btIP_imgRescale($width,$height,$scale) unless $scale eq '1'; my $mimetype = $info->{file_media_type}; my $data = "data:$mimetype;base64,".encode_base64($arg); - return ($width,$height,$data); + return ($width,$height,$mimetype,$data); } sub _btIP_imgRescale { @@ -515,13 +516,13 @@ sub btIP_returnSVG($) { my ($width,$height)= split(/x/, AttrVal($name,"size","800x600")); my $bgcolor = AttrVal($name,'bgcolor','000000'); - my $svg = ""; + our $svg = ""; eval { $svg = "\n\n\n"; - $svg .= btIP_evalLayout($svg, $name, $defs{$name}{fhem}{layout}); + $svg = btIP_evalLayout($svg, $name, $defs{$name}{fhem}{layout}); $defs{$name}{STATE} = localtime();