# See COPYING file for license details.
# See AUTHORS file for a complete list of contributors.
#
-
-binmode STDOUT, ":encoding(utf8)";
-
+package Clawsker;
use 5.010_000;
use strict;
use utf8;
use Locale::gettext;
use Encode;
use Digest::MD5 qw(md5_hex);
-use Getopt::Long;
+use Getopt::Long qw(GetOptionsFromArray);
my $NAME = 'clawsker';
my $PREFIX = '@PREFIX@';
my $CLAWSV = undef;
my $main_window = undef;
-my $locale = (defined($ENV{LC_MESSAGES}) ? $ENV{LC_MESSAGES} : $ENV{LANG});
-$locale = "C" unless defined($locale);
-setlocale (LC_ALL, $locale);
-bindtextdomain ($NAME, catdir ($PREFIX, 'share', 'locale'));
-textdomain ($NAME);
+sub initialise {
+ binmode STDOUT, ":encoding(utf8)";
+ my $locale = (defined($ENV{LC_MESSAGES}) ? $ENV{LC_MESSAGES} : $ENV{LANG});
+ $locale = "C" unless defined($locale);
+ setlocale (LC_ALL, $locale);
+ bindtextdomain ($NAME, catdir ($PREFIX, 'share', 'locale'));
+ textdomain ($NAME);
+}
sub _ {
my $str = shift;
h_acc_gtls_set => _('Enables using user provided GnuTLS priority string.'),
l_acc_gtls_pri => _('GnuTLS priority'),
h_acc_gtls_pri => _('Value to use as GnuTLS priority string if custom priority check is enabled. Otherwise this value is ignored.'),
+ l_acc_tls_sni => _('Use TLS SNI extension'),
+ h_acc_tls_sni => _('Enables sending your hostname, if available, so the server can select the appropriate certificate for your domain. Useful for servers which host multiple domains on the same IP address.'),
l_plu_gpg_alimit => _('Autocompletion limit'),
h_plu_gpg_alimit => _('Limits the number of addresses obtained from keyring through autocompletion. Use 0 to get all matches.'),
}
sub get_claws_version {
- $_ = which ('claws-mail');
- return "" unless defined $_; # not installed
- my $res = "";
- $_ = qx/$_ -v/;
- chomp;
- my @fver = split (/ /);
- die "Invalid version string" unless ($fver[2] eq "version");
- my @ver = split (/\./, $fver[3]);
- $res .= "$ver[0].";
- $res .= "$ver[1].";
- if ($ver[2] =~ /(\d+)git(\d+)/) {
- $res .= "$1.$2";
- }
- else {
- $res .= "$ver[2].0";
- }
- return $res;
+ my $cm_path = which ('claws-mail') or return ""; # not found
+ open my $ph, "-|", $cm_path, "-v" or return ""; # no pipe
+ chomp (my $v = <$ph>);
+ close $ph;
+ # Claws Mail version 3.17.2git17
+ $v =~ m/\bversion\s+(\d[\w.]+)/ or die "Invalid version string: '$v'";
+ my $cmv = $1;
+ my @ver = split m/(?:\.|git)/, $cmv;
+ @ver < 4 and push @ver, 0;
+ return join ".", @ver;
}
# data handlers and auxiliar functions
'3.9.0.181',
'0',
],
+ tls_sni => [
+ 'use_tls_sni',
+ $xl::s{l_acc_tls_sni},
+ $xl::s{h_acc_tls_sni},
+ 'bool',
+ '3.17.2.16',
+ '0',
+ ],
);
sub new_account_subpage($) {
my ($akey) = @_;
- return new_grid_pack (1, 3, [
+ return new_grid_pack (1, 5, [
[ _('GnuTLS priority') ],
[ new_check_button_for (\%pr::acc, 'tls_set', $ACHPVALUE{$akey}) ],
- [ new_text_box_for_nchar (\%pr::acc, 'tls_pri', $ACHPVALUE{$akey}) ]
+ [ new_text_box_for_nchar (\%pr::acc, 'tls_pri', $ACHPVALUE{$akey}) ],
+ [ _('Server Name Indication') ],
+ [ new_check_button_for (\%pr::acc, 'tls_sni', $ACHPVALUE{$akey}) ],
]);
}
}
sub print_version() {
- print $xl::s{about_title} . "\n";
- print $xl::s{about_version} . " $VERSION\n";
+ say $xl::s{about_title};
+ say _('Version:') . " $VERSION";
my $v = get_toolkit_versions ();
if ($v->{'glib-b'}) {
- print _("Perl-GLib version {glibv}, built for {glibb}, running with {glibr}.",
+ say _("Perl-GLib version {glibv}, built for {glibb}, running with {glibr}.",
glibv => $v->{'glib'},
glibb => $v->{'glib-b'},
glibr => $v->{'glib-r'});
} else {
- print _("Perl-GLib version {glibv}.", glibv => $v->{'glib'});
+ say _("Perl-GLib version {glibv}.", glibv => $v->{'glib'});
}
- print "\n";
if ($v->{'gtk-b'}) {
- print _("Perl-GTK3 version {gtkv}, built for {gtkb}, running with {gtkr}.",
+ say _("Perl-GTK3 version {gtkv}, built for {gtkb}, running with {gtkr}.",
gtkv => $v->{'gtk'},
gtkb => $v->{'gtk-b'},
gtkr => $v->{'gtk-r'});
} else {
- print _("Perl-GTK3 version {gtkv}.", gtkv => $v->{'gtk'});
+ say _("Perl-GTK3 version {gtkv}.", gtkv => $v->{'gtk'});
}
- print "\n";
my $clawsver = ($CLAWSV eq "") ?
_("Claws Mail was not found!") :
_("Claws Mail returned version {cmv}.", cmv => $CLAWSV);
- print $clawsver . "\n";
+ say $clawsver;
}
# the command line help
}
sub parse_command_line {
+ my $argv = shift;
my $cont = TRUE;
$CLAWSV = get_claws_version ();
eval {
- GetOptions('h|help' => sub { print_help (); $cont = FALSE },
+ GetOptionsFromArray($argv,
+ 'h|help' => sub { print_help (); $cont = FALSE },
'v|version' => sub { print_version (); $cont = FALSE },
'b|verbose' => sub { $VERBOSE = TRUE },
'r|read-only' => sub { $READONLY = TRUE },
}
}
-# initialise
-exit unless parse_command_line ();
-Gtk3->init;
-$main_window = Gtk3::Window->new ('toplevel');
-exit unless load_preferences ();
-exit unless init_hidden_preferences ();
-# create main GUI
-my $box = Gtk3::VBox->new (FALSE, 5);
-$box->set_border_width(3);
-my $about = new_about_dialog ($main_window);
-$box->pack_start (new_notebook (), TRUE, TRUE, 0);
-$box->pack_end (new_button_box ($main_window, $about), FALSE, FALSE, 0);
-$main_window->signal_connect (delete_event => sub { exit_handler($main_window) });
-$main_window->signal_connect (key_press_event => \&escape_key_handler);
-$main_window->set_title (_('Claws Mail Hidden Preferences'));
-$main_window->set_icon_list (get_app_icons ());
-$main_window->add ($box);
-$main_window->show_all;
-$MODIFIED = 0;
-Gtk3->main;
-
+sub main {
+ my $args = shift;
+ initialise;
+ exit unless parse_command_line ($args);
+ Gtk3->init;
+ $main_window = Gtk3::Window->new ('toplevel');
+ exit unless load_preferences ();
+ exit unless init_hidden_preferences ();
+ # create main GUI
+ my $box = Gtk3::VBox->new (FALSE, 5);
+ $box->set_border_width(3);
+ my $about = new_about_dialog ($main_window);
+ $box->pack_start (new_notebook (), TRUE, TRUE, 0);
+ $box->pack_end (new_button_box ($main_window, $about), FALSE, FALSE, 0);
+ $main_window->signal_connect (delete_event => sub { exit_handler($main_window) });
+ $main_window->signal_connect (key_press_event => \&escape_key_handler);
+ $main_window->set_title (_('Claws Mail Hidden Preferences'));
+ $main_window->set_icon_list (get_app_icons ());
+ $main_window->add ($box);
+ $main_window->show_all;
+ $MODIFIED = 0;
+ Gtk3->main;
+ return 0;
+}
+
+exit Clawsker::main(\@ARGV) unless caller;