diff options
author | ubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2012-08-03 22:46:46 +0000 |
---|---|---|
committer | ubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2012-08-03 22:46:46 +0000 |
commit | 57eb187661072f51c1facf0970a2d70445fd242c (patch) | |
tree | 71ba2b42ef2e176332ee4aefaa3d645b29123d52 /mainwindow.cpp | |
parent | append selected keys works (diff) | |
download | gpg4usb-57eb187661072f51c1facf0970a2d70445fd242c.tar.gz gpg4usb-57eb187661072f51c1facf0970a2d70445fd242c.zip |
import from textedit works
git-svn-id: http://cpunk.de/svn/src/gpg4usb/branches/0.3.2-mac@937 34ebc366-c3a9-4b3c-9f84-69acf7962910
Diffstat (limited to 'mainwindow.cpp')
-rw-r--r-- | mainwindow.cpp | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/mainwindow.cpp b/mainwindow.cpp index 985ee0d..1b00289 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -756,7 +756,72 @@ void MainWindow::importKeyFromEdit() return; } - keyMgmt->importKeys(edit->curTextPage()->toPlainText().toAscii()); + //keyMgmt->importKeys(edit->curTextPage()->toPlainText().toAscii()); + QString text = edit->curTextPage()->toPlainText(); + + if (text.isEmpty()) + return; + + KGpgImport *imp; + + if (!KGpgImport::isKey(text) && KGpgDecrypt::isEncryptedText(text)) { + /*if (KMessageBox::questionYesNo(this, + i18n("<qt>The text in the clipboard does not look like a key, but like encrypted text.<br />Do you want to decrypt it first and then try importing it?</qt>"), + i18n("Import from Clipboard")) != KMessageBox::Yes) + return;*/ + + imp = new KGpgImport(this); + KGpgDecrypt *decr = new KGpgDecrypt(this, text); + imp->setInputTransaction(decr); + } else { + imp = new KGpgImport(this, text); + } + + startImport(imp); +} + +void MainWindow::startImport(KGpgImport *import) +{ + qDebug() << "start import"; + //changeMessage(i18n("Importing..."), true); + connect(import, SIGNAL(done(int)), SLOT(slotImportDone(int))); + import->start(); +} + +void MainWindow::slotImportDone(int result) +{ + KGpgImport *import = qobject_cast<KGpgImport *>(sender()); + + qDebug() << "import Done"; + + Q_ASSERT(import != NULL); + const QStringList rawmsgs(import->getMessages()); + + if (result != 0) { + /*KMessageBox::detailedSorry(this, i18n("Key importing failed. Please see the detailed log for more information."), + rawmsgs.join( QLatin1String( "\n")) , i18n("Key Import" ));*/ + qDebug() << "Key importing failed. Please see the detailed log for more information." << rawmsgs.join( QLatin1String( "\n")); + } + + QStringList keys(import->getImportedIds(0x1f)); + const bool needsRefresh = !keys.isEmpty(); + keys << import->getImportedIds(0); +/* + if (!keys.isEmpty()) { + const QString msg(import->getImportMessage()); + const QStringList keynames(import->getImportedKeys()); + + new KgpgDetailedInfo(this, msg, rawmsgs.join( QLatin1String( "\n") ), keynames, i18n("Key Import" )); + if (needsRefresh) + imodel->refreshKeys(keys); + else + changeMessage(i18nc("Application ready for user input", "Ready")); + } else{ + changeMessage(i18nc("Application ready for user input", "Ready")); + } +*/ + mCtx->emitKeyDBChanged(); + import->deleteLater(); } void MainWindow::openKeyManagement() |