02_HTTPSRV: support tabletui (Forum #37232)
git-svn-id: https://svn.fhem.de/fhem/trunk@8933 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -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.
|
||||||
|
- feature: 02_HTTPSRV: support tabletui (Forum #37232)
|
||||||
- bugfix: SOMFY: Only send stop if position changed
|
- bugfix: SOMFY: Only send stop if position changed
|
||||||
improved timing for position update
|
improved timing for position update
|
||||||
fix typos (go-my instead of go_my)
|
fix typos (go-my instead of go_my)
|
||||||
|
|||||||
@@ -13,16 +13,27 @@ use warnings;
|
|||||||
use vars qw(%data);
|
use vars qw(%data);
|
||||||
use HttpUtils;
|
use HttpUtils;
|
||||||
|
|
||||||
|
my $HTTPSRV_matchlink = "^\/?(([^\/]*(\/[^\/]+)*)\/?)\$";
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
sub
|
sub
|
||||||
HTTPSRV_addExtension($$$$) {
|
HTTPSRV_addExtension($$$$) {
|
||||||
my ($name,$func,$link,$friendlyname)= @_;
|
my ($name,$func,$link,$friendlyname)= @_;
|
||||||
|
|
||||||
my $url = "/$link";
|
# do some cleanup on link/url
|
||||||
Log3 $name, 3, "Registering HTTPSRV $name for URL $url...";
|
# link should really show the link as expected to be called (might include trailing / but no leading /)
|
||||||
|
# url should only contain the directory piece with a leading / but no trailing /
|
||||||
|
# $1 is complete link without potentially leading /
|
||||||
|
# $2 is complete link without potentially leading / and trailing /
|
||||||
|
$link =~ /$HTTPSRV_matchlink/;
|
||||||
|
|
||||||
|
my $url = "/".$2;
|
||||||
|
my $modlink = $1;
|
||||||
|
|
||||||
|
Log3 $name, 3, "Registering HTTPSRV $name for URL $url and assigned link $modlink ...";
|
||||||
$data{FWEXT}{$url}{deviceName}= $name;
|
$data{FWEXT}{$url}{deviceName}= $name;
|
||||||
$data{FWEXT}{$url}{FUNC} = $func;
|
$data{FWEXT}{$url}{FUNC} = $func;
|
||||||
$data{FWEXT}{$url}{LINK} = $link;
|
$data{FWEXT}{$url}{LINK} = $modlink;
|
||||||
$data{FWEXT}{$url}{NAME} = $friendlyname;
|
$data{FWEXT}{$url}{NAME} = $friendlyname;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +41,15 @@ sub
|
|||||||
HTTPSRV_removeExtension($) {
|
HTTPSRV_removeExtension($) {
|
||||||
my ($link)= @_;
|
my ($link)= @_;
|
||||||
|
|
||||||
my $url = "/$link";
|
# do some cleanup on link/url
|
||||||
|
# link should really show the link as expected to be called (might include trailing / but no leading /)
|
||||||
|
# url should only contain the directory piece with a leading / but no trailing /
|
||||||
|
# $1 is complete link without potentially leading /
|
||||||
|
# $2 is complete link without potentially leading / and trailing /
|
||||||
|
$link =~ /$HTTPSRV_matchlink/;
|
||||||
|
|
||||||
|
my $url = "/".$2;
|
||||||
|
|
||||||
my $name= $data{FWEXT}{$url}{deviceName};
|
my $name= $data{FWEXT}{$url}{deviceName};
|
||||||
Log3 $name, 3, "Unregistering HTTPSRV $name for URL $url...";
|
Log3 $name, 3, "Unregistering HTTPSRV $name for URL $url...";
|
||||||
delete $data{FWEXT}{$url};
|
delete $data{FWEXT}{$url};
|
||||||
@@ -70,6 +89,8 @@ HTTPSRV_Define($$) {
|
|||||||
$hash->{fhem}{directory}= $directory;
|
$hash->{fhem}{directory}= $directory;
|
||||||
$hash->{fhem}{friendlyname}= $friendlyname;
|
$hash->{fhem}{friendlyname}= $friendlyname;
|
||||||
|
|
||||||
|
Log3 $name, 3, "$name: new ext defined infix:$infix: dir:$directory:";
|
||||||
|
|
||||||
HTTPSRV_addExtension($name, "HTTPSRV_CGI", $infix, $friendlyname);
|
HTTPSRV_addExtension($name, "HTTPSRV_CGI", $infix, $friendlyname);
|
||||||
|
|
||||||
$hash->{STATE} = $name;
|
$hash->{STATE} = $name;
|
||||||
@@ -114,17 +135,26 @@ sub HTTPSRV_CGI() {
|
|||||||
|
|
||||||
my ($request) = @_; # /$infix/filename
|
my ($request) = @_; # /$infix/filename
|
||||||
|
|
||||||
|
# Debug "request= $request";
|
||||||
|
|
||||||
|
# Match request first without trailing / in the link part
|
||||||
if($request =~ m,^(/[^/]+)(/(.*)?)?$,) {
|
if($request =~ m,^(/[^/]+)(/(.*)?)?$,) {
|
||||||
my $link= $1;
|
my $link= $1;
|
||||||
my $filename= $3;
|
my $filename= $3;
|
||||||
my $name;
|
my $name;
|
||||||
|
|
||||||
# get device name
|
# If FWEXT not found for this make a second try with a trailing slash in the link part
|
||||||
$name= $data{FWEXT}{$link}{deviceName} if($data{FWEXT}{$link});
|
if(! $data{FWEXT}{$link}) {
|
||||||
|
$link = $link."/";
|
||||||
|
return("text/plain; charset=utf-8", "Illegal request: $request") if(! $data{FWEXT}{$link});
|
||||||
|
}
|
||||||
|
|
||||||
#Debug "link= $link";
|
# get device name
|
||||||
#Debug "filename= $filename";
|
$name= $data{FWEXT}{$link}{deviceName};
|
||||||
#Debug "name= $name";
|
|
||||||
|
# Debug "link= $link";
|
||||||
|
# Debug "filename= $filename";
|
||||||
|
# Debug "name= $name";
|
||||||
|
|
||||||
# return error if no such device
|
# return error if no such device
|
||||||
return("text/plain; charset=utf-8", "No HTTPSRV device for $link") unless($name);
|
return("text/plain; charset=utf-8", "No HTTPSRV device for $link") unless($name);
|
||||||
@@ -146,6 +176,7 @@ sub HTTPSRV_CGI() {
|
|||||||
|
|
||||||
my $directory= $defs{$name}{fhem}{directory};
|
my $directory= $defs{$name}{fhem}{directory};
|
||||||
$filename= "$directory/$filename";
|
$filename= "$directory/$filename";
|
||||||
|
#Debug "read filename= $filename";
|
||||||
my @contents;
|
my @contents;
|
||||||
if(open(INPUTFILE, $filename)) {
|
if(open(INPUTFILE, $filename)) {
|
||||||
binmode(INPUTFILE);
|
binmode(INPUTFILE);
|
||||||
|
|||||||
Reference in New Issue
Block a user