3 # * Copyright 2001 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 chdir '.sylpheed' || die("You don't appear to have Sylpheed installed\n");
25 open(ACCOUNTRC, "<accountrc") || die("Can't find accountrc\n");
26 @accountrc = <ACCOUNTRC>;
29 foreach $accountrc (@accountrc) {
30 if ($accountrc =~ m/nntp_server=[A-Za-z0-9]/) {
31 $accountrc =~ s/nntp_server=//;
33 push(@newsserver, "$accountrc");
38 foreach $newsserver (@newsserver) {
42 opendir(NEWSCACHE, "newscache") || die("Can't open newscache\n");
43 push(@cached,(readdir(NEWSCACHE)));
45 splice(@cached, 0, 2);
46 foreach $cached (@cached) { ## remove old newsserver directory tree
47 rmtree("./newscache/$cached") unless $seen{$cached};
50 open(FOLDERLIST, "<folderlist.xml") || die("Can't find folderlist.xml\n");
51 @folderlist = <FOLDERLIST>;
55 foreach $folderlist (@folderlist) { ## remove old newsgroups directory trees
57 if ($folderlist =~ m/<folder type="news"/) {
60 $nntpserver = shift(@newsserver);
63 if ($wegotnews && $folderlist =~ m/<\/folder>\n/ && !$done_grp) {
64 opendir(NEWSGCACHE, "newscache/$nntpserver") || die("Can't open newscache/$nntpserver\n");
65 push(@cachedgrp,(readdir(NEWSGCACHE)));
67 splice(@cachedgrp, 0, 2);
68 foreach $cachedgrp (@cachedgrp) {
69 rmtree("./newscache/$nntpserver/$cachedgrp") unless ($saw{$cachedgrp}) || ($cachedgrp eq ".newsgroup_list");
75 if ($wegotnews && $folderlist !~ m/<\/folder>\n/) {
76 if ($folderlist =~ m/<folderitem type="normal"/) {
77 $folderlist =~ s/<folderitem type="normal" name="[A-Z0-9.]+" path="//i;
78 $folderlist =~ s/" threaded="[0-1]+//;
79 $folderlist =~ s/" hidereadmsgs="[0-1]+//;
80 $folderlist =~ s/" mtime="[0-9]+" new="[0-9]+" unread="[0-9]+" total="[0-9]+" \/>//;
81 $folderlist =~ s/ +//;
87 print "Finished cleaning Sylpheed's newscache\n";