summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGianni Ceccarelli <gianni.ceccarelli@broadbean.com>2018-02-05 17:39:43 +0000
committerGianni Ceccarelli <gianni.ceccarelli@broadbean.com>2018-02-05 17:39:43 +0000
commit899c6fbc3f522537fe05ae5bd360d8bb9a19e017 (patch)
tree3068e91c449707abab8990b041dd4ded6367bfc7 /lib
parentdzil works (diff)
downloadconfig-clawsmail-899c6fbc3f522537fe05ae5bd360d8bb9a19e017.tar.gz
config-clawsmail-899c6fbc3f522537fe05ae5bd360d8bb9a19e017.tar.bz2
config-clawsmail-899c6fbc3f522537fe05ae5bd360d8bb9a19e017.zip
update for Claws Mail 3.16
Diffstat (limited to 'lib')
-rw-r--r--lib/Config/ClawsMail.pm12
-rw-r--r--lib/Config/ClawsMail/Account.pm13
-rw-r--r--lib/Config/ClawsMail/PasswordStoreParser.pm16
3 files changed, 31 insertions, 10 deletions
diff --git a/lib/Config/ClawsMail.pm b/lib/Config/ClawsMail.pm
index decb99f..9c11636 100644
--- a/lib/Config/ClawsMail.pm
+++ b/lib/Config/ClawsMail.pm
@@ -3,6 +3,7 @@ use Moo;
# VERSION
use Config::INI::Reader;
use Config::ClawsMail::Account;
+use Config::ClawsMail::PasswordStoreParser;
use Types::Standard qw(HashRef InstanceOf);
use Path::Tiny;
use namespace::clean;
@@ -26,9 +27,16 @@ sub BUILDARGS {
my $config_hash = Config::INI::Reader->read_file(
$config_file,
);
+ my $password_file = delete $args->{password_file}
+ || path($ENV{HOME},'.claws-mail','passwordstorerc');
+ my $password_hash = Config::ClawsMail::PasswordStoreParser->read_file(
+ $password_file,
+ );
- for my $account_conf (values %{$config_hash}) {
- my $account = Config::ClawsMail::Account->new_from_config($account_conf);
+ for my $account_id (keys %{$config_hash}) {
+ my $account_conf = $config_hash->{$account_id};
+ my $password_conf = $password_hash->{$account_id};
+ my $account = Config::ClawsMail::Account->new_from_config($account_conf,$password_conf);
$args->{accounts}{$account->account_name} = $account;
}
diff --git a/lib/Config/ClawsMail/Account.pm b/lib/Config/ClawsMail/Account.pm
index 4f51273..6cd291f 100644
--- a/lib/Config/ClawsMail/Account.pm
+++ b/lib/Config/ClawsMail/Account.pm
@@ -21,8 +21,8 @@ has [qw(imap smtp)] => (
my @ssl_string=qw(no ssl starttls);
sub new_from_config {
- my ($class,$config) = @_;
- die "unhandled protocol" unless $config->{protocol} eq '3';
+ my ($class,$config,$password) = @_;
+ die "unhandled protocol" unless $config->{protocol} eq '1';
my $imap_server = Config::ClawsMail::Server->new({
host => $config->{receive_server},
@@ -34,7 +34,8 @@ sub new_from_config {
: scalar getservbyname('imap','tcp')
),
ssl => $ssl_string[$config->{ssl_imap}],
- %{$config}{qw(user_id password)},
+ %{$config}{qw(user_id)},
+ password => $password->{recv},
});
my $smtp_server = Config::ClawsMail::Server->new({
@@ -49,11 +50,7 @@ sub new_from_config {
ssl => $ssl_string[$config->{ssl_smtp}],
( $config->{use_smtp_auth} ? (
user_id => $config->{smtp_user_id} || $config->{user_id},
- password => (
- $config->{smtp_password} eq '!'
- ? $config->{password}
- : $config->{smtp_password}
- ),
+ password => $password->{send} || $password->{recv},
) : () ),
});
diff --git a/lib/Config/ClawsMail/PasswordStoreParser.pm b/lib/Config/ClawsMail/PasswordStoreParser.pm
new file mode 100644
index 0000000..227baa6
--- /dev/null
+++ b/lib/Config/ClawsMail/PasswordStoreParser.pm
@@ -0,0 +1,16 @@
+package Config::ClawsMail::PasswordStoreParser;
+use parent 'Config::INI::Reader';
+
+sub parse_section_header {
+ my ($head) = $_[1] =~ /^\s*\[\s*(.+?)\s*\]\s*$/
+ or return;
+ $head =~ s{account:}{Account: };
+ return $head;
+}
+
+sub parse_value_assignment {
+ return ($1, $2) if $_[1] =~ /^\s*([^\s\pC]+?)\s+(.*?)\s*$/;
+ return;
+}
+
+1;