Bug 145002 - KGPG should search un-encrypted text for embedded cryptogram(s)
Summary: KGPG should search un-encrypted text for embedded cryptogram(s)
Status: RESOLVED FIXED
Alias: None
Product: kgpg
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR wishlist
Target Milestone: ---
Assignee: Jimmy Gilles
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-04 03:10 UTC by John Candy
Modified: 2007-08-28 19:44 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Candy 2007-05-04 03:10:59 UTC
Version:           1.2.2 (using KDE KDE 3.5.5)
Installed from:    Gentoo Packages
OS:                Linux

When attempting to decrypt the clipboard or a text file, the decrypt option is not available if un-encrypted text exists above the GPG header. It would be really nice if Kgpg would always make decrypt available for the clipboard and text files. If a user selects the decrypt option, Kgpg should search for embeded cryptograms, decrypt them, and reconstitute the clipbard/text file with decrypted segments indicated by ----- Begin/End Decrypted Message ----- with a decryption time stamp and any signature details.

I've been spoiled by PGP which has done this for quite some time, and I really miss this kind of robust functionality in Kgpg.
Comment 1 Jimmy Gilles 2007-08-28 19:44:03 UTC
SVN commit 705831 by jimmygilles:

Some little changes.
FEATURE:145002
The feature 145002 is finished. Now, the user can verify a message or decrypt a message if there is text before or after the encoded message.
The editor detects if the message contains an encoded/signed message.
If it is an encoded message, the original message is replaced by the decrypted one.


 M  +21 -17    kgpgview.cpp  
 M  +2 -2      kgpgview.h  


--- trunk/KDE/kdeutils/kgpg/kgpgview.cpp #705830:705831
@@ -38,6 +38,15 @@
 #include "selectpublickeydialog.h"
 #include "detailedconsole.h"
 
+#define ENCODEDMESSAGE_BEGIN "-----BEGIN PGP MESSAGE-----"
+#define ENCODEDMESSAGE_END   "-----END PGP MESSAGE-----"
+#define SIGNEDMESSAGE_BEGIN  "-----BEGIN PGP SIGNED MESSAGE-----"
+#define SIGNEDMESSAGE_END    "-----END PGP SIGNATURE-----"
+#define PUBLICKEY_BEGIN      "-----BEGIN PGP PUBLIC KEY BLOCK-----"
+#define PUBLICKEY_END        "-----END PGP PUBLIC KEY BLOCK-----"
+#define PRIVATEKEY_BEGIN     "-----BEGIN PGP PRIVATE KEY BLOCK-----"
+#define PRIVATEKEY_END       "-----END PGP PRIVATE KEY BLOCK-----"
+
 KgpgTextEdit::KgpgTextEdit(QWidget *parent)
             : KTextEdit(parent)
 {
@@ -126,8 +135,8 @@
 
 void KgpgTextEdit::slotDecode()
 {
-    QString startmsg = QString("-----BEGIN PGP MESSAGE-----");
-    QString endmsg = QString("-----END PGP MESSAGE-----");
+    QString startmsg = ENCODEDMESSAGE_BEGIN;
+    QString endmsg = ENCODEDMESSAGE_END;
 
     QString fullcontent = toPlainText();
 
@@ -140,7 +149,6 @@
         return;
     m_posend += endmsg.length();
 
-    // decode data from the editor. triggered by the decode button
     KgpgInterface *interface = new KgpgInterface();
     connect(interface, SIGNAL(txtDecryptionFinished(QString, KgpgInterface*)), this, SLOT(slotDecodeUpdateSuccess(QString, KgpgInterface*)));
     connect(interface, SIGNAL(txtDecryptionFailed(QString, KgpgInterface*)), this, SLOT(slotDecodeUpdateFailed(QString, KgpgInterface*)));
@@ -149,10 +157,8 @@
 
 void KgpgTextEdit::slotSign()
 {
-    // Sign the text in Editor
     QString signkeyid;
 
-    // open key selection dialog
     KgpgSelectSecretKey *opts = new KgpgSelectSecretKey(this);
     if (opts->exec() == QDialog::Accepted)
         signkeyid = opts->getKeyID();
@@ -175,8 +181,8 @@
 
 void KgpgTextEdit::slotVerify()
 {
-    QString startmsg = QString("-----BEGIN PGP SIGNED MESSAGE-----");
-    QString endmsg = QString("-----END PGP SIGNATURE-----");
+    QString startmsg = QString(SIGNEDMESSAGE_BEGIN);
+    QString endmsg = QString(SIGNEDMESSAGE_END);
 
     QString fullcontent = toPlainText();
 
@@ -189,7 +195,6 @@
         return;
     posend += endmsg.length();
 
-    // this is a signed message, verify it
     KgpgInterface *interface = new KgpgInterface();
     connect(interface, SIGNAL(txtVerifyMissingSignature(QString, KgpgInterface*)), this, SLOT(slotVerifyKeyNeeded(QString, KgpgInterface*)));
     connect(interface, SIGNAL(txtVerifyFinished(QString, QString, KgpgInterface*)), this, SLOT(slotVerifySuccess(QString, QString, KgpgInterface*)));
@@ -226,8 +231,8 @@
     qfile.close();
 
     KgpgInterface *interface = new KgpgInterface();
-    connect(interface, SIGNAL(txtDecryptionFinished(QString, KgpgInterface*)), this, SLOT(editorUpdateDecryptedtxt(QString, KgpgInterface*)));
-    connect(interface, SIGNAL(txtDecryptionFailed(QString, KgpgInterface*)), this, SLOT(editorFailedDecryptedtxt(QString, KgpgInterface*)));
+    connect(interface, SIGNAL(txtDecryptionFinished(QString, KgpgInterface*)), this, SLOT(slotDecodeFileSuccess(QString, KgpgInterface*)));
+    connect(interface, SIGNAL(txtDecryptionFailed(QString, KgpgInterface*)), this, SLOT(slotDecodeFileFailed(QString, KgpgInterface*)));
     interface->KgpgDecryptFileToText(KUrl(m_tempfile), KGpgSettings::customDecrypt().simplified().split(" "));
 }
 
@@ -246,25 +251,25 @@
     if (result.isEmpty())
         return false;
 
-    if (checkforpgpmessage && result.startsWith("-----BEGIN PGP MESSAGE"))
+    if (checkforpgpmessage && result.startsWith(ENCODEDMESSAGE_BEGIN))
     {
         // if pgp data found, decode it
         slotDecodeFile();
         return true;
     }
 
-    if (result.startsWith("-----BEGIN PGP PUBLIC KEY BLOCK") || result.startsWith("-----BEGIN PGP PRIVATE KEY BLOCK"))
+    if (result.startsWith(PUBLICKEY_BEGIN) || result.startsWith(PRIVATEKEY_BEGIN))
     {
         // dropped file is a public key or a private key
         bool ispublickey = false;
         QString tmpinfo;
-        if (result.startsWith("-----BEGIN PGP PUBLIC KEY BLOCK"))
+        if (result.startsWith(PUBLICKEY_BEGIN))
         {
             ispublickey = true;
             tmpinfo = i18n("<qt>This file is a <b>public</b> key.\nPlease use kgpg key management to import it.</qt>");
         }
 
-        if (result.startsWith("-----BEGIN PGP PRIVATE KEY BLOCK"))
+        if (result.startsWith(PRIVATEKEY_BEGIN))
         {
             ispublickey = false;
             tmpinfo = i18n("<qt>This file is a <b>private</b> key.\nPlease use kgpg key management to import it.</qt>");
@@ -295,14 +300,14 @@
     return false;
 }
 
-void KgpgTextEdit::editorUpdateDecryptedtxt(const QString &content, KgpgInterface *interface)
+void KgpgTextEdit::slotDecodeFileSuccess(const QString &content, KgpgInterface *interface)
 {
     delete interface;
     setPlainText(content);
     emit newText();
 }
 
-void KgpgTextEdit::editorFailedDecryptedtxt(const QString &content, KgpgInterface *interface)
+void KgpgTextEdit::slotDecodeFileFailed(const QString &content, KgpgInterface *interface)
 {
     delete interface;
     if (!slotCheckFile(false))
@@ -407,7 +412,6 @@
 
 
 
-// main view configuration
 KgpgView::KgpgView(QWidget *parent)
         : QWidget(parent)
 {
--- trunk/KDE/kdeutils/kgpg/kgpgview.h #705830:705831
@@ -58,8 +58,8 @@
     void slotDecodeFile();
     bool slotCheckFile(const bool &checkforpgpmessage = true);
 
-    void editorUpdateDecryptedtxt(const QString &content, KgpgInterface *interface);
-    void editorFailedDecryptedtxt(const QString &content, KgpgInterface *interface);
+    void slotDecodeFileSuccess(const QString &content, KgpgInterface *interface);
+    void slotDecodeFileFailed(const QString &content, KgpgInterface *interface);
 
     void slotEncodeUpdate(const QString &content, KgpgInterface *interface);
     void slotDecodeUpdateSuccess(const QString &content, KgpgInterface *interface);