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) {
28 if ($folderlist =~ m/<folder type="mh"/) {
29 $folderlist =~ s/<folder type="mh" name="//;
30 $folderlist =~ s/" path="[A-Z0-9]+">\n//ig;
31 $folderlist =~ s/^ +//;
32 $mailbox = $folderlist;
36 open (FILTERRC, "<filterrc") || die("Can't find your old filter rules\n");
37 @filterrc = <FILTERRC>;
44 open (MATCHER, "<matcherrc") || die("Can't open matcherrc\n");
45 @matcherrc = <MATCHER>;
47 foreach $matcherrc (@matcherrc) {
48 $WRITE_THIS .= $matcherrc;
53 $WRITE_THIS .= "[global]\n";
55 foreach $filterrc (@filterrc) {
57 @split_lines = split("\t", $filterrc);
58 if ($split_lines[2] eq "&") {
62 elsif ($split_lines[2] eq "|") {
65 } elsif ($split_lines[0] eq "To") {
66 $WRITE_THIS .= "to matchcase \"$split_lines[1]\"";
67 } elsif ($split_lines[0] eq "Reply-To") {
68 $WRITE_THIS .= "inreplyto matchcase \"$split_lines[1]\"";
69 } elsif ($split_lines[0] eq "Subject") {
70 $WRITE_THIS .= "subject matchcase \"$split_lines[1]\"";
71 } elsif (($split_lines[0] eq "From") || ($split_lines[0] eq "Sender")){
72 $WRITE_THIS .= "from matchcase \"$split_lines[1]\"";
74 if (!$split_lines[5]) {
75 $WRITE_THIS .= " delete";
76 } elsif ($split_lines[8] eq "m\n"){
77 $WRITE_THIS .= " move \"\#mh/$mailbox/$split_lines[5]\"";
83 open (MATCHERRC, ">matcherrc");
84 print MATCHERRC $WRITE_THIS;
87 print "\nYou have sucessfully converted $COUNT filtering rules\n\n";
91 if ($split_lines[0] eq "To" && $split_lines[3] eq "Cc" &&
92 $split_lines[1] eq $split_lines[4]) {
93 $WRITE_THIS .= "to_or_cc matchcase \"$split_lines[1]\"";
95 elsif ($split_lines[0] eq "To") {
96 $WRITE_THIS .= "to matchcase \"$split_lines[1]\" $operator ";
97 } elsif ($split_lines[0] eq "Reply-To") {
98 $WRITE_THIS .= "inreplyto matchcase \"$split_lines[1]\" $operator ";
99 } elsif ($split_lines[0] eq "Subject") {
100 $WRITE_THIS .= "subject matchcase \"$split_lines[1]\" $operator ";
101 } elsif (($split_lines[0] eq "From") || ($split_lines[0] eq "Sender")) {
102 $WRITE_THIS .= "from matchcase \"$split_lines[1]\" $operator ";
104 if ($split_lines[3] eq "To") {
105 $WRITE_THIS .= "to matchcase \"$split_lines[4]\"";
106 } elsif ($split_lines[3] eq "Reply-To") {
107 $WRITE_THIS .= "inreplyto matchcase \"$split_lines[4]\"";
108 } elsif ($split_lines[3] eq "Subject") {
109 $WRITE_THIS .= "subject matchcase \"$split_lines[4]\"";
110 } elsif (($split_lines[3] eq "From") || ($split_lines[3] eq "Sender")) {
111 $WRITE_THIS .= "from matchcase \"$split_lines[4]\"";