diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.cpp b/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.cpp index dec90ec398d..3e84432b510 100644 --- a/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.cpp +++ b/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.cpp @@ -31,6 +31,7 @@ #include "blackberrydeviceconfigurationwizardpages.h" #include "blackberrydebugtokenrequestdialog.h" +#include "blackberrysshkeysgenerator.h" #include "ui_blackberrydeviceconfigurationwizardsetuppage.h" #include "ui_blackberrydeviceconfigurationwizardsshkeypage.h" @@ -150,28 +151,31 @@ void BlackBerryDeviceConfigurationWizardSetupPage::requestDebugToken() BlackBerryDeviceConfigurationWizardSshKeyPage::BlackBerryDeviceConfigurationWizardSshKeyPage(QWidget *parent) : QWizardPage(parent) , m_ui(new Ui::BlackBerryDeviceConfigurationWizardSshKeyPage) - , m_keyGen(0) + , m_sshKeysGenerator(new BlackBerrySshKeysGenerator(this)) , m_isGenerated(false) { m_ui->setupUi(this); m_ui->privateKey->setExpectedKind(Utils::PathChooser::File); + m_ui->progressBar->hide(); setTitle(tr("SSH Key Setup")); setSubTitle(tr("Please select an existing 4096-bit key or click Generate to create a new one.")); connect(m_ui->privateKey, SIGNAL(changed(QString)), this, SLOT(findMatchingPublicKey(QString))); connect(m_ui->privateKey, SIGNAL(changed(QString)), this, SIGNAL(completeChanged())); - connect(m_ui->generate, SIGNAL(clicked()), this, SLOT(generateSshKey())); + connect(m_ui->generate, SIGNAL(clicked()), this, SLOT(generateSshKeys())); + connect(m_sshKeysGenerator, SIGNAL(sshKeysGenerationFinished(bool)), this, SLOT(processSshKeys(bool))); } BlackBerryDeviceConfigurationWizardSshKeyPage::~BlackBerryDeviceConfigurationWizardSshKeyPage() { + // Make sure the m_sshKeysGenerator thread is terminated before it's destroyed + m_sshKeysGenerator->terminate(); + m_sshKeysGenerator->wait(); + delete m_ui; m_ui = 0; - - delete m_keyGen; - m_keyGen = 0; } void BlackBerryDeviceConfigurationWizardSshKeyPage::initializePage() @@ -203,7 +207,7 @@ bool BlackBerryDeviceConfigurationWizardSshKeyPage::isGenerated() const QSsh::SshKeyGenerator *BlackBerryDeviceConfigurationWizardSshKeyPage::keyGenerator() const { - return m_keyGen; + return m_sshKeysGenerator->keyGenerator(); } void BlackBerryDeviceConfigurationWizardSshKeyPage::findMatchingPublicKey(const QString &privateKeyPath) @@ -213,21 +217,14 @@ void BlackBerryDeviceConfigurationWizardSshKeyPage::findMatchingPublicKey(const m_ui->publicKey->setText(candidate); } -void BlackBerryDeviceConfigurationWizardSshKeyPage::generateSshKey() +void BlackBerryDeviceConfigurationWizardSshKeyPage::processSshKeys(bool success) { - if (!m_keyGen) - m_keyGen = new QSsh::SshKeyGenerator; - - const bool success = m_keyGen->generateKeys(QSsh::SshKeyGenerator::Rsa, - QSsh::SshKeyGenerator::Mixed, 4096, - QSsh::SshKeyGenerator::DoNotOfferEncryption); - - if (!success) { - QMessageBox::critical(this, tr("Key Generation Failed"), m_keyGen->error()); - m_isGenerated = false; + m_isGenerated = success; + if (!m_isGenerated) { + QMessageBox::critical(this, tr("Key Generation Failed"), m_sshKeysGenerator->error()); + setBusy(false); return; } - m_isGenerated = true; const QString storeLocation = Core::ICore::userResourcePath() + QLatin1String("/qnx/") + field(QLatin1String(DEVICENAME_FIELD_ID)).toString(); @@ -237,8 +234,27 @@ void BlackBerryDeviceConfigurationWizardSshKeyPage::generateSshKey() m_ui->privateKey->setFileName(Utils::FileName::fromString(privKeyPath)); m_ui->publicKey->setText(pubKeyPath); m_ui->privateKey->setEnabled(false); + + setBusy(false); } +void BlackBerryDeviceConfigurationWizardSshKeyPage::generateSshKeys() +{ + setBusy(true); + m_sshKeysGenerator->start(); +} + +void BlackBerryDeviceConfigurationWizardSshKeyPage::setBusy(bool busy) +{ + m_ui->privateKey->setEnabled(!busy); + m_ui->generate->setEnabled(!busy); + m_ui->progressBar->setVisible(busy); + + wizard()->button(QWizard::BackButton)->setEnabled(!busy); + wizard()->button(QWizard::NextButton)->setEnabled(!busy); + wizard()->button(QWizard::FinishButton)->setEnabled(!busy); + wizard()->button(QWizard::CancelButton)->setEnabled(!busy); +} // ---------------------------------------------------------------------------- @@ -251,3 +267,6 @@ BlackBerryDeviceConfigurationWizardFinalPage::BlackBerryDeviceConfigurationWizar QLabel *label = new QLabel(tr("The new device configuration will now be created."), this); layout->addWidget(label); } + + + diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.h b/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.h index 95feefbbb95..6a2e926a2bd 100644 --- a/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.h +++ b/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.h @@ -46,6 +46,7 @@ namespace Ui { class BlackBerryDeviceConfigurationWizardSetupPage; class BlackBerryDeviceConfigurationWizardSshKeyPage; } +class BlackBerrySshKeysGenerator; class BlackBerryDeviceConfigurationWizardSetupPage : public QWizardPage { @@ -89,14 +90,16 @@ public: private slots: void findMatchingPublicKey(const QString &privateKeyPath); - void generateSshKey(); + void processSshKeys(bool success); + void generateSshKeys(); private: void saveKeys(); + void setBusy(bool busy); Ui::BlackBerryDeviceConfigurationWizardSshKeyPage *m_ui; - QSsh::SshKeyGenerator *m_keyGen; + BlackBerrySshKeysGenerator *m_sshKeysGenerator; bool m_isGenerated; }; diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwizardsshkeypage.ui b/src/plugins/qnx/blackberrydeviceconfigurationwizardsshkeypage.ui index d2d11e670b1..8754794586a 100644 --- a/src/plugins/qnx/blackberrydeviceconfigurationwizardsshkeypage.ui +++ b/src/plugins/qnx/blackberrydeviceconfigurationwizardsshkeypage.ui @@ -7,7 +7,7 @@ 0 0 413 - 88 + 139 @@ -45,6 +45,16 @@ + + + + 0 + + + -1 + + + diff --git a/src/plugins/qnx/blackberrysshkeysgenerator.cpp b/src/plugins/qnx/blackberrysshkeysgenerator.cpp new file mode 100644 index 00000000000..d8f6dd0b7c7 --- /dev/null +++ b/src/plugins/qnx/blackberrysshkeysgenerator.cpp @@ -0,0 +1,65 @@ +/************************************************************************** +** +** Copyright (C) 2011 - 2013 Research In Motion +** +** Contact: Research In Motion (blackberry-qt@qnx.com) +** Contact: KDAB (info@kdab.com) +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ +#include "blackberrysshkeysgenerator.h" + +#include + +using namespace Qnx::Internal; + +BlackBerrySshKeysGenerator::BlackBerrySshKeysGenerator(QObject *parent) + : QThread(parent) + , m_keyGen(new QSsh::SshKeyGenerator) +{ +} + +BlackBerrySshKeysGenerator::~BlackBerrySshKeysGenerator() +{ + delete m_keyGen; + m_keyGen = 0; +} + +void BlackBerrySshKeysGenerator::run() +{ + const bool success = m_keyGen->generateKeys(QSsh::SshKeyGenerator::Rsa, + QSsh::SshKeyGenerator::Mixed, 4096, + QSsh::SshKeyGenerator::DoNotOfferEncryption); + emit sshKeysGenerationFinished(success); +} + +QSsh::SshKeyGenerator *BlackBerrySshKeysGenerator::keyGenerator() const +{ + return m_keyGen; +} + +QString BlackBerrySshKeysGenerator::error() const +{ + return m_keyGen->error(); +} diff --git a/src/plugins/qnx/blackberrysshkeysgenerator.h b/src/plugins/qnx/blackberrysshkeysgenerator.h new file mode 100644 index 00000000000..459a9e205f7 --- /dev/null +++ b/src/plugins/qnx/blackberrysshkeysgenerator.h @@ -0,0 +1,63 @@ +/************************************************************************** +** +** Copyright (C) 2011 - 2013 Research In Motion +** +** Contact: Research In Motion (blackberry-qt@qnx.com) +** Contact: KDAB (info@kdab.com) +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ +#ifndef BLACKBERRYSSHKEYSGENERATOR_H +#define BLACKBERRYSSHKEYSGENERATOR_H + +#include + +namespace QSsh { +class SshKeyGenerator; +} + +namespace Qnx { +namespace Internal { + +class BlackBerrySshKeysGenerator : public QThread +{ + Q_OBJECT +public: + BlackBerrySshKeysGenerator(QObject *parent = 0); + ~BlackBerrySshKeysGenerator(); + QSsh::SshKeyGenerator *keyGenerator() const; + QString error() const; + +signals: + void sshKeysGenerationFinished(bool success); + +private: + QSsh::SshKeyGenerator *m_keyGen; + void run(); +}; + +} // namespace Internal +} // namespace Qnx + +#endif // BLACKBERRYSSHKEYSGENERATOR_H diff --git a/src/plugins/qnx/qnx.pro b/src/plugins/qnx/qnx.pro index ca088da04ec..5c9271bb54c 100644 --- a/src/plugins/qnx/qnx.pro +++ b/src/plugins/qnx/qnx.pro @@ -76,7 +76,8 @@ SOURCES += qnxplugin.cpp \ blackberrycheckdevmodestepconfigwidget.cpp \ blackberrydeviceconnection.cpp \ blackberrydeviceconnectionmanager.cpp \ - blackberrydeviceinformation.cpp + blackberrydeviceinformation.cpp \ + blackberrysshkeysgenerator.cpp HEADERS += qnxplugin.h\ qnxconstants.h \ @@ -152,7 +153,8 @@ HEADERS += qnxplugin.h\ blackberrycheckdevmodestepconfigwidget.h \ blackberrydeviceconnection.h \ blackberrydeviceconnectionmanager.h \ - blackberrydeviceinformation.h + blackberrydeviceinformation.h \ + blackberrysshkeysgenerator.h FORMS += \ blackberrydeviceconfigurationwizardsetuppage.ui \ diff --git a/src/plugins/qnx/qnx.qbs b/src/plugins/qnx/qnx.qbs index 70a8f986b78..0aac4ce906f 100644 --- a/src/plugins/qnx/qnx.qbs +++ b/src/plugins/qnx/qnx.qbs @@ -140,6 +140,8 @@ QtcPlugin { "blackberrydebugtokenuploader.h", "blackberryndkprocess.cpp", "blackberryndkprocess.h", + "blackberrysshkeysgenerator.cpp", + "blackberrysshkeysgenerator.h", "pathchooserdelegate.cpp", "pathchooserdelegate.h", "qnx.qrc",