From 58d144cc23b8dd9464a04f1764d1610f124a4854 Mon Sep 17 00:00:00 2001 From: justme1968 Date: Mon, 14 Jul 2014 10:21:15 +0000 Subject: [PATCH] allow user and password as perl expression git-svn-id: https://svn.fhem.de/fhem/trunk@6252 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/32_mailcheck.pm | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 5c6fffc2a..8cdece604 100644 --- a/fhem/CHANGED +++ b/fhem/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. + - 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) diff --git a/fhem/FHEM/32_mailcheck.pm b/fhem/FHEM/32_mailcheck.pm index a6cee1584..68d22b4ef 100755 --- a/fhem/FHEM/32_mailcheck.pm +++ b/fhem/FHEM/32_mailcheck.pm @@ -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($)