aboutsummaryrefslogtreecommitdiffstats
path: root/mainwindow.cpp
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 /mainwindow.cpp
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
Diffstat (limited to 'mainwindow.cpp')
-rw-r--r--mainwindow.cpp76
1 files changed, 51 insertions, 25 deletions
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()