SVN_SILENT made messages (.desktop file)
[kdepim.git] / kmail / kconf_update / kmail-upd-identities.pl
blob3dd9f4e9878ffffc30fc4f0b640ac3835c2f8f69
1 #!/usr/bin/perl
3 my (%data);
5 $currentGroup = "";
7 while (<>) {
8 next if /^$/;
9 # filter out groups:
10 if ( /^\[(.+)\]$/ ) { $currentGroup = $1; next; };
11 # store all keys regarding Identities in the hash:
12 if ( $currentGroup =~ /^Identity/ ) {
13 ($key,$value) = split /=/;
14 chomp $value;
15 $data{$currentGroup}{$key} = $value;
19 # We need to prevent this script from being run twice, since it would
20 # kill all identities then.
21 # Non-presence of the [Identity]IdentityList key is the best indiator:
22 unless ( defined( $data{'Identity'}{'IdentityList'} ) ) { exit; }
24 # first, delete all old groups:
25 foreach $group ( keys %data ) {
26 print "# DELETEGROUP [$group]\n";
29 # now, extract the list of valid identities (and their sequence):
30 $rawIdentityList = $data{'Identity'}{'IdentityList'};
31 # don't include the IdentityList anymore:
32 delete $data{'Identity'}{'IdentityList'};
33 # remove backslash-quoting:
34 $rawIdentityList =~ s/\\(.)/$1/g;
35 # split into a list at unquoted commas:
36 @identities = split /(?<!\\),/, $rawIdentityList;
37 # unquote individual items yet again:
38 for ( @identities ) { s/\\(.)/$1/g; }
39 # build the list of groups (this time incl. the default identity):
40 @groups = ( 'Identity', map { $_ = "Identity-$_"; } @identities );
41 # write out the groups, now named "Identity #n",
42 # with the same data and the same keys that the old groups had:
43 $n = 0;
44 foreach $group (@groups) {
45 %groupData = %{$data{$group}};
46 print "[Identity #$n]\n";
47 foreach $key ( keys %groupData ) {
48 print "$key="
49 . $groupData{$key} . "\n";
51 $n++;
53 # remember which one is default:
54 print "[General]\nDefault Identity=" . $data{'Identity'}{'Identity'} . "\n";