From 44aca43b5730898ff465139fe01d29c3287b6443 Mon Sep 17 00:00:00 2001 From: Ingo Klcker Date: Sun, 17 Apr 2005 22:20:44 +0000 Subject: [PATCH] Add configuration update script for fixing changed keys for filtering by status. BUGS:101001 svn path=/trunk/kdepim/; revision=406208 --- Makefile.am | 3 +- kmail-3.4.1-update-status-filters.pl | 42 ++++++++++++++++++++++++++++ kmail.upd | 4 +++ kmstartup.cpp | 3 +- 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 kmail-3.4.1-update-status-filters.pl diff --git a/Makefile.am b/Makefile.am index b9f0d4f85..c93c8b99c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -167,7 +167,8 @@ update_SCRIPTS = upgrade-transport.pl kmail-pgpidentity.pl \ kmail-3.3-split-sign-encr-keys.sh \ kmail-3.3-misc.pl \ kmail-3.3b1-misc.pl \ - kmail-3.4-misc.pl + kmail-3.4-misc.pl \ + kmail-3.4.1-update-status-filters.pl confdir = $(kde_confdir) conf_DATA = kmail.antispamrc kmail.antivirusrc diff --git a/kmail-3.4.1-update-status-filters.pl b/kmail-3.4.1-update-status-filters.pl new file mode 100644 index 000000000..735daf774 --- /dev/null +++ b/kmail-3.4.1-update-status-filters.pl @@ -0,0 +1,42 @@ +#!/usr/bin/perl -w + +use strict; + +# This script converts lower case status filter rules to upper case. + +# read the whole config file +my $currentGroup = ""; +my %configFile; +while ( <> ) { + chomp; + next if ( /^$/ ); # skip empty lines + next if ( /^\#/ ); # skip comments + if ( /^\[/ ) { # group begin + $currentGroup = $_; + next; + } elsif ( $currentGroup ne "" ) { # normal entry + my ($key,$value) = split /=/; + $configFile{$currentGroup}{$key}=$value; + } +} + +# go through all filters and check for rules which are no longer valid +my @filterGroups = grep { /^\[Filter \#\d+\]/ } keys %configFile; +foreach my $filterGroup (@filterGroups) { + my $numRules = $configFile{$filterGroup}{'rules'}; + # go through all rules: + for ( my $i = 0; $i < $numRules; ++$i ) { + my $c = chr( ord("A") + $i ); + my $fieldKey = "field$c"; + my $field = $configFile{$filterGroup}{$fieldKey}; + if ( $field eq "" ) { + my $contentsKey = "contents$c"; + my $contents = $configFile{$filterGroup}{$contentsKey}; + if ( $contents =~ /^[a-z]/ ) { + $contents = ucfirst( $contents ); + print "# DELETE $filterGroup$contentsKey\n"; + print "$filterGroup\n$contentsKey=$contents\n"; + } + } + } +} diff --git a/kmail.upd b/kmail.upd index 9bab87611..ca5b66fe5 100644 --- a/kmail.upd +++ b/kmail.upd @@ -154,6 +154,10 @@ Options=copy Key=list-font,list-new-font Options=copy Key=list-font,list-unread-font +# Convert status filter rules to upper case (cf. bug #101001) +Id=3.4.1 +File=kmailrc +Script=kmail-3.4.1-update-status-filters.pl,perl # # Important notice: # If you add updates here, keep this text below them. diff --git a/kmstartup.cpp b/kmstartup.cpp index fc3c92710..e4f09723a 100644 --- a/kmstartup.cpp +++ b/kmstartup.cpp @@ -112,7 +112,8 @@ void checkConfigUpdates() { "3.3b1-misc", "3.4-misc", "3.4a", - "3.4b" + "3.4b", + "3.4.1" }; static const int numUpdates = sizeof updates / sizeof *updates; // Warning: do not remove entries in the above array, or the update-level check below will break