diff options
author | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2013-10-15 21:49:28 +0000 |
---|---|---|
committer | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2013-10-15 21:49:28 +0000 |
commit | fbf736b1f6a294bb6cfec0f12217297252b289db (patch) | |
tree | 072d19afab6034d92cf593288e2da0045ebef3ef | |
parent | keydetails widget in qml working (diff) | |
download | gpg4usb-fbf736b1f6a294bb6cfec0f12217297252b289db.tar.gz gpg4usb-fbf736b1f6a294bb6cfec0f12217297252b289db.zip |
removed key management and old key details dialog
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@1062 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r-- | gpg4usb.pro | 4 | ||||
-rw-r--r-- | gpgcontext.cpp | 63 | ||||
-rw-r--r-- | gpgcontext.h | 7 | ||||
-rw-r--r-- | keyserverimportdialog.cpp | 5 | ||||
-rw-r--r-- | mainwindow.cpp | 50 | ||||
-rw-r--r-- | mainwindow.h | 13 | ||||
-rw-r--r-- | wizard.cpp | 31 | ||||
-rw-r--r-- | wizard.h | 12 |
8 files changed, 117 insertions, 68 deletions
diff --git a/gpg4usb.pro b/gpg4usb.pro index a210fb2..3f29f7b 100644 --- a/gpg4usb.pro +++ b/gpg4usb.pro @@ -30,9 +30,7 @@ HEADERS += attachments.h \ keyimportdetaildialog.h \ mime.h \ keygendialog.h \ - keydetailsdialog.h \ keylist.h \ - keymgmt.h \ settingsdialog.h \ attachmenttablemodel.h \ textedit.h \ @@ -58,9 +56,7 @@ SOURCES += attachments.cpp \ keyimportdetaildialog.cpp \ mime.cpp \ keygendialog.cpp \ - keydetailsdialog.cpp \ keylist.cpp \ - keymgmt.cpp \ settingsdialog.cpp \ attachmenttablemodel.cpp \ textedit.cpp \ diff --git a/gpgcontext.cpp b/gpgcontext.cpp index bb4d7ca..cef4f10 100644 --- a/gpgcontext.cpp +++ b/gpgcontext.cpp @@ -308,6 +308,69 @@ void GpgContext::slotExportPrivateKeyDone(int result) { exp->deleteLater(); } +// import for text based keys +void GpgContext::slotImportKeys(QString text) +{ + KGpgImport *imp = new KGpgImport(this, text); + connect(imp, SIGNAL(done(int)), SLOT(slotImportDone(int))); + imp->start(); +} + +void GpgContext::slotImportDone(int result) +{ + KGpgImport *import = qobject_cast<KGpgImport *>(sender()); + + 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")); + } +*/ + //changeMessage(tr("Application ready for user input", "Ready")); + emitKeyDBChanged(); + import->deleteLater(); +} + +void GpgContext::slotimportKeyFromFile() +{ + QString fileName = QFileDialog::getOpenFileName(NULL, tr("Open Key"), "", tr("Key Files") + " (*.asc *.txt);;"+tr("Keyring files")+" (*.gpg);;All Files (*)"); + if (! fileName.isNull()) { + + QList<QUrl> urlList; + urlList << QUrl::fromLocalFile(fileName); + + KGpgImport *imp = new KGpgImport(this, urlList); + connect(imp, SIGNAL(done(int)), SLOT(slotImportDone(int))); + imp->start(); + } +} + +void GpgContext::slotImportKeyFromClipboard() +{ + QClipboard *cb = QApplication::clipboard(); + slotImportKeys(cb->text(QClipboard::Clipboard).toAscii()); +} + QString GpgContext::getReport(const QStringList &log) { QString result; diff --git a/gpgcontext.h b/gpgcontext.h index 6857c2c..58181b6 100644 --- a/gpgcontext.h +++ b/gpgcontext.h @@ -31,6 +31,7 @@ #include "kgpg/core/kgpgkey.h" #include "kgpg/transactions/kgpgverify.h" #include "kgpg/transactions/kgpgexport.h" +#include "kgpg/transactions/kgpgimport.h" QT_BEGIN_NAMESPACE class QMessageBox; @@ -110,6 +111,12 @@ class GpgContext : public QObject { Q_OBJECT +public slots: + void slotimportKeyFromFile(); + void slotImportKeyFromClipboard(); + void slotImportKeys(QString text); + void slotImportDone(int result); + public: GpgContext(); // Constructor ~GpgContext(); // Destructor diff --git a/keyserverimportdialog.cpp b/keyserverimportdialog.cpp index 138e27b..5dac60d 100644 --- a/keyserverimportdialog.cpp +++ b/keyserverimportdialog.cpp @@ -21,13 +21,10 @@ */ #include "keyserverimportdialog.h" -#include "keymgmt.h" KeyServerImportDialog::KeyServerImportDialog(GpgME::GpgContext *ctx, KeyList *keyList, QWidget *parent) - : QDialog(parent) + : QDialog(parent), mCtx(ctx), mKeyList(keyList) { - mCtx = ctx; - mKeyList = keyList; // Buttons closeButton = createButton(tr("&Close"), SLOT(close())); importButton = createButton(tr("&Import"), SLOT(slotImport())); diff --git a/mainwindow.cpp b/mainwindow.cpp index d3777a0..3ebf9db 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -41,13 +41,10 @@ MainWindow::MainWindow() /* Variable containing if restart is needed */ this->slotSetRestartNeeded(false); - keyMgmt = new KeyMgmt(mCtx, this); - keyMgmt->hide(); /* test attachmentdir for files alll 15s */ QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(slotCheckAttachmentFolder())); timer->start(5000); - createActions(); createMenus(); createKeyListMenu(); @@ -313,6 +310,21 @@ void MainWindow::createActions() importKeyFromEditAct->setToolTip(tr("Import New Key From Editor")); connect(importKeyFromEditAct, SIGNAL(triggered()), this, SLOT(slotImportKeyFromEdit())); + importKeyFromFileAct = new QAction(tr("&File"), this); + importKeyFromFileAct->setIcon(QIcon(":import_key_from_file.png")); + importKeyFromFileAct->setToolTip(tr("Import New Key From File")); + connect(importKeyFromFileAct, SIGNAL(triggered()), mCtx, SLOT(slotimportKeyFromFile())); + + importKeyFromClipboardAct = new QAction(tr("&Clipboard"), this); + importKeyFromClipboardAct->setIcon(QIcon(":import_key_from_clipboard.png")); + importKeyFromClipboardAct->setToolTip(tr("Import New Key From Clipboard")); + connect(importKeyFromClipboardAct, SIGNAL(triggered()), mCtx, SLOT(slotImportKeyFromClipboard())); + + importKeyFromKeyServerAct = new QAction(tr("&Keyserver"), this); + importKeyFromKeyServerAct->setIcon(QIcon(":import_key_from_server.png")); + importKeyFromKeyServerAct->setToolTip(tr("Import New Key From Keyserver")); + connect(importKeyFromKeyServerAct, SIGNAL(triggered()), this, SLOT(slotImportKeyFromKeyServer())); + exportKeyToClipboardAct = new QAction(tr("&Clipboard"), this); exportKeyToClipboardAct->setIcon(QIcon(":export_key_to_clipboard.png")); exportKeyToClipboardAct->setToolTip(tr("Export Selected Key(s) To Clipboard")); @@ -328,11 +340,6 @@ void MainWindow::createActions() deleteCheckedKeysAct->setIcon(QIcon(":button_cancel.png")); connect(deleteCheckedKeysAct, SIGNAL(triggered()), this, SLOT(slotDeleteCheckedKeys())); - openKeyManagementAct = new QAction(tr("Manage &keys"), this); - openKeyManagementAct->setIcon(QIcon(":keymgmt.png")); - openKeyManagementAct->setToolTip(tr("Open Keymanagement")); - connect(openKeyManagementAct, SIGNAL(triggered()), this, SLOT(slotOpenKeyManagement())); - generateKeyDialogAct = new QAction(tr("Generate Key"), this); generateKeyDialogAct->setToolTip(tr("Generate New Key")); generateKeyDialogAct->setIcon(QIcon(":key_generate.png")); @@ -372,7 +379,6 @@ void MainWindow::createActions() copyMailAddressToClipboardAct->setToolTip(tr("Copy selected EMailaddress to clipboard")); connect(copyMailAddressToClipboardAct, SIGNAL(triggered()), this, SLOT(slotCopyMailAddressToClipboard())); - // TODO: find central place for shared actions, to avoid code-duplication with keymgmt.cpp showKeyDetailsAct = new QAction(tr("Show key details"), this); showKeyDetailsAct->setToolTip(tr("Show Details for this Key")); connect(showKeyDetailsAct, SIGNAL(triggered()), this, SLOT(slotShowKeyDetails())); @@ -495,12 +501,11 @@ void MainWindow::createMenus() keyMenu = menuBar()->addMenu(tr("&Keys")); importKeyMenu = keyMenu->addMenu(tr("&Import Key From...")); importKeyMenu->setIcon(QIcon(":key_import.png")); - importKeyMenu->addAction(keyMgmt->importKeyFromFileAct); + importKeyMenu->addAction(importKeyFromFileAct); importKeyMenu->addAction(importKeyFromEditAct); - importKeyMenu->addAction(keyMgmt->importKeyFromClipboardAct); - importKeyMenu->addAction(keyMgmt->importKeyFromKeyServerAct); - importKeyMenu->addAction(keyMgmt->importKeyFromKeyServerAct); + importKeyMenu->addAction(importKeyFromClipboardAct); + importKeyMenu->addAction(importKeyFromKeyServerAct); exportKeyMenu = keyMenu->addMenu(tr("&Export Key(s) To...")); exportKeyMenu->setIcon(QIcon(":key_export.png")); @@ -511,7 +516,6 @@ void MainWindow::createMenus() keyMenu->addAction(deleteCheckedKeysAct); keyMenu->addSeparator(); keyMenu->addAction(generateKeyDialogAct); - keyMenu->addAction(openKeyManagementAct); steganoMenu = menuBar()->addMenu(tr("&Steganography")); steganoMenu->addAction(cutPgpHeaderAct); @@ -565,7 +569,6 @@ void MainWindow::createToolBars() keyToolBar = addToolBar(tr("Key")); keyToolBar->setObjectName("keyToolBar"); - keyToolBar->addAction(openKeyManagementAct); viewMenu->addAction(keyToolBar->toggleViewAction()); editToolBar = addToolBar(tr("Edit")); @@ -709,7 +712,7 @@ void MainWindow::slotSetStatusBarText(QString text) void MainWindow::slotStartWizard() { - Wizard *wizard = new Wizard(mCtx,keyMgmt,this); + Wizard *wizard = new Wizard(mCtx,this); wizard->show(); wizard->setModal(true); } @@ -861,6 +864,12 @@ void MainWindow::slotImportKeyFromEdit() slotStartImport(imp); } +void MainWindow::slotImportKeyFromKeyServer() +{ + KeyServerImportDialog *importDialog = new KeyServerImportDialog(mCtx, mKeyList, this); + importDialog->show(); +} + void MainWindow::slotStartImport(KGpgImport *import) { qDebug() << "start import"; @@ -911,13 +920,6 @@ void MainWindow::changeMessage(const QString &msg, const bool keep) statusBar()->showMessage(msg, timeout); } -void MainWindow::slotOpenKeyManagement() -{ - keyMgmt->show(); - keyMgmt->raise(); - keyMgmt->activateWindow(); -} - void MainWindow::slotEncrypt() { if (edit->tabCount()==0 || edit->curPage() == 0) { @@ -1227,8 +1229,6 @@ void MainWindow::slotShowKeyDetails() if (key.id() != "") { // TODO: get qml working here ;-) edit->slotNewQMLTab(tr("Key: ") + key.name(), mCtx, key); - - new KeyDetailsDialog(mCtx, key, this); } } diff --git a/mainwindow.h b/mainwindow.h index 058d488..1d090bb 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -24,7 +24,6 @@ #include "gpgconstants.h" #include "attachments.h" -#include "keymgmt.h" #include "textedit.h" #include "fileencryptiondialog.h" #include "settingsdialog.h" @@ -39,6 +38,7 @@ #include "kgpg/transactions/kgpgexport.h" #include "kgpg/transactions/kgpgimport.h" #include "kgpg/transactions/kgpgsigntext.h" +#include "kgpg/transactions/kgpgdelkey.h" QT_BEGIN_NAMESPACE class QMainWindow; @@ -171,6 +171,7 @@ private slots: * @details Import keys from currently active tab to keylist if possible. */ void slotImportKeyFromEdit(); + void slotImportKeyFromKeyServer(); void slotStartImport(KGpgImport *import); void slotImportDone(int result); @@ -198,11 +199,6 @@ private slots: void slotCopyMailAddressToClipboard(); /** - * @details Open key management dialog. - */ - void slotOpenKeyManagement(); - - /** * @details Open about-dialog. */ void slotAbout(); @@ -399,7 +395,6 @@ private: QAction *appendSelectedKeysAct; /** Action to append selected keys to edit */ QAction *generateKeyDialogAct; /** Action to open key generation dialog */ QAction *copyMailAddressToClipboardAct; /** Action to copy mail to clipboard */ - QAction *openKeyManagementAct; /** Action to open key management */ QAction *copyAct; /** Action to copy text */ QAction *quoteAct; /** Action to quote text */ QAction *cutAct; /** Action to cut text */ @@ -427,13 +422,15 @@ private: QAction *startWizardAct; /** Action to open the wizard */ QAction *cutPgpHeaderAct; /** Action for cutting the PGP header */ QAction *addPgpHeaderAct; /** Action for adding the PGP header */ + QAction *importKeyFromFileAct; + QAction *importKeyFromClipboardAct; + QAction *importKeyFromKeyServerAct; QLabel *statusBarIcon; /**< TODO */ QSettings settings; /**< TODO */ KeyList *mKeyList; /**< TODO */ Attachments *mAttachments; /**< TODO */ GpgME::GpgContext *mCtx; /**< TODO */ - KeyMgmt *keyMgmt; /**< TODO */ KeyServerImportDialog *importDialog; /**< TODO */ bool attachmentDockCreated; bool restartNeeded; @@ -26,16 +26,13 @@ #include "windows.h" #endif -Wizard::Wizard(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent) - : QWizard(parent) +Wizard::Wizard(GpgME::GpgContext *ctx, QWidget *parent) + : QWizard(parent), mCtx(ctx) { - mCtx=ctx; - mKeyMgmt=keyMgmt; - setPage(Page_Intro,new IntroPage(this)); setPage(Page_Choose, new ChoosePage(this)); - setPage(Page_ImportFromGpg4usb,new ImportFromGpg4usbPage(mCtx, mKeyMgmt, this)); - setPage(Page_ImportFromGnupg,new ImportFromGnupgPage(mCtx, mKeyMgmt, this)); + setPage(Page_ImportFromGpg4usb,new ImportFromGpg4usbPage(mCtx, this)); + setPage(Page_ImportFromGnupg,new ImportFromGnupgPage(mCtx, this)); setPage(Page_GenKey,new KeyGenPage(mCtx, this)); setPage(Page_Conclusion,new ConclusionPage(this)); @@ -66,7 +63,7 @@ void Wizard::wizardAccepted() { } } -bool Wizard::importPubAndSecKeysFromDir(const QString dir, KeyMgmt *keyMgmt) +bool Wizard::importPubAndSecKeysFromDir(const QString dir, GpgME::GpgContext *ctx) { QFile secRingFile(dir+"/secring.gpg"); QFile pubRingFile(dir+"/pubring.gpg"); @@ -97,7 +94,7 @@ bool Wizard::importPubAndSecKeysFromDir(const QString dir, KeyMgmt *keyMgmt) inBuffer.append(pubRingFile.readAll()); pubRingFile.close(); } - keyMgmt->slotImportKeys(inBuffer); + ctx->slotImportKeys(inBuffer); inBuffer.clear(); return true; @@ -203,11 +200,9 @@ void ChoosePage::jumpPage(const QString& page) wizard()->next(); } -ImportFromGpg4usbPage::ImportFromGpg4usbPage(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent) - : QWizardPage(parent) +ImportFromGpg4usbPage::ImportFromGpg4usbPage(GpgME::GpgContext *ctx, QWidget *parent) + : QWizardPage(parent), mCtx(ctx) { - mCtx=ctx; - mKeyMgmt=keyMgmt; setTitle(tr("Import from...")); setSubTitle(tr("...existing gpg4usb")); @@ -249,7 +244,7 @@ void ImportFromGpg4usbPage::slotImportFromOlderGpg4usb() // try to import keys, if appropriate box is checked, return, if import was unsuccessful if (gpg4usbKeyCheckBox->isChecked()) { - if (!Wizard::importPubAndSecKeysFromDir(dir+"/keydb",mKeyMgmt)) { + if (!Wizard::importPubAndSecKeysFromDir(dir+"/keydb",mCtx)) { return; } } @@ -283,11 +278,9 @@ int ImportFromGpg4usbPage::nextId() const return Wizard::Page_Conclusion; } -ImportFromGnupgPage::ImportFromGnupgPage(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent) - : QWizardPage(parent) +ImportFromGnupgPage::ImportFromGnupgPage(GpgME::GpgContext *ctx, QWidget *parent) + : QWizardPage(parent), mCtx(ctx) { - mCtx=ctx; - mKeyMgmt=keyMgmt; setTitle(tr("Import keys...")); setSubTitle(tr("...from existing GnuPG installation")); @@ -315,7 +308,7 @@ void ImportFromGnupgPage::slotImportKeysFromGnupg() } // Try to import the keyring files and return the return value of the method - Wizard::importPubAndSecKeysFromDir(gnuPGHome,mKeyMgmt); + Wizard::importPubAndSecKeysFromDir(gnuPGHome,mCtx); wizard()->next(); } @@ -25,7 +25,6 @@ #include <QWizard> #include "keygendialog.h" -#include "keymgmt.h" #include "gpgconstants.h" #include "settingsdialog.h" @@ -43,12 +42,11 @@ public: enum WizardPages { Page_Intro, Page_Choose, Page_ImportFromGpg4usb, Page_ImportFromGnupg, Page_GenKey, Page_Conclusion }; - Wizard(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent = 0); - static bool importPubAndSecKeysFromDir(const QString dir, KeyMgmt *keyMgmt); + Wizard(GpgME::GpgContext *ctx, QWidget *parent = 0); + static bool importPubAndSecKeysFromDir(const QString dir, GpgME::GpgContext *ctx); private: GpgME::GpgContext *mCtx; - KeyMgmt *mKeyMgmt; private slots: void wizardAccepted(); @@ -90,7 +88,7 @@ class ImportFromGpg4usbPage : public QWizardPage Q_OBJECT public: - ImportFromGpg4usbPage(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent = 0); + ImportFromGpg4usbPage(GpgME::GpgContext *ctx, QWidget *parent = 0); private slots: /** @@ -102,7 +100,6 @@ private slots: private: int nextId() const; - KeyMgmt *mKeyMgmt; GpgME::GpgContext *mCtx; QCheckBox *gpg4usbKeyCheckBox; QCheckBox *gpg4usbConfigCheckBox; @@ -113,7 +110,7 @@ class ImportFromGnupgPage : public QWizardPage Q_OBJECT public: - ImportFromGnupgPage(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent = 0); + ImportFromGnupgPage(GpgME::GpgContext *ctx, QWidget *parent = 0); private slots: /** @@ -122,7 +119,6 @@ private slots: void slotImportKeysFromGnupg(); private: - KeyMgmt *mKeyMgmt; int nextId() const; /** |