Not used anymore
[clawsker.git] / clawsker
index 05f86f1ac1c589338c31a436724523c3e4bda796..3625b06f1ee23ec9bad36c1fd8bc0f745315aa2c 100755 (executable)
--- a/clawsker
+++ b/clawsker
@@ -31,6 +31,7 @@ my $LIBDIR = '@LIBDIR@';
 my $DATADIR = '@DATADIR@';
 my $VERSION = '@VERSION@';
 my $VERBOSE = FALSE;
+my $READONLY = FALSE;
 my $CLAWSV = undef;
 my $main_window = undef;
 
@@ -68,6 +69,7 @@ sub _ {
     tab_gui => _('GUI'),
     tab_other => _('Other'),
     tab_winpos => _('Windows'),
+    tab_accounts => _('Accounts'),
 
     ab_frame => _('Addressbook'),
     mem_frame => _('Memory'),
@@ -96,7 +98,7 @@ sub _ {
     h_oth_use_netm => _('Use NetworkManager to switch offline automatically.'),
     l_oth_mp_rounds => _('Rounds for PBKDF2 function'),
     h_oth_mp_rounds => _('Specify the number of iterations the key derivation function will be applied on master passphrase computation. Does not modify currently stored passphrase, only master passphrases computed after changing this value are affected.'),
-    
+
     l_gui_b_unread => _('Show unread messages with bold font'),
     h_gui_b_unread => _('Show unread messages in the Message List using a bold font.'),
     l_gui_no_markup => _('Don\'t use markup'),
@@ -205,6 +207,20 @@ sub _ {
     l_win_main_fs => _('Full-screen'),
     h_win_main_fs => _('Changes full screen status.'),
 
+    l_acc_gtls_set => _('Use custom GnuTLS priority'),
+    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_plu_lav_burl => _('Base URL'),
+    h_plu_lav_burl => _('This is the URL where avatar requests are sent. You can use the one of your own libravatar server, if available.'),
+    l_plu_prl_flvb => _('Log level'),
+    h_plu_prl_flvb => _('Verbosity level of log, acumulative.'),
+    l_plu_prl_none => _('None'),
+    l_plu_prl_manual => _('Manual'),
+    l_plu_prl_action => _('Actions'),
+    l_plu_prl_match => _('Matches'),
+
     e_error => _('Error: '),
     e_noclawsrc => _('resource file for Claws Mail was not found.'),
     e_running => _('seems Claws Mail is currently running, close it first.'),
@@ -212,12 +228,15 @@ sub _ {
 
 # all preferences read by load_preferences
 my %PREFS = ();
+my %ACPREFS = ();
 # values of all preferences handled by clawsker
 my %HPVALUE = ();
+my %ACHPVALUE = ();
 # default config dir and file name
 my $ALTCONFIGDIR = FALSE;
 my $CONFIGDIR = $ENV{HOME} . '/.claws-mail/';
 my $CONFIGRC = 'clawsrc';
+my $ACCOUNTRC = 'accountrc';
 
 # index constants for preference arrays
 use constant NAME  => 0; # the name on the rc file
@@ -226,7 +245,6 @@ use constant DESC  => 2; # the description for the hint/help
 use constant TYPE  => 3; # data type: bool, int, float, string, color
 use constant CMVER => 4; # lowest[,highest] Claws Mail version(s) the feature exists
 use constant CMDEF => 5; # default value for the preference in Claws Mail
-use constant GUI   => 6; # GUI element
 
 # constants for GUI spacing
 use constant HBOX_SPC => 5;
@@ -243,7 +261,7 @@ sub version_greater_or_equal {
         push (@version, '0');
     }
     my $idx = 0;
-    while (($idx <= $#refvers) 
+    while (($idx <= $#refvers)
             and (int ($version[$idx]) == int ($refvers[$idx]))) {
         ++$idx;
     }
@@ -253,16 +271,10 @@ sub version_greater_or_equal {
 }
 
 sub get_claws_version {
-    my @cmbin = (
-        'claws-mail',
-    );
-    my $res = "";
-    foreach my $bin (@cmbin) {
-        $_ = qx/which $bin/;
-        chomp;
-        last if ($_ ne "");
-    }
+    $_ = qx/which claws-mail/;
+    chomp;
     return "" unless ($_); # not installed
+    my $res = "";
     $_ = qx/$_ -v/;
     chomp;
     my @fver = split (/ /);
@@ -306,8 +318,8 @@ sub handle_string_value {
 }
 
 sub handle_nchar_value {
-    my ($widget, $event, $dataref, $minlen) = @_;
-    $_ = substr ($widget->get_text (), 0, $minlen);
+    my ($widget, $event, $dataref, $minlen, $maxlen) = @_;
+    $_ = substr ($widget->get_text (), 0, $maxlen);
     $widget->set_text ($_);
     $$dataref = $_;
 }
@@ -318,7 +330,7 @@ sub gdk_color_from_str {
     $_ = uc ($str);
     if (/\#([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])/) {
         $rr = hex($1) * 256;
-        $gg = hex($2) * 256; 
+        $gg = hex($2) * 256;
         $bb = hex($3) * 256;
     }
     my $color = Gtk2::Gdk::Color->new ($rr, $gg, $bb);
@@ -349,6 +361,10 @@ sub get_rc_filename {
     return $CONFIGDIR . $CONFIGRC;
 }
 
+sub get_ac_rc_filename {
+    return $CONFIGDIR . $ACCOUNTRC;
+}
+
 sub set_rc_filename {
     my ($fullname) = @_;
     my @parts = split ('/', $fullname);
@@ -384,10 +400,11 @@ sub claws_is_running {
 }
 
 sub check_claws_not_running {
+    return TRUE if $READONLY;
     my $tmpdir = (defined $ENV{TMPDIR})? $ENV{TMPDIR}: '/tmp';
     $tmpdir = '/tmp' if ($tmpdir eq '');
     my $lockdir = "$tmpdir/claws-mail-$<";
-    -d $lockdir and do { 
+    -d $lockdir and do {
         $_ = $CONFIGDIR;
         s/\/$//;
         my $socket = "$lockdir/" . md5_hex ($_);
@@ -409,7 +426,7 @@ sub check_rc_file {
 
 sub set_widget_hint {
     if ($SHOWHINTS) {
-        my ($wdgt, $hint) = @_;    
+        my ($wdgt, $hint) = @_;
         $wdgt->set_tooltip_text ($hint);
         $wdgt->set_has_tooltip (TRUE);
     }
@@ -428,7 +445,7 @@ sub set_widget_sens {
     }
 }
 
-# graphic element creation 
+# graphic element creation
 
 sub new_check_button_for($$$) {
     my ($hash, $key, $vhash) = @_;
@@ -437,7 +454,6 @@ sub new_check_button_for($$$) {
     #
     my $hbox = Gtk2::HBox->new (FALSE, 5);
     my $cb = Gtk2::CheckButton->new ($label);
-    $$hash{$key}[GUI] = $cb;
     my $value = $$vhash{$name};
     $value //= $$hash{$key}[CMDEF];
     $cb->set_active ($value eq '1');
@@ -457,7 +473,7 @@ sub new_text_box_for_int($$$) {
     my $name = $$hash{$key}[NAME];
     my $label = $$hash{$key}[LABEL];
     my @type = split (/,/, $$hash{$key}[TYPE]);
-    push (@type, 0), push (@type, 10000) unless ($#type > 0); 
+    push (@type, 0), push (@type, 10000) unless ($#type > 0);
     #
     my $hbox = Gtk2::HBox->new (FALSE, 5);
     my $glabel = Gtk2::Label->new ($label);
@@ -467,7 +483,6 @@ sub new_text_box_for_int($$$) {
     $value //= $$hash{$key}[CMDEF];
     $gentry->set_numeric (TRUE);
     $gentry->set_value ($value);
-    $$hash{$key}[GUI] = $gentry;
     $gentry->signal_connect('value-changed' => sub {
             my ($w, $e) = @_;
             handle_int_value ($w, $e, \$$vhash{$name});
@@ -485,19 +500,20 @@ sub new_text_box_for_nchar($$$) {
     my ($hash, $key, $vhash) = @_;
     my $name = $$hash{$key}[NAME];
     my $label = $$hash{$key}[LABEL];
-    my @type = split (/,/, $$hash{$key}[TYPE]); # char,minlen,maxlen
+    my @type = split (/,/, $$hash{$key}[TYPE]); # char,minlen,maxlen,width
     my $hbox = Gtk2::HBox->new (FALSE, 5);
     my $glabel = Gtk2::Label->new ($label);
     my $gentry = Gtk2::Entry->new ();
     $gentry->set_max_length($type[2]) if defined ($type[2]);
-    $gentry->set_width_chars(int ($type[2]) + 2) if defined ($type[2]);
+    my $width = $type[3];
+    $width //= $type[2];
+    $gentry->set_width_chars(int ($width) + 2) if defined ($width);
     my $value = $$vhash{$name};
     $value //= $$hash{$key}[CMDEF];
     $gentry->set_text ($value);
-    $$hash{$key}[GUI] = $gentry;
     $gentry->signal_connect('key-release-event' => sub {
             my ($w, $e) = @_;
-            handle_nchar_value ($w, $e, \$$vhash{$name}, $type[1]);
+            handle_nchar_value ($w, $e, \$$vhash{$name}, $type[1], $type[2]);
         });
     set_widget_hint ($gentry, $$hash{$key}[DESC]);
     set_widget_sens ($gentry, $$hash{$key}[CMVER]);
@@ -519,7 +535,6 @@ sub new_color_button_for($$$) {
     my $hbox = Gtk2::HBox->new (FALSE, 5);
     my $glabel = Gtk2::Label->new ($label);
     my $button = Gtk2::ColorButton->new_with_color ($col);
-    $$hash{$key}[GUI] = $button;
     $button->set_title ($label);
     $button->set_relief ('none');
     $button->signal_connect ('color-set' => sub {
@@ -535,15 +550,14 @@ sub new_color_button_for($$$) {
     return $hbox;
 }
 
-sub new_selection_box_for {
-    my ($hash, $key) = @_;
+sub new_selection_box_for($$$) {
+    my ($hash, $key, $vhash) = @_;
     my $name = $$hash{$key}[NAME];
     my $label = $$hash{$key}[LABEL];
     #
     my $hbox = Gtk2::HBox->new (FALSE, 5);
     my $glabel = Gtk2::Label->new ($label);
     my $combo = Gtk2::ComboBox->new_text;
-    $$hash{$key}[GUI] = $combo;
     my @options = split (';', $$hash{$key}[TYPE]);
     foreach my $opt (@options) {
         my ($index, $textkey) = split ('=', $opt);
@@ -551,9 +565,9 @@ sub new_selection_box_for {
     }
     $combo->signal_connect ('changed' => sub {
             my ($w, $e) = @_;
-            handle_selection_value ($w, $e, \$HPVALUE{$name});
+            handle_selection_value ($w, $e, \$$vhash{$name});
         });
-    my $value = $HPVALUE{$name};
+    my $value = $$vhash{$name};
     $value //= $$hash{$key}[CMDEF];
     $combo->set_active ($value);
     set_widget_hint ($combo, $$hash{$key}[DESC]);
@@ -574,7 +588,7 @@ sub new_hbox_pack {
         $hbox->pack_start ($item, FALSE, FALSE, 0);
     }
     return $hbox;
-}    
+}
 
 sub new_vbox_pack {
     my $vbox = Gtk2::VBox->new (FALSE, 5);
@@ -583,7 +597,7 @@ sub new_vbox_pack {
         $vbox->pack_start ($item, FALSE, FALSE, 0);
     }
     return $vbox;
-}    
+}
 
 sub new_vbox_pack_compact {
     my $vbox = Gtk2::VBox->new (FALSE, 0);
@@ -592,12 +606,12 @@ sub new_vbox_pack_compact {
         $vbox->pack_start ($item, FALSE, FALSE, 0);
     }
     return $vbox;
-}    
+}
 
 sub new_subpage_frame {
     my ($box, $title, $notpacked) = @_;
     my $frame = Gtk2::Frame->new ($title);
-    $frame->add ($box);    
+    $frame->add ($box);
     return new_vbox_pack ($frame) unless defined ($notpacked);
     return $frame;
 }
@@ -605,14 +619,13 @@ sub new_subpage_frame {
 # preference maps and corresponding page creation subs
 
 %pr::oth = ( # other preferences
-    use_dlg => [ 
+    use_dlg => [
         'addressbook_use_editaddress_dialog',
         $xl::s{l_oth_use_dlg},
         $xl::s{h_oth_use_dlg},
         'bool',
         '2.7.0',
         '0',
-        undef,
     ],
     max_use => [
         'cache_max_mem_usage',
@@ -621,7 +634,6 @@ sub new_subpage_frame {
         'int,0,262144', # 0 Kb - 256 Mb
         '0.0.0',
         '4096',
-        undef,
     ],
     min_time => [
         'cache_min_keep_time',
@@ -630,7 +642,6 @@ sub new_subpage_frame {
         'int,0,120', # 0 minutes - 2 hours
         '0.0.0',
         '15',
-        undef,
     ],
     use_netm => [
         'use_networkmanager',
@@ -639,7 +650,6 @@ sub new_subpage_frame {
         'bool',
         '3.3.1',
         '1',
-        undef,
     ],
     mp_rounds => [
         'master_passphrase_pbkdf2_rounds',
@@ -648,7 +658,6 @@ sub new_subpage_frame {
         'int,50000,1000000',
         '3.13.2.110',
         '50000',
-        undef,
     ],
 );
 
@@ -675,14 +684,13 @@ sub new_other_page() {
 }
 
 %pr::gui = ( # gui bells and whistles
-    b_unread => [ 
+    b_unread => [
         'bold_unread',
         $xl::s{l_gui_b_unread},
         $xl::s{h_gui_b_unread},
         'bool',
         '0.0.0',
         '1',
-        undef,
     ],
     no_markup => [
         'compose_no_markup',
@@ -691,7 +699,6 @@ sub new_other_page() {
         'bool',
         '0.0.0',
         '0',
-        undef,
     ],
     dot_lines => [
         'enable_dotted_lines',
@@ -700,7 +707,6 @@ sub new_other_page() {
         'bool',
         '0.0.0,3.7.10.44',
         '0',
-        undef,
     ],
     h_scroll => [
         'enable_hscrollbar',
@@ -709,7 +715,6 @@ sub new_other_page() {
         'bool',
         '0.0.0',
         '1',
-        undef,
     ],
     swp_from => [
         'enable_swap_from',
@@ -718,7 +723,6 @@ sub new_other_page() {
         'bool',
         '0.0.0',
         '0',
-        undef,
     ],
     v_scroll => [
         'folderview_vscrollbar_policy',
@@ -727,7 +731,6 @@ sub new_other_page() {
         '0=l_gui_v_scroll_show;1=l_gui_v_scroll_auto;2=l_gui_v_scroll_hide',
         '0.0.0',
         '0',
-        undef,
     ],
     from_show => [
         'summary_from_show',
@@ -736,7 +739,6 @@ sub new_other_page() {
         '0=l_gui_from_show_name;1=l_gui_from_show_addr;2=l_gui_from_show_both',
         '3.7.10',
         '0',
-        undef,
     ],
     strip_off => [
         'stripes_color_offset',
@@ -745,7 +747,6 @@ sub new_other_page() {
         'int,0,40000', # no idea what this number means
         '0.0.0',
         '4000',
-        undef,
     ],
     cursor_v => [
         'textview_cursor_visible',
@@ -754,7 +755,6 @@ sub new_other_page() {
         'bool',
         '0.0.0',
         '0',
-        undef,
     ],
     toolbar_d => [
         'toolbar_detachable',
@@ -763,7 +763,6 @@ sub new_other_page() {
         'bool',
         '0.0.0',
         '0',
-        undef,
     ],
     strip_all => [
         'use_stripes_everywhere',
@@ -772,7 +771,6 @@ sub new_other_page() {
         'bool',
         '0.0.0',
         '1',
-        undef,
     ],
     strip_sum => [
         'use_stripes_in_summaries',
@@ -781,7 +779,6 @@ sub new_other_page() {
         'bool',
         '0.0.0',
         '1',
-        undef,
     ],
     two_linev => [
         'two_line_vertical',
@@ -790,7 +787,6 @@ sub new_other_page() {
         'bool',
         '3.4.0.7',
         '0',
-        undef,
     ],
     margin_co => [
         'show_compose_margin',
@@ -799,7 +795,6 @@ sub new_other_page() {
         'bool',
         '3.7.6.7',
         '0',
-        undef,
     ],
     mview_date => [
         'msgview_date_format',
@@ -808,7 +803,6 @@ sub new_other_page() {
         'bool',
         '3.7.8.42',
         '0',
-        undef,
     ],
     zero_char => [
         'zero_replacement_char',
@@ -817,7 +811,6 @@ sub new_other_page() {
         'char,1,1',
         '2.8.1.77',
         '0',
-        undef,
     ],
     type_any => [
         'type_any_header',
@@ -826,7 +819,6 @@ sub new_other_page() {
         'bool',
         '3.12.0.44',
         '0',
-        undef,
     ],
     next_del => [
         'next_on_delete',
@@ -835,7 +827,6 @@ sub new_other_page() {
         'bool',
         '3.13.0.5',
         '0',
-        undef,
     ],
 );
 
@@ -860,28 +851,28 @@ sub new_gui_page() {
                              new_check_button_for (\%pr::gui, 'swp_from', \%HPVALUE),
                              new_check_button_for (\%pr::gui, 'two_linev', \%HPVALUE),
                              new_check_button_for (\%pr::gui, 'next_del', \%HPVALUE),
-                             new_selection_box_for (\%pr::gui, 'from_show')),
-                         $xl::s{mlist_frame}, 'not-packed'), 
+                             new_selection_box_for (\%pr::gui, 'from_show', \%HPVALUE)),
+                         $xl::s{mlist_frame}, 'not-packed'),
                      FALSE, FALSE, FRAME_SPC);
     $gf->pack_start (new_subpage_frame (
                          new_hbox_pack (
                              new_check_button_for (\%pr::gui, 'cursor_v', \%HPVALUE),
                              new_check_button_for (\%pr::gui, 'mview_date', \%HPVALUE)),
-                         $xl::s{mview_frame}, 'not-packed'), 
+                         $xl::s{mview_frame}, 'not-packed'),
                      FALSE, FALSE, FRAME_SPC);
     $gf->pack_start (new_subpage_frame (
                          new_hbox_pack (
                              new_check_button_for (\%pr::gui, 'no_markup', \%HPVALUE),
                              new_check_button_for (\%pr::gui, 'margin_co', \%HPVALUE),
                              new_check_button_for (\%pr::gui, 'type_any', \%HPVALUE)),
-                         $xl::s{compo_frame}, 'not-packed'), 
+                         $xl::s{compo_frame}, 'not-packed'),
                      FALSE, FALSE, FRAME_SPC);
     $gf->pack_start ($cb_dot_lines, FALSE, FALSE, 0);
     $gf->pack_start ($cb_toolbar_d, FALSE, FALSE, 0);
     $gf->pack_start (new_subpage_frame (
                          new_vbox_pack (
                              new_check_button_for (\%pr::gui, 'h_scroll', \%HPVALUE),
-                             new_selection_box_for (\%pr::gui, 'v_scroll')),
+                             new_selection_box_for (\%pr::gui, 'v_scroll', \%HPVALUE)),
                          $xl::s{sbar_frame}, 'not-packed'),
                      FALSE, FALSE, FRAME_SPC);
     $gf->pack_start ($tb_zero_char, FALSE, FALSE, 0);
@@ -897,7 +888,6 @@ sub new_gui_page() {
         'int,100,3000', # 0.1 seconds - 3 seconds
         '0.0.0',
         '500',
-        undef,
     ],
     dangerous => [
         'live_dangerously',
@@ -906,7 +896,6 @@ sub new_gui_page() {
         'bool',
         '0.0.0',
         '0',
-        undef,
     ],
     flowed => [
         'respect_flowed_format',
@@ -915,7 +904,6 @@ sub new_gui_page() {
         'bool',
         '0.0.0',
         '0',
-        undef,
     ],
     parts_rw => [
         'save_parts_readwrite',
@@ -924,7 +912,6 @@ sub new_gui_page() {
         'bool',
         '0.0.0',
         '0',
-        undef,
     ],
     skip_ssl => [
         'skip_ssl_cert_check',
@@ -933,7 +920,6 @@ sub new_gui_page() {
         'bool',
         '0.0.0',
         '0',
-        undef,
     ],
     up_step => [
         'statusbar_update_step',
@@ -942,7 +928,6 @@ sub new_gui_page() {
         'int,1,200', # 1 item - 200 items
         '0.0.0',
         '10',
-        undef,
     ],
     thread_a => [
         'thread_by_subject_max_age',
@@ -951,7 +936,6 @@ sub new_gui_page() {
         'int,1,30', # 1 day - 30 days
         '0.0.0',
         '10',
-        undef,
     ],
     unsafe_ssl => [
         'unsafe_ssl_certs',
@@ -960,7 +944,6 @@ sub new_gui_page() {
         'bool',
         '0.0.0',
         '0',
-        undef,
     ],
     use_utf8 => [
         'utf8_instead_of_locale_for_broken_mail',
@@ -969,7 +952,6 @@ sub new_gui_page() {
         'bool',
         '0.0.0',
         '0',
-        undef,
     ],
     warn_dnd => [
         'warn_dnd',
@@ -978,7 +960,6 @@ sub new_gui_page() {
         'bool',
         '0.0.0',
         '1',
-        undef,
     ],
     out_ascii => [
         'outgoing_fallback_to_ascii',
@@ -987,7 +968,6 @@ sub new_gui_page() {
         'bool',
         '3.4.0.37',
         '1',
-        undef,
     ],
     pp_unsel => [
         'primary_paste_unselects',
@@ -996,7 +976,6 @@ sub new_gui_page() {
         'bool',
         '3.6.1.35',
         '0',
-        undef,
     ],
     inline_at => [
         'show_inline_attachments',
@@ -1005,7 +984,6 @@ sub new_gui_page() {
         'bool',
         '3.7.8.48',
         '1',
-        undef,
     ],
     addr_swc => [
         'address_search_wildcard',
@@ -1014,7 +992,6 @@ sub new_gui_page() {
         'bool',
         '3.9.3.18',
         '0',
-        undef,
     ],
     fold_swc => [
         'folder_search_wildcard',
@@ -1023,7 +1000,6 @@ sub new_gui_page() {
         'bool',
         '3.9.3.18',
         '0',
-        undef,
     ],
 );
 
@@ -1038,7 +1014,7 @@ sub new_behaviour_page() {
                          new_vbox_pack (
                              new_text_box_for_int (\%pr::beh, 'hover_t', \%HPVALUE),
                              new_check_button_for (\%pr::beh, 'warn_dnd', \%HPVALUE)),
-                         $xl::s{dnd_frame}, 'not-packed'), 
+                         $xl::s{dnd_frame}, 'not-packed'),
                      FALSE, FALSE, FRAME_SPC);
     $bf->pack_start (new_subpage_frame (
                          new_hbox_pack (
@@ -1076,7 +1052,6 @@ sub new_behaviour_page() {
         'color',
         '0.0.0',
         '#0000cf',
-        undef,
     ],
     log_err => [
         'log_error_color',
@@ -1085,7 +1060,6 @@ sub new_behaviour_page() {
         'color',
         '0.0.0',
         '#af0000',
-        undef,
     ],
     log_in => [
         'log_in_color',
@@ -1094,7 +1068,6 @@ sub new_behaviour_page() {
         'color',
         '0.0.0',
         '#000000',
-        undef,
     ],
     log_msg => [
         'log_msg_color',
@@ -1103,7 +1076,6 @@ sub new_behaviour_page() {
         'color',
         '0.0.0',
         '#00af00',
-        undef,
     ],
     log_out => [
         'log_out_color',
@@ -1112,7 +1084,6 @@ sub new_behaviour_page() {
         'color',
         '0.0.0',
         '#0000ef',
-        undef,
     ],
     log_warn => [
         'log_warn_color',
@@ -1121,7 +1092,6 @@ sub new_behaviour_page() {
         'color',
         '0.0.0',
         '#af0000',
-        undef,
     ],
     diff_add => [
         'diff_added_color',
@@ -1130,7 +1100,6 @@ sub new_behaviour_page() {
         'color',
         '3.8.0.54',
         '#008b8b',
-        undef,
     ],
     diff_del => [
         'diff_deleted_color',
@@ -1139,7 +1108,6 @@ sub new_behaviour_page() {
         'color',
         '3.8.0.54',
         '#6a5acd',
-        undef,
     ],
     diff_hunk => [
         'diff_hunk_color',
@@ -1148,7 +1116,6 @@ sub new_behaviour_page() {
         'color',
         '3.8.0.54',
         '#a52a2a',
-        undef,
     ],
 );
 
@@ -1183,7 +1150,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '16',
-        undef,
     ],
     main_y => [
         'mainwin_y',
@@ -1192,7 +1158,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '16',
-        undef,
     ],
     main_w => [
         'mainwin_width',
@@ -1201,7 +1166,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '779',
-        undef,
     ],
     main_h => [
         'mainwin_height',
@@ -1210,7 +1174,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '568',
-        undef,
     ],
     main_mx => [
         'mainwin_maximised',
@@ -1219,7 +1182,6 @@ sub new_colours_page() {
         'bool',
         '0.0.0',
         '0',
-        undef,
     ],
     main_fs => [
         'mainwin_fullscreen',
@@ -1228,7 +1190,6 @@ sub new_colours_page() {
         'bool',
         '0.0.0',
         '0',
-        undef,
     ],
     msgs_x => [
         'main_messagewin_x',
@@ -1237,7 +1198,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '256',
-        undef,
     ],
     msgs_y => [
         'main_messagewin_y',
@@ -1246,7 +1206,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '210',
-        undef,
     ],
     msgs_w => [
         'messagewin_width',
@@ -1255,7 +1214,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '600',
-        undef,
     ],
     msgs_h => [
         'messagewin_height',
@@ -1264,7 +1222,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '540',
-        undef,
     ],
     send_w => [
         'sendwin_width',
@@ -1273,7 +1230,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '460',
-        undef,
     ],
     send_h => [
         'sendwin_height',
@@ -1282,7 +1238,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '-1',
-        undef,
     ],
     recv_w => [
         'receivewin_width',
@@ -1291,7 +1246,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '460',
-        undef,
     ],
     recv_h => [
         'receivewin_height',
@@ -1300,7 +1254,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '-1',
-        undef,
     ],
     fold_x => [
         'folderwin_x',
@@ -1309,7 +1262,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '16',
-        undef,
     ],
     fold_y => [
         'folderwin_y',
@@ -1318,7 +1270,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '16',
-        undef,
     ],
     fold_w => [
         'folderitemwin_width',
@@ -1327,7 +1278,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '500',
-        undef,
     ],
     fold_h => [
         'folderitemwin_height',
@@ -1336,7 +1286,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '-1',
-        undef,
     ],
     fsel_w => [
         'folderselwin_width',
@@ -1345,7 +1294,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '300',
-        undef,
     ],
     fsel_h => [
         'folderselwin_height',
@@ -1354,7 +1302,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '-1',
-        undef,
     ],
     sour_w => [
         'sourcewin_width',
@@ -1363,7 +1310,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '600',
-        undef,
     ],
     sour_h => [
         'sourcewin_height',
@@ -1372,7 +1318,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '500',
-        undef,
     ],
     addr_w => [
         'addressbookwin_width',
@@ -1381,7 +1326,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '520',
-        undef,
     ],
     addr_h => [
         'addressbookwin_height',
@@ -1390,7 +1334,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '-1',
-        undef,
     ],
     adep_w => [
         'addressbookeditpersonwin_width',
@@ -1399,7 +1342,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '640',
-        undef,
     ],
     adep_h => [
         'addressbookeditpersonwin_height',
@@ -1408,7 +1350,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '320',
-        undef,
     ],
     adeg_w => [
         'addressbookeditgroupwin_width',
@@ -1417,7 +1358,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '580',
-        undef,
     ],
     adeg_h => [
         'addressbookeditgroupwin_height',
@@ -1426,7 +1366,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '340',
-        undef,
     ],
     adda_w => [
         'addressaddwin_width',
@@ -1435,7 +1374,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '300',
-        undef,
     ],
     adda_h => [
         'addressaddwin_height',
@@ -1444,7 +1382,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '-1',
-        undef,
     ],
     addf_w => [
         'addressbook_folderselwin_width',
@@ -1453,7 +1390,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '300',
-        undef,
     ],
     addf_h => [
         'addressbook_folderselwin_height',
@@ -1462,7 +1398,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '-1',
-        undef,
     ],
     acce_w => [
         'editaccountwin_width',
@@ -1471,7 +1406,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '500',
-        undef,
     ],
     acce_h => [
         'editaccountwin_height',
@@ -1480,7 +1414,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '-1',
-        undef,
     ],
     acco_w => [
         'accountswin_width',
@@ -1489,7 +1422,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '500',
-        undef,
     ],
     acco_h => [
         'accountswin_height',
@@ -1498,7 +1430,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '-1',
-        undef,
     ],
     filt_w => [
         'filteringwin_width',
@@ -1507,7 +1438,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '500',
-        undef,
     ],
     filt_h => [
         'filteringwin_height',
@@ -1516,7 +1446,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '-1',
-        undef,
     ],
     fila_w => [
         'filteringactionwin_width',
@@ -1525,7 +1454,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '490',
-        undef,
     ],
     fila_h => [
         'filteringactionwin_height',
@@ -1534,7 +1462,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '-1',
-        undef,
     ],
     fild_w => [
         'filtering_debugwin_width',
@@ -1543,7 +1470,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '600',
-        undef,
     ],
     fild_h => [
         'filtering_debugwin_height',
@@ -1552,7 +1478,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '-1',
-        undef,
     ],
     matc_w => [
         'matcherwin_width',
@@ -1561,7 +1486,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '520',
-        undef,
     ],
     matc_h => [
         'matcherwin_height',
@@ -1570,7 +1494,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '-1',
-        undef,
     ],
     pref_w => [
         'prefswin_width',
@@ -1579,7 +1502,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '600',
-        undef,
     ],
     pref_h => [
         'prefswin_height',
@@ -1588,7 +1510,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '-1',
-        undef,
     ],
     temp_w => [
         'templateswin_width',
@@ -1597,7 +1518,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '480',
-        undef,
     ],
     temp_h => [
         'templateswin_height',
@@ -1606,7 +1526,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '-1',
-        undef,
     ],
     acti_w => [
         'actionswin_width',
@@ -1615,7 +1534,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '486',
-        undef,
     ],
     acti_h => [
         'actionswin_height',
@@ -1624,7 +1542,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '-1',
-        undef,
     ],
     tags_w => [
         'tagswin_width',
@@ -1633,7 +1550,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '486',
-        undef,
     ],
     tags_h => [
         'tagswin_height',
@@ -1642,7 +1558,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '-1',
-        undef,
     ],
     plug_w => [
         'pluginswin_width',
@@ -1651,7 +1566,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '-1',
-        undef,
     ],
     plug_h => [
         'pluginswin_height',
@@ -1660,7 +1574,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '-1',
-        undef,
     ],
     logw_w => [
         'logwin_width',
@@ -1669,7 +1582,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '520',
-        undef,
     ],
     logw_h => [
         'logwin_height',
@@ -1678,7 +1590,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '-1',
-        undef,
     ],
     prin_w => [
         'print_previewwin_width',
@@ -1687,7 +1598,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '600',
-        undef,
     ],
     prin_h => [
         'print_previewwin_height',
@@ -1696,7 +1606,6 @@ sub new_colours_page() {
         'int,0,3000', # 0 pixels - 3000 pixels
         '0.0.0',
         '-1',
-        undef,
     ],
 );
 
@@ -1898,6 +1807,84 @@ sub new_winpos_page() {
     return $winbook;
 }
 
+%pr::acc = ( # per account hidden preferences
+    tls_set => [
+        'gnutls_set_priority',
+        $xl::s{l_acc_gtls_set},
+        $xl::s{h_acc_gtls_set},
+        'bool',
+        '3.9.0.181',
+        '0',
+    ],
+    tls_pri => [
+        'gnutls_priority',
+        $xl::s{l_acc_gtls_pri},
+        $xl::s{h_acc_gtls_pri},
+        'char,0,256,32',
+        '3.9.0.181',
+        '0',
+    ],
+);
+
+sub new_account_subpage($) {
+    my ($akey) = @_;
+    return new_vbox_pack (
+                new_subpage_frame (
+                    new_vbox_pack (
+                        new_check_button_for (\%pr::acc, 'tls_set', $ACHPVALUE{$akey}),
+                        new_text_box_for_nchar (\%pr::acc, 'tls_pri', $ACHPVALUE{$akey})),
+                    _('GnuTLS priority'), 'not-packed')
+           );
+}
+
+sub new_accounts_page() {
+    my $accbook = Gtk2::Notebook->new;
+    $accbook->set_tab_pos ('right');
+    foreach (keys %ACPREFS) {
+        my $name = $ACPREFS{$_}{'account_name'};
+        $accbook->append_page (new_account_subpage ($_), $name);
+    }
+    return $accbook;
+}
+
+%pr::plu = ( # plugins hidden preferences
+    # att_remover
+    arm_winw => [
+        'win_width',
+        $xl::s{l_win_w},
+        $xl::s{h_win_w},
+        'int,0,3000', # 0 pixels - 3000 pixels
+        '3.9.0.74',
+        '-1',
+    ],
+    arm_winh => [
+        'win_height',
+        $xl::s{l_win_h},
+        $xl::s{h_win_h},
+        'int,0,3000', # 0 pixels - 3000 pixels
+        '3.9.0.74',
+        '-1',
+    ],
+    # libravatar
+    lav_burl => [
+        'base_url',
+        $xl::s{l_plu_lav_burl},
+        $xl::s{h_plu_lav_burl},
+        'char,0,1024,32',
+        '3.9.3.32',
+        'http://cdn.libravatar.org/avatar',
+    ],
+    # perl
+    prl_flvb => [
+        'filter_log_verbosity',
+        $xl::s{l_plu_prl_flvb},
+        $xl::s{h_plu_prl_flvb},
+        '0=l_plu_prl_none;1=l_plu_prl_manual;2=l_plu_prl_action;3=l_plu_prl_match',
+        '3.9.0.75',
+        '2',
+    ],
+);
+
 # version info
 sub print_version() {
     print $xl::s{about_title} . "\n";
@@ -1905,20 +1892,20 @@ sub print_version() {
     print "Perl-GLib " . $Glib::VERSION;
     # version info stuff appeared in 1.040
     if ($Glib::VERSION >= 1.040) {
-        print _(", built for ") . join(".", Glib->GET_VERSION_INFO) 
-              . _(", running with ") . join(".", &Glib::major_version, 
+        print _(", built for ") . join(".", Glib->GET_VERSION_INFO)
+              . _(", running with ") . join(".", &Glib::major_version,
               &Glib::minor_version, &Glib::micro_version);
     }
     print "\n";
     print "Perl-GTK2 " . $Gtk2::VERSION;
     if ($Gtk2::VERSION >= 1.040) {
         print _(", built for ") . join(".", Gtk2->GET_VERSION_INFO)
-              . _(", running with ") . join(".", &Gtk2::major_version, 
+              . _(", running with ") . join(".", &Gtk2::major_version,
               &Gtk2::minor_version, &Gtk2::micro_version);
     }
     print "\n";
-    my $clawsver = ($CLAWSV eq "") ? 
-                _("was not found!") : 
+    my $clawsver = ($CLAWSV eq "") ?
+                _("was not found!") :
                 (_("returned version ") . $CLAWSV);
     print "Claws Mail " . $clawsver . "\n";
 }
@@ -1946,9 +1933,10 @@ sub parse_command_line {
         GetOptions('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 },
             'u|use-claws-version=s' => \&opt_use_claws_version,
             'a|alternate-config-dir=s' => \&opt_alternate_config_dir,
-            'r|clawsrc=s' => \&opt_clawsrc)
+            'c|clawsrc=s' => \&opt_clawsrc)
         or die _("try -h or --help for syntax.\n");
     };
     if ($@) {
@@ -1988,13 +1976,23 @@ sub opt_clawsrc {
 # update the hidden preferences status from loaded values
 sub init_hidden_preferences {
     foreach my $hash (\%pr::beh, \%pr::col, \%pr::gui, \%pr::oth, \%pr::win) {
-        foreach my $key (keys %$hash) { 
+        foreach my $key (keys %$hash) {
             $HPVALUE{${$hash}{$key}[NAME]} = $PREFS{${$hash}{$key}[NAME]};
         }
     }
     return TRUE;
 }
 
+sub init_ac_hidden_preferences {
+    foreach my $akey (keys %ACPREFS) {
+        foreach my $key (keys %pr::acc) {
+            my $pname = $pr::acc{$key}[NAME];
+            $ACHPVALUE{$akey}{$pname} = $ACPREFS{$akey}{$pname};
+        }
+    }
+    return TRUE;
+}
+
 # load current status from disc
 sub load_preferences {
     my $rc = get_rc_filename ();
@@ -2012,6 +2010,27 @@ sub load_preferences {
     return TRUE;
 }
 
+sub load_ac_preferences {
+    my $rc = get_ac_rc_filename ();
+    log_message ("Loading account preferences from $rc\n");
+    return FALSE unless check_rc_file ($rc);
+    return FALSE unless check_claws_not_running ();
+    open (RCF, "<$rc");
+    my $akey;
+    while (<RCF>) {
+        chomp;
+        if (/^\[Account: (\d+)\]$/) {
+          $akey = $1;
+          next;
+        }
+        if (/^([8a-z_]+)=(.*)$/) {
+            $ACPREFS{$akey}{$1} = decode('UTF-8', $2);
+        }
+    }
+    close (RCF);
+    return TRUE;
+}
+
 # save current preferences to disc
 sub save_preferences {
     my $rc = get_rc_filename ();
@@ -2041,15 +2060,50 @@ sub save_preferences {
     return TRUE;
 }
 
+sub save_ac_preferences {
+    my $rc = get_ac_rc_filename ();
+    log_message ("Saving account preferences to $rc\n");
+    return FALSE unless check_rc_file ($rc);
+    return FALSE unless check_claws_not_running ();
+    my $rcbak = "$rc.backup";
+    rename ($rc, $rcbak);
+    open (RCF, ">$rc");
+    open (RCB, "<$rcbak");
+    my $akey;
+    while (<RCB>) {
+        chomp;
+        if (/^\[Account: (\d+)\]$/) {
+          $akey = $1;
+          print RCF $_ . "\n";
+          next;
+        }
+        if (/^([8a-z_]+)=(.*)$/) {
+            if (defined($ACHPVALUE{$akey}{$1})) {
+                print RCF $1 . "=" . $ACHPVALUE{$akey}{$1} . "\n";
+            }
+            else {
+                print RCF $_ . "\n";
+            }
+        }
+        else {
+            print RCF $_ . "\n";
+        }
+    }
+    close (RCB);
+    close (RCF);
+    return TRUE;
+}
+
 # create notebook
 sub new_notebook {
     my $nb = Gtk2::Notebook->new;
-    # 
+    #
     $nb->append_page (new_behaviour_page (), $xl::s{tab_behaviour});
     $nb->append_page (new_colours_page (), $xl::s{tab_colours});
     $nb->append_page (new_gui_page (), $xl::s{tab_gui});
     $nb->append_page (new_other_page (), $xl::s{tab_other});
     $nb->append_page (new_winpos_page (), $xl::s{tab_winpos});
+    $nb->append_page (new_accounts_page (), $xl::s{tab_accounts});
 
     return $nb;
 }
@@ -2060,7 +2114,7 @@ sub new_about_dialog {
     my $title = $xl::s{about_title};
     my $lic = $xl::s{about_license};
     my $vers = $xl::s{about_version} . " $VERSION";
-    my $license = 
+    my $license =
 "This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
@@ -2077,9 +2131,9 @@ along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.";
     my $holder = "Ricardo Mones &lt;ricardo\@mones.org&gt;";
     my $url = "http://www.claws-mail.org/clawsker.php";
 
-    my $dialog = Gtk2::MessageDialog->new_with_markup ($parent, 
-                    [qw/modal destroy-with-parent/], 
-                    'info', 'close', 
+    my $dialog = Gtk2::MessageDialog->new_with_markup ($parent,
+                    [qw/modal destroy-with-parent/],
+                    'info', 'close',
                     "<span size=\"x-large\" weight=\"bold\">$title</span>\n"
                     . "<span size=\"large\">$vers</span>\n\n"
                     . "<span color=\"blue\" size=\"large\">$url</span>\n\n"
@@ -2100,9 +2154,13 @@ sub new_button_box {
     # disable button until is really implemented
     # my $b_undo = Gtk2::Button->new_from_stock ('gtk-undo');
     my $hbox = Gtk2::HBox->new (FALSE, 5);
-    # signal handlers 
+    # signal handlers
     $b_exit->signal_connect (clicked => sub { Gtk2->main_quit });
-    $b_apply->signal_connect (clicked => sub { save_preferences ($parent) });
+    $b_apply->set_sensitive (not $READONLY);
+    $b_apply->signal_connect (clicked => sub {
+        save_preferences ($parent);
+        save_ac_preferences ($parent);
+    });
     # $b_undo->signal_connect (clicked => sub { undo_current_changes });
     $b_about->signal_connect (clicked => sub { $adlg->run; $adlg->hide });
     # package them
@@ -2133,7 +2191,9 @@ exit unless parse_command_line ();
 Gtk2->init;
 $main_window = Gtk2::Window->new ('toplevel');
 exit unless load_preferences ();
+exit unless load_ac_preferences ();
 exit unless init_hidden_preferences ();
+exit unless init_ac_hidden_preferences ();
 # create main GUI
 my $box = Gtk2::VBox->new (FALSE, 5);
 $box->set_border_width(3);