3 # * Copyright 2002 Paul Mangan <claws@thewildbeast.co.uk>
5 # * This file is free software; you can redistribute it and/or modify it
6 # * under the terms of the GNU General Public License as published by
7 # * the Free Software Foundation; either version 2 of the License, or
8 # * (at your option) any later version.
10 # * This program is distributed in the hope that it will be useful, but
11 # * WITHOUT ANY WARRANTY; without even the implied warranty of
12 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # * General Public License for more details.
15 # * You should have received a copy of the GNU General Public License
16 # * along with this program; if not, write to the Free Software
17 # * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 chdir '.sylpheed' || die("You don't appear to have Sylpheed installed\n");
23 open(FOLDERLIST, "<folderlist.xml") || die("Can't find folderlist.xml\n");
24 @folderlist = <FOLDERLIST>;
27 foreach $folderlist (@folderlist) {
29 if ($folderlist =~ m/<folder type="mh"/) {
30 $folderlist =~ s/<folder type="mh" name="//;
31 $folderlist =~ s/" path="[A-Z0-9]+">\n//ig;
32 $folderlist =~ s/^ +//;
33 $mailbox = $folderlist;
38 open (FILTERRC, "<filterrc") || die("Can't find your old filter rules\n");
39 @filterrc = <FILTERRC>;
43 print "\nYou don't have any filter rules\n\n";
51 open (MATCHER, "<matcherrc") || die("Can't open matcherrc\n");
52 @matcherrc = <MATCHER>;
54 foreach $matcherrc (@matcherrc) {
55 $WRITE_THIS .= $matcherrc;
60 $WRITE_THIS .= "[global]\n";
62 foreach $filterrc (@filterrc) {
64 @split_lines = split("\t", $filterrc);
65 if ($split_lines[6] eq "0") {
66 $match_type = "matchcase";
68 } elsif ($split_lines[6] eq "1") {
69 $match_type = "matchcase";
71 } elsif ($split_lines[6] eq "4") {
72 $match_type = "regexpcase";
74 } elsif ($split_lines[6] eq "5") {
75 $match_type = "regexpcase";
78 if ($split_lines[7] eq "0") {
79 $match_type = "matchcase";
81 } elsif ($split_lines[7] eq "1") {
82 $match_type = "matchcase";
84 } elsif ($split_lines[7] eq "4") {
85 $match_type = "regexpcase";
87 } elsif ($split_lines[7] eq "5") {
88 $match_type = "regexpcase";
92 if ($split_lines[2] eq "&") {
96 elsif ($split_lines[2] eq "|") {
99 } elsif ($split_lines[0] eq "To") {
100 $WRITE_THIS .= "$predicate_one"."to $match_type \"$split_lines[1]\"";
101 } elsif ($split_lines[0] eq "Reply-To") {
102 $WRITE_THIS .= "$predicate_one"."inreplyto $match_type \"$split_lines[1]\"";
103 } elsif ($split_lines[0] eq "Subject") {
104 $WRITE_THIS .= "$predicate_one"."subject $match_type \"$split_lines[1]\"";
105 } elsif ($split_lines[0] eq "From"){
106 $WRITE_THIS .= "$predicate_one"."from $match_type \"$split_lines[1]\"";
107 } elsif ($split_lines[0] eq "Sender" || $split_lines[0] eq "List-Id" ||
108 $split_lines[0] eq "X-ML-Name" || $split_lines[0] eq "X-List" ||
109 $split_lines[0] eq "X-Sequence" || $split_lines[0] eq "X-Mailer" ||
110 $split_lines[0] eq "Cc") {
111 $WRITE_THIS .= "$predicate_one"."header $split_lines[0] $match_type \"$split_lines[1]\"";
113 if ($split_lines[8] eq "n\n") {
114 $WRITE_THIS .= " delete";
115 } elsif ($split_lines[8] eq "m\n"){
116 $WRITE_THIS .= " move \"\#mh/$mailbox/$split_lines[5]\"";
122 open (MATCHERRC, ">matcherrc");
123 print MATCHERRC $WRITE_THIS;
126 rename ("filterrc","filterrc.old");
128 print "\nYou have sucessfully converted $COUNT filtering rules\n\n";
129 print "'filterrc' has been renamed 'filterrc.old'\n\n";
133 if ($split_lines[0] eq "To" && $split_lines[3] eq "Cc" &&
134 $split_lines[1] eq $split_lines[4]) {
135 $WRITE_THIS .= "$predicate_one"."to_or_cc $match_type \"$split_lines[1]\"";
137 elsif ($split_lines[0] eq "To") {
138 $WRITE_THIS .= "$predicate_one"."to $match_type \"$split_lines[1]\" $operator ";
139 } elsif ($split_lines[0] eq "Reply-To") {
140 $WRITE_THIS .= "$predicate_one"."inreplyto $match_type \"$split_lines[1]\" $operator ";
141 } elsif ($split_lines[0] eq "Subject") {
142 $WRITE_THIS .= "$predicate_one"."subject $match_type \"$split_lines[1]\" $operator ";
143 } elsif ($split_lines[0] eq "From") {
144 $WRITE_THIS .= "$predicate_one"."from $match_type \"$split_lines[1]\" $operator ";
145 } elsif ($split_lines[0] eq "Sender" || $split_lines[0] eq "List-Id" ||
146 $split_lines[0] eq "X-ML-Name" || $split_lines[0] eq "X-List" ||
147 $split_lines[0] eq "X-Sequence" || $split_lines[0] eq "X-Mailer" ||
148 $split_lines[0] eq "Cc") {
149 $WRITE_THIS .= "$predicate_one"."header $split_lines[0] $match_type \"$split_lines[1]\" $operator ";
152 if ($split_lines[3] eq "To") {
153 $WRITE_THIS .= "$predicate_two"."to $match_type \"$split_lines[4]\"";
154 } elsif ($split_lines[3] eq "Reply-To") {
155 $WRITE_THIS .= "$predicate_two"."inreplyto $match_type \"$split_lines[4]\"";
156 } elsif ($split_lines[3] eq "Subject") {
157 $WRITE_THIS .= "$predicate_two"."subject $match_type \"$split_lines[4]\"";
158 } elsif ($split_lines[3] eq "From") {
159 $WRITE_THIS .= "$predicate_two"."from $match_type \"$split_lines[4]\"";
160 } elsif ($split_lines[3] eq "Sender" || $split_lines[3] eq "List-Id" ||
161 $split_lines[3] eq "X-ML-Name" || $split_lines[3] eq "X-List" ||
162 $split_lines[3] eq "X-Sequence" || $split_lines[3] eq "X-Mailer" ||
163 $split_lines[3] eq "Cc") {
164 $WRITE_THIS .= "$predicate_two"."header $split_lines[3] $match_type \"$split_lines[4]\"";