summaryrefslogtreecommitdiffstats
path: root/kmail/kmail-3.1.4-dont-use-UOID-0-for-any-identity.pl
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /kmail/kmail-3.1.4-dont-use-UOID-0-for-any-identity.pl
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmail/kmail-3.1.4-dont-use-UOID-0-for-any-identity.pl')
-rw-r--r--kmail/kmail-3.1.4-dont-use-UOID-0-for-any-identity.pl88
1 files changed, 88 insertions, 0 deletions
diff --git a/kmail/kmail-3.1.4-dont-use-UOID-0-for-any-identity.pl b/kmail/kmail-3.1.4-dont-use-UOID-0-for-any-identity.pl
new file mode 100644
index 000000000..0dba90802
--- /dev/null
+++ b/kmail/kmail-3.1.4-dont-use-UOID-0-for-any-identity.pl
@@ -0,0 +1,88 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+# this script goes through all the config keys that deal with
+# identities and replaces UOID 0 (which was erroneously always assigned to the
+# first identity) with a non-zero UOID.
+
+# 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;
+ }
+}
+
+# filter out identity groups
+my @identityGroups = grep { /^\[Identity \#\d+\]/ } keys %configFile;
+
+# create new UOID for an identity with UOID 0
+my $newUoid = 0;
+foreach my $identityGroup (@identityGroups) {
+ my $oldUoid = $configFile{$identityGroup}{'uoid'};
+ if ( $oldUoid eq "0" ) {
+ $newUoid = int(rand 0x7fFFffFE) + 1;
+ # change the uoid entry this identity
+ print "# DELETE ${identityGroup}uoid\n";
+ print "${identityGroup}\nuoid=$newUoid\n";
+ }
+}
+
+if ( $newUoid != 0 ) {
+ # change the default identity value if it was 0
+ my $tempId = $configFile{'[General]'}{'Default Identity'};
+ if ( $tempId eq "0" ) {
+ print "# DELETE [General]Default Identity\n";
+ print "[General]\nDefault Identity=$newUoid\n";
+ }
+
+ # [Composer]previous-identity
+ $tempId = $configFile{'[Composer]'}{'previous-identity'};
+ if ( $tempId eq "0" ) {
+ print "# DELETE [Composer]previous-identity\n";
+ print "[Composer]\nprevious-identity=$newUoid\n";
+ }
+
+ # Now, go through all [Folder-*] groups and replace all occurrences of
+ # Identity=0 with Identity=$newUoid
+ my @folderGroups = grep { /^\[Folder-.*\]/ } keys %configFile;
+
+ foreach my $folderGroup ( @folderGroups ) {
+ $tempId = $configFile{$folderGroup}{'Identity'};
+ if ( $tempId eq "0" ) {
+ print "# DELETE ${folderGroup}Identity\n";
+ print "$folderGroup\nIdentity=$newUoid\n";
+ }
+ }
+
+ # Now, go through all [Filter #n] groups and replace all occurrences of
+ # UOID 0 as argument to the 'set identity' filter action with the new UOID
+ my @filterGroups = grep { /^\[Filter \#\d+\]/ } keys %configFile;
+
+ foreach my $filterGroup (@filterGroups) {
+ my $numActions = +$configFile{$filterGroup}{'actions'};
+ # go through all actions in search for "set identity":
+ for ( my $i = 0 ; $i < $numActions ; ++$i ) {
+ my $actionName = "action-name-$i";
+ my $actionArgs = "action-args-$i";
+ if ( $configFile{$filterGroup}{$actionName} eq "set identity" ) {
+ # found one:
+ # replace it's argument with the new UOID if necessary
+ $tempId = $configFile{$filterGroup}{$actionArgs};;
+ if ( $tempId eq "0" ) {
+ print "# DELETE $filterGroup$actionArgs\n";
+ print "$filterGroup\n$actionArgs=$newUoid\n";
+ }
+ }
+ }
+ }
+}