allow user and password as perl expression
git-svn-id: https://svn.fhem.de/fhem/trunk@6252 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.
|
||||
# Do not insert empty lines here, update check depends on it.
|
||||
- feature: mailcheck: allow user and pssword as perl expression
|
||||
- feature: netatmo: support for public stations
|
||||
- feature: PRESENCE: new set command "powerOn" to execute a Perl function
|
||||
which power on the checked device (given via attribute)
|
||||
|
||||
@@ -66,13 +66,35 @@ mailcheck_Define($$)
|
||||
my $password = $a[4];
|
||||
my $folder = $a[5];
|
||||
|
||||
if( $user =~ m/^{.*}$/ ) {
|
||||
my $NAME = $name;
|
||||
my $HOST = $host;
|
||||
my $u = eval $user;
|
||||
if( $@ ) {
|
||||
Log3 $name, 2, $name .": ". $user .": ". $@;
|
||||
}
|
||||
$user = $u if( $u );
|
||||
}
|
||||
|
||||
if( $password =~ m/^{.*}$/ ) {
|
||||
my $NAME = $name;
|
||||
my $HOST = $host;
|
||||
my $USER = $user;
|
||||
my $p = eval $password;
|
||||
if( $@ ) {
|
||||
Log3 $name, 2, $name .": ". $password .": ". $@;
|
||||
}
|
||||
$password = $p if( $p );
|
||||
}
|
||||
Log 3, $password;
|
||||
|
||||
$hash->{tag} = undef;
|
||||
|
||||
$hash->{NAME} = $name;
|
||||
|
||||
$hash->{Host} = $host;
|
||||
$hash->{User} = $user;
|
||||
$hash->{helper}{PASS} = $password;
|
||||
$hash->{helper}{user} = $user;
|
||||
$hash->{helper}{password} = $password;
|
||||
|
||||
$hash->{Folder} = "INBOX";
|
||||
$hash->{Folder} = $folder if( $folder );
|
||||
@@ -133,8 +155,8 @@ mailcheck_Connect($)
|
||||
my $client = Mail::IMAPClient->new(
|
||||
Socket => $socket,
|
||||
KeepAlive => 'true',
|
||||
User => $hash->{User},
|
||||
Password => $hash->{helper}{PASS},
|
||||
User => $hash->{helper}{user},
|
||||
Password => $hash->{helper}{password},
|
||||
);
|
||||
|
||||
$client->Debug(AttrVal($name, "debug", 0)) if( $client );
|
||||
@@ -462,12 +484,15 @@ mailcheck_Read($)
|
||||
<ul>
|
||||
<code>define <name> mailcheck <host> <user> <password> [<folder>]</code><br>
|
||||
<br>
|
||||
<user> and <li><password> can be of the form {perl-code}. no spaces are allowed. for both evals $NAME and $HOST is set to the name and host of the mailcheck device and $USER is set to the user in the password eval.
|
||||
<br>
|
||||
|
||||
Defines a mailcheck device.<br><br>
|
||||
|
||||
Examples:
|
||||
<ul>
|
||||
<code>define mailcheck mailcheck imap.mail.me.com x.y@me.com</code><br>
|
||||
<code>define mailcheck mailcheck imap.mail.me.com x.y@me.com myPassword</code><br>
|
||||
<code>define mailcheck mailcheck imap.mail.me.com {"x.y@me.com"} {myPasswordOfAccount($USER)}</code><br>
|
||||
</ul>
|
||||
</ul><br>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user