From 884c7f20f0c4843d842e5b83e98dbbd3ccec722c Mon Sep 17 00:00:00 2001 From: Paul Mangan Date: Wed, 11 Jan 2006 13:44:17 +0000 Subject: [PATCH] 2006-01-11 [paul] 1.9.100cvs137 * tools/README * tools/filter_conv_new.pl add info to README also check .sylpheed for filter.xml be a bit informative to the user --- ChangeLog | 8 ++++++++ PATCHSETS | 1 + configure.ac | 2 +- tools/README | 32 ++++++++++++++++++++++++++++---- tools/filter_conv_new.pl | 33 ++++++++++++++++++++++++--------- 5 files changed, 62 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index f1f64c137..b7f0e8fcf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-01-11 [paul] 1.9.100cvs137 + + * tools/README + * tools/filter_conv_new.pl + add info to README + also check .sylpheed for filter.xml + be a bit informative to the user + 2006-01-11 [colin] 1.9.100cvs136 * src/textview.c diff --git a/PATCHSETS b/PATCHSETS index c0ba1f218..cbd8c194b 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -1120,3 +1120,4 @@ ( cvs diff -u -r 1.382.2.217 -r 1.382.2.218 src/compose.c; ) > 1.9.100cvs134.patchset ( cvs diff -u -r 1.25.2.7 -r 1.25.2.8 tools/Makefile.am; diff -u /dev/null tools/filter_conv_new.pl; ) > 1.9.100cvs135.patchset ( cvs diff -u -r 1.96.2.87 -r 1.96.2.88 src/textview.c; ) > 1.9.100cvs136.patchset +( cvs diff -u -r 1.30.2.7 -r 1.30.2.8 tools/README; cvs diff -u -r 1.1.2.1 -r 1.1.2.2 tools/filter_conv_new.pl; ) > 1.9.100cvs137.patchset diff --git a/configure.ac b/configure.ac index 9d6074328..6bac73204 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=9 MICRO_VERSION=100 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=136 +EXTRA_VERSION=137 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/tools/README b/tools/README index 77293267f..93abe9c52 100644 --- a/tools/README +++ b/tools/README @@ -26,7 +26,8 @@ Mailbox conversion: Other tools: acroread2sylpheed.pl Send PDFs from Adobe Reader 7 - filter_conv.pl Convert old-style filters to new filtering + filter_conv_new.pl Convert new-style Sylpheed filters to filtering + filter_conv.pl Convert old-style Sylpheed filters to filtering nautilus2sylpheed.sh Send files from Nautilus OOo2sylpheed.pl Send documents from OpenOffice.org sylprint.pl Printing engine, explained in README.sylprint @@ -380,13 +381,36 @@ Other tools Contact: Paul Mangan +* filter_conv_new.pl + + WHAT IT DOES + This perl script provides easy conversion of your filtering rules from + sylpheed's new filter system (>= 0.9.99) to the filtering system used in + sylpheed-claws. (Disabled rules are ignored) + It reads '~/.sylpheed-2.0/filter.xml' or '~/.sylpheed/filter.xml' and + writes '~/[CLAWS CONFIG DIR]/matcherrc' + + HOW TO USE IT + Issue the following command from the 'tools' directory: + + perl filter_conv_new.pl + + That's it, the claws' filtering system is now implemented with your + previous rules applied. + + REQUIREMENTS + XML::SimpleObject + + Contact: Paul Mangan + + * filter_conv.pl WHAT IT DOES This perl script provides easy conversion of your filtering rules - form sylpheed's old filter system (pre version 0.9.99) to the new - filtering system used in sylpheed-claws. - It reads '~/.sylpheed/filterrc' and outputs '~/.sylpheed-claws/matcherrc'. + from sylpheed's old filter system (< 0.9.99) to the filtering system + used in sylpheed-claws. + It reads '~/.sylpheed/filterrc' and writes '~/.sylpheed-claws/matcherrc' HOW TO USE IT Issue the following command from the 'tools' directory: diff --git a/tools/filter_conv_new.pl b/tools/filter_conv_new.pl index 8bab8eb01..b63ef35c1 100644 --- a/tools/filter_conv_new.pl +++ b/tools/filter_conv_new.pl @@ -78,16 +78,28 @@ use strict; use XML::SimpleObject; my $old_config = "$ENV{HOME}/.sylpheed-2.0/filter.xml"; -my $config_dir = `sylpheed-claws --config-dir`; +my $older_config = "$ENV{HOME}/.sylpheed/filter.xml"; +my $old_filters; + +my $config_dir = `sylpheed-claws --config-dir` or die("ERROR: + You don't appear to have Sylpheed-Claws installed\n"); chomp $config_dir; -chdir($ENV{ HOME } . "/$config_dir") - or die("You don't appear to have Sylpheed-Claws installed\n"); +chdir($ENV{HOME} . "/$config_dir") or die("ERROR: + Sylpheed-Claws config directory not found [~/$config_dir] + You need to run Sylpheed-Claws once, quit it, and then rerun this script\n"); --e $old_config or die("Can't find old filters [$old_config]\n"); +if (-e $old_config) { + $old_filters = $old_config; +} elsif (-e $older_config) { + $old_filters = $older_config; +} else { + print "ERROR:\n\tSylpheed filter not found\n\t[$old_config]\n\t[$older_config]\n"; + exit; +} my $parser = XML::Parser->new(ErrorContext => 2, Style => "Tree"); -my $xmlobj = XML::SimpleObject->new($parser->parsefile($old_config)); +my $xmlobj = XML::SimpleObject->new($parser->parsefile($old_filters)); my @conditions = ('match-header','match-to-or-cc','match-any-header', 'match-body-text','command-test','size','age'); @@ -102,6 +114,7 @@ my $exact_matches = qr/^(?:move|copy|delete|mark)$/; my @new_filters = ("[filtering]"); +my $disabled = 0; my $bool; ## rules list @@ -114,6 +127,7 @@ foreach my $element ($xmlobj->child("filter")->children("rule")) { } if ($element->attribute("enabled")) { if ($element->attribute("enabled") eq "false") { + $disabled++; next; # skip disabled rules } } @@ -177,8 +191,7 @@ foreach my $element ($xmlobj->child("filter")->children("rule")) { $new_filter .= "matchcase "; } } - my $value = $sibling->value; - $value = clean_me($value); + my $value = clean_me($sibling->value); if ($condition =~ m/$numeric_matches/) { $new_filter .= "$value"; } else { @@ -209,8 +222,7 @@ foreach my $element ($xmlobj->child("filter")->children("rule")) { $new_filter .= " stop"; } if ($sibling->value) { - my $value = $sibling->value; - $value = clean_me($value); + my $value = clean_me($sibling->value); if ($action eq "color-label") { $new_filter .= " $value"; } else { @@ -233,6 +245,9 @@ open(MATCHERRC, ">>matcherrc"); close(MATCHERRC); print "Converted ". ($#new_filters-1) . " filters\n"; +if ($disabled) { + print "[$disabled disabled filter(s) not converted]\n"; +} exit; -- 2.25.1