From a274da36798b7aa7a7cbc9e85ec30748fa66047e Mon Sep 17 00:00:00 2001 From: ubbo Date: Fri, 3 Aug 2012 20:38:27 +0000 Subject: start porting encrypt from kgpg, not yet working git-svn-id: http://cpunk.de/svn/src/gpg4usb/branches/0.3.2-mac@932 34ebc366-c3a9-4b3c-9f84-69acf7962910 --- mainwindow.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'mainwindow.cpp') diff --git a/mainwindow.cpp b/mainwindow.cpp index 024fb35..6f9efc2 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -775,10 +775,35 @@ void MainWindow::encrypt() QStringList *uidList = mKeyList->getChecked(); QByteArray *tmp = new QByteArray(); - if (mCtx->encrypt(uidList, edit->curTextPage()->toPlainText().toUtf8(), tmp)) { + /*if (mCtx->encrypt(uidList, edit->curTextPage()->toPlainText().toUtf8(), tmp)) { QString *tmp2 = new QString(*tmp); edit->fillTextEditWithText(*tmp2); + }*/ + + QStringList options; + KGpgEncrypt::EncryptOptions opts = KGpgEncrypt::DefaultEncryption; + + KGpgEncrypt *encr = new KGpgEncrypt(this, *uidList, edit->curTextPage()->toPlainText(), opts, options); + encr->start(); + connect(encr, SIGNAL(done(int)), SLOT(slotEncryptDone(int))); +} + +void MainWindow::slotEncryptDone(int result) +{ + KGpgEncrypt *enc = qobject_cast(sender()); + Q_ASSERT(enc != NULL); + + if (result == KGpgTransaction::TS_OK) { + const QString lf = QLatin1String("\n"); + //setPlainText(enc->encryptedText().join(lf) + lf); + edit->fillTextEditWithText(enc->encryptedText().join(lf) + lf); + } else { + /*KMessageBox::sorry(this, i18n("The encryption failed with error code %1", result), + i18n("Encryption failed."));*/ + qDebug() << "The encryption failed with error code " << result; } + + sender()->deleteLater(); } void MainWindow::sign() -- cgit v1.2.3