diff options
author | ubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2012-08-07 10:45:21 +0000 |
---|---|---|
committer | ubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2012-08-07 10:45:21 +0000 |
commit | 865aaaed3fd163ba4c347a08f34780933bcda949 (patch) | |
tree | ab0b51c9030a8b904e3352786159f3810b9ee74e | |
parent | some work on verify (diff) | |
download | gpg4usb-0.3.2-mac.tar.gz gpg4usb-0.3.2-mac.zip |
fix secret key export0.3.2-mac
git-svn-id: http://cpunk.de/svn/src/gpg4usb/branches/0.3.2-mac@944 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r-- | gpgcontext.cpp | 21 | ||||
-rw-r--r-- | keydetailsdialog.cpp | 28 | ||||
-rw-r--r-- | keydetailsdialog.h | 1 |
3 files changed, 39 insertions, 11 deletions
diff --git a/gpgcontext.cpp b/gpgcontext.cpp index 677c2c5..2d98372 100644 --- a/gpgcontext.cpp +++ b/gpgcontext.cpp @@ -197,18 +197,21 @@ bool GpgContext::exportKeys(QStringList *uidList, QByteArray *outBuffer) KgpgCore::KgpgKey GpgContext::getKeyDetails(QString uid) { - //KgpgCore::KgpgKey key; + // try secret - /*qDebug() << "blubb"; - KgpgCore::KgpgKey key = KgpgInterface::readSecretKeys(QStringList() << uid).first(); + KgpgCore::KgpgKeyList keys = KgpgInterface::readSecretKeys(QStringList() << uid); + if(keys.empty()) { + // ok try public + keys = KgpgInterface::readPublicKeys(QStringList() << uid); + // that should not happen + /*if(keys.empty()) { + qDebug() << "error, no key with uid" << uid; + return ; + }*/ - qDebug() << "bla"; - qDebug() << "id: " << key.id(); + } - // ok, its a public key - if (key.id() == "") {*/ - KgpgCore::KgpgKey key = KgpgInterface::readPublicKeys(QStringList() << uid).first(); - //} + KgpgCore::KgpgKey key = keys.first(); return key; } diff --git a/keydetailsdialog.cpp b/keydetailsdialog.cpp index 64d8420..fb6edf6 100644 --- a/keydetailsdialog.cpp +++ b/keydetailsdialog.cpp @@ -20,6 +20,7 @@ */ #include "keydetailsdialog.h" +#include "kgpg/transactions/kgpgexport.h" KeyDetailsDialog::KeyDetailsDialog(GpgME::GpgContext* ctx, KgpgCore::KgpgKey key, QWidget *parent) : QDialog(parent) @@ -192,7 +193,7 @@ void KeyDetailsDialog::exportPrivateKey() // export key, if ok was clicked if (ret == QMessageBox::Ok) { - QByteArray *keyArray = new QByteArray(); + /* QByteArray *keyArray = new QByteArray(); mCtx->exportSecretKey(*keyid, keyArray); KgpgCore::KgpgKey key = mCtx->getKeyDetails(*keyid); QString fileString = key.name() + " " + key.email() + "(" + key.id()+ ")_pub_sec.asc"; @@ -205,10 +206,33 @@ void KeyDetailsDialog::exportPrivateKey() QTextStream stream(&file); stream << *keyArray; file.close(); - delete keyArray; + delete keyArray;*/ + KgpgCore::KgpgKey key = mCtx->getKeyDetails(*keyid); + QString fileString = key.name() + " " + key.email() + "(" + key.id()+ ")_pub_sec.asc"; + + QString fileName = QFileDialog::getSaveFileName(this, tr("Export Key To File"), fileString, tr("Key Files") + " (*.asc *.txt);;All Files (*)"); + + QStringList expopts; + expopts.append(QLatin1String( "--armor" )); + KGpgExport *exp = new KGpgExport(this, QStringList() << *keyid, fileName, expopts, true); + connect(exp, SIGNAL(done(int)), SLOT(slotExportPrivateKeyDone(int))); + exp->start(); } } +void KeyDetailsDialog::slotExportPrivateKeyDone(int result) { + KGpgExport *exp = qobject_cast<KGpgExport *>(sender()); + Q_ASSERT(exp != NULL); + + if (result == KGpgTransaction::TS_OK) { + qDebug() << "export seems ok"; + } else { + qDebug() << "Your key could not be exported\nCheck the key."; + } + + exp->deleteLater(); +} + QString KeyDetailsDialog::beautifyFingerprint(QString fingerprint) { uint len = fingerprint.length(); diff --git a/keydetailsdialog.h b/keydetailsdialog.h index e0893c2..8863553 100644 --- a/keydetailsdialog.h +++ b/keydetailsdialog.h @@ -57,6 +57,7 @@ private slots: * @details Export the key to a file, which is choosen in a file dialog */ void exportPrivateKey(); + void slotExportPrivateKeyDone(int result); /** * @details Copy the fingerprint to clipboard |