mirror of
https://github.com/fhem/fhem-mirror.git
synced 2024-11-22 09:49:50 +00:00
SMUtils.pm: new version 1.27.3
git-svn-id: https://svn.fhem.de/fhem/trunk@29299 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
6f1d69bc05
commit
10f7630c79
@ -26,6 +26,7 @@
|
||||
#########################################################################################################################
|
||||
|
||||
# Version History
|
||||
# 1.27.3 26.10.2024 compatibility to SSCam V 9.12.0
|
||||
# 1.27.2 16.03.2024 change checkModVer text output
|
||||
# 1.27.1 04.12.2023 change checkModVer
|
||||
# 1.27.0 03.12.2023 new function checkModVer
|
||||
@ -59,7 +60,7 @@ use FHEM::SynoModules::ErrCodes qw(:all); # Erro
|
||||
use GPUtils qw( GP_Import GP_Export );
|
||||
use Carp qw(croak carp);
|
||||
|
||||
use version 0.77; our $VERSION = version->declare('1.27.2');
|
||||
use version 0.77; our $VERSION = version->declare('1.27.3');
|
||||
|
||||
use Exporter ('import');
|
||||
our @EXPORT_OK = qw(
|
||||
@ -1295,6 +1296,8 @@ sub login {
|
||||
|
||||
delete $hash->{HELPER}{SID};
|
||||
|
||||
$apiauthpath = 'webapi/entry.cgi' if($apiauthpath eq 'entry.cgi'); # compatibility SSCam >= V 9.12.0
|
||||
|
||||
Log3 ($name, 4, "$name - --- Begin Function login ---");
|
||||
|
||||
my ($success, $username, $password) = getCredentials($hash,0,"credentials",$sep); # Credentials abrufen
|
||||
@ -1322,12 +1325,12 @@ sub login {
|
||||
my $sid = AttrVal($name, "noQuotesForSID", 0) ? "sid" : qq{"sid"}; # sid in Quotes einschliessen oder nicht -> bei Problemen mit 402 - Permission denied
|
||||
|
||||
if (AttrVal($name,"session","DSM") eq "DSM") {
|
||||
$url = "$proto://$serveraddr:$serverport/webapi/$apiauthpath?api=$apiauth&version=$apiauthver&method=Login&account=$username&passwd=$password&format=$sid";
|
||||
$urlwopw = "$proto://$serveraddr:$serverport/webapi/$apiauthpath?api=$apiauth&version=$apiauthver&method=Login&account=$username&passwd=*****&format=$sid";
|
||||
$url = "$proto://$serveraddr:$serverport/$apiauthpath?api=$apiauth&version=$apiauthver&method=Login&account=$username&passwd=$password&format=$sid";
|
||||
$urlwopw = "$proto://$serveraddr:$serverport/$apiauthpath?api=$apiauth&version=$apiauthver&method=Login&account=$username&passwd=*****&format=$sid";
|
||||
}
|
||||
else {
|
||||
$url = "$proto://$serveraddr:$serverport/webapi/$apiauthpath?api=$apiauth&version=$apiauthver&method=Login&account=$username&passwd=$password&session=SurveillanceStation&format=$sid";
|
||||
$urlwopw = "$proto://$serveraddr:$serverport/webapi/$apiauthpath?api=$apiauth&version=$apiauthver&method=Login&account=$username&passwd=*****&session=SurveillanceStation&format=$sid";
|
||||
$url = "$proto://$serveraddr:$serverport/$apiauthpath?api=$apiauth&version=$apiauthver&method=Login&account=$username&passwd=$password&session=SurveillanceStation&format=$sid";
|
||||
$urlwopw = "$proto://$serveraddr:$serverport/$apiauthpath?api=$apiauth&version=$apiauthver&method=Login&account=$username&passwd=*****&session=SurveillanceStation&format=$sid";
|
||||
}
|
||||
|
||||
my $printurl = AttrVal($name, "showPassInLog", 0) ? $url : $urlwopw;
|
||||
@ -1431,67 +1434,69 @@ return login($hash,$apiref,$fret,$fretarg,$sep);
|
||||
# $sep = Separator für split Credentials in getCredentials, default ":"
|
||||
###################################################################################
|
||||
sub logout {
|
||||
my $hash = shift // carp $carpnohash && return;
|
||||
my $apiref = shift // carp $carpnoapir && return;
|
||||
my $sep = shift // $splitdef;
|
||||
my $hash = shift // carp $carpnohash && return;
|
||||
my $apiref = shift // carp $carpnoapir && return;
|
||||
my $sep = shift // $splitdef;
|
||||
|
||||
my $name = $hash->{NAME};
|
||||
my $serveraddr = $hash->{SERVERADDR};
|
||||
my $serverport = $hash->{SERVERPORT};
|
||||
my $proto = $hash->{PROTOCOL};
|
||||
my $type = $hash->{TYPE};
|
||||
my $name = $hash->{NAME};
|
||||
my $serveraddr = $hash->{SERVERADDR};
|
||||
my $serverport = $hash->{SERVERPORT};
|
||||
my $proto = $hash->{PROTOCOL};
|
||||
my $type = $hash->{TYPE};
|
||||
|
||||
my $apiauth = $apiref->{AUTH}{NAME};
|
||||
my $apiauthpath = $apiref->{AUTH}{PATH};
|
||||
my $apiauthver = $apiref->{AUTH}{VER};
|
||||
|
||||
my $sid = delete $hash->{HELPER}{SID} // q{};
|
||||
|
||||
my $url;
|
||||
|
||||
Log3 ($name, 4, "$name - --- Start Synology logout ---");
|
||||
|
||||
my ($success, $username) = getCredentials($hash,0,"credentials",$sep);
|
||||
|
||||
if (!$sid) {
|
||||
if ($username) {
|
||||
Log3 ($name, 2, qq{$name - User "$username" has no valid session, logout is cancelled});
|
||||
}
|
||||
|
||||
readingsBeginUpdate ($hash);
|
||||
readingsBulkUpdate ($hash, "Errorcode", "none");
|
||||
readingsBulkUpdate ($hash, "Error", "none");
|
||||
readingsBulkUpdate ($hash, "state", "logout done");
|
||||
readingsEndUpdate ($hash, 1);
|
||||
|
||||
delActiveToken ($hash) if($type eq "SSCam"); # ausgeführte Funktion ist erledigt (auch wenn logout nicht erfolgreich), Freigabe Funktionstoken
|
||||
CancelDelayedShutdown ($name);
|
||||
return;
|
||||
}
|
||||
|
||||
my $timeout = AttrVal($name,"timeout",60);
|
||||
$timeout = 60 if($timeout < 60);
|
||||
Log3 ($name, 5, "$name - Call logout will be done with timeout value: $timeout s");
|
||||
my $apiauth = $apiref->{AUTH}{NAME};
|
||||
my $apiauthpath = $apiref->{AUTH}{PATH};
|
||||
my $apiauthver = $apiref->{AUTH}{VER};
|
||||
|
||||
if (AttrVal($name,"session","DSM") eq "DSM") {
|
||||
$url = "$proto://$serveraddr:$serverport/webapi/$apiauthpath?api=$apiauth&version=$apiauthver&method=Logout&_sid=$sid";
|
||||
}
|
||||
else {
|
||||
$url = "$proto://$serveraddr:$serverport/webapi/$apiauthpath?api=$apiauth&version=$apiauthver&method=Logout&session=SurveillanceStation&_sid=$sid";
|
||||
}
|
||||
|
||||
my $param = {
|
||||
url => $url,
|
||||
timeout => $timeout,
|
||||
hash => $hash,
|
||||
sid => $sid,
|
||||
username => $username,
|
||||
method => "GET",
|
||||
header => "Accept: application/json",
|
||||
callback => \&_logoutReturn
|
||||
};
|
||||
my $sid = delete $hash->{HELPER}{SID} // q{};
|
||||
|
||||
HttpUtils_NonblockingGet ($param);
|
||||
my $url;
|
||||
|
||||
$apiauthpath = 'webapi/entry.cgi' if($apiauthpath eq 'entry.cgi'); # compatibility SSCam >= V 9.12.0
|
||||
|
||||
Log3 ($name, 4, "$name - --- Start Synology logout ---");
|
||||
|
||||
my ($success, $username) = getCredentials($hash,0,"credentials",$sep);
|
||||
|
||||
if (!$sid) {
|
||||
if ($username) {
|
||||
Log3 ($name, 2, qq{$name - User "$username" has no valid session, logout is cancelled});
|
||||
}
|
||||
|
||||
readingsBeginUpdate ($hash);
|
||||
readingsBulkUpdate ($hash, "Errorcode", "none");
|
||||
readingsBulkUpdate ($hash, "Error", "none");
|
||||
readingsBulkUpdate ($hash, "state", "logout done");
|
||||
readingsEndUpdate ($hash, 1);
|
||||
|
||||
delActiveToken ($hash) if($type eq "SSCam"); # ausgeführte Funktion ist erledigt (auch wenn logout nicht erfolgreich), Freigabe Funktionstoken
|
||||
CancelDelayedShutdown ($name);
|
||||
return;
|
||||
}
|
||||
|
||||
my $timeout = AttrVal($name,"timeout",60);
|
||||
$timeout = 60 if($timeout < 60);
|
||||
Log3 ($name, 5, "$name - Call logout will be done with timeout value: $timeout s");
|
||||
|
||||
if (AttrVal($name,"session","DSM") eq "DSM") {
|
||||
$url = "$proto://$serveraddr:$serverport/$apiauthpath?api=$apiauth&version=$apiauthver&method=Logout&_sid=$sid";
|
||||
}
|
||||
else {
|
||||
$url = "$proto://$serveraddr:$serverport/$apiauthpath?api=$apiauth&version=$apiauthver&method=Logout&session=SurveillanceStation&_sid=$sid";
|
||||
}
|
||||
|
||||
my $param = {
|
||||
url => $url,
|
||||
timeout => $timeout,
|
||||
hash => $hash,
|
||||
sid => $sid,
|
||||
username => $username,
|
||||
method => "GET",
|
||||
header => "Accept: application/json",
|
||||
callback => \&_logoutReturn
|
||||
};
|
||||
|
||||
HttpUtils_NonblockingGet ($param);
|
||||
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user