aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2013-02-27 00:01:05 +0000
committernils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2013-02-27 00:01:05 +0000
commit498c1a147bd94ba044f1f0e4999e2be125f871bf (patch)
treeb1d97364abf7da259b035e279d59efbcb32b4335
parentupload to keyserver now works (diff)
downloadgpg4usb-498c1a147bd94ba044f1f0e4999e2be125f871bf.tar.gz
gpg4usb-498c1a147bd94ba044f1f0e4999e2be125f871bf.zip
eport key to file and to clipboard now works
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@1020 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r--TODO1
-rw-r--r--mainwindow.cpp76
-rw-r--r--mainwindow.h2
3 files changed, 54 insertions, 25 deletions
diff --git a/TODO b/TODO
index 61a3986..457d677 100644
--- a/TODO
+++ b/TODO
@@ -40,6 +40,7 @@ Release 0.4
- save the last used directory in open file dialog
- discuss: show message, when key export is successful (statusbar)
- set focus to close dialog with unsaved data
+- have a look on selected/checked keys (which keys should when be used?)
BUG:
- check PGP-Mime
diff --git a/mainwindow.cpp b/mainwindow.cpp
index d0a11a6..9eacc91 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -1167,7 +1167,6 @@ void MainWindow::slotUploadKeyToServerReady(int result)
}
exp->deleteLater();
-
}
void MainWindow::slotCopyMailAddressToClipboard()
@@ -1184,37 +1183,64 @@ void MainWindow::slotCopyMailAddressToClipboard()
void MainWindow::slotExportKeyToFile()
{
-// TODO
-/* QByteArray *keyArray = new QByteArray();
- if (!mCtx->exportKeys(mKeyList->getChecked(), keyArray)) {
- return;
+ QStringList expopts;
+ KGpgExport *exp = new KGpgExport(this, *mKeyList->getChecked(), expopts);
+ connect(exp, SIGNAL(done(int)), SLOT(slotExportKeyToFileReady(int)));
+ exp->start();
+}
+
+void MainWindow::slotExportKeyToFileReady(int result)
+{
+ KGpgExport *exp = qobject_cast<KGpgExport *>(sender());
+ Q_ASSERT(exp != NULL);
+
+ if (result == KGpgTransaction::TS_OK) {
+
+ GpgKey key = mCtx->getKeyById(exp->getKeyIds().first());
+
+ QString fileString = key.name + " " + key.email + "(" + key.id+ ")_pub.asc";
+
+ QString fileName = QFileDialog::getSaveFileName(this, tr("Export Key To File"), fileString, tr("Key Files") + " (*.asc *.txt);;All Files (*)");
+ QFile file(fileName);
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
+ return;
+ QTextStream stream(&file);
+ QByteArray keyArray = exp->getOutputData();
+ qDebug() << *keyArray;
+ stream << keyArray;
+ file.close();
+ //emit statusBarChanged(QString(tr("key(s) exported")));
+ } else {
+ //KMessageBox::sorry(this, i18n("Your public key could not be exported\nCheck the key."));
+ qDebug() << "Your public key could not be exported\nCheck the key.";
}
- KgpgCore::KgpgKey key = mCtx->getKeyDetails(mKeyList->getChecked()->first());
- QString fileString = key.name() + " " + key.email() + "(" + key.id()+ ")_pub.asc";
- QString fileName = QFileDialog::getSaveFileName(this, tr("Export Key To File"), fileString, tr("Key Files") + " (*.asc *.txt);;All Files (*)");
- QFile file(fileName);
- if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
- return;
- QTextStream stream(&file);
- stream << *keyArray;
- file.close();
- delete keyArray;
- emit statusBarChanged(QString(tr("key(s) exported")));
-*/
+ exp->deleteLater();
}
void MainWindow::slotExportKeyToClipboard()
{
-// TODO
-/* QByteArray *keyArray = new QByteArray();
- QClipboard *cb = QApplication::clipboard();
- if (!mCtx->exportKeys(mKeyList->getChecked(), keyArray)) {
- return;
+ QStringList expopts;
+ KGpgExport *exp = new KGpgExport(this, *mKeyList->getChecked(), expopts);
+ connect(exp, SIGNAL(done(int)), SLOT(slotExportKeyToClipboardReady(int)));
+ exp->start();
+}
+
+void MainWindow::slotExportKeyToClipboardReady(int result)
+{
+ KGpgExport *exp = qobject_cast<KGpgExport *>(sender());
+ Q_ASSERT(exp != NULL);
+
+ if (result == KGpgTransaction::TS_OK) {
+ QClipboard *cb = QApplication::clipboard();
+ cb->setText(exp->getOutputData());
+ //emit statusBarChanged(QString(tr("key(s) exported")));
+ } else {
+ //KMessageBox::sorry(this, i18n("Your public key could not be exported\nCheck the key."));
+ qDebug() << "Your public key could not be exported\nCheck the key.";
}
- cb->setText(*keyArray);
- delete keyArray;
-*/
+
+ exp->deleteLater();
}
void MainWindow::slotGenerateKeyDialog()
diff --git a/mainwindow.h b/mainwindow.h
index 40af5c9..8ba5499 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -178,11 +178,13 @@ private slots:
* @details Export checked keys to file.
*/
void slotExportKeyToFile();
+ void slotExportKeyToFileReady(int result);
/**
* @details Export checked keys to clipboard.
*/
void slotExportKeyToClipboard();
+ void slotExportKeyToClipboardReady(int result);
/**
* @details Append the selected keys to currently active textedit.