aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--context.cpp5
-rw-r--r--context.h2
-rwxr-xr-xkeymgmt.cpp11
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<QString> *uidList, QByteArray *outBuffer)
+bool Context::exportKeys(QList<QString> *uidList, QByteArray *outBuffer)
{
size_t read_bytes;
gpgme_data_t out = 0;
@@ -129,7 +129,7 @@ void Context::exportKeys(QList<QString> *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<QString> *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<QString> *uidList, QByteArray *outBuffer);
+ bool exportKeys(QList<QString> *uidList, QByteArray *outBuffer);
void generateKey(QString *params);
GpgKeyList listKeys();
void deleteKeys(QList<QString> *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;
}