2006-01-11 [paul] 1.9.100cvs137
authorPaul Mangan <paul@claws-mail.org>
Wed, 11 Jan 2006 13:44:17 +0000 (13:44 +0000)
committerPaul Mangan <paul@claws-mail.org>
Wed, 11 Jan 2006 13:44:17 +0000 (13:44 +0000)
* 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
PATCHSETS
configure.ac
tools/README
tools/filter_conv_new.pl

index f1f64c137d19cee708c8988894e42bd3713886e5..b7f0e8fcf0eadc57506cbee847f6d18b9e1caafb 100644 (file)
--- 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
index c0ba1f21885dd9f4da217604072a63d00f572e8a..cbd8c194b69ef9d7785334598a12e4ac2e1fefe7 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( 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
index 9d6074328e714af8b0f7784b83722811d8489ffc..6bac73204ae4a44441327c97a8aaa6dbe0882072 100644 (file)
@@ -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=
 
index 77293267f17baecc29d2502eaafdb8bb8ed0961d..93abe9c5280fe652cd2a98dfaa336dd2fe4951ea 100644 (file)
@@ -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 <claws@thewildbeast.co.uk>
 
 
+* 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 <claws@thewildbeast.co.uk>
+  
+
 * 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:
index 8bab8eb016515b613332f2605b9fa4724b842d01..b63ef35c17d71f048a2fcb3a259b26f27083000c 100644 (file)
@@ -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;