tab_other => _('Other'),
tab_winpos => _('Windows'),
tab_accounts => _('Accounts'),
+ tab_plugins => _('Plugins'),
ab_frame => _('Addressbook'),
mem_frame => _('Memory'),
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.'),
);
+# data and metadata of resource files
+my $CONFIGDATA;
+my $CONFIGMETA;
+my $ACCOUNTDATA;
+my $ACCOUNTMETA;
# all preferences read by load_preferences
my %PREFS = ();
my %ACPREFS = ();
'int,0,3000', # 0 pixels - 3000 pixels
'3.9.0.74',
'-1',
- undef,
],
arm_winh => [
'win_height',
'int,0,3000', # 0 pixels - 3000 pixels
'3.9.0.74',
'-1',
- undef,
],
# libravatar
lav_burl => [
'char,0,1024,32',
'3.9.3.32',
'http://cdn.libravatar.org/avatar',
- undef,
+ ],
+ # 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',
],
);
+sub new_plugins_page() {
+ return new_vbox_pack (
+ new_subpage_frame (
+ new_hbox_pack (
+ new_text_box_for_int (\%pr::plu, 'arm_winw', \%HPVALUE),
+ new_text_box_for_int (\%pr::plu, 'arm_winh', \%HPVALUE)),
+ _('Attachment remover'), 'not-packed'),
+ new_subpage_frame (
+ new_hbox_pack (
+ new_text_box_for_nchar (\%pr::plu, 'lav_burl', \%HPVALUE)),
+ _('Libravatar'), 'not-packed'),
+ new_subpage_frame (
+ new_hbox_pack (
+ new_selection_box_for (\%pr::plu, 'prl_flvb', \%HPVALUE)),
+ _('Perl'), 'not-packed')
+ );
+}
+
# version info
sub print_version() {
print $xl::s{about_title} . "\n";
return TRUE;
}
+# generic load/save resource files
+sub load_resource {
+ my $rc = shift;
+ my %data = ();
+ my %meta = ();
+ my $line = 0;
+ open (RCF, '<:encoding(utf8)', $rc)
+ or die _("Error: opening '{file}' for reading", file => $rc) . ": $!";
+ my $section = '_'; # default unnamed section
+ while (<RCF>) {
+ chomp;
+ ++$line;
+ next if (/^\s*$/);
+ if (/^\[([^\]]+)\]$/) { # new section
+ $section = $1;
+ die _("Error: duplicate section '{sect}' in resource file '{file}'\n",
+ sect => $section, file => $rc) if ($data{$section});
+ $data{$section} = {};
+ $meta{$section}{'#'} = $line;
+ }
+ elsif (/^([0-9a-z_]+)=(.*)$/) { # key=value
+ $data{$section}{$1} = $2;
+ $meta{$section}{$1} = $line;
+ }
+ elsif (/^(.*)$/) { # lone value
+ push (@{$data{$section}{'_'}}, $1);
+ }
+ }
+ close (RCF);
+ return (\%data, \%meta);
+}
+
+sub save_resource {
+ my ($rc, $data, $meta) = @_;
+ open (RCF, '>:utf8', $rc)
+ or die _("Error: opening '{file}' for writing", file => $rc) . ": $!";
+ my @sections = keys %$data;
+ if (defined $meta) {
+ @sections = sort {
+ $meta->{$a}{'#'} <=> $meta->{$b}{'#'}
+ } @sections
+ }
+ foreach my $section (@sections) {
+ say RCF "[$section]";
+ if (ref ($data->{$section}{'_'}) eq 'ARRAY') {
+ foreach my $val (@{$data->{$section}{'_'}}) {
+ say RCF $val;
+ }
+ } else {
+ my @keys = keys %{$data->{$section}};
+ if (defined $meta) {
+ @keys = sort {
+ $meta->{$section}{$a} <=> $meta->{$section}{$b}
+ } @keys
+ }
+ foreach my $key (@keys) {
+ my $val = $data->{$section}{$key};
+ say RCF "$key=$val";
+ }
+ }
+ say RCF "";
+ }
+ close (RCF);
+}
+
# load current status from disc
sub load_preferences {
my $rc = get_rc_filename ();
log_message ("Loading preferences from $rc\n");
return FALSE unless check_rc_file ($rc);
return FALSE unless check_claws_not_running ();
- open (RCF, "<$rc");
- while (<RCF>) {
- chomp;
- if (/^([8a-z_]+)=(.*)$/) {
- $PREFS{$1} = decode('UTF-8', $2);
- }
+ ($CONFIGDATA, $CONFIGMETA) = load_resource ($rc);
+ foreach (keys %{$CONFIGDATA->{'Common'}}) {
+ $PREFS{$_} = $CONFIGDATA->{'Common'}{$_};
}
- close (RCF);
return TRUE;
}
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);
+ ($ACCOUNTDATA, $ACCOUNTMETA) = load_resource ($rc);
+ foreach my $asect (keys %$ACCOUNTDATA) {
+ if ($asect =~ /^Account: (\d+)$/) {
+ foreach (keys %{$ACCOUNTDATA->{$asect}}) {
+ $ACPREFS{$1}{$_} = $ACCOUNTDATA->{$asect}{$_};
+ }
}
}
- close (RCF);
return TRUE;
}
$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});
+ $nb->append_page (new_plugins_page (), $xl::s{tab_plugins});
return $nb;
}