diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch) | |
tree | 67208f7c145782a7e90b123b982ca78d88cc2c87 /kmail/kmail-upd-identities.pl | |
download | tdepim-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-upd-identities.pl')
-rwxr-xr-x | kmail/kmail-upd-identities.pl | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/kmail/kmail-upd-identities.pl b/kmail/kmail-upd-identities.pl new file mode 100755 index 000000000..3dd9f4e98 --- /dev/null +++ b/kmail/kmail-upd-identities.pl @@ -0,0 +1,54 @@ +#!/usr/bin/perl + +my (%data); + +$currentGroup = ""; + +while (<>) { + next if /^$/; + # filter out groups: + if ( /^\[(.+)\]$/ ) { $currentGroup = $1; next; }; + # store all keys regarding Identities in the hash: + if ( $currentGroup =~ /^Identity/ ) { + ($key,$value) = split /=/; + chomp $value; + $data{$currentGroup}{$key} = $value; + } +} + +# We need to prevent this script from being run twice, since it would +# kill all identities then. +# Non-presence of the [Identity]IdentityList key is the best indiator: +unless ( defined( $data{'Identity'}{'IdentityList'} ) ) { exit; } + +# first, delete all old groups: +foreach $group ( keys %data ) { + print "# DELETEGROUP [$group]\n"; +} + +# now, extract the list of valid identities (and their sequence): +$rawIdentityList = $data{'Identity'}{'IdentityList'}; +# don't include the IdentityList anymore: +delete $data{'Identity'}{'IdentityList'}; +# remove backslash-quoting: +$rawIdentityList =~ s/\\(.)/$1/g; +# split into a list at unquoted commas: +@identities = split /(?<!\\),/, $rawIdentityList; +# unquote individual items yet again: +for ( @identities ) { s/\\(.)/$1/g; } +# build the list of groups (this time incl. the default identity): +@groups = ( 'Identity', map { $_ = "Identity-$_"; } @identities ); +# write out the groups, now named "Identity #n", +# with the same data and the same keys that the old groups had: +$n = 0; +foreach $group (@groups) { + %groupData = %{$data{$group}}; + print "[Identity #$n]\n"; + foreach $key ( keys %groupData ) { + print "$key=" + . $groupData{$key} . "\n"; + } + $n++; +} +# remember which one is default: +print "[General]\nDefault Identity=" . $data{'Identity'}{'Identity'} . "\n"; |