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]+"//ig;
32 $folderlist =~ s/ collapsed="1"//;
33 $folderlist =~ s/>\n//ig;
34 $folderlist =~ s/^ +//;
35 $mailbox = $folderlist;
40 open (FILTERRC, "<filterrc") || die("Can't find your old filter rules\n");
41 @filterrc = <FILTERRC>;
45 print "\nYou don't have any filter rules\n\n";
53 open (MATCHER, "<matcherrc") || die("Can't open matcherrc\n");
54 @matcherrc = <MATCHER>;
56 foreach $matcherrc (@matcherrc) {
57 $WRITE_THIS .= $matcherrc;
62 $WRITE_THIS .= "[global]\n";
64 foreach $filterrc (@filterrc) {
66 @split_lines = split("\t", $filterrc);
67 if ($split_lines[6] eq "0") {
68 $match_type = "matchcase";
70 } elsif ($split_lines[6] eq "1") {
71 $match_type = "matchcase";
73 } elsif ($split_lines[6] eq "4") {
74 $match_type = "regexpcase";
76 } elsif ($split_lines[6] eq "5") {
77 $match_type = "regexpcase";
80 if ($split_lines[7] eq "0") {
81 $match_type = "matchcase";
83 } elsif ($split_lines[7] eq "1") {
84 $match_type = "matchcase";
86 } elsif ($split_lines[7] eq "4") {
87 $match_type = "regexpcase";
89 } elsif ($split_lines[7] eq "5") {
90 $match_type = "regexpcase";
94 if ($split_lines[2] eq "&") {
98 elsif ($split_lines[2] eq "|") {
101 } elsif ($split_lines[0] eq "To") {
102 $WRITE_THIS .= "$predicate_one"."to $match_type \"$split_lines[1]\"";
103 } elsif ($split_lines[0] eq "Reply-To") {
104 $WRITE_THIS .= "$predicate_one"."inreplyto $match_type \"$split_lines[1]\"";
105 } elsif ($split_lines[0] eq "Subject") {
106 $WRITE_THIS .= "$predicate_one"."subject $match_type \"$split_lines[1]\"";
107 } elsif ($split_lines[0] eq "From"){
108 $WRITE_THIS .= "$predicate_one"."from $match_type \"$split_lines[1]\"";
109 } elsif ($split_lines[0] eq "Sender" || $split_lines[0] eq "List-Id" ||
110 $split_lines[0] eq "X-ML-Name" || $split_lines[0] eq "X-List" ||
111 $split_lines[0] eq "X-Sequence" || $split_lines[0] eq "X-Mailer" ||
112 $split_lines[0] eq "Cc") {
113 $WRITE_THIS .= "$predicate_one"."header \"$split_lines[0]\" $match_type \"$split_lines[1]\"";
115 if ($split_lines[8] eq "n\n") {
116 $WRITE_THIS .= " delete";
117 } elsif ($split_lines[8] eq "m\n"){
118 $WRITE_THIS .= " move \"\#mh/$mailbox/$split_lines[5]\"";
124 open (MATCHERRC, ">matcherrc");
125 print MATCHERRC $WRITE_THIS;
128 rename ("filterrc","filterrc.old");
130 print "\nYou have sucessfully converted $COUNT filtering rules\n\n";
131 print "'filterrc' has been renamed 'filterrc.old'\n\n";
135 if ($split_lines[0] eq "To" && $split_lines[3] eq "Cc" &&
136 $split_lines[1] eq $split_lines[4]) {
137 $WRITE_THIS .= "$predicate_one"."to_or_cc $match_type \"$split_lines[1]\"";
139 elsif ($split_lines[0] eq "To") {
140 $WRITE_THIS .= "$predicate_one"."to $match_type \"$split_lines[1]\" $operator ";
141 } elsif ($split_lines[0] eq "Reply-To") {
142 $WRITE_THIS .= "$predicate_one"."inreplyto $match_type \"$split_lines[1]\" $operator ";
143 } elsif ($split_lines[0] eq "Subject") {
144 $WRITE_THIS .= "$predicate_one"."subject $match_type \"$split_lines[1]\" $operator ";
145 } elsif ($split_lines[0] eq "From") {
146 $WRITE_THIS .= "$predicate_one"."from $match_type \"$split_lines[1]\" $operator ";
147 } elsif ($split_lines[0] eq "Sender" || $split_lines[0] eq "List-Id" ||
148 $split_lines[0] eq "X-ML-Name" || $split_lines[0] eq "X-List" ||
149 $split_lines[0] eq "X-Sequence" || $split_lines[0] eq "X-Mailer" ||
150 $split_lines[0] eq "Cc") {
151 $WRITE_THIS .= "$predicate_one"."header \"$split_lines[0]\" $match_type \"$split_lines[1]\" $operator ";
154 if ($split_lines[3] eq "To") {
155 $WRITE_THIS .= "$predicate_two"."to $match_type \"$split_lines[4]\"";
156 } elsif ($split_lines[3] eq "Reply-To") {
157 $WRITE_THIS .= "$predicate_two"."inreplyto $match_type \"$split_lines[4]\"";
158 } elsif ($split_lines[3] eq "Subject") {
159 $WRITE_THIS .= "$predicate_two"."subject $match_type \"$split_lines[4]\"";
160 } elsif ($split_lines[3] eq "From") {
161 $WRITE_THIS .= "$predicate_two"."from $match_type \"$split_lines[4]\"";
162 } elsif ($split_lines[3] eq "Sender" || $split_lines[3] eq "List-Id" ||
163 $split_lines[3] eq "X-ML-Name" || $split_lines[3] eq "X-List" ||
164 $split_lines[3] eq "X-Sequence" || $split_lines[3] eq "X-Mailer" ||
165 $split_lines[3] eq "Cc") {
166 $WRITE_THIS .= "$predicate_two"."header \"$split_lines[3]\" $match_type \"$split_lines[4]\"";