summaryrefslogtreecommitdiffstats
path: root/kmail/upgrade-signature.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/upgrade-signature.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/upgrade-signature.pl')
-rwxr-xr-xkmail/upgrade-signature.pl63
1 files changed, 63 insertions, 0 deletions
diff --git a/kmail/upgrade-signature.pl b/kmail/upgrade-signature.pl
new file mode 100755
index 00000000..23c3d63b
--- /dev/null
+++ b/kmail/upgrade-signature.pl
@@ -0,0 +1,63 @@
+#!/usr/bin/perl
+
+my (%data);
+my $section = "";
+
+sub process {
+ # delete obsolete keys:
+ print "# DELETE [$section]UseSignatureFile\n";
+
+ # now determine the type of signature:
+ if ( $data{'usefile'} =~ /false/i ) {
+ # type = inline
+ if ( $data{'inline'} ne "" ) {
+ print "[$section]\nSignature Type=inline\n";
+ } else {
+ print "[$section]\nSignature Type=disabled\n";
+ print "# DELETE [$section]Inline Signature\n";
+ }
+ print "# DELETE [$section]Signature File\n";
+ } else {
+ # type = file or command
+ if ( $data{'file'} =~ /\|$/ ) {
+ # a trailing pipe means:
+ # type = command
+ chop $data{'file'};
+ print "[$section]\nSignature Type=command\n";
+ print "[$section]\nSignature Command=", $data{'file'}, "\n";
+ print "# DELETE [$section]Signature File\n";
+ print "# DELETE [$section]Inline Signature\n";
+ } elsif ( $data{'file'} eq "" ) {
+ # empty filename means:
+ # type = disabled
+ print "[$section]\nSignature Type=disabled\n";
+ print "# DELETE [$section]Inline Signature\n";
+ print "# DELETE [$section]Signature File\n";
+ } else {
+ # type = file
+ print "[$section]\nSignature Type=file\n";
+ print "# DELETE [$section]Inline Signature\n";
+ }
+ }
+}
+
+#loop over all lines to find Identity sections:
+while (<>) {
+ if ( /\[(Identity[^]]*)\]/ ) {
+ # new group means that we have to process the old group:
+ if ( $section ne "" ) { process(); }
+ $section = $1;
+ %data = ();
+ next;
+ }
+ chomp;
+ # We need to prevent this script from begin run twice
+ # since it would set all signatures to 'disabled' then.
+ # Presence of the Signature Type key is the best indicator.
+ /^Signature Type/ and exit;
+ /^Inline Signature=(.*)$/ and $data{'inline'} = $1;
+ /^Signature File=(.*)$/ and $data{'file'} = $1;
+ /^UseSignatureFile=(.*)$/ and $data{'usefile'} = $1;
+}
+#and don't forget to preocess the last group ;-)
+if ( $section ne "" ) { process(); }