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 (FILTERRC, "<filterrc") || die("Can't find your old filter rules\n");
24 @filterrc = <FILTERRC>;
28 print "\nYou don't have any filter rules\n\n";
36 open (MATCHER, "<matcherrc") || die("Can't open matcherrc\n");
37 @matcherrc = <MATCHER>;
39 foreach $matcherrc (@matcherrc) {
40 $WRITE_THIS .= $matcherrc;
45 $WRITE_THIS .= "[global]\n";
47 foreach $filterrc (@filterrc) {
49 @split_lines = split("\t", $filterrc);
50 if ($split_lines[6] eq "0") {
51 $match_type = "matchcase";
53 } elsif ($split_lines[6] eq "1") {
54 $match_type = "matchcase";
56 } elsif ($split_lines[6] eq "4") {
57 $match_type = "regexpcase";
59 } elsif ($split_lines[6] eq "5") {
60 $match_type = "regexpcase";
63 if ($split_lines[7] eq "0") {
64 $match_type = "matchcase";
66 } elsif ($split_lines[7] eq "1") {
67 $match_type = "matchcase";
69 } elsif ($split_lines[7] eq "4") {
70 $match_type = "regexpcase";
72 } elsif ($split_lines[7] eq "5") {
73 $match_type = "regexpcase";
77 if ($split_lines[2] eq "&") {
81 elsif ($split_lines[2] eq "|") {
84 } elsif ($split_lines[0] eq "To") {
85 $WRITE_THIS .= "$predicate_one"."to $match_type \"$split_lines[1]\"";
86 } elsif ($split_lines[0] eq "Reply-To") {
87 $WRITE_THIS .= "$predicate_one"."inreplyto $match_type \"$split_lines[1]\"";
88 } elsif ($split_lines[0] eq "Subject") {
89 $WRITE_THIS .= "$predicate_one"."subject $match_type \"$split_lines[1]\"";
90 } elsif ($split_lines[0] eq "From"){
91 $WRITE_THIS .= "$predicate_one"."from $match_type \"$split_lines[1]\"";
92 } elsif ($split_lines[0] eq "Sender" || $split_lines[0] eq "List-Id" ||
93 $split_lines[0] eq "X-ML-Name" || $split_lines[0] eq "X-List" ||
94 $split_lines[0] eq "X-Sequence" || $split_lines[0] eq "X-Mailer" ||
95 $split_lines[0] eq "Cc") {
96 $WRITE_THIS .= "$predicate_one"."header $split_lines[0] $match_type \"$split_lines[1]\"";
98 if ($split_lines[8] eq "n\n") {
99 $WRITE_THIS .= " delete";
100 } elsif ($split_lines[8] eq "m\n"){
101 $WRITE_THIS .= " move \"$split_lines[5]\"";
107 open (MATCHERRC, ">matcherrc");
108 print MATCHERRC $WRITE_THIS;
111 rename ("filterrc","filterrc.old");
113 print "\nYou have sucessfully converted $COUNT filtering rules\n\n";
114 print "'filterrc' has been renamed 'filterrc.old'\n\n";
118 if ($split_lines[0] eq "To" && $split_lines[3] eq "Cc" &&
119 $split_lines[1] eq $split_lines[4]) {
120 $WRITE_THIS .= "$predicate_one"."to_or_cc $match_type \"$split_lines[1]\"";
122 elsif ($split_lines[0] eq "To") {
123 $WRITE_THIS .= "$predicate_one"."to $match_type \"$split_lines[1]\" $operator ";
124 } elsif ($split_lines[0] eq "Reply-To") {
125 $WRITE_THIS .= "$predicate_one"."inreplyto $match_type \"$split_lines[1]\" $operator ";
126 } elsif ($split_lines[0] eq "Subject") {
127 $WRITE_THIS .= "$predicate_one"."subject $match_type \"$split_lines[1]\" $operator ";
128 } elsif ($split_lines[0] eq "From") {
129 $WRITE_THIS .= "$predicate_one"."from $match_type \"$split_lines[1]\" $operator ";
130 } elsif ($split_lines[0] eq "Sender" || $split_lines[0] eq "List-Id" ||
131 $split_lines[0] eq "X-ML-Name" || $split_lines[0] eq "X-List" ||
132 $split_lines[0] eq "X-Sequence" || $split_lines[0] eq "X-Mailer" ||
133 $split_lines[0] eq "Cc") {
134 $WRITE_THIS .= "$predicate_one"."header $split_lines[0] $match_type \"$split_lines[1]\" $operator ";
137 if ($split_lines[3] eq "To") {
138 $WRITE_THIS .= "$predicate_two"."to $match_type \"$split_lines[4]\"";
139 } elsif ($split_lines[3] eq "Reply-To") {
140 $WRITE_THIS .= "$predicate_two"."inreplyto $match_type \"$split_lines[4]\"";
141 } elsif ($split_lines[3] eq "Subject") {
142 $WRITE_THIS .= "$predicate_two"."subject $match_type \"$split_lines[4]\"";
143 } elsif ($split_lines[3] eq "From") {
144 $WRITE_THIS .= "$predicate_two"."from $match_type \"$split_lines[4]\"";
145 } elsif ($split_lines[3] eq "Sender" || $split_lines[3] eq "List-Id" ||
146 $split_lines[3] eq "X-ML-Name" || $split_lines[3] eq "X-List" ||
147 $split_lines[3] eq "X-Sequence" || $split_lines[3] eq "X-Mailer" ||
148 $split_lines[3] eq "Cc") {
149 $WRITE_THIS .= "$predicate_two"."header $split_lines[3] $match_type \"$split_lines[4]\"";