summaryrefslogtreecommitdiffstats
path: root/kmail/kmail-pgpidentity.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-pgpidentity.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-pgpidentity.pl')
-rwxr-xr-xkmail/kmail-pgpidentity.pl34
1 files changed, 34 insertions, 0 deletions
diff --git a/kmail/kmail-pgpidentity.pl b/kmail/kmail-pgpidentity.pl
new file mode 100755
index 00000000..b6e7bcad
--- /dev/null
+++ b/kmail/kmail-pgpidentity.pl
@@ -0,0 +1,34 @@
+#!/usr/bin/perl
+
+# For each KMail Identity convert the "PGP Identity" entry (which contains a
+# user ID) to a "Default PGP Key" entry (which contains a key ID)
+
+$DEBUG = 0;
+
+while(<>)
+{
+ if( /\[(Identity.*)\]/ )
+ {
+ $section = $1;
+ next;
+ }
+ if( /^PGP Identity=(.*)$/ )
+ {
+ print STDERR "\n[$section]PGP Identity=$1\n" if ( $DEBUG );
+
+ if( ( $1 ne "" ) &&
+ ( open GnuPG, "gpg --list-secret-keys --utf8-strings '$1' |" ) )
+ {
+ while (<GnuPG>)
+ {
+ # search in gpg's output for the key id of the first matching key
+ if(/^sec[^\/]*\/([0-9A-F]*)/)
+ {
+ print "[$section]\nDefault PGP Key=$1\n";
+ last;
+ }
+ }
+ }
+ print "# DELETE [$section]PGP Identity\n";
+ }
+}