diff options
author | Rafael Roquetto <rafael.roquetto@kdab.com> | 2013-09-10 17:38:16 -0300 |
---|---|---|
committer | Rafael Roquetto <rafael.roquetto@kdab.com> | 2013-09-30 20:50:34 +0200 |
commit | 9f0583f87d93d59a19ef6c7a2c1653bef61cffea (patch) | |
tree | 7203e0e031fa28ac229e038afe69d3298fa09d48 | |
parent | 9654df9f1f92ab2c1548c10ca614a6ab82783ac4 (diff) | |
download | qt-creator-9f0583f87d93d59a19ef6c7a2c1653bef61cffea.tar.gz |
BlackBerry NDK 10.2 signing support
Change-Id: I7bd6649dd20b0b204b7a4f4bcbcee6bc45fa0272
Reviewed-by: Nicolas Arnaud-Cormos <nicolas@kdab.com>
33 files changed, 1013 insertions, 2133 deletions
diff --git a/src/plugins/qnx/blackberrycertificate.cpp b/src/plugins/qnx/blackberrycertificate.cpp index c97f973ad6..ef80841a89 100644 --- a/src/plugins/qnx/blackberrycertificate.cpp +++ b/src/plugins/qnx/blackberrycertificate.cpp @@ -1,8 +1,8 @@ /************************************************************************** ** -** Copyright (C) 2011 - 2013 Research In Motion +** Copyright (C) 2013 BlackBerry Limited. All rights reserved. ** -** Contact: Research In Motion (blackberry-qt@qnx.com) +** Contact: BlackBerry (qt@blackberry.com) ** Contact: KDAB (info@kdab.com) ** ** This file is part of Qt Creator. @@ -50,6 +50,7 @@ BlackBerryCertificate::BlackBerryCertificate(const QString &fileName, m_storePass(storePass), m_process(new QProcess(this)) { + m_process->setProcessChannelMode(QProcess::MergedChannels); } void BlackBerryCertificate::load() @@ -142,10 +143,12 @@ void BlackBerryCertificate::loadFinished() while (!processOutput.atEnd()) { QString chunk = processOutput.readLine(); - if (chunk.contains( - QLatin1String("Error: Failed to decrypt keystore, invalid password"))) { + if (chunk.contains(QLatin1String("invalid password"))) { status = WrongPassword; break; + } else if (chunk.contains(QLatin1String("must be at least 6 characters"))) { + status = PasswordTooSmall; + break; } else if (chunk.startsWith(QLatin1String("Owner:"))) { chunk.remove(QLatin1String("Owner:")); m_author = chunk.remove(QLatin1String("CN=")).trimmed(); diff --git a/src/plugins/qnx/blackberrycertificate.h b/src/plugins/qnx/blackberrycertificate.h index e15cb5f87d..02f380c93d 100644 --- a/src/plugins/qnx/blackberrycertificate.h +++ b/src/plugins/qnx/blackberrycertificate.h @@ -1,8 +1,8 @@ /************************************************************************** ** -** Copyright (C) 2011 - 2013 Research In Motion +** Copyright (C) 2013 BlackBerry Limited. All rights reserved. ** -** Contact: Research In Motion (blackberry-qt@qnx.com) +** Contact: BlackBerry (qt@blackberry.com) ** Contact: KDAB (info@kdab.com) ** ** This file is part of Qt Creator. @@ -51,6 +51,7 @@ public: Success, Busy, WrongPassword, + PasswordTooSmall, InvalidOutputFormat, Error }; diff --git a/src/plugins/qnx/blackberrycertificatemodel.cpp b/src/plugins/qnx/blackberrycertificatemodel.cpp deleted file mode 100644 index 9f177e2b9d..0000000000 --- a/src/plugins/qnx/blackberrycertificatemodel.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/************************************************************************** -** -** 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 "blackberrycertificatemodel.h" -#include "blackberrycertificate.h" -#include "blackberryconfigurationmanager.h" - -#include <coreplugin/icore.h> - -#include <QSettings> -#include <QStringList> - -namespace Qnx { -namespace Internal { - -const QLatin1String SettingsGroup("BlackBerryConfiguration"); -const QLatin1String CertificateGroup("Certificates"); - -BlackBerryCertificateModel::BlackBerryCertificateModel(QObject *parent) : - QAbstractTableModel(parent), - m_activeCertificate(0) -{ - load(); -} - -BlackBerryCertificateModel::~BlackBerryCertificateModel() -{ -} - -int BlackBerryCertificateModel::rowCount(const QModelIndex &parent) const -{ - if (parent.isValid()) - return 0; - - return m_certificates.count(); -} - -int BlackBerryCertificateModel::columnCount(const QModelIndex &parent) const -{ - if (parent.isValid()) - return 0; - - return ColumnCount; -} - -QVariant BlackBerryCertificateModel::data(const QModelIndex &index, int role) const -{ - if (index.row() >= rowCount() || index.column() >= columnCount()) - return QVariant(); - - const BlackBerryCertificate *cert = m_certificates.at(index.row()); - - if (role == Qt::CheckStateRole) { - if (index.column() == CertActive) - return (m_activeCertificate == cert) ? Qt::Checked : Qt::Unchecked; - } else if (role == Qt::DisplayRole) { - if (index.column() == CertPath) - return cert->fileName(); - else if (index.column() == CertAuthor) - return cert->author(); - } - - return QVariant(); -} - -QVariant BlackBerryCertificateModel::headerData(int section, - Qt::Orientation orientation, int role) const -{ - if (role != Qt::DisplayRole) - return QVariant(); - - if (orientation == Qt::Vertical) - return section; - - switch (section) { - case CertPath: - return tr("Path"); - case CertAuthor: - return tr("Author"); - case CertActive: - return tr("Active"); - default: - break; - } - - return section; -} - -bool BlackBerryCertificateModel::setData(const QModelIndex &ind, - const QVariant &value, int role) -{ - Q_UNUSED(value); - - if (role == Qt::CheckStateRole && ind.column() == CertActive) { - const int oldIndex = m_certificates.indexOf(m_activeCertificate); - - m_activeCertificate = m_certificates.at(ind.row()); - - if (oldIndex >= 0) - emit dataChanged(index(oldIndex, CertActive), index(oldIndex, CertActive)); - - emit dataChanged(ind, ind); - - return true; - } - - return false; -} - -bool BlackBerryCertificateModel::removeRows(int row, int count, - const QModelIndex &parent) -{ - - beginRemoveRows(parent, row, row + count - 1); - - for (int i = 0; i < count; i++) { - m_certificates.removeAt(row); - //XXX shall we also delete from disk? - } - - endRemoveRows(); - - return true; -} - -Qt::ItemFlags BlackBerryCertificateModel::flags(const QModelIndex &index) const -{ - Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable; - - switch (index.column()) { - case CertActive: - flags |= Qt::ItemIsUserCheckable; - break; - default: - break; - } - - return flags; -} - -BlackBerryCertificate * BlackBerryCertificateModel::activeCertificate() const -{ - return m_activeCertificate; -} - -QList<BlackBerryCertificate*> BlackBerryCertificateModel::certificates() const -{ - return m_certificates; -} - -bool BlackBerryCertificateModel::insertCertificate(BlackBerryCertificate *certificate) -{ - if (m_certificates.contains(certificate)) - return false; - - beginInsertRows(QModelIndex(), m_certificates.count(), m_certificates.count()); - - if (m_certificates.isEmpty()) - m_activeCertificate = certificate; - - certificate->setParent(this); - m_certificates << certificate; - - endInsertRows(); - - return true; -} - -void BlackBerryCertificateModel::load() -{ - BlackBerryConfigurationManager &configManager = BlackBerryConfigurationManager::instance(); - m_certificates = configManager.certificates(); - m_activeCertificate = configManager.activeCertificate(); -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/blackberrycertificatemodel.h b/src/plugins/qnx/blackberrycertificatemodel.h deleted file mode 100644 index 1e49fcfdc2..0000000000 --- a/src/plugins/qnx/blackberrycertificatemodel.h +++ /dev/null @@ -1,89 +0,0 @@ -/************************************************************************** -** -** 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 BLACKBERRYCERTIFICATEMODEL_H -#define BLACKBERRYCERTIFICATEMODEL_H - -#include <QAbstractTableModel> -#include <QList> - -namespace Qnx { -namespace Internal { - -class BlackBerryCertificate; - -class BlackBerryCertificateModel : public QAbstractTableModel -{ - Q_OBJECT - -public: - explicit BlackBerryCertificateModel(QObject *parent = 0); - ~BlackBerryCertificateModel(); - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - - QVariant data(const QModelIndex &index, - int role = Qt::DisplayRole) const; - QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const; - - bool setData(const QModelIndex &index, const QVariant &value, - int role = Qt::EditRole); - bool removeRows(int row, int count, - const QModelIndex &parent = QModelIndex()); - - bool insertCertificate(BlackBerryCertificate *certificate); - - Qt::ItemFlags flags(const QModelIndex &index) const; - - BlackBerryCertificate *activeCertificate() const; - QList<BlackBerryCertificate*> certificates() const; - -private slots: - void load(); - -private: - enum Columns { - CertPath, - CertAuthor, - CertActive, - ColumnCount - }; - - QList<BlackBerryCertificate*> m_certificates; - BlackBerryCertificate *m_activeCertificate; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // BLACKBERRYCERTIFICATEMODEL_H diff --git a/src/plugins/qnx/blackberryconfigurationmanager.cpp b/src/plugins/qnx/blackberryconfigurationmanager.cpp index 1553c62bc2..fab197f259 100644 --- a/src/plugins/qnx/blackberryconfigurationmanager.cpp +++ b/src/plugins/qnx/blackberryconfigurationmanager.cpp @@ -1,8 +1,8 @@ /************************************************************************** ** -** Copyright (C) 2011 - 2013 Research In Motion +** Copyright (C) 2013 BlackBerry Limited. All rights reserved. ** -** Contact: Research In Motion (blackberry-qt@qnx.com) +** Contact: BlackBerry (qt@blackberry.com) ** Contact: KDAB (info@kdab.com) ** ** This file is part of Qt Creator. @@ -71,33 +71,6 @@ BlackBerryConfigurationManager::BlackBerryConfigurationManager(QObject *parent) connect(Core::ICore::instance(), SIGNAL(saveSettingsRequested()), this, SLOT(saveSettings())); } -void BlackBerryConfigurationManager::loadCertificates() -{ - QSettings *settings = Core::ICore::settings(); - - settings->beginGroup(SettingsGroup); - settings->beginGroup(CertificateGroup); - - foreach (const QString &certificateId, settings->childGroups()) { - settings->beginGroup(certificateId); - - BlackBerryCertificate *cert = - new BlackBerryCertificate(settings->value(QLatin1String(Qnx::Constants::QNX_KEY_PATH)).toString(), - settings->value(QLatin1String(Qnx::Constants::QNX_KEY_AUTHOR)).toString()); - cert->setParent(this); - - if (settings->value(QLatin1String(Qnx::Constants::QNX_KEY_ACTIVE)).toBool()) - m_activeCertificate = cert; - - m_certificates << cert; - - settings->endGroup(); - } - - settings->endGroup(); - settings->endGroup(); -} - void BlackBerryConfigurationManager::loadManualConfigurations() { QSettings *settings = Core::ICore::settings(); @@ -173,29 +146,6 @@ QStringList BlackBerryConfigurationManager::activeConfigurationNdkEnvPaths() return actives; } -void BlackBerryConfigurationManager::saveCertificates() -{ - QSettings *settings = Core::ICore::settings(); - settings->beginGroup(SettingsGroup); - settings->beginGroup(CertificateGroup); - - settings->remove(QString()); - - foreach (const BlackBerryCertificate *cert, m_certificates) { - settings->beginGroup(cert->id()); - settings->setValue(QLatin1String(Qnx::Constants::QNX_KEY_PATH), cert->fileName()); - settings->setValue(QLatin1String(Qnx::Constants::QNX_KEY_AUTHOR), cert->author()); - - if (cert == m_activeCertificate) - settings->setValue(QLatin1String(Qnx::Constants::QNX_KEY_ACTIVE), true); - - settings->endGroup(); - } - - settings->endGroup(); - settings->endGroup(); -} - void BlackBerryConfigurationManager::saveManualConfigurations() { if (manualConfigurations().isEmpty()) @@ -331,52 +281,6 @@ BlackBerryConfiguration *BlackBerryConfigurationManager::configurationFromEnvFil return 0; } -void BlackBerryConfigurationManager::syncCertificates(QList<BlackBerryCertificate*> certificates, - BlackBerryCertificate *activeCertificate) -{ - m_activeCertificate = activeCertificate; - - foreach (BlackBerryCertificate *cert, certificates) { - if (!certificates.contains(cert)) - removeCertificate(cert); - } - - foreach (BlackBerryCertificate *cert, certificates) - addCertificate(cert); -} - -void BlackBerryConfigurationManager::addCertificate(BlackBerryCertificate *certificate) -{ - if (m_certificates.contains(certificate)) - return; - - if (m_certificates.isEmpty()) - m_activeCertificate = certificate; - - certificate->setParent(this); - m_certificates << certificate; -} - -void BlackBerryConfigurationManager::removeCertificate(BlackBerryCertificate *certificate) -{ - if (m_activeCertificate == certificate) - m_activeCertificate = 0; - - m_certificates.removeAll(certificate); - - delete certificate; -} - -QList<BlackBerryCertificate*> BlackBerryConfigurationManager::certificates() const -{ - return m_certificates; -} - -BlackBerryCertificate * BlackBerryConfigurationManager::activeCertificate() -{ - return m_activeCertificate; -} - // Returns a valid qnxEnv map from a valid configuration; // Needed by other classes to get blackberry process path (keys registration, debug token...) QMultiMap<QString, QString> BlackBerryConfigurationManager::defaultQnxEnv() @@ -394,7 +298,6 @@ void BlackBerryConfigurationManager::loadSettings() clearInvalidConfigurations(); loadAutoDetectedConfigurations(); loadManualConfigurations(); - loadCertificates(); emit settingsLoaded(); } @@ -423,7 +326,6 @@ void BlackBerryConfigurationManager::saveSettings() { saveActiveConfigurationNdkEnvPath(); saveManualConfigurations(); - saveCertificates(); } BlackBerryConfigurationManager &BlackBerryConfigurationManager::instance() @@ -444,6 +346,11 @@ QString BlackBerryConfigurationManager::barsignerCskPath() const return QnxUtils::dataDirPath() + QLatin1String("/barsigner.csk"); } +QString BlackBerryConfigurationManager::idTokenPath() const +{ + return QnxUtils::dataDirPath() + QLatin1String("/bbidtoken.csk"); +} + QString BlackBerryConfigurationManager::barsignerDbPath() const { return QnxUtils::dataDirPath() + QLatin1String("/barsigner.db"); diff --git a/src/plugins/qnx/blackberryconfigurationmanager.h b/src/plugins/qnx/blackberryconfigurationmanager.h index 4283f766cc..ea94d90741 100644 --- a/src/plugins/qnx/blackberryconfigurationmanager.h +++ b/src/plugins/qnx/blackberryconfigurationmanager.h @@ -1,8 +1,8 @@ /************************************************************************** ** -** Copyright (C) 2011 - 2013 Research In Motion +** Copyright (C) 2013 BlackBerry Limited. All rights reserved. ** -** Contact: Research In Motion (blackberry-qt@qnx.com) +** Contact: BlackBerry (qt@blackberry.com) ** Contact: KDAB (info@kdab.com) ** ** This file is part of Qt Creator. @@ -42,7 +42,6 @@ namespace Qnx { namespace Internal { class BlackBerryConfiguration; -class BlackBerryCertificate; class BlackBerryConfigurationManager : public QObject { @@ -58,17 +57,11 @@ public: BlackBerryConfiguration *configurationFromEnvFile(const Utils::FileName &envFile) const; QString barsignerCskPath() const; + QString idTokenPath() const; QString barsignerDbPath() const; QString defaultKeystorePath() const; QString defaultDebugTokenPath() const; void clearConfigurationSettings(BlackBerryConfiguration *config); - void syncCertificates(QList<BlackBerryCertificate*> certificates, - BlackBerryCertificate *activeCertificate); - void addCertificate(BlackBerryCertificate *certificate); - void removeCertificate(BlackBerryCertificate *certificate); - - QList<BlackBerryCertificate*> certificates() const; - BlackBerryCertificate *activeCertificate(); QMultiMap<QString, QString> defaultQnxEnv(); @@ -84,13 +77,8 @@ private: static BlackBerryConfigurationManager *m_instance; QList<BlackBerryConfiguration*> m_configs; - QList<BlackBerryCertificate*> m_certificates; - BlackBerryCertificate *m_activeCertificate; - - void loadCertificates(); void loadManualConfigurations(); void loadAutoDetectedConfigurations(); - void saveCertificates(); void saveManualConfigurations(); void saveActiveConfigurationNdkEnvPath(); void clearInvalidConfigurations(); diff --git a/src/plugins/qnx/blackberrycreatecertificatedialog.cpp b/src/plugins/qnx/blackberrycreatecertificatedialog.cpp index 5be8398c00..3fd3ac18c9 100644 --- a/src/plugins/qnx/blackberrycreatecertificatedialog.cpp +++ b/src/plugins/qnx/blackberrycreatecertificatedialog.cpp @@ -1,8 +1,8 @@ /************************************************************************** ** -** Copyright (C) 2011 - 2013 Research In Motion +** Copyright (C) 2013 BlackBerry Limited. All rights reserved. ** -** Contact: Research In Motion (blackberry-qt@qnx.com) +** Contact: BlackBerry (qt@blackberry.com) ** Contact: KDAB (info@kdab.com) ** ** This file is part of Qt Creator. @@ -31,6 +31,7 @@ #include "blackberrycreatecertificatedialog.h" #include "blackberrycertificate.h" +#include "blackberryconfigurationmanager.h" #include "ui_blackberrycreatecertificatedialog.h" #include <QPushButton> @@ -49,9 +50,6 @@ BlackBerryCreateCertificateDialog::BlackBerryCreateCertificateDialog( { m_ui->setupUi(this); m_ui->progressBar->hide(); - m_ui->certPath->setExpectedKind(Utils::PathChooser::Any); - m_ui->certPath->setPromptDialogTitle(tr("Create Certificate")); - m_ui->certPath->setPromptDialogFilter(tr("PKCS 12 archives (*.p12)")); m_ui->status->clear(); m_cancelButton = m_ui->buttonBox->button(QDialogButtonBox::Cancel); @@ -64,10 +62,6 @@ BlackBerryCreateCertificateDialog::BlackBerryCreateCertificateDialog( this, SLOT(reject())); connect(m_okButton, SIGNAL(clicked()), this, SLOT(createCertificate())); - connect(m_ui->certPath, SIGNAL(changed(QString)), - this, SLOT(validate())); - connect(m_ui->certPath, SIGNAL(editingFinished()), - this, SLOT(appendExtension())); connect(m_ui->author, SIGNAL(textChanged(QString)), this, SLOT(validate())); connect(m_ui->password, SIGNAL(textChanged(QString)), @@ -85,7 +79,7 @@ QString BlackBerryCreateCertificateDialog::author() const QString BlackBerryCreateCertificateDialog::certPath() const { - return m_ui->certPath->path(); + return BlackBerryConfigurationManager::instance().defaultKeystorePath(); } QString BlackBerryCreateCertificateDialog::keystorePassword() const @@ -100,8 +94,7 @@ BlackBerryCertificate * BlackBerryCreateCertificateDialog::certificate() const void BlackBerryCreateCertificateDialog::validate() { - if (!m_ui->certPath->isValid() - || m_ui->author->text().isEmpty() + if (m_ui->author->text().isEmpty() || m_ui->password->text().isEmpty() || m_ui->password2->text().isEmpty()) { m_ui->status->clear(); @@ -109,7 +102,7 @@ void BlackBerryCreateCertificateDialog::validate() return; } - QFileInfo fileInfo(m_ui->certPath->path()); + QFileInfo fileInfo(certPath()); if (!fileInfo.dir().exists()) { m_ui->status->setText(tr("Base directory does not exist.")); @@ -123,6 +116,12 @@ void BlackBerryCreateCertificateDialog::validate() return; } + if (m_ui->password->text().size() < 6) { + m_ui->status->setText(tr("Password must be at least 6 characters long.")); + m_okButton->setEnabled(false); + return; + } + m_ui->status->clear(); m_okButton->setEnabled(true); } @@ -131,7 +130,7 @@ void BlackBerryCreateCertificateDialog::createCertificate() { setBusy(true); - QFile file(m_ui->certPath->path()); + QFile file(certPath()); if (file.exists()) { const int result = QMessageBox::question(this, tr("Are you sure?"), @@ -153,16 +152,6 @@ void BlackBerryCreateCertificateDialog::createCertificate() m_certificate->store(); } -void BlackBerryCreateCertificateDialog::appendExtension() -{ - QString path = m_ui->certPath->path(); - - if (!path.endsWith(QLatin1String(".p12"))) { - path += QLatin1String(".p12"); - m_ui->certPath->setPath(path); - } -} - void BlackBerryCreateCertificateDialog::checkBoxChanged(int state) { if (state == Qt::Checked) { @@ -176,22 +165,41 @@ void BlackBerryCreateCertificateDialog::checkBoxChanged(int state) void BlackBerryCreateCertificateDialog::certificateCreated(int status) { - if (status == BlackBerryCertificate::Success) { + QString errorMessage; + + switch (status) { + case BlackBerryCertificate::Success: accept(); - } else { - m_certificate->deleteLater(); - m_certificate = 0; - QMessageBox::critical(this, tr("Error"), - tr("An unknown error occurred while creating the certificate.")); - reject(); + return; + case BlackBerryCertificate::Busy: + errorMessage = tr("The blackberry-keytool process is already running"); + break; + case BlackBerryCertificate::WrongPassword: + errorMessage = tr("The enteres password is invalid"); + break; + case BlackBerryCertificate::PasswordTooSmall: + errorMessage = tr("The enteres password is too small"); + break; + case BlackBerryCertificate::InvalidOutputFormat: + errorMessage = tr("Invalid output format"); + break; + case BlackBerryCertificate::Error: + default: + errorMessage = tr("An unknown error occurred"); + break; } + + m_certificate->deleteLater(); + m_certificate = 0; + QMessageBox::critical(this, tr("Error"), errorMessage); + + reject(); } void BlackBerryCreateCertificateDialog::setBusy(bool busy) { m_okButton->setEnabled(!busy); m_cancelButton->setEnabled(!busy); - m_ui->certPath->setEnabled(!busy); m_ui->author->setEnabled(!busy); m_ui->password->setEnabled(!busy); m_ui->password2->setEnabled(!busy); diff --git a/src/plugins/qnx/blackberrycreatecertificatedialog.h b/src/plugins/qnx/blackberrycreatecertificatedialog.h index 19a7734e64..f347689d37 100644 --- a/src/plugins/qnx/blackberrycreatecertificatedialog.h +++ b/src/plugins/qnx/blackberrycreatecertificatedialog.h @@ -1,8 +1,8 @@ /************************************************************************** ** -** Copyright (C) 2011 - 2013 Research In Motion +** Copyright (C) 2013 BlackBerry Limited. All rights reserved. ** -** Contact: Research In Motion (blackberry-qt@qnx.com) +** Contact: BlackBerry (qt@blackberry.com) ** Contact: KDAB (info@kdab.com) ** ** This file is part of Qt Creator. @@ -61,7 +61,6 @@ public: private slots: void validate(); void createCertificate(); - void appendExtension(); void checkBoxChanged(int state); void certificateCreated(int status); diff --git a/src/plugins/qnx/blackberrycreatecertificatedialog.ui b/src/plugins/qnx/blackberrycreatecertificatedialog.ui index 521ca6dda7..02369458c1 100644 --- a/src/plugins/qnx/blackberrycreatecertificatedialog.ui +++ b/src/plugins/qnx/blackberrycreatecertificatedialog.ui @@ -17,19 +17,6 @@ <item> <layout class="QGridLayout" name="gridLayout"> <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Path:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="Utils::PathChooser" name="certPath" native="true"/> - </item> - <item row="1" column="0"> <widget class="QLabel" name="label_2"> <property name="text"> <string>Author:</string> @@ -39,10 +26,10 @@ </property> </widget> </item> - <item row="1" column="1"> + <item row="0" column="1"> <widget class="QLineEdit" name="author"/> </item> - <item row="2" column="0"> + <item row="1" column="0"> <widget class="QLabel" name="label_3"> <property name="text"> <string>Password:</string> @@ -52,14 +39,14 @@ </property> </widget> </item> - <item row="2" column="1"> + <item row="1" column="1"> <widget class="QLineEdit" name="password"> <property name="echoMode"> <enum>QLineEdit::Password</enum> </property> </widget> </item> - <item row="3" column="0"> + <item row="2" column="0"> <widget class="QLabel" name="label_4"> <property name="text"> <string>Confirm password:</string> @@ -69,21 +56,21 @@ </property> </widget> </item> - <item row="3" column="1"> + <item row="2" column="1"> <widget class="QLineEdit" name="password2"> <property name="echoMode"> <enum>QLineEdit::Password</enum> </property> </widget> </item> - <item row="4" column="0"> + <item row="3" column="0"> <widget class="QCheckBox" name="showPassword"> <property name="text"> <string>Show password</string> </property> </widget> </item> - <item row="4" column="1"> + <item row="3" column="1"> <widget class="QLabel" name="status"> <property name="font"> <font> @@ -120,14 +107,6 @@ </item> </layout> </widget> - <customwidgets> - <customwidget> - <class>Utils::PathChooser</class> - <extends>QWidget</extends> - <header location="global">utils/pathchooser.h</header> - <container>1</container> - </customwidget> - </customwidgets> <resources/> <connections/> </ui> diff --git a/src/plugins/qnx/blackberrycsjregistrar.cpp b/src/plugins/qnx/blackberrycsjregistrar.cpp deleted file mode 100644 index 0661f156cc..0000000000 --- a/src/plugins/qnx/blackberrycsjregistrar.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/************************************************************************** -** -** 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 "blackberrycsjregistrar.h" -#include "blackberryconfigurationmanager.h" -#include "blackberryconfiguration.h" - -#include <utils/hostosinfo.h> - -#include <QProcess> -#include <QStringList> -#include <QString> - -namespace Qnx { -namespace Internal { - -BlackBerryCsjRegistrar::BlackBerryCsjRegistrar(QObject *parent) : - QObject(parent), - m_process(new QProcess(this)) -{ - connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), - this, SLOT(processFinished())); - connect(m_process, SIGNAL(error(QProcess::ProcessError)), - this, SLOT(processError(QProcess::ProcessError))); -} - -void BlackBerryCsjRegistrar::tryRegister(const QStringList &csjFiles, - const QString &csjPin, const QString &cskPassword) -{ - if (m_process->state() != QProcess::NotRunning) - return; - - if (BlackBerryConfigurationManager::instance().configurations().isEmpty()) - return; - - QMultiMap<QString, QString> qnxEnv = BlackBerryConfigurationManager::instance().defaultQnxEnv(); - if (qnxEnv.isEmpty()) - return; - - QString command = qnxEnv.value(QLatin1String("QNX_HOST")) - + (QLatin1String("/usr/bin/blackberry-signer")); - - if (Utils::HostOsInfo::isWindowsHost()) - command += QLatin1String(".bat"); - - QStringList arguments; - - arguments << QLatin1String("-register") - << QLatin1String("-cskpass") - << cskPassword - << QLatin1String("-csjpin") - << csjPin - << csjFiles; - - m_process->start(command, arguments); -} - -void BlackBerryCsjRegistrar::processFinished() -{ - QByteArray result = m_process->readAllStandardOutput(); - - if (result.contains("Successfully registered with server.")) - emit finished(RegisterSuccess, QString()); - else - emit finished(Error, QLatin1String(result)); -} - -void BlackBerryCsjRegistrar::processError(QProcess::ProcessError error) -{ - QString errorMessage; - - switch (error) { - case QProcess::FailedToStart: - errorMessage = tr("Failed to start blackberry-signer process."); - break; - case QProcess::Timedout: - errorMessage = tr("Process timed out."); - break; - case QProcess::Crashed: - errorMessage = tr("Child process has crashed."); - break; - case QProcess::WriteError: - case QProcess::ReadError: - errorMessage = tr("Process I/O error."); - break; - case QProcess::UnknownError: - errorMessage = tr("Unknown process error."); - break; - } - - emit finished(Error, errorMessage); -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/blackberrycsjregistrar.h b/src/plugins/qnx/blackberrycsjregistrar.h deleted file mode 100644 index 28bba48d4a..0000000000 --- a/src/plugins/qnx/blackberrycsjregistrar.h +++ /dev/null @@ -1,71 +0,0 @@ -/************************************************************************** -** -** 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 QNX_INTERNAL_BLACKBERRYCSJREGISTRAR_H -#define QNX_INTERNAL_BLACKBERRYCSJREGISTRAR_H - -#include <QObject> -#include <QString> -#include <QProcess> - -namespace Qnx { -namespace Internal { - -class BlackBerryCsjRegistrar : public QObject -{ -Q_OBJECT - -public: - enum RegisterStatus - { - RegisterSuccess, - Error - }; - - BlackBerryCsjRegistrar(QObject *parent = 0); - - void tryRegister(const QStringList &csjFiles, const QString &csjPin, const QString &cskPassword); - -signals: - void finished(int status, const QString &errorString); - -private slots: - void processFinished(); - void processError(QProcess::ProcessError error); - -private: - QProcess *m_process; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYCSJREGISTRAR_H diff --git a/src/plugins/qnx/blackberrydebugtokenrequestdialog.cpp b/src/plugins/qnx/blackberrydebugtokenrequestdialog.cpp index b753243e8a..d4011d246b 100644 --- a/src/plugins/qnx/blackberrydebugtokenrequestdialog.cpp +++ b/src/plugins/qnx/blackberrydebugtokenrequestdialog.cpp @@ -1,8 +1,8 @@ /************************************************************************** ** -** Copyright (C) 2011 - 2013 Research In Motion +** Copyright (C) 2013 BlackBerry Limited. All rights reserved. ** -** Contact: Research In Motion (blackberry-qt@qnx.com) +** Contact: BlackBerry (qt@blackberry.com) ** Contact: KDAB (info@kdab.com) ** ** This file is part of Qt Creator. @@ -33,7 +33,7 @@ #include "blackberrydebugtokenrequester.h" #include "blackberrydeviceinformation.h" #include "blackberryconfigurationmanager.h" -#include "blackberrycertificate.h" +#include "blackberrysigningutils.h" #include "ui_blackberrydebugtokenrequestdialog.h" #include <QPushButton> @@ -48,7 +48,8 @@ BlackBerryDebugTokenRequestDialog::BlackBerryDebugTokenRequestDialog( QDialog(parent, f), m_ui(new Ui_BlackBerryDebugTokenRequestDialog), m_requester(new BlackBerryDebugTokenRequester(this)), - m_deviceInfo(new BlackBerryDeviceInformation(this)) + m_deviceInfo(new BlackBerryDeviceInformation(this)), + m_utils(BlackBerrySigningUtils::instance()) { m_ui->setupUi(this); m_ui->progressBar->hide(); @@ -61,8 +62,6 @@ BlackBerryDebugTokenRequestDialog::BlackBerryDebugTokenRequestDialog( m_okButton = m_ui->buttonBox->button(QDialogButtonBox::Ok); m_okButton->setEnabled(false); - populateComboBox(); - connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(reject())); connect(m_okButton, SIGNAL(clicked()), @@ -75,14 +74,8 @@ BlackBerryDebugTokenRequestDialog::BlackBerryDebugTokenRequestDialog( this, SLOT(appendExtension())); connect(m_ui->debugTokenPath, SIGNAL(editingFinished()), this, SLOT(expandPath())); - connect(m_ui->keystorePassword, SIGNAL(textChanged(QString)), - this, SLOT(validate())); - connect(m_ui->cskPassword, SIGNAL(textChanged(QString)), - this, SLOT(validate())); connect(m_ui->devicePin, SIGNAL(textChanged(QString)), this, SLOT(validate())); - connect(m_ui->showPassword, SIGNAL(stateChanged(int)), - this, SLOT(checkBoxChanged(int))); connect(m_requester, SIGNAL(finished(int)), this, SLOT(debugTokenArrived(int))); connect(m_deviceInfo, SIGNAL(finished(int)), @@ -112,10 +105,7 @@ void BlackBerryDebugTokenRequestDialog::setTargetDetails(const QString &deviceIp void BlackBerryDebugTokenRequestDialog::validate() { - if (!m_ui->debugTokenPath->isValid() - || m_ui->keystorePassword->text().isEmpty() - || m_ui->devicePin->text().isEmpty() - || m_ui->cskPassword->text().isEmpty()) { + if (!m_ui->debugTokenPath->isValid() || m_ui->devicePin->text().isEmpty()) { m_okButton->setEnabled(false); return; } @@ -151,10 +141,11 @@ void BlackBerryDebugTokenRequestDialog::requestDebugToken() } } + BlackBerryConfigurationManager &configuration = BlackBerryConfigurationManager::instance(); + m_requester->requestDebugToken(m_ui->debugTokenPath->path(), - m_ui->cskPassword->text(), - m_ui->keystore->itemText(m_ui->keystore->currentIndex()), - m_ui->keystorePassword->text(), m_ui->devicePin->text()); + m_utils.cskPassword(), configuration.defaultKeystorePath(), + m_utils.certificatePassword(), m_ui->devicePin->text()); } void BlackBerryDebugTokenRequestDialog::setDefaultPath() @@ -198,17 +189,6 @@ void BlackBerryDebugTokenRequestDialog::expandPath() m_ui->debugTokenPath->setPath(fileInfo.absoluteFilePath()); } -void BlackBerryDebugTokenRequestDialog::checkBoxChanged(int state) -{ - if (state == Qt::Checked) { - m_ui->cskPassword->setEchoMode(QLineEdit::Normal); - m_ui->keystorePassword->setEchoMode(QLineEdit::Normal); - } else { - m_ui->cskPassword->setEchoMode(QLineEdit::Password); - m_ui->keystorePassword->setEchoMode(QLineEdit::Password); - } -} - void BlackBerryDebugTokenRequestDialog::debugTokenArrived(int status) { QString errorString = tr("Failed to request debug token: "); @@ -218,9 +198,11 @@ void BlackBerryDebugTokenRequestDialog::debugTokenArrived(int status) accept(); return; case BlackBerryDebugTokenRequester::WrongCskPassword: + m_utils.clearCskPassword(); errorString += tr("Wrong CSK password."); break; case BlackBerryDebugTokenRequester::WrongKeystorePassword: + m_utils.clearCertificatePassword(); errorString += tr("Wrong keystore password."); break; case BlackBerryDebugTokenRequester::NetworkUnreachable: @@ -246,6 +228,9 @@ void BlackBerryDebugTokenRequestDialog::debugTokenArrived(int status) errorString += tr("Not yet registered to request debug tokens."); break; case BlackBerryDebugTokenRequester::UnknownError: + default: + m_utils.clearCertificatePassword(); + m_utils.clearCskPassword(); errorString += tr("An unknwon error has occurred."); break; } @@ -273,10 +258,6 @@ void BlackBerryDebugTokenRequestDialog::setBusy(bool busy) m_okButton->setEnabled(!busy); m_cancelButton->setEnabled(!busy); m_ui->debugTokenPath->setEnabled(!busy); - m_ui->keystore->setEnabled(!busy); - m_ui->keystorePassword->setEnabled(!busy); - m_ui->cskPassword->setEnabled(!busy); - m_ui->showPassword->setEnabled(!busy); m_ui->devicePin->setEnabled(!busy); m_ui->progressBar->setVisible(busy); @@ -286,15 +267,5 @@ void BlackBerryDebugTokenRequestDialog::setBusy(bool busy) m_ui->status->clear(); } -void BlackBerryDebugTokenRequestDialog::populateComboBox() -{ - BlackBerryConfigurationManager &configManager = BlackBerryConfigurationManager::instance(); - - QList<BlackBerryCertificate*> certificates = configManager.certificates(); - - foreach (const BlackBerryCertificate *certificate, certificates) - m_ui->keystore->addItem(certificate->fileName()); -} - } } // namespace Qnx diff --git a/src/plugins/qnx/blackberrydebugtokenrequestdialog.h b/src/plugins/qnx/blackberrydebugtokenrequestdialog.h index e4a17a5391..06fd0468a6 100644 --- a/src/plugins/qnx/blackberrydebugtokenrequestdialog.h +++ b/src/plugins/qnx/blackberrydebugtokenrequestdialog.h @@ -1,8 +1,8 @@ /************************************************************************** ** -** Copyright (C) 2011 - 2013 Research In Motion +** Copyright (C) 2013 BlackBerry Limited. All rights reserved. ** -** Contact: Research In Motion (blackberry-qt@qnx.com) +** Contact: BlackBerry (qt@blackberry.com) ** Contact: KDAB (info@kdab.com) ** ** This file is part of Qt Creator. @@ -44,6 +44,7 @@ namespace Internal { class Ui_BlackBerryDebugTokenRequestDialog; class BlackBerryDebugTokenRequester; class BlackBerryDeviceInformation; +class BlackBerrySigningUtils; class BlackBerryDebugTokenRequestDialog : public QDialog { @@ -64,18 +65,17 @@ private slots: void setDefaultPath(); void appendExtension(); void expandPath(); - void checkBoxChanged(int state); void debugTokenArrived(int status); void setDevicePin(int status); private: void setBusy(bool busy); - void populateComboBox(); Ui_BlackBerryDebugTokenRequestDialog *m_ui; BlackBerryDebugTokenRequester *m_requester; BlackBerryDeviceInformation *m_deviceInfo; + BlackBerrySigningUtils &m_utils; QPushButton *m_cancelButton; QPushButton *m_okButton; diff --git a/src/plugins/qnx/blackberrydebugtokenrequestdialog.ui b/src/plugins/qnx/blackberrydebugtokenrequestdialog.ui index e2059c5555..aa65f78ce4 100644 --- a/src/plugins/qnx/blackberrydebugtokenrequestdialog.ui +++ b/src/plugins/qnx/blackberrydebugtokenrequestdialog.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>388</width> - <height>198</height> + <height>153</height> </rect> </property> <property name="windowTitle"> @@ -30,53 +30,6 @@ <widget class="Utils::PathChooser" name="debugTokenPath" native="true"/> </item> <item row="1" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Keystore:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QComboBox" name="keystore"/> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Keystore password:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="keystorePassword"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>CSK password:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLineEdit" name="cskPassword"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item row="4" column="0"> <widget class="QLabel" name="label_5"> <property name="text"> <string>Device PIN:</string> @@ -86,36 +39,29 @@ </property> </widget> </item> - <item row="4" column="1"> + <item row="1" column="1"> <widget class="QLineEdit" name="devicePin"> <property name="inputMask"> - <string notr="true">HHHHHHHH; </string> + <string notr="true">HHHHHHHH</string> </property> <property name="maxLength"> <number>8</number> </property> </widget> </item> - <item row="5" column="0"> - <widget class="QCheckBox" name="showPassword"> - <property name="text"> - <string>Show password</string> - </property> - </widget> - </item> - <item row="5" column="1"> - <widget class="QProgressBar" name="progressBar"> - <property name="maximum"> - <number>0</number> - </property> - <property name="value"> - <number>0</number> - </property> - </widget> - </item> </layout> </item> <item> + <widget class="QProgressBar" name="progressBar"> + <property name="maximum"> + <number>0</number> + </property> + <property name="value"> + <number>0</number> + </property> + </widget> + </item> + <item> <widget class="QLabel" name="status"> <property name="font"> <font> diff --git a/src/plugins/qnx/blackberrykeyspage.cpp b/src/plugins/qnx/blackberrykeyspage.cpp index 0bcfa4048b..39493bf5a0 100644 --- a/src/plugins/qnx/blackberrykeyspage.cpp +++ b/src/plugins/qnx/blackberrykeyspage.cpp @@ -1,8 +1,8 @@ /************************************************************************** ** -** Copyright (C) 2011 - 2013 Research In Motion +** Copyright (C) 2013 BlackBerry Limited. All rights reserved. ** -** Contact: Research In Motion (blackberry-qt@qnx.com) +** Contact: BlackBerry (qt@blackberry.com) ** Contact: KDAB (info@kdab.com) ** ** This file is part of Qt Creator. @@ -59,7 +59,6 @@ QWidget *BlackBerryKeysPage::createPage(QWidget *parent) void BlackBerryKeysPage::apply() { - m_widget->apply(); } void BlackBerryKeysPage::finish() diff --git a/src/plugins/qnx/blackberrykeyswidget.cpp b/src/plugins/qnx/blackberrykeyswidget.cpp index 708260b31a..31ded4630d 100644 --- a/src/plugins/qnx/blackberrykeyswidget.cpp +++ b/src/plugins/qnx/blackberrykeyswidget.cpp @@ -1,8 +1,8 @@ /************************************************************************** ** -** Copyright (C) 2011 - 2013 Research In Motion +** Copyright (C) 2013 BlackBerry Limited. All rights reserved. ** -** Contact: Research In Motion (blackberry-qt@qnx.com) +** Contact: BlackBerry (qt@blackberry.com) ** Contact: KDAB (info@kdab.com) ** ** This file is part of Qt Creator. @@ -30,18 +30,13 @@ ****************************************************************************/ #include "blackberrykeyswidget.h" -#include "blackberryregisterkeydialog.h" #include "blackberryconfigurationmanager.h" -#include "blackberrycertificatemodel.h" -#include "blackberryimportcertificatedialog.h" -#include "blackberrycreatecertificatedialog.h" #include "blackberrycertificate.h" -#include "blackberryutils.h" +#include "blackberrysigningutils.h" +#include "blackberrycreatecertificatedialog.h" #include "ui_blackberrykeyswidget.h" -#include <QFileInfo> -#include <QHeaderView> -#include <QItemSelectionModel> +#include <QInputDialog> #include <QMessageBox> namespace Qnx { @@ -49,142 +44,147 @@ namespace Internal { BlackBerryKeysWidget::BlackBerryKeysWidget(QWidget *parent) : QWidget(parent), - m_ui(new Ui_BlackBerryKeysWidget), - m_model(new BlackBerryCertificateModel(this)) + m_utils(BlackBerrySigningUtils::instance()), + m_ui(new Ui_BlackBerryKeysWidget) { m_ui->setupUi(this); - m_ui->certificatesView->setModel(m_model); - m_ui->certificatesView->resizeColumnsToContents(); - - QHeaderView *headerView = m_ui->certificatesView->horizontalHeader(); - headerView->setResizeMode(QHeaderView::Stretch); - headerView->setResizeMode(2, QHeaderView::Fixed); - - QItemSelectionModel *selectionModel = m_ui->certificatesView->selectionModel(); - connect(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - this, SLOT(handleSelectionChanged(QItemSelection,QItemSelection))); - - updateRegisterSection(); - - connect(m_ui->registerButton, SIGNAL(clicked()), this, SLOT(registerKey())); - connect(m_ui->unregisterButton, SIGNAL(clicked()), this, SLOT(unregisterKey())); - connect(m_ui->createCertificate, SIGNAL(clicked()), this, SLOT(createCertificate())); - connect(m_ui->importCertificate, SIGNAL(clicked()), this, SLOT(importCertificate())); - connect(m_ui->deleteCertificate, SIGNAL(clicked()), this, SLOT(deleteCertificate())); + m_ui->keyStatus->setTextFormat(Qt::RichText); + m_ui->keyStatus->setTextInteractionFlags(Qt::TextBrowserInteraction); + m_ui->keyStatus->setOpenExternalLinks(true); + m_ui->openCertificateButton->setVisible(false); + + connect(m_ui->createCertificateButton, SIGNAL(clicked()), + this, SLOT(createCertificate())); + connect(m_ui->clearCertificateButton, SIGNAL(clicked()), + this, SLOT(clearCertificate())); + connect(m_ui->openCertificateButton, SIGNAL(clicked()), + this, SLOT(loadDefaultCertificate())); } -void BlackBerryKeysWidget::apply() +void BlackBerryKeysWidget::certificateLoaded(int status) { - BlackBerryConfigurationManager &configManager = BlackBerryConfigurationManager::instance(); - - configManager.syncCertificates(m_model->certificates(), m_model->activeCertificate()); + disconnect(&m_utils, SIGNAL(defaultCertificateLoaded(int)), this, SLOT(certificateLoaded(int))); + + switch (status) { + case BlackBerryCertificate::Success: + m_ui->certificateAuthor->setText(m_utils.defaultCertificate()->author()); + m_ui->openCertificateButton->setVisible(false); + break; + case BlackBerryCertificate::WrongPassword: + if (QMessageBox::question(this, tr("Qt Creator"), + tr("Invalid certificate password. Try again?"), + QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { + loadDefaultCertificate(); + } else { + m_ui->certificateAuthor->clear(); + m_ui->openCertificateButton->setVisible(true); + } + break; + case BlackBerryCertificate::Busy: + case BlackBerryCertificate::InvalidOutputFormat: + case BlackBerryCertificate::Error: + setCertificateError(tr("Error loading certificate!")); + m_ui->openCertificateButton->setVisible(true); + break; + } } -void BlackBerryKeysWidget::registerKey() +void BlackBerryKeysWidget::createCertificate() { - BlackBerryRegisterKeyDialog dialog; + BlackBerryCreateCertificateDialog dialog; const int result = dialog.exec(); - if (result != QDialog::Accepted) + if (result == QDialog::Rejected) return; - BlackBerryCertificate *cert = dialog.certificate(); + BlackBerryCertificate *certificate = dialog.certificate(); - if (cert) { - if (!m_model->insertCertificate(cert)) - QMessageBox::information(this, tr("Error"), tr("Could not insert default certificate.")); + if (certificate) { + m_utils.setDefaultCertificate(certificate); + updateCertificateSection(); } - - updateRegisterSection(); } -void BlackBerryKeysWidget::unregisterKey() +void BlackBerryKeysWidget::clearCertificate() { - const QMessageBox::StandardButton answer = - QMessageBox::question(this, tr("Unregister Key"), - tr("Do you really want to unregister your key? This action cannot be undone."), - QMessageBox::Yes | QMessageBox::No); - - if (answer & QMessageBox::No) - return; - - BlackBerryConfigurationManager &configManager = BlackBerryConfigurationManager::instance(); - - QFile f(configManager.barsignerCskPath()); - f.remove(); - - f.setFileName(configManager.barsignerDbPath()); - f.remove(); - - updateRegisterSection(); + if (QMessageBox::warning(this, tr("Qt Creator"), + tr("This action cannot be undone. Would you like to continue?"), + QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { + m_utils.deleteDefaultCertificate(); + updateCertificateSection(); + } } -void BlackBerryKeysWidget::createCertificate() +void BlackBerryKeysWidget::showEvent(QShowEvent *) { - BlackBerryCreateCertificateDialog dialog; + updateKeysSection(); + updateCertificateSection(); +} - const int result = dialog.exec(); +void BlackBerryKeysWidget::updateCertificateSection() +{ + if (m_utils.hasDefaultCertificate()) { + setCreateCertificateVisible(false); - if (result == QDialog::Rejected) - return; + BlackBerryConfigurationManager &configManager = BlackBerryConfigurationManager::instance(); - BlackBerryCertificate *cert = dialog.certificate(); + m_ui->certificatePath->setText(configManager.defaultKeystorePath()); + m_ui->certificateAuthor->setText(tr("Loading...")); - if (cert) { - if (!m_model->insertCertificate(cert)) - QMessageBox::information(this, tr("Error"), tr("Error storing certificate.")); + loadDefaultCertificate(); + } else { + setCreateCertificateVisible(true); } } -void BlackBerryKeysWidget::importCertificate() +void BlackBerryKeysWidget::updateKeysSection() { - BlackBerryImportCertificateDialog dialog; - - const int result = dialog.exec(); - - if (result == QDialog::Rejected) - return; - - BlackBerryCertificate *cert = dialog.certificate(); - - if (cert) { - if (!m_model->insertCertificate(cert)) - QMessageBox::information(this, tr("Error"), tr("This certificate already exists.")); + if (m_utils.hasLegacyKeys()) { + m_ui->keyStatus->setText(tr("It appears you are using legacy key files. " + "Please refer to the " + "<a href=\"https://developer.blackberry.com/native/documentation" + "/core/com.qnx.doc.native_sdk.devguide/com.qnx.doc.native_sdk.devguide/topic/bbid_to_sa.html\">" + "BlackBerry website</a> to find out how to update your keys.")); + } else if (m_utils.hasRegisteredKeys()) { + m_ui->keyStatus->setText(tr("Your keys are ready to be used")); + } else { + m_ui->keyStatus->setText(tr("No keys found. Please refer to the " + "<a href=\"https://www.blackberry.com/SignedKeys/codesigning.html\">BlackBerry website</a> " + "to find out how to request your keys.")); } } -void BlackBerryKeysWidget::deleteCertificate() +void BlackBerryKeysWidget::loadDefaultCertificate() { - const int result = QMessageBox::question(this, tr("Delete Certificate"), - tr("Are you sure you want to delete this certificate?"), - QMessageBox::Yes | QMessageBox::No); + const BlackBerryCertificate *certificate = m_utils.defaultCertificate(); - if (result & QMessageBox::No) + if (certificate) { + m_ui->certificateAuthor->setText(certificate->author()); + m_ui->openCertificateButton->setVisible(false); return; + } - m_model->removeRow(m_ui->certificatesView->selectionModel()->currentIndex().row()); + connect(&m_utils, SIGNAL(defaultCertificateLoaded(int)), this, SLOT(certificateLoaded(int))); + m_utils.openDefaultCertificate(); } -void BlackBerryKeysWidget::handleSelectionChanged(const QItemSelection &selected, - const QItemSelection &deselected) +void BlackBerryKeysWidget::setCertificateError(const QString &error) { - Q_UNUSED(deselected); - - m_ui->deleteCertificate->setEnabled(!selected.indexes().isEmpty()); + m_ui->certificateAuthor->clear(); + QMessageBox::critical(this, tr("Qt Creator"), error); } -void BlackBerryKeysWidget::updateRegisterSection() +void BlackBerryKeysWidget::setCreateCertificateVisible(bool visible) { - if (BlackBerryUtils::hasRegisteredKeys()) { - m_ui->registerButton->hide(); - m_ui->unregisterButton->show(); - m_ui->registeredLabel->setText(tr("Registered: Yes")); - } else { - m_ui->registerButton->show(); - m_ui->unregisterButton->hide(); - m_ui->registeredLabel->setText(tr("Registered: No")); - } + m_ui->pathLabel->setVisible(!visible); + m_ui->authorLabel->setVisible(!visible); + m_ui->certificatePath->setVisible(!visible); + m_ui->certificateAuthor->setVisible(!visible); + m_ui->clearCertificateButton->setVisible(!visible); + m_ui->openCertificateButton->setVisible(!visible); + m_ui->noCertificateLabel->setVisible(visible); + m_ui->createCertificateButton->setVisible(visible); } } // namespace Internal diff --git a/src/plugins/qnx/blackberrykeyswidget.h b/src/plugins/qnx/blackberrykeyswidget.h index 9e9721f473..11008d0b54 100644 --- a/src/plugins/qnx/blackberrykeyswidget.h +++ b/src/plugins/qnx/blackberrykeyswidget.h @@ -1,8 +1,8 @@ /************************************************************************** ** -** Copyright (C) 2011 - 2013 Research In Motion +** Copyright (C) 2013 BlackBerry Limited. All rights reserved. ** -** Contact: Research In Motion (blackberry-qt@qnx.com) +** Contact: BlackBerry (qt@blackberry.com) ** Contact: KDAB (info@kdab.com) ** ** This file is part of Qt Creator. @@ -35,16 +35,13 @@ #include "blackberryconfiguration.h" #include <QWidget> -#include <QStandardItemModel> - -QT_BEGIN_NAMESPACE -class QItemSelection; -QT_END_NAMESPACE +#include <QString> namespace Qnx { namespace Internal { -class BlackBerryCertificateModel; +class BlackBerryCertificate; +class BlackBerrySigningUtils; class Ui_BlackBerryKeysWidget; class BlackBerryKeysWidget : public QWidget @@ -53,27 +50,24 @@ class BlackBerryKeysWidget : public QWidget public: explicit BlackBerryKeysWidget(QWidget *parent = 0); - void apply(); - private slots: - void registerKey(); - void unregisterKey(); + void certificateLoaded(int status); void createCertificate(); - void importCertificate(); - void deleteCertificate(); - void handleSelectionChanged( - const QItemSelection &selected, - const QItemSelection &deselected); + void clearCertificate(); + void loadDefaultCertificate(); + +protected: + void showEvent(QShowEvent *event); private: - void updateRegisterSection(); + void updateKeysSection(); + void updateCertificateSection(); + void setCertificateError(const QString &error); + void setCreateCertificateVisible(bool show); - QString dataDir() const; - QString cskFilePath() const; - QString dbFilePath() const; + BlackBerrySigningUtils &m_utils; Ui_BlackBerryKeysWidget *m_ui; - BlackBerryCertificateModel *m_model; }; } // namespace Internal diff --git a/src/plugins/qnx/blackberrykeyswidget.ui b/src/plugins/qnx/blackberrykeyswidget.ui index a9156c533e..da510fff6e 100644 --- a/src/plugins/qnx/blackberrykeyswidget.ui +++ b/src/plugins/qnx/blackberrykeyswidget.ui @@ -21,36 +21,24 @@ </property> <layout class="QHBoxLayout" name="horizontalLayout"> <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> + <widget class="QLabel" name="keyStatus"> + <property name="font"> + <font> + <weight>50</weight> + <bold>false</bold> + </font> </property> - <property name="sizeHint" stdset="0"> - <size> - <width>658</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="registeredLabel"> <property name="text"> - <string>Registered: Yes</string> + <string>STATUS</string> </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="registerButton"> - <property name="text"> - <string>Register</string> + <property name="textFormat"> + <enum>Qt::RichText</enum> </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="unregisterButton"> - <property name="text"> - <string>Unregister</string> + <property name="wordWrap"> + <bool>true</bool> + </property> + <property name="textInteractionFlags"> + <set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse</set> </property> </widget> </item> @@ -62,57 +50,148 @@ <property name="title"> <string>Developer Certificate</string> </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="3" column="2"> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>189</height> - </size> - </property> - </spacer> - </item> - <item row="0" column="0" rowspan="4"> - <widget class="QTableView" name="certificatesView"> - <property name="selectionBehavior"> - <enum>QAbstractItemView::SelectRows</enum> - </property> - <attribute name="verticalHeaderVisible"> - <bool>false</bool> - </attribute> - </widget> - </item> - <item row="0" column="2"> - <widget class="QPushButton" name="createCertificate"> - <property name="text"> - <string>Create</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QPushButton" name="importCertificate"> - <property name="text"> - <string>Import</string> - </property> - </widget> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="pathLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="font"> + <font> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>Path:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="certificatePath"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>PATH</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="authorLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="font"> + <font> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>Author:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLabel" name="certificateAuthor"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>LABEL</string> + </property> + </widget> + </item> + </layout> </item> - <item row="2" column="2"> - <widget class="QPushButton" name="deleteCertificate"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Delete</string> - </property> - </widget> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QLabel" name="noCertificateLabel"> + <property name="font"> + <font> + <weight>50</weight> + <bold>false</bold> + </font> + </property> + <property name="text"> + <string>No developer certificate has been found.</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="openCertificateButton"> + <property name="text"> + <string>Open certificate</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="clearCertificateButton"> + <property name="text"> + <string>Clear certificate</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="createCertificateButton"> + <property name="text"> + <string>Create certificate</string> + </property> + </widget> + </item> + </layout> </item> </layout> </widget> </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>207</height> + </size> + </property> + </spacer> + </item> </layout> </widget> <resources/> diff --git a/src/plugins/qnx/blackberryndksettingswidget.cpp b/src/plugins/qnx/blackberryndksettingswidget.cpp index f86cdb6435..862e478c99 100644 --- a/src/plugins/qnx/blackberryndksettingswidget.cpp +++ b/src/plugins/qnx/blackberryndksettingswidget.cpp @@ -1,8 +1,8 @@ /************************************************************************** ** -** Copyright (C) 2011 - 2013 Research In Motion +** Copyright (C) 2013 BlackBerry Limited. All rights reserved. ** -** Contact: Research In Motion (blackberry-qt@qnx.com) +** Contact: BlackBerry (qt@blackberry.com) ** Contact: KDAB (info@kdab.com) ** ** This file is part of Qt Creator. @@ -32,7 +32,7 @@ #include "blackberryndksettingswidget.h" #include "ui_blackberryndksettingswidget.h" #include "qnxutils.h" -#include "blackberryutils.h" +#include "blackberrysigningutils.h" #include "blackberrysetupwizard.h" #include "blackberryconfigurationmanager.h" @@ -99,7 +99,8 @@ QList<BlackBerryConfiguration *> BlackBerryNDKSettingsWidget::deactivatedTargets void BlackBerryNDKSettingsWidget::launchBlackBerrySetupWizard() const { - const bool alreadyConfigured = BlackBerryUtils::hasRegisteredKeys(); + BlackBerrySigningUtils &blackBerryUtils = BlackBerrySigningUtils::instance(); + const bool alreadyConfigured = blackBerryUtils.hasRegisteredKeys() && blackBerryUtils.hasDefaultCertificate(); if (alreadyConfigured) { QMessageBox::information(0, tr("Qt Creator"), diff --git a/src/plugins/qnx/blackberryregisterkeydialog.cpp b/src/plugins/qnx/blackberryregisterkeydialog.cpp deleted file mode 100644 index e97d74ba8c..0000000000 --- a/src/plugins/qnx/blackberryregisterkeydialog.cpp +++ /dev/null @@ -1,324 +0,0 @@ -/************************************************************************** -** -** 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 "blackberryregisterkeydialog.h" -#include "blackberrycsjregistrar.h" -#include "blackberryconfigurationmanager.h" -#include "blackberrycertificate.h" -#include "blackberryutils.h" -#include "ui_blackberryregisterkeydialog.h" - -#include <QFileDialog> -#include <QFileInfo> -#include <QDir> -#include <QPushButton> -#include <QMessageBox> -#include <QTextStream> - -#include <utils/pathchooser.h> - -namespace Qnx { -namespace Internal { - -BlackBerryRegisterKeyDialog::BlackBerryRegisterKeyDialog(QWidget *parent, - Qt::WindowFlags f) : - QDialog(parent, f), - m_ui(new Ui_BlackBerryRegisterKeyDialog), - m_registrar(new BlackBerryCsjRegistrar(this)), - m_certificate(0) -{ - m_ui->setupUi(this); - m_ui->statusLabel->clear(); - - setupCsjPathChooser(m_ui->pbdtPath); - setupCsjPathChooser(m_ui->rdkPath); - - m_cancelButton = m_ui->buttonBox->button(QDialogButtonBox::Cancel); - - m_okButton = m_ui->buttonBox->button(QDialogButtonBox::Ok); - - setBusy(false); - - m_okButton->setEnabled(false); - - QFileInfo authorP12(BlackBerryConfigurationManager::instance().defaultKeystorePath()); - - if (authorP12.exists()) { - m_ui->genCert->setEnabled(false); - m_ui->genCert->setChecked(false); - m_ui->keystorePassword->setEnabled(false); - m_ui->keystorePassword2->setEnabled(false); - } else { - m_ui->genCert->setEnabled(true); - m_ui->genCert->setChecked(true); - m_ui->keystorePassword->setEnabled(true); - m_ui->keystorePassword2->setEnabled(true); - } - - - connect(m_cancelButton, SIGNAL(clicked()), - this, SLOT(reject())); - connect(m_okButton, SIGNAL(clicked()), - this, SLOT(createKey())); - connect(m_ui->pbdtPath, SIGNAL(changed(QString)), - this, SLOT(csjAutoComplete(QString))); - connect(m_ui->rdkPath, SIGNAL(changed(QString)), - this, SLOT(csjAutoComplete(QString))); - connect(m_ui->showPins, SIGNAL(stateChanged(int)), - this, SLOT(pinCheckBoxChanged(int))); - connect(m_registrar, SIGNAL(finished(int,QString)), - this, SLOT(registrarFinished(int,QString))); - connect(m_ui->genCert, SIGNAL(stateChanged(int)), - this, SLOT(certCheckBoxChanged(int))); - connect(m_ui->pbdtPath, SIGNAL(changed(QString)), this, SLOT(validate())); - connect(m_ui->rdkPath, SIGNAL(changed(QString)), this, SLOT(validate())); - connect(m_ui->csjPin, SIGNAL(textChanged(QString)), this, SLOT(validate())); - connect(m_ui->cskPin, SIGNAL(textChanged(QString)), this, SLOT(validate())); - connect(m_ui->cskPin2, SIGNAL(textChanged(QString)), this, SLOT(validate())); - connect(m_ui->keystorePassword, SIGNAL(textChanged(QString)), this, SLOT(validate())); - connect(m_ui->keystorePassword2, SIGNAL(textChanged(QString)), this, SLOT(validate())); -} - -void BlackBerryRegisterKeyDialog::csjAutoComplete(const QString &path) -{ - Utils::PathChooser *chooser = 0; - QString file = path; - - if (file.contains(QLatin1String("PBDT"))) { - file.replace(QLatin1String("PBDT"), QLatin1String("RDK")); - chooser = m_ui->rdkPath; - } else if (file.contains(QLatin1String("RDK"))) { - file.replace(QLatin1String("RDK"), QLatin1String("PBDT")); - chooser = m_ui->pbdtPath; - } - - if (!chooser) - return; - - QFileInfo fileInfo(file); - - if (fileInfo.exists()) - chooser->setPath(file); -} - -void BlackBerryRegisterKeyDialog::validate() -{ - if (!m_ui->pbdtPath->isValid() - || !m_ui->rdkPath->isValid() - || m_ui->csjPin->text().isEmpty() - || m_ui->cskPin->text().isEmpty() - || m_ui->cskPin2->text().isEmpty()) { - m_okButton->setEnabled(false); - m_ui->statusLabel->clear(); - return; - } - - if (m_ui->cskPin->text() != m_ui->cskPin2->text()) { - m_okButton->setEnabled(false); - m_ui->statusLabel->setText(tr("CSK passwords do not match.")); - return; - } - - if (m_ui->genCert->isChecked()) { - if (m_ui->keystorePassword->text().isEmpty() - || m_ui->keystorePassword2->text().isEmpty()) { - m_okButton->setEnabled(false); - m_ui->statusLabel->clear(); - return; - } - - if (m_ui->keystorePassword->text() - != m_ui->keystorePassword2->text()) { - m_ui->statusLabel->setText(tr("Keystore password does not match.")); - m_okButton->setEnabled(false); - return; - } - } - - m_ui->statusLabel->clear(); - m_okButton->setEnabled(true); -} - -void BlackBerryRegisterKeyDialog::pinCheckBoxChanged(int state) -{ - if (state == Qt::Checked) { - m_ui->csjPin->setEchoMode(QLineEdit::Normal); - m_ui->cskPin->setEchoMode(QLineEdit::Normal); - m_ui->cskPin2->setEchoMode(QLineEdit::Normal); - m_ui->keystorePassword->setEchoMode(QLineEdit::Normal); - m_ui->keystorePassword2->setEchoMode(QLineEdit::Normal); - } else { - m_ui->csjPin->setEchoMode(QLineEdit::Password); - m_ui->cskPin->setEchoMode(QLineEdit::Password); - m_ui->cskPin2->setEchoMode(QLineEdit::Password); - m_ui->keystorePassword->setEchoMode(QLineEdit::Password); - m_ui->keystorePassword2->setEchoMode(QLineEdit::Password); - } -} - -void BlackBerryRegisterKeyDialog::certCheckBoxChanged(int state) -{ - m_ui->keystorePassword->setEnabled(state == Qt::Checked); - m_ui->keystorePassword2->setEnabled(state == Qt::Checked); - - validate(); -} - -void BlackBerryRegisterKeyDialog::createKey() -{ - setBusy(true); - - QStringList csjFiles; - csjFiles << rdkPath() << pbdtPath(); - - m_registrar->tryRegister(csjFiles, csjPin(), cskPin()); -} - -void BlackBerryRegisterKeyDialog::registrarFinished(int status, - const QString &errorString) -{ - if (status == BlackBerryCsjRegistrar::Error) { - QMessageBox::critical(this, tr("Error"), errorString); - cleanup(); - setBusy(false); - return; - } - - if (m_ui->genCert->isChecked()) - generateDeveloperCertificate(); - else - accept(); -} - -void BlackBerryRegisterKeyDialog::certificateCreated(int status) -{ - if (status == BlackBerryCertificate::Error) { - QMessageBox::critical(this, tr("Error"), tr("Error creating developer certificate.")); - cleanup(); - m_certificate->deleteLater(); - m_certificate = 0; - setBusy(false); - } else { - accept(); - } -} - -QString BlackBerryRegisterKeyDialog::pbdtPath() const -{ - return m_ui->pbdtPath->path(); -} - -QString BlackBerryRegisterKeyDialog::rdkPath() const -{ - return m_ui->rdkPath->path(); -} - -QString BlackBerryRegisterKeyDialog::csjPin() const -{ - return m_ui->csjPin->text(); -} - -QString BlackBerryRegisterKeyDialog::cskPin() const -{ - return m_ui->cskPin->text(); -} - -QString BlackBerryRegisterKeyDialog::keystorePassword() const -{ - return m_ui->keystorePassword->text(); -} - -QString BlackBerryRegisterKeyDialog::keystorePath() const -{ - if (m_ui->genCert->isChecked()) { - BlackBerryConfigurationManager &configManager = BlackBerryConfigurationManager::instance(); - return configManager.defaultKeystorePath(); - } - - return QString(); -} - -BlackBerryCertificate * BlackBerryRegisterKeyDialog::certificate() const -{ - return m_certificate; -} - -void BlackBerryRegisterKeyDialog::generateDeveloperCertificate() -{ - m_certificate = new BlackBerryCertificate(keystorePath(), - BlackBerryUtils::getCsjAuthor(rdkPath()), keystorePassword()); - - connect(m_certificate, SIGNAL(finished(int)), this, SLOT(certificateCreated(int))); - - m_certificate->store(); -} - -void BlackBerryRegisterKeyDialog::cleanup() const -{ - BlackBerryConfigurationManager &configuration = BlackBerryConfigurationManager::instance(); - - QFile f(configuration.barsignerCskPath()); - f.remove(); - - f.setFileName(configuration.barsignerDbPath()); - f.remove(); - - if (m_ui->genCert->isChecked()) { - f.setFileName(configuration.defaultKeystorePath()); - f.remove(); - } -} - -void BlackBerryRegisterKeyDialog::setBusy(bool busy) -{ - m_ui->progressBar->setVisible(busy); - m_okButton->setEnabled(!busy); - m_cancelButton->setEnabled(!busy); - m_ui->rdkPath->setEnabled(!busy); - m_ui->pbdtPath->setEnabled(!busy); - m_ui->csjPin->setEnabled(!busy); - m_ui->cskPin->setEnabled(!busy); - m_ui->cskPin2->setEnabled(!busy); - m_ui->keystorePassword->setEnabled(!busy); - m_ui->keystorePassword2->setEnabled(!busy); - m_ui->showPins->setEnabled(!busy); - -} - -void BlackBerryRegisterKeyDialog::setupCsjPathChooser(Utils::PathChooser *chooser) -{ - chooser->setExpectedKind(Utils::PathChooser::File); - chooser->setPromptDialogTitle(tr("Browse CSJ File")); - chooser->setPromptDialogFilter(tr("CSJ files (*.csj)")); -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/blackberryregisterkeydialog.h b/src/plugins/qnx/blackberryregisterkeydialog.h deleted file mode 100644 index 0a8f974376..0000000000 --- a/src/plugins/qnx/blackberryregisterkeydialog.h +++ /dev/null @@ -1,97 +0,0 @@ -/************************************************************************** -** -** 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 QNX_INTERNAL_BLACKBERRYREGISTERKEYDIALOG_H -#define QNX_INTERNAL_BLACKBERRYREGISTERKEYDIALOG_H - -#include <QDialog> - -QT_BEGIN_NAMESPACE -class QPushButton; -QT_END_NAMESPACE - -namespace Utils { -class PathChooser; -} - -namespace Qnx { -namespace Internal { - -class Ui_BlackBerryRegisterKeyDialog; -class BlackBerryCsjRegistrar; -class BlackBerryCertificate; - -class BlackBerryRegisterKeyDialog : public QDialog -{ -Q_OBJECT - -public: - explicit BlackBerryRegisterKeyDialog(QWidget *parent = 0, - Qt::WindowFlags f = 0); - - QString pbdtPath() const; - QString rdkPath() const; - QString csjPin() const; - QString cskPin() const; - QString keystorePassword() const; - QString keystorePath() const; - - BlackBerryCertificate *certificate() const; - -private slots: - void csjAutoComplete(const QString &path); - void validate(); - void createKey(); - void pinCheckBoxChanged(int state); - void certCheckBoxChanged(int state); - void registrarFinished(int status, const QString &errorString); - void certificateCreated(int status); - -private: - void setupCsjPathChooser(Utils::PathChooser *chooser); - void generateDeveloperCertificate(); - void cleanup() const; - void setBusy(bool busy); - - Ui_BlackBerryRegisterKeyDialog *m_ui; - - BlackBerryCsjRegistrar *m_registrar; - - BlackBerryCertificate *m_certificate; - - QPushButton *m_okButton; - QPushButton *m_cancelButton; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYREGISTERKEYDIALOG_H diff --git a/src/plugins/qnx/blackberryregisterkeydialog.ui b/src/plugins/qnx/blackberryregisterkeydialog.ui deleted file mode 100644 index c3f36b784c..0000000000 --- a/src/plugins/qnx/blackberryregisterkeydialog.ui +++ /dev/null @@ -1,360 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BlackBerryRegisterKeyDialog</class> - <widget class="QDialog" name="Qnx::Internal::BlackBerryRegisterKeyDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>583</width> - <height>339</height> - </rect> - </property> - <property name="windowTitle"> - <string>Register Key</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QLabel" name="label"> - <property name="palette"> - <palette> - <active> - <colorrole role="Button"> - <brush brushstyle="SolidPattern"> - <color alpha="255"> - <red>255</red> - <green>255</green> - <blue>255</blue> - </color> - </brush> - </colorrole> - <colorrole role="Base"> - <brush brushstyle="SolidPattern"> - <color alpha="255"> - <red>255</red> - <green>255</green> - <blue>255</blue> - </color> - </brush> - </colorrole> - <colorrole role="Window"> - <brush brushstyle="SolidPattern"> - <color alpha="255"> - <red>255</red> - <green>255</green> - <blue>255</blue> - </color> - </brush> - </colorrole> - </active> - <inactive> - <colorrole role="Button"> - <brush brushstyle="SolidPattern"> - <color alpha="255"> - <red>255</red> - <green>255</green> - <blue>255</blue> - </color> - </brush> - </colorrole> - <colorrole role="Base"> - <brush brushstyle="SolidPattern"> - <color alpha="255"> - <red>255</red> - <green>255</green> - <blue>255</blue> - </color> - </brush> - </colorrole> - <colorrole role="Window"> - <brush brushstyle="SolidPattern"> - <color alpha="255"> - <red>255</red> - <green>255</green> - <blue>255</blue> - </color> - </brush> - </colorrole> - </inactive> - <disabled> - <colorrole role="Button"> - <brush brushstyle="SolidPattern"> - <color alpha="255"> - <red>255</red> - <green>255</green> - <blue>255</blue> - </color> - </brush> - </colorrole> - <colorrole role="Base"> - <brush brushstyle="SolidPattern"> - <color alpha="255"> - <red>255</red> - <green>255</green> - <blue>255</blue> - </color> - </brush> - </colorrole> - <colorrole role="Window"> - <brush brushstyle="SolidPattern"> - <color alpha="255"> - <red>255</red> - <green>255</green> - <blue>255</blue> - </color> - </brush> - </colorrole> - </disabled> - </palette> - </property> - <property name="autoFillBackground"> - <bool>true</bool> - </property> - <property name="frameShape"> - <enum>QFrame::WinPanel</enum> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-weight:600;">Obtaining keys</span></p><p>You will need to order a pair of CSJ files from BlackBerry, by <a href="https://www.blackberry.com/SignedKeys/codesigning.html"><span style=" text-decoration: underline; color:#004f69;">visiting this page.</span></a></p></body></html></string> - </property> - <property name="textFormat"> - <enum>Qt::RichText</enum> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - <property name="wordWrap"> - <bool>false</bool> - </property> - <property name="openExternalLinks"> - <bool>true</bool> - </property> - <property name="textInteractionFlags"> - <set>Qt::TextBrowserInteraction</set> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer_2"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>4</height> - </size> - </property> - </spacer> - </item> - <item> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>PBDT CSJ file:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="0" column="1" colspan="3"> - <widget class="Utils::PathChooser" name="pbdtPath" native="true"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>RDK CSJ file:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="1" column="1" colspan="3"> - <widget class="Utils::PathChooser" name="rdkPath" native="true"/> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>CSJ PIN:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>CSK password:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="label_6"> - <property name="text"> - <string>Confirm CSK password:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="6" column="0" colspan="2"> - <widget class="QLabel" name="label_7"> - <property name="text"> - <string>Keystore password:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="7" column="0" colspan="2"> - <widget class="QLabel" name="label_8"> - <property name="text"> - <string>Confirm password:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="5" column="0" colspan="3"> - <widget class="QCheckBox" name="genCert"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Generate developer certificate automatically</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="5" column="3"> - <widget class="QCheckBox" name="showPins"> - <property name="text"> - <string>Show</string> - </property> - </widget> - </item> - <item row="7" column="2"> - <widget class="QLineEdit" name="keystorePassword2"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item row="6" column="2"> - <widget class="QLineEdit" name="keystorePassword"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - <property name="placeholderText"> - <string/> - </property> - </widget> - </item> - <item row="2" column="1" colspan="2"> - <widget class="QLineEdit" name="csjPin"> - <property name="maxLength"> - <number>10</number> - </property> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - <property name="placeholderText"> - <string>This is the PIN you entered when you requested the CSJ files.</string> - </property> - </widget> - </item> - <item row="3" column="1" colspan="2"> - <widget class="QLineEdit" name="cskPin"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - <property name="placeholderText"> - <string/> - </property> - </widget> - </item> - <item row="4" column="1" colspan="2"> - <widget class="QLineEdit" name="cskPin2"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QLabel" name="statusLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Status</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <property name="wordWrap"> - <bool>false</bool> - </property> - </widget> - </item> - <item> - <widget class="QProgressBar" name="progressBar"> - <property name="maximum"> - <number>0</number> - </property> - <property name="value"> - <number>-1</number> - </property> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>Utils::PathChooser</class> - <extends>QWidget</extends> - <header location="global">utils/pathchooser.h</header> - <container>1</container> - </customwidget> - </customwidgets> - <tabstops> - <tabstop>csjPin</tabstop> - <tabstop>cskPin</tabstop> - <tabstop>cskPin2</tabstop> - <tabstop>genCert</tabstop> - <tabstop>keystorePassword</tabstop> - <tabstop>keystorePassword2</tabstop> - <tabstop>showPins</tabstop> - <tabstop>buttonBox</tabstop> - </tabstops> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/blackberrysetupwizard.cpp b/src/plugins/qnx/blackberrysetupwizard.cpp index c0cd68f7c1..8c0427feb5 100644 --- a/src/plugins/qnx/blackberrysetupwizard.cpp +++ b/src/plugins/qnx/blackberrysetupwizard.cpp @@ -1,8 +1,8 @@ /************************************************************************** ** -** Copyright (C) 2011 - 2013 Research In Motion +** Copyright (C) 2013 BlackBerry Limited. All rights reserved. ** -** Contact: Research In Motion (blackberry-qt@qnx.com) +** Contact: BlackBerry (qt@blackberry.com) ** Contact: KDAB (info@kdab.com) ** ** This file is part of Qt Creator. @@ -32,13 +32,12 @@ #include "blackberrysetupwizard.h" #include "blackberrysetupwizardpages.h" #include "blackberrydeviceconfiguration.h" -#include "blackberrycsjregistrar.h" #include "blackberrycertificate.h" #include "blackberryconfigurationmanager.h" #include "blackberrydebugtokenrequester.h" #include "blackberrydebugtokenuploader.h" #include "blackberrydeviceinformation.h" -#include "blackberryutils.h" +#include "blackberrysigningutils.h" #include "qnxconstants.h" #include <projectexplorer/devicesupport/devicemanager.h> @@ -61,12 +60,13 @@ BlackBerrySetupWizard::BlackBerrySetupWizard(QWidget *parent) : QWizard(parent), m_ndkPage(0), m_keysPage(0), + m_certificatePage(0), m_devicePage(0), - m_registrar(0), m_certificate(0), m_deviceInfo(0), m_requester(0), m_uploader(0), + m_utils(BlackBerrySigningUtils::instance()), m_keyGenerator(0), m_currentStep(-1), m_stepOffset(0) @@ -77,23 +77,22 @@ BlackBerrySetupWizard::BlackBerrySetupWizard(QWidget *parent) : m_welcomePage = new BlackBerrySetupWizardWelcomePage(this); m_ndkPage = new BlackBerrySetupWizardNdkPage(this); m_keysPage = new BlackBerrySetupWizardKeysPage(this); + m_certificatePage = new BlackBerrySetupWizardCertificatePage(this); m_devicePage = new BlackBerrySetupWizardDevicePage(this); m_finishPage = new BlackBerrySetupWizardFinishPage(this); setPage(WelcomePageId, m_welcomePage); setPage(NdkPageId, m_ndkPage); setPage(KeysPageId, m_keysPage); + setPage(CertificatePageId, m_certificatePage); setPage(DevicePageId, m_devicePage); setPage(FinishPageId, m_finishPage); - m_registrar = new BlackBerryCsjRegistrar(this); m_deviceInfo = new BlackBerryDeviceInformation(this); m_requester = new BlackBerryDebugTokenRequester(this); m_uploader = new BlackBerryDebugTokenUploader(this); m_keyGenerator = new QSsh::SshKeyGenerator; - connect(m_registrar, SIGNAL(finished(int,QString)), - this, SLOT(registrarFinished(int,QString))); connect(m_deviceInfo, SIGNAL(finished(int)), this, SLOT(deviceInfoFinished(int))); connect(m_requester, SIGNAL(finished(int)), @@ -104,7 +103,6 @@ BlackBerrySetupWizard::BlackBerrySetupWizard(QWidget *parent) : this, SLOT(processNextStep())); registerStep("requestDevicePin", tr("Reading device PIN...")); - registerStep("createKeys", tr("Registering CSJ keys...")); registerStep("generateDeveloperCertificate", tr("Generating developer certificate...")); registerStep("generateSshKeys", tr("Generating SSH keys...")); registerStep("requestDebugToken", tr("Requesting a debug token for the device...")); @@ -163,18 +161,6 @@ void BlackBerrySetupWizard::deviceInfoFinished(int status) emit stepFinished(); } -void BlackBerrySetupWizard::registrarFinished(int status, - const QString &errorString) -{ - if (status == BlackBerryCsjRegistrar::Error) { - QMessageBox::critical(this, tr("Error"), errorString); - reset(); - return; - } - - emit stepFinished(); -} - void BlackBerrySetupWizard::certificateCreated(int status) { if (status == BlackBerryCertificate::Error) { @@ -185,9 +171,6 @@ void BlackBerrySetupWizard::certificateCreated(int status) return; } - BlackBerryConfigurationManager &configManager = BlackBerryConfigurationManager::instance(); - configManager.addCertificate(m_certificate); - emit stepFinished(); } @@ -200,6 +183,7 @@ void BlackBerrySetupWizard::debugTokenArrived(int status) emit stepFinished(); return; case BlackBerryDebugTokenRequester::WrongCskPassword: + m_utils.clearCskPassword(); errorString += tr("Wrong CSK password."); break; case BlackBerryDebugTokenRequester::WrongKeystorePassword: @@ -225,6 +209,8 @@ void BlackBerrySetupWizard::debugTokenArrived(int status) errorString += tr("Failed to communicate with the inferior process."); break; case BlackBerryDebugTokenRequester::UnknownError: + default: + m_utils.clearCskPassword(); errorString += tr("An unknwon error has occurred."); break; } @@ -299,11 +285,7 @@ void BlackBerrySetupWizard::cleanupFiles() const { BlackBerryConfigurationManager &configuration = BlackBerryConfigurationManager::instance(); - QFile f(configuration.barsignerCskPath()); - f.remove(); - - f.setFileName(configuration.barsignerDbPath()); - f.remove(); + QFile f; f.setFileName(configuration.defaultKeystorePath()); f.remove(); @@ -327,8 +309,7 @@ void BlackBerrySetupWizard::reset() m_currentStep = -1; if (m_certificate) { - BlackBerryConfigurationManager &configuration = BlackBerryConfigurationManager::instance(); - configuration.removeCertificate(m_certificate); + m_certificate->deleteLater(); m_certificate = 0; } } @@ -343,20 +324,12 @@ void BlackBerrySetupWizard::requestDevicePin() m_deviceInfo->setDeviceTarget(hostName(), devicePassword()); } -void BlackBerrySetupWizard::createKeys() -{ - QStringList csjFiles; - csjFiles << rdkPath() << pbdtPath(); - - m_registrar->tryRegister(csjFiles, csjPin(), password()); -} - void BlackBerrySetupWizard::generateDeveloperCertificate() { BlackBerryConfigurationManager &configuration = BlackBerryConfigurationManager::instance(); m_certificate = new BlackBerryCertificate(configuration.defaultKeystorePath(), - BlackBerryUtils::getCsjAuthor(rdkPath()), password()); + certificateAuthor(), certificatePassword()); connect(m_certificate, SIGNAL(finished(int)), this, SLOT(certificateCreated(int))); @@ -433,7 +406,7 @@ void BlackBerrySetupWizard::requestDebugToken() BlackBerryConfigurationManager &configuration = BlackBerryConfigurationManager::instance(); m_requester->requestDebugToken(configuration.defaultDebugTokenPath(), - password(), configuration.defaultKeystorePath(), password(), m_devicePin); + m_utils.cskPassword(), configuration.defaultKeystorePath(), certificatePassword(), m_devicePin); } void BlackBerrySetupWizard::uploadDebugToken() @@ -454,6 +427,8 @@ void BlackBerrySetupWizard::writeDeviceInformation() DeviceManager * const deviceManager = DeviceManager::instance(); deviceManager->addDevice(device()); + m_utils.setDefaultCertificate(m_certificate); + QWizard::accept(); } @@ -477,24 +452,14 @@ QString BlackBerrySetupWizard::storeLocation() const return Core::ICore::userResourcePath() + QLatin1String("/qnx/") + deviceName(); } -QString BlackBerrySetupWizard::rdkPath() const -{ - return field(QLatin1String(BlackBerrySetupWizardKeysPage::RdkPathField)).toString(); -} - -QString BlackBerrySetupWizard::pbdtPath() const -{ - return field(QLatin1String(BlackBerrySetupWizardKeysPage::PbdtPathField)).toString(); -} - -QString BlackBerrySetupWizard::csjPin() const +QString BlackBerrySetupWizard::certificatePassword() const { - return field(QLatin1String(BlackBerrySetupWizardKeysPage::CsjPinField)).toString(); + return field(QLatin1String(BlackBerrySetupWizardCertificatePage::PasswordField)).toString(); } -QString BlackBerrySetupWizard::password() const +QString BlackBerrySetupWizard::certificateAuthor() const { - return field(QLatin1String(BlackBerrySetupWizardKeysPage::PasswordField)).toString(); + return field(QLatin1String(BlackBerrySetupWizardCertificatePage::AuthorField)).toString(); } QString BlackBerrySetupWizard::hostName() const diff --git a/src/plugins/qnx/blackberrysetupwizard.h b/src/plugins/qnx/blackberrysetupwizard.h index 263d652f79..e40530aff0 100644 --- a/src/plugins/qnx/blackberrysetupwizard.h +++ b/src/plugins/qnx/blackberrysetupwizard.h @@ -1,8 +1,8 @@ /************************************************************************** ** -** Copyright (C) 2011 - 2013 Research In Motion +** Copyright (C) 2013 BlackBerry Limited. All rights reserved. ** -** Contact: Research In Motion (blackberry-qt@qnx.com) +** Contact: BlackBerry (qt@blackberry.com) ** Contact: KDAB (info@kdab.com) ** ** This file is part of Qt Creator. @@ -48,13 +48,14 @@ namespace Internal { class BlackBerrySetupWizardWelcomePage; class BlackBerrySetupWizardNdkPage; class BlackBerrySetupWizardKeysPage; +class BlackBerrySetupWizardCertificatePage; class BlackBerrySetupWizardDevicePage; class BlackBerrySetupWizardFinishPage; -class BlackBerryCsjRegistrar; class BlackBerryCertificate; class BlackBerryDeviceInformation; class BlackBerryDebugTokenRequester; class BlackBerryDebugTokenUploader; +class BlackBerrySigningUtils; class BlackBerrySetupWizard : public QWizard { @@ -72,12 +73,10 @@ signals: private slots: void processNextStep(); void deviceInfoFinished(int status); - void registrarFinished(int status, const QString &errorString); void certificateCreated(int status); void debugTokenArrived(int status); void uploaderFinished(int status); void requestDevicePin(); - void createKeys(); void generateDeveloperCertificate(); void generateSshKeys(); void requestDebugToken(); @@ -89,6 +88,7 @@ private: WelcomePageId, NdkPageId, KeysPageId, + CertificatePageId, DevicePageId, FinishPageId }; @@ -107,10 +107,8 @@ private: QString publicKeyPath() const; QString deviceName() const; QString storeLocation() const; - QString rdkPath() const; - QString pbdtPath() const; - QString csjPin() const; - QString password() const; + QString certificatePassword() const; + QString certificateAuthor() const; QString devicePassword() const; QString hostName() const; @@ -121,14 +119,15 @@ private: BlackBerrySetupWizardWelcomePage *m_welcomePage; BlackBerrySetupWizardNdkPage *m_ndkPage; BlackBerrySetupWizardKeysPage *m_keysPage; + BlackBerrySetupWizardCertificatePage *m_certificatePage; BlackBerrySetupWizardDevicePage *m_devicePage; BlackBerrySetupWizardFinishPage *m_finishPage; - BlackBerryCsjRegistrar *m_registrar; BlackBerryCertificate *m_certificate; BlackBerryDeviceInformation *m_deviceInfo; BlackBerryDebugTokenRequester *m_requester; BlackBerryDebugTokenUploader *m_uploader; + BlackBerrySigningUtils &m_utils; QSsh::SshKeyGenerator *m_keyGenerator; diff --git a/src/plugins/qnx/blackberrysetupwizardcertificatepage.ui b/src/plugins/qnx/blackberrysetupwizardcertificatepage.ui new file mode 100644 index 0000000000..b723cbffaa --- /dev/null +++ b/src/plugins/qnx/blackberrysetupwizardcertificatepage.ui @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Qnx::Internal::BlackBerrySetupWizardCertificatePage</class> + <widget class="QWidget" name="Qnx::Internal::BlackBerrySetupWizardCertificatePage"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>223</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Author:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="author"/> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Password:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="password"> + <property name="echoMode"> + <enum>QLineEdit::Password</enum> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Confirm password:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLineEdit" name="password2"> + <property name="echoMode"> + <enum>QLineEdit::Password</enum> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QCheckBox" name="showPassword"> + <property name="text"> + <string>Show password</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLabel" name="status"> + <property name="font"> + <font> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>Status</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>93</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/src/plugins/qnx/blackberrysetupwizardkeyspage.ui b/src/plugins/qnx/blackberrysetupwizardkeyspage.ui index 6a868be2f5..c5cba65fa5 100644 --- a/src/plugins/qnx/blackberrysetupwizardkeyspage.ui +++ b/src/plugins/qnx/blackberrysetupwizardkeyspage.ui @@ -15,7 +15,20 @@ </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> - <widget class="QLabel" name="linkLabel"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>63</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="legacyLabel"> <property name="palette"> <palette> <active> @@ -114,7 +127,7 @@ <enum>QFrame::StyledPanel</enum> </property> <property name="text"> - <string><html><head/><body><p><span style=" font-weight:600;">Obtaining keys</span></p><p>You will need to order a pair of CSJ files from BlackBerry, by <a href="https://www.blackberry.com/SignedKeys/codesigning.html"><span style=" text-decoration: underline; color:#004f69;">visiting this page.</span></a></p></body></html></string> + <string><html><head/><body><p><span style=" font-weight:600;">Legacy keys detected</span></p><p>It appears you are using legacy key files. Please visit <a href="https://developer.blackberry.com/native/documentation/core/com.qnx.doc.native_sdk.devguide/com.qnx.doc.native_sdk.devguide/topic/bbid_to_sa.html"><span style=" text-decoration: underline; color:#004f69;">this page</span></a> to upgrade your keys.</p></body></html></string> </property> <property name="textFormat"> <enum>Qt::RichText</enum> @@ -134,91 +147,123 @@ </widget> </item> <item> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>PBDT CSJ file:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="Utils::PathChooser" name="pbdtPath" native="true"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>RDK CSJ file:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="Utils::PathChooser" name="rdkPath" native="true"/> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>CSJ PIN:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="csjPin"> - <property name="toolTip"> - <string>The PIN you provided on the key request website</string> - </property> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Password:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLineEdit" name="password"> - <property name="toolTip"> - <string>The password that will be used to access your keys and CSK files</string> - </property> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="label_6"> - <property name="text"> - <string>Confirm password:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QLineEdit" name="password2"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - </layout> + <widget class="QLabel" name="linkLabel"> + <property name="palette"> + <palette> + <active> + <colorrole role="Button"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Base"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Window"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + </active> + <inactive> + <colorrole role="Button"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Base"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Window"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + </inactive> + <disabled> + <colorrole role="Button"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Base"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Window"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + </disabled> + </palette> + </property> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="text"> + <string><html><head/><body><p><span style=" font-weight:600;">Obtaining keys</span></p><p>You will need to order your signing keys from BlackBerry, by <a href="https://www.blackberry.com/SignedKeys/codesigning.html"><span style=" text-decoration: underline; color:#004f69;">visiting this page.</span></a></p></body></html></string> + </property> + <property name="textFormat"> + <enum>Qt::RichText</enum> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + <property name="openExternalLinks"> + <bool>false</bool> + </property> + <property name="textInteractionFlags"> + <set>Qt::TextBrowserInteraction</set> + </property> + </widget> </item> <item> <widget class="QLabel" name="statusLabel"> @@ -235,7 +280,7 @@ </font> </property> <property name="text"> - <string>Status</string> + <string>Your BlackBerry signing keys have already been installed.</string> </property> <property name="alignment"> <set>Qt::AlignCenter</set> @@ -246,28 +291,20 @@ </widget> </item> <item> - <spacer name="verticalSpacer"> + <spacer name="verticalSpacer_2"> <property name="orientation"> <enum>Qt::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> - <height>40</height> + <height>62</height> </size> </property> </spacer> </item> </layout> </widget> - <customwidgets> - <customwidget> - <class>Utils::PathChooser</class> - <extends>QWidget</extends> - <header location="global">utils/pathchooser.h</header> - <container>1</container> - </customwidget> - </customwidgets> <resources/> <connections/> </ui> diff --git a/src/plugins/qnx/blackberrysetupwizardpages.cpp b/src/plugins/qnx/blackberrysetupwizardpages.cpp index ce42e93e00..4284591a3c 100644 --- a/src/plugins/qnx/blackberrysetupwizardpages.cpp +++ b/src/plugins/qnx/blackberrysetupwizardpages.cpp @@ -1,8 +1,8 @@ /************************************************************************** ** -** Copyright (C) 2011 - 2013 Research In Motion +** Copyright (C) 2013 BlackBerry Limited. All rights reserved. ** -** Contact: Research In Motion (blackberry-qt@qnx.com) +** Contact: BlackBerry (qt@blackberry.com) ** Contact: KDAB (info@kdab.com) ** ** This file is part of Qt Creator. @@ -32,7 +32,9 @@ #include "blackberrysetupwizardpages.h" #include "blackberryndksettingswidget.h" #include "blackberryconfiguration.h" +#include "blackberrysigningutils.h" #include "ui_blackberrysetupwizardkeyspage.h" +#include "ui_blackberrysetupwizardcertificatepage.h" #include "ui_blackberrysetupwizarddevicepage.h" #include "ui_blackberrysetupwizardfinishpage.h" @@ -103,18 +105,12 @@ bool BlackBerrySetupWizardNdkPage::isComplete() const //----------------------------------------------------------------------------- -const char BlackBerrySetupWizardKeysPage::PbdtPathField[] = "KeysPage::PbdtPath"; -const char BlackBerrySetupWizardKeysPage::RdkPathField[] = "KeysPage::RdkPath"; -const char BlackBerrySetupWizardKeysPage::CsjPinField[] = "KeysPage::CsjPin"; -const char BlackBerrySetupWizardKeysPage::PasswordField[] = "KeysPage::Password"; -const char BlackBerrySetupWizardKeysPage::Password2Field[] = "KeysPage::Password2"; - BlackBerrySetupWizardKeysPage::BlackBerrySetupWizardKeysPage(QWidget *parent) : QWizardPage(parent), m_ui(0), m_complete(false) { - setTitle(tr("Register Signing Keys")); + setTitle(tr("Setup Signing Keys")); initUi(); } @@ -125,29 +121,6 @@ BlackBerrySetupWizardKeysPage::~BlackBerrySetupWizardKeysPage() m_ui = 0; } -void BlackBerrySetupWizardKeysPage::validateFields() -{ - if (!m_ui->pbdtPath->isValid() - || !m_ui->rdkPath->isValid() - || m_ui->csjPin->text().isEmpty() - || m_ui->password->text().isEmpty() - || m_ui->password2->text().isEmpty()) { - m_ui->statusLabel->clear(); - setComplete(false); - return; - } - - if (m_ui->password->text() != m_ui->password2->text()) { - m_ui->statusLabel->setText(tr("Passwords do not match.")); - setComplete(false); - return; - } - - m_ui->statusLabel->clear(); - - setComplete(true); -} - void BlackBerrySetupWizardKeysPage::showKeysMessage(const QString &url) { const QMessageBox::StandardButton button = QMessageBox::question(this, @@ -169,67 +142,100 @@ bool BlackBerrySetupWizardKeysPage::isComplete() const void BlackBerrySetupWizardKeysPage::initUi() { + BlackBerrySigningUtils &utils = BlackBerrySigningUtils::instance(); + m_ui = new Ui::BlackBerrySetupWizardKeysPage; m_ui->setupUi(this); - m_ui->statusLabel->clear(); - - setupCsjPathChooser(m_ui->pbdtPath); - setupCsjPathChooser(m_ui->rdkPath); - - connect(m_ui->pbdtPath, SIGNAL(changed(QString)), - this, SLOT(csjAutoComplete(QString))); - connect(m_ui->rdkPath, SIGNAL(changed(QString)), - this, SLOT(csjAutoComplete(QString))); - connect(m_ui->pbdtPath, SIGNAL(changed(QString)), this, SLOT(validateFields())); - connect(m_ui->rdkPath, SIGNAL(changed(QString)), this, SLOT(validateFields())); - connect(m_ui->csjPin, SIGNAL(textChanged(QString)), this, SLOT(validateFields())); - connect(m_ui->password, SIGNAL(textChanged(QString)), this, SLOT(validateFields())); - connect(m_ui->password2, SIGNAL(textChanged(QString)), this, SLOT(validateFields())); + + if (utils.hasLegacyKeys()) { + m_ui->linkLabel->setVisible(false); + m_ui->legacyLabel->setVisible(true); + m_ui->statusLabel->setVisible(false); + + setComplete(false); + } else if (utils.hasRegisteredKeys()) { + m_ui->linkLabel->setVisible(false); + m_ui->legacyLabel->setVisible(false); + m_ui->statusLabel->setVisible(true); + + setComplete(true); + } else { + m_ui->linkLabel->setVisible(true); + m_ui->legacyLabel->setVisible(false); + m_ui->statusLabel->setVisible(false); + + setComplete(false); + } + connect(m_ui->linkLabel, SIGNAL(linkActivated(QString)), this, SLOT(showKeysMessage(QString))); - - registerField(QLatin1String(PbdtPathField) + QLatin1Char('*'), - m_ui->pbdtPath, "path", SIGNAL(changed(QString))); - registerField(QLatin1String(RdkPathField) + QLatin1Char('*'), - m_ui->rdkPath, "path", SIGNAL(changed(QString))); - registerField(QLatin1String(CsjPinField) + QLatin1Char('*'), - m_ui->csjPin); - registerField(QLatin1String(PasswordField) + QLatin1Char('*'), - m_ui->password); - registerField(QLatin1String(Password2Field) + QLatin1Char('*'), - m_ui->password2); + connect(m_ui->legacyLabel, SIGNAL(linkActivated(QString)), + this, SLOT(showKeysMessage(QString))); } -void BlackBerrySetupWizardKeysPage::csjAutoComplete(const QString &path) +void BlackBerrySetupWizardKeysPage::setComplete(bool complete) { - Utils::PathChooser *chooser = 0; - QString file = path; - - if (file.contains(QLatin1String("PBDT"))) { - file.replace(QLatin1String("PBDT"), QLatin1String("RDK")); - chooser = m_ui->rdkPath; - } else if (file.contains(QLatin1String("RDK"))) { - file.replace(QLatin1String("RDK"), QLatin1String("PBDT")); - chooser = m_ui->pbdtPath; + if (m_complete != complete) { + m_complete = complete; + m_ui->linkLabel->setVisible(!complete); + m_ui->statusLabel->setVisible(complete); + emit completeChanged(); } +} + +//----------------------------------------------------------------------------- + +const char BlackBerrySetupWizardCertificatePage::AuthorField[] = "CertificatePage::Author"; +const char BlackBerrySetupWizardCertificatePage::PasswordField[] = "CertificatePage::Password"; +const char BlackBerrySetupWizardCertificatePage::PasswordField2[] = "CertificatePage::Password2"; + +BlackBerrySetupWizardCertificatePage::BlackBerrySetupWizardCertificatePage(QWidget *parent) + : QWizardPage(parent), + m_ui(0), + m_complete(false) +{ + setTitle(tr("Create Developer Certificate")); + + initUi(); +} + +bool BlackBerrySetupWizardCertificatePage::isComplete() const +{ + return m_complete; +} - if (!chooser) +void BlackBerrySetupWizardCertificatePage::validate() +{ + if (m_ui->author->text().isEmpty() + || m_ui->password->text().isEmpty() + || m_ui->password2->text().isEmpty()) { + m_ui->status->clear(); + setComplete(false); return; + } - QFileInfo fileInfo(file); + if (m_ui->password->text() != m_ui->password2->text()) { + m_ui->status->setText(tr("The entered passwords do not match.")); + setComplete(false); + return; + } - if (fileInfo.exists()) - chooser->setPath(file); + m_ui->status->clear(); + setComplete(true); } -void BlackBerrySetupWizardKeysPage::setupCsjPathChooser(Utils::PathChooser *chooser) +void BlackBerrySetupWizardCertificatePage::checkBoxChanged(int state) { - chooser->setExpectedKind(Utils::PathChooser::File); - chooser->setPromptDialogTitle(tr("Browse CSJ File")); - chooser->setPromptDialogFilter(tr("CSJ files (*.csj)")); + if (state == Qt::Checked) { + m_ui->password->setEchoMode(QLineEdit::Normal); + m_ui->password2->setEchoMode(QLineEdit::Normal); + } else { + m_ui->password->setEchoMode(QLineEdit::Password); + m_ui->password2->setEchoMode(QLineEdit::Password); + } } -void BlackBerrySetupWizardKeysPage::setComplete(bool complete) +void BlackBerrySetupWizardCertificatePage::setComplete(bool complete) { if (m_complete != complete) { m_complete = complete; @@ -237,6 +243,26 @@ void BlackBerrySetupWizardKeysPage::setComplete(bool complete) } } +void BlackBerrySetupWizardCertificatePage::initUi() +{ + m_ui = new Ui::BlackBerrySetupWizardCertificatePage; + m_ui->setupUi(this); + m_ui->status->clear(); + + connect(m_ui->author, SIGNAL(textChanged(QString)), + this, SLOT(validate())); + connect(m_ui->password, SIGNAL(textChanged(QString)), + this, SLOT(validate())); + connect(m_ui->password2, SIGNAL(textChanged(QString)), + this, SLOT(validate())); + connect(m_ui->showPassword, SIGNAL(stateChanged(int)), + this, SLOT(checkBoxChanged(int))); + + registerField(QLatin1String(AuthorField) + QLatin1Char('*'), m_ui->author); + registerField(QLatin1String(PasswordField) + QLatin1Char('*'), m_ui->password); + registerField(QLatin1String(PasswordField2) + QLatin1Char('*'), m_ui->password2); +} + //----------------------------------------------------------------------------- const char BlackBerrySetupWizardDevicePage::NameField[] = "DevicePage::Name"; diff --git a/src/plugins/qnx/blackberrysetupwizardpages.h b/src/plugins/qnx/blackberrysetupwizardpages.h index a5c2106519..ba586a3da4 100644 --- a/src/plugins/qnx/blackberrysetupwizardpages.h +++ b/src/plugins/qnx/blackberrysetupwizardpages.h @@ -1,8 +1,8 @@ /************************************************************************** ** -** Copyright (C) 2011 - 2013 Research In Motion +** Copyright (C) 2013 BlackBerry Limited. All rights reserved. ** -** Contact: Research In Motion (blackberry-qt@qnx.com) +** Contact: BlackBerry (qt@blackberry.com) ** Contact: KDAB (info@kdab.com) ** ** This file is part of Qt Creator. @@ -44,11 +44,11 @@ namespace Ui { class BlackBerrySetupWizardKeysPage; class BlackBerrySetupWizardDevicePage; +class BlackBerrySetupWizardCertificatePage; class BlackBerrySetupWizardFinishPage; } // namespace Ui -class BlackBerryCsjRegistrar; class BlackBerryCertificate; class BlackBerryNDKSettingsWidget; @@ -80,25 +80,16 @@ class BlackBerrySetupWizardKeysPage : public QWizardPage { Q_OBJECT public: - static const char PbdtPathField[]; - static const char RdkPathField[]; - static const char CsjPinField[]; - static const char PasswordField[]; - static const char Password2Field[]; - explicit BlackBerrySetupWizardKeysPage(QWidget *parent = 0); virtual ~BlackBerrySetupWizardKeysPage(); bool isComplete() const; private slots: - void csjAutoComplete(const QString &path); - void validateFields(); void showKeysMessage(const QString &url); private: void initUi(); - void setupCsjPathChooser(Utils::PathChooser *chooser); void setComplete(bool complete); Ui::BlackBerrySetupWizardKeysPage *m_ui; @@ -107,6 +98,33 @@ private: //----------------------------------------------------------------------------- +class BlackBerrySetupWizardCertificatePage : public QWizardPage +{ + Q_OBJECT +public: + static const char AuthorField[]; + static const char PasswordField[]; + static const char PasswordField2[]; + + explicit BlackBerrySetupWizardCertificatePage(QWidget *parent = 0); + + bool isComplete() const; + +private slots: + void validate(); + void checkBoxChanged(int state); + +private: + void setComplete(bool complete); + void initUi(); + + Ui::BlackBerrySetupWizardCertificatePage *m_ui; + + bool m_complete; +}; + +//----------------------------------------------------------------------------- + class BlackBerrySetupWizardDevicePage : public QWizardPage { Q_OBJECT diff --git a/src/plugins/qnx/blackberrysigningutils.cpp b/src/plugins/qnx/blackberrysigningutils.cpp new file mode 100644 index 0000000000..646205ae3e --- /dev/null +++ b/src/plugins/qnx/blackberrysigningutils.cpp @@ -0,0 +1,180 @@ +/************************************************************************** +** +** Copyright (C) 2013 BlackBerry Limited. All rights reserved. +** +** Contact: BlackBerry (qt@blackberry.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 "blackberrysigningutils.h" +#include "blackberrycertificate.h" +#include "blackberryconfiguration.h" +#include "blackberryconfigurationmanager.h" + +#include <QFileInfo> +#include <QString> +#include <QFile> +#include <QTextStream> +#include <QInputDialog> + +using namespace Qnx::Internal; + +BlackBerrySigningUtils & BlackBerrySigningUtils::instance() +{ + static BlackBerrySigningUtils utils; + + return utils; +} + +BlackBerrySigningUtils::BlackBerrySigningUtils(QObject *parent) : + QObject(parent), + m_defaultCertificate(0) +{ +} + +bool BlackBerrySigningUtils::hasRegisteredKeys() +{ + BlackBerryConfigurationManager &configuration = BlackBerryConfigurationManager::instance(); + + QFileInfo cskFile(configuration.idTokenPath()); + + return cskFile.exists(); +} + +bool BlackBerrySigningUtils::hasLegacyKeys() +{ + BlackBerryConfigurationManager &configuration = BlackBerryConfigurationManager::instance(); + + QFileInfo cskFile(configuration.barsignerCskPath()); + + return cskFile.exists(); +} + +bool BlackBerrySigningUtils::hasDefaultCertificate() +{ + BlackBerryConfigurationManager &configuration = BlackBerryConfigurationManager::instance(); + + QFileInfo keystore(configuration.defaultKeystorePath()); + + return keystore.exists(); +} + +QString BlackBerrySigningUtils::cskPassword() +{ + if (m_cskPassword.isEmpty()) + m_cskPassword = promptPassword(tr("Please provide your bbidtoken.csk PIN")); + + return m_cskPassword; +} + +QString BlackBerrySigningUtils::certificatePassword() +{ + if (m_certificatePassword.isEmpty()) + m_certificatePassword = promptPassword(tr("Please enter your certificate password")); + + return m_certificatePassword; +} + +const BlackBerryCertificate * BlackBerrySigningUtils::defaultCertificate() const +{ + return m_defaultCertificate; +} + +void BlackBerrySigningUtils::openDefaultCertificate() +{ + if (m_defaultCertificate) { + emit defaultCertificateLoaded(BlackBerryCertificate::Success); + return; + } + + const QString password = certificatePassword(); + + BlackBerryConfigurationManager &configManager = BlackBerryConfigurationManager::instance(); + + m_defaultCertificate = new BlackBerryCertificate(configManager.defaultKeystorePath(), + QString(), password, this); + + connect(m_defaultCertificate, SIGNAL(finished(int)), this, SLOT(certificateLoaded(int))); + + m_defaultCertificate->load(); +} + +void BlackBerrySigningUtils::setDefaultCertificate(BlackBerryCertificate *certificate) +{ + if (m_defaultCertificate) + m_defaultCertificate->deleteLater(); + + certificate->setParent(this); + m_defaultCertificate = certificate; +} + +void BlackBerrySigningUtils::clearCskPassword() +{ + m_cskPassword.clear(); +} + +void BlackBerrySigningUtils::clearCertificatePassword() +{ + m_certificatePassword.clear(); +} + +void BlackBerrySigningUtils::deleteDefaultCertificate() +{ + clearCertificatePassword(); + m_defaultCertificate->deleteLater(); + m_defaultCertificate = 0; + + BlackBerryConfigurationManager &configuration = BlackBerryConfigurationManager::instance(); + + QFile::remove(configuration.defaultKeystorePath()); +} + +void BlackBerrySigningUtils::certificateLoaded(int status) +{ + if (status != BlackBerryCertificate::Success) { + m_defaultCertificate->deleteLater(); + m_defaultCertificate = 0; + + if (status == BlackBerryCertificate::WrongPassword) + clearCertificatePassword(); + } + + emit defaultCertificateLoaded(status); +} + +QString BlackBerrySigningUtils::promptPassword(const QString &message) const +{ + QInputDialog dialog; + dialog.setWindowTitle(tr("Qt Creator")); + dialog.setInputMode(QInputDialog::TextInput); + dialog.setLabelText(message); + dialog.setTextEchoMode(QLineEdit::Password); + + if (dialog.exec() == QDialog::Rejected) + return QString(); + + return dialog.textValue(); +} diff --git a/src/plugins/qnx/blackberryutils.h b/src/plugins/qnx/blackberrysigningutils.h index 9bc17b8c84..c18f202245 100644 --- a/src/plugins/qnx/blackberryutils.h +++ b/src/plugins/qnx/blackberrysigningutils.h @@ -1,8 +1,8 @@ /************************************************************************** ** -** Copyright (C) 2011 - 2013 Research In Motion +** Copyright (C) 2013 BlackBerry Limited. All rights reserved. ** -** Contact: Research In Motion (blackberry-qt@qnx.com) +** Contact: BlackBerry (qt@blackberry.com) ** Contact: KDAB (info@kdab.com) ** ** This file is part of Qt Creator. @@ -29,10 +29,11 @@ ** ****************************************************************************/ -#ifndef QNX_INTERNAL_BLACKBERRYUTILS_H -#define QNX_INTERNAL_BLACKBERRYUTILS_H +#ifndef QNX_INTERNAL_BLACKBERRYSIGNINGUTILS_H +#define QNX_INTERNAL_BLACKBERRYSIGNINGUTILS_H #include <QtGlobal> +#include <QObject> QT_BEGIN_NAMESPACE class QString; @@ -41,15 +42,50 @@ QT_END_NAMESPACE namespace Qnx { namespace Internal { -class BlackBerryUtils +class BlackBerryCertificate; + +class BlackBerrySigningUtils : public QObject { + Q_OBJECT + public: - static bool hasRegisteredKeys(); + static BlackBerrySigningUtils &instance(); + + bool hasRegisteredKeys(); + bool hasLegacyKeys(); + bool hasDefaultCertificate(); + + QString cskPassword(); + QString certificatePassword(); + + const BlackBerryCertificate *defaultCertificate() const; + + void openDefaultCertificate(); + void setDefaultCertificate(BlackBerryCertificate *certificate); + void clearCskPassword(); + void clearCertificatePassword(); + void deleteDefaultCertificate(); + +signals: + void defaultCertificateLoaded(int status); + +private slots: + void certificateLoaded(int status); + +private: + Q_DISABLE_COPY(BlackBerrySigningUtils) + + BlackBerrySigningUtils(QObject *parent = 0); + + QString promptPassword(const QString &message) const; + + BlackBerryCertificate *m_defaultCertificate; - static QString getCsjAuthor(const QString &fileName); + QString m_cskPassword; + QString m_certificatePassword; }; } // namespace Internal } // namespace Qnx -#endif // QNX_INTERNAL_BLACKBERRYUTILS_H +#endif // QNX_INTERNAL_BLACKBERRYSIGNINGUTILS_H diff --git a/src/plugins/qnx/blackberryutils.cpp b/src/plugins/qnx/blackberryutils.cpp deleted file mode 100644 index 3693bec2cf..0000000000 --- a/src/plugins/qnx/blackberryutils.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/************************************************************************** -** -** 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 "blackberryutils.h" -#include "blackberryconfiguration.h" -#include "blackberryconfigurationmanager.h" - -#include <QFileInfo> -#include <QString> -#include <QFile> -#include <QTextStream> - -using namespace Qnx::Internal; - -bool BlackBerryUtils::hasRegisteredKeys() -{ - BlackBerryConfigurationManager &configuration = BlackBerryConfigurationManager::instance(); - - QFileInfo cskFile(configuration.barsignerCskPath()); - - if (!cskFile.exists()) - return false; - - QFileInfo dbFile(configuration.barsignerDbPath()); - - if (!dbFile.exists()) - return false; - - return true; -} - -QString BlackBerryUtils::getCsjAuthor(const QString &fileName) -{ - QFile file(fileName); - - QString author = QLatin1String("Unknown Author"); - - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) - return author; - - QTextStream stream(&file); - - while (!stream.atEnd()) { - QString line = stream.readLine(); - - if (line.startsWith(QLatin1String("Company="))) { - author = line.remove(QLatin1String("Company=")).trimmed(); - break; - } - } - - file.close(); - - return author; -} diff --git a/src/plugins/qnx/qnx.pro b/src/plugins/qnx/qnx.pro index 68128385a7..b32df8ee21 100644 --- a/src/plugins/qnx/qnx.pro +++ b/src/plugins/qnx/qnx.pro @@ -61,10 +61,7 @@ SOURCES += qnxplugin.cpp \ bardescriptorpermissionsmodel.cpp \ blackberrykeyswidget.cpp \ blackberrykeyspage.cpp \ - blackberrycsjregistrar.cpp \ blackberrycertificate.cpp \ - blackberrycertificatemodel.cpp \ - blackberryregisterkeydialog.cpp \ blackberryimportcertificatedialog.cpp \ blackberrycreatecertificatedialog.cpp \ blackberrydebugtokenrequester.cpp \ @@ -91,7 +88,7 @@ SOURCES += qnxplugin.cpp \ bardescriptoreditorabstractpanelwidget.cpp \ blackberrysetupwizard.cpp \ blackberrysetupwizardpages.cpp \ - blackberryutils.cpp \ + blackberrysigningutils.cpp \ qnxdevicetester.cpp \ blackberryconfigurationmanager.cpp \ blackberrydevicelistdetector.cpp \ @@ -158,10 +155,7 @@ HEADERS += qnxplugin.h\ bardescriptorpermissionsmodel.h \ blackberrykeyswidget.h \ blackberrykeyspage.h \ - blackberrycsjregistrar.h \ blackberrycertificate.h \ - blackberrycertificatemodel.h \ - blackberryregisterkeydialog.h \ blackberryimportcertificatedialog.h \ blackberrycreatecertificatedialog.h \ blackberrydebugtokenrequester.h \ @@ -188,7 +182,7 @@ HEADERS += qnxplugin.h\ bardescriptoreditorabstractpanelwidget.h \ blackberrysetupwizard.h \ blackberrysetupwizardpages.h \ - blackberryutils.h \ + blackberrysigningutils.h \ qnxdevicetester.h \ blackberryconfigurationmanager.h \ blackberrydevicelistdetector.h \ @@ -204,7 +198,6 @@ FORMS += \ qnxbaseqtconfigwidget.ui \ blackberryndksettingswidget.ui \ blackberrykeyswidget.ui \ - blackberryregisterkeydialog.ui \ blackberryimportcertificatedialog.ui \ blackberrycreatecertificatedialog.ui \ blackberrydebugtokenrequestdialog.ui \ @@ -218,6 +211,7 @@ FORMS += \ bardescriptoreditorenvironmentwidget.ui \ bardescriptoreditorassetswidget.ui \ blackberrysetupwizardkeyspage.ui \ + blackberrysetupwizardcertificatepage.ui \ blackberrysetupwizarddevicepage.ui \ blackberrysetupwizardfinishpage.ui \ blackberrydeviceconfigurationwizardconfigpage.ui \ diff --git a/src/plugins/qnx/qnx.qbs b/src/plugins/qnx/qnx.qbs index e8797e2911..71e00e9a18 100644 --- a/src/plugins/qnx/qnx.qbs +++ b/src/plugins/qnx/qnx.qbs @@ -144,8 +144,6 @@ QtcPlugin { "blackberryndksettingspage.h", "blackberryconfiguration.cpp", "blackberryconfiguration.h", - "blackberrycsjregistrar.cpp", - "blackberrycsjregistrar.h", "blackberrycertificate.cpp", "blackberrycertificate.h", "blackberrykeyspage.cpp", @@ -153,11 +151,6 @@ QtcPlugin { "blackberrykeyswidget.cpp", "blackberrykeyswidget.h", "blackberrykeyswidget.ui", - "blackberrycertificatemodel.cpp", - "blackberrycertificatemodel.h", - "blackberryregisterkeydialog.cpp", - "blackberryregisterkeydialog.h", - "blackberryregisterkeydialog.ui", "blackberryimportcertificatedialog.cpp", "blackberryimportcertificatedialog.h", "blackberryimportcertificatedialog.ui", @@ -180,10 +173,11 @@ QtcPlugin { "blackberrysetupwizardpages.cpp", "blackberrysetupwizardpages.h", "blackberrysetupwizardkeyspage.ui", + "blackberrysetupwizardcertificatepage.ui", "blackberrysetupwizarddevicepage.ui", "blackberrysetupwizardfinishpage.ui", - "blackberryutils.cpp", - "blackberryutils.h", + "blackberrysigningutils.cpp", + "blackberrysigningutils.h", "pathchooserdelegate.cpp", "pathchooserdelegate.h", "qnx.qrc", |