From a6e1eb872b6de85d4b4059ac561a18f0a3a1fd30 Mon Sep 17 00:00:00 2001 From: nils Date: Sun, 4 Jan 2009 01:44:25 +0000 Subject: updated TODO and fixed key export error, when no key is selected git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@207 34ebc366-c3a9-4b3c-9f84-69acf7962910 --- context.cpp | 5 +++-- context.h | 2 +- keymgmt.cpp | 11 ++++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/context.cpp b/context.cpp index 846cf36..a46fa87 100644 --- a/context.cpp +++ b/context.cpp @@ -121,7 +121,7 @@ void Context::generateKey(QString *params) /** Export Key to QByteArray * */ -void Context::exportKeys(QList *uidList, QByteArray *outBuffer) +bool Context::exportKeys(QList *uidList, QByteArray *outBuffer) { size_t read_bytes; gpgme_data_t out = 0; @@ -129,7 +129,7 @@ void Context::exportKeys(QList *uidList, QByteArray *outBuffer) if (uidList->count() == 0) { QMessageBox::critical(0, "Export Keys Error", "No Keys Selected"); - return; + return false; } for (int i = 0; i < uidList->count(); i++) { @@ -145,6 +145,7 @@ void Context::exportKeys(QList *uidList, QByteArray *outBuffer) checkErr(err); gpgme_data_release(out); } + return true; } /** List all availabe Keys (VERY much like kgpgme) diff --git a/context.h b/context.h index cb6be9f..56b8dee 100644 --- a/context.h +++ b/context.h @@ -60,7 +60,7 @@ public: ~Context(); // Destructor void importKey(QByteArray inBuffer); - void exportKeys(QList *uidList, QByteArray *outBuffer); + bool exportKeys(QList *uidList, QByteArray *outBuffer); void generateKey(QString *params); GpgKeyList listKeys(); void deleteKeys(QList *uidList); diff --git a/keymgmt.cpp b/keymgmt.cpp index 7829f50..de0ec35 100755 --- a/keymgmt.cpp +++ b/keymgmt.cpp @@ -151,9 +151,9 @@ void KeyMgmt::deleteCheckedKeys() void KeyMgmt::exportKeyToFile() { QByteArray *keyArray = new QByteArray(); - - mCtx->exportKeys(mKeyList->getChecked(), keyArray); - + if (!mCtx->exportKeys(mKeyList->getChecked(), keyArray)) { + return; + } QString fileName = QFileDialog::getSaveFileName(this, tr("Export Key To File"), "", tr("Key Files") + " (*.asc *.txt);;All Files (*.*)"); QFile file(fileName); if (!file.open( QIODevice::WriteOnly |QIODevice::Text)) @@ -168,8 +168,9 @@ void KeyMgmt::exportKeyToClipboard() { QByteArray *keyArray = new QByteArray(); QClipboard *cb = QApplication::clipboard(); - - mCtx->exportKeys(mKeyList->getChecked(), keyArray); + if (!mCtx->exportKeys(mKeyList->getChecked(), keyArray)) { + return; + } cb->setText(*keyArray); delete keyArray; } -- cgit v1.2.3