Commit 8d5d0b0c authored by David Kaspar's avatar David Kaspar

Qnx: BlackBerry Setup options page

Setup options page checks for general setup of API Levels, Signing Keys
and Devices. It is meant to become a central point for BlackBerry settings.

Adding BlackBerryConfigurationManager::settingsChanged signal
to notify about any change to BBConfig settings.

Fixing BlackBerrySigningUtils to correctly ask for password and reopen
the certificate in case an invalid password is entered and a generic
ResultCode::Error happens.

Fixing header define for blackberryinstallwizard.h

Fixing URL for BlackBerry Legacy Keys.

Change-Id: I1c4592c03ab07678ef829b85ce7b13457b9304a9
Reviewed-by: default avatarDavid Kaspar <dkaspar@blackberry.com>
Reviewed-by: Nicolas Arnaud-Cormos's avatarNicolas Arnaud-Cormos <nicolas@kdab.com>
parent 0d46aa40
......@@ -30,6 +30,7 @@
****************************************************************************/
#include "blackberryconfiguration.h"
#include "blackberryconfigurationmanager.h"
#include "blackberryqtversion.h"
#include "qnxtoolchain.h"
......@@ -435,6 +436,8 @@ bool BlackBerryConfiguration::activate()
if (qt5X86Version)
createKit(qt5X86Version, x86ToolChain, x86DebuggerItemId);
BlackBerryConfigurationManager::instance().emitSettingsChanged();
return true;
}
......@@ -456,6 +459,8 @@ void BlackBerryConfiguration::deactivate()
KitManager::deregisterKit(kit);
}
}
BlackBerryConfigurationManager::instance().emitSettingsChanged();
}
#ifdef WITH_TESTS
......
......@@ -150,6 +150,8 @@ void BlackBerryConfigurationManager::restoreConfigurations()
if (!useNewestConfiguration && (config->ndkEnvFile().toString() == ndkEnvFile))
setDefaultConfiguration(config);
}
emit settingsChanged();
}
// Backward compatibility: Read existing entries in the ManualNDKsGroup
......@@ -205,6 +207,7 @@ void BlackBerryConfigurationManager::setDefaultConfiguration(BlackBerryConfigura
}
m_defaultConfiguration = config;
emit settingsChanged();
}
bool BlackBerryConfigurationManager::newestConfigurationEnabled() const
......@@ -212,6 +215,11 @@ bool BlackBerryConfigurationManager::newestConfigurationEnabled() const
return !m_defaultConfiguration;
}
void BlackBerryConfigurationManager::emitSettingsChanged()
{
emit settingsChanged();
}
void BlackBerryConfigurationManager::setKitsAutoDetectionSource()
{
foreach (Kit *kit, KitManager::kits()) {
......@@ -267,6 +275,7 @@ bool BlackBerryConfigurationManager::addConfiguration(BlackBerryConfiguration *c
if (config->isValid()) {
insertByVersion(config);
emit settingsChanged();
return true;
}
......@@ -287,6 +296,8 @@ void BlackBerryConfigurationManager::removeConfiguration(BlackBerryConfiguration
setDefaultConfiguration(0);
delete config;
emit settingsChanged();
}
QList<BlackBerryConfiguration *> BlackBerryConfigurationManager::configurations() const
......@@ -369,6 +380,7 @@ void BlackBerryConfigurationManager::loadSettings()
m_configs.first()->activate();
emit settingsLoaded();
emit settingsChanged();
}
void BlackBerryConfigurationManager::saveSettings()
......
......@@ -64,7 +64,6 @@ public:
QString barsignerDbPath() const;
QString defaultKeystorePath() const;
QString defaultDebugTokenPath() const;
void clearConfigurationSettings(BlackBerryConfiguration *config);
// returns the environment for the default API level
QList<Utils::EnvironmentItem> defaultConfigurationEnv() const;
......@@ -74,6 +73,8 @@ public:
bool newestConfigurationEnabled() const;
void emitSettingsChanged();
public slots:
void loadSettings();
void saveSettings();
......@@ -81,6 +82,7 @@ public slots:
signals:
void settingsLoaded();
void settingsChanged();
private:
BlackBerryConfigurationManager(QObject *parent = 0);
......
......@@ -29,8 +29,8 @@
**
****************************************************************************/
#ifndef QNX_INTERNAL_BLACKBERRYDEVICECONFIGURATIONWIZARD_H
#define QNX_INTERNAL_BLACKBERRYDEVICECONFIGURATIONWIZARD_H
#ifndef QNX_INTERNAL_BLACKBERRYINSTALLWIZARD_H
#define QNX_INTERNAL_BLACKBERRYINSTALLWIZARD_H
#include <utils/wizard.h>
......@@ -105,4 +105,4 @@ private:
} // namespace Internal
} // namespace Qnx
#endif // QNX_INTERNAL_BLACKBERRYDEVICECONFIGURATIONWIZARD_H
#endif // QNX_INTERNAL_BLACKBERRYINSTALLWIZARD_H
......@@ -135,19 +135,8 @@ void BlackBerryKeysWidget::certificateLoaded(int status)
void BlackBerryKeysWidget::createCertificate()
{
BlackBerryCreateCertificateDialog dialog(this);
const int result = dialog.exec();
if (result == QDialog::Rejected)
return;
BlackBerryCertificate *certificate = dialog.certificate();
if (certificate) {
m_utils.setDefaultCertificate(certificate);
if (m_utils.createCertificate())
updateCertificateSection();
}
}
void BlackBerryKeysWidget::clearCertificate()
......@@ -194,17 +183,16 @@ void BlackBerryKeysWidget::updateCertificateSection()
void BlackBerryKeysWidget::updateKeysSection()
{
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."));
m_ui->keyStatus->setText(tr("It appears you are using legacy key files. Please refer to the "
"<a href=\"%1\">BlackBerry website</a> to find out how to update your keys.")
.arg(QLatin1String(Qnx::Constants::QNX_LEGACY_KEYS_URL)));
} 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."));
"<a href=\"%1\">BlackBerry website</a> "
"to find out how to request your keys.")
.arg(QLatin1String(Qnx::Constants::QNX_REGISTER_KEYS_URL)));
}
}
......
......@@ -91,8 +91,15 @@ BlackBerryNDKSettingsWidget::BlackBerryNDKSettingsWidget(QWidget *parent) :
connect(m_ui->ndksTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(updateInfoTable(QTreeWidgetItem*)));
connect(this, SIGNAL(targetsUpdated()), this, SLOT(populateDefaultConfigurationCombo()));
updateNdkList();
populateDefaultConfigurationCombo();
// BlackBerryConfigurationManager.settingsChanged signal may be emitted multiple times
// during the same event handling. This would result in multiple updatePage() calls even through
// just one is needed.
// QTimer allows to merge those multiple signal emits into a single updatePage() call.
m_timer.setSingleShot(true);
connect(&m_timer, SIGNAL(timeout()), this, SLOT(updatePage()));
updatePage();
connect(&m_bbConfigManager, SIGNAL(settingsChanged()), &m_timer, SLOT(start()));
}
void BlackBerryNDKSettingsWidget::setWizardMessageVisible(bool visible)
......@@ -393,6 +400,12 @@ void BlackBerryNDKSettingsWidget::launchBlackBerryInstallerWizard(BlackBerryInst
wizard.exec();
}
void BlackBerryNDKSettingsWidget::updatePage()
{
updateNdkList();
populateDefaultConfigurationCombo();
}
} // namespace Internal
} // namespace Qnx
......@@ -35,6 +35,7 @@
#include "blackberryinstallwizard.h"
#include <QWidget>
#include <QTimer>
QT_BEGIN_NAMESPACE
class QStandardItemModel;
......@@ -80,6 +81,7 @@ public slots:
void handleUninstallationFinished();
void updateUi(QTreeWidgetItem* item, BlackBerryConfiguration* config);
void populateDefaultConfigurationCombo();
void updatePage();
private:
void launchBlackBerryInstallerWizard(BlackBerryInstallerDataHandler::Mode mode,
......@@ -93,6 +95,8 @@ private:
QList<BlackBerryConfiguration *> m_activatedTargets;
QList<BlackBerryConfiguration *> m_deactivatedTargets;
QTimer m_timer;
};
} // namespace Internal
......
/**************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
**
** Contact: BlackBerry (qt@blackberry.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 "blackberrysetuppage.h"
#include "blackberrysetupwidget.h"
#include "qnxconstants.h"
#include <QCoreApplication>
namespace Qnx {
namespace Internal {
BlackBerrySetupPage::BlackBerrySetupPage(QObject *parent)
: Core::IOptionsPage(parent)
{
setId(Core::Id(Constants::QNX_BB_SETUP_ID));
setDisplayName(tr("Setup"));
setCategory(Constants::QNX_BB_CATEGORY);
setDisplayCategory(QCoreApplication::translate("BlackBerry", Constants::QNX_BB_CATEGORY_TR));
setCategoryIcon(QLatin1String(Constants::QNX_BB_CATEGORY_ICON));
}
QWidget *BlackBerrySetupPage::widget()
{
if (!m_widget)
m_widget = new BlackBerrySetupWidget;
return m_widget;
}
void BlackBerrySetupPage::apply()
{
}
void BlackBerrySetupPage::finish()
{
delete m_widget;
}
} // namespace Internal
} // namespace Qnx
/**************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
**
** Contact: BlackBerry (qt@blackberry.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 BLACKBERRYSETUPPAGE_H
#define BLACKBERRYSETUPPAGE_H
#include <coreplugin/dialogs/ioptionspage.h>
#include <QPointer>
namespace Qnx {
namespace Internal {
class BlackBerrySetupWidget;
class BlackBerrySetupPage : public Core::IOptionsPage
{
Q_OBJECT
public:
explicit BlackBerrySetupPage(QObject *parent = 0);
QWidget *widget();
void apply();
void finish();
private:
QPointer<BlackBerrySetupWidget> m_widget;
};
} // namespace Internal
} // namespace Qnx
#endif // BLACKBERRYSETUPPAGE_H
This diff is collapsed.
/**************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
**
** Contact: BlackBerry (qt@blackberry.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 BLACKBERRYSETUPWIDGET_H
#define BLACKBERRYSETUPWIDGET_H
#include <QFrame>
#include <QWidget>
#include <QCoreApplication>
#include <QTimer>
QT_BEGIN_NAMESPACE
class QLabel;
class QPushButton;
QT_END_NAMESPACE
namespace Qnx {
namespace Internal {
class SetupItem : public QFrame {
Q_OBJECT
public:
enum Status {
Ok, Info, Warning, Error
};
SetupItem(const QString &desc = QString(), QWidget *parent = 0);
protected:
void set(Status status, const QString &message, const QString &fixText = QString());
Q_SLOT virtual void validate() = 0;
virtual void fix() = 0;
private slots:
void onFixPressed();
void validateLater();
private:
QLabel *m_icon;
QLabel *m_label;
QPushButton *m_button;
QLabel *m_desc;
QTimer m_timer;
};
class APILevelSetupItem : public SetupItem
{
Q_OBJECT
public:
APILevelSetupItem(QWidget *parent = 0);
enum FoundType {
Any = (1 << 0),
Valid = (1 << 1),
Active = (1 << 2),
V_10_2 = (1 << 3),
V_10_2_AS_DEFAULT = (1 << 4)
};
Q_DECLARE_FLAGS(FoundTypes, FoundType)
protected:
virtual void validate();
virtual void fix();
private slots:
void handleInstallationFinished();
private:
FoundTypes resolvedFoundType();
void installAPILevel();
};
Q_DECLARE_OPERATORS_FOR_FLAGS(APILevelSetupItem::FoundTypes)
class SigningKeysSetupItem : public SetupItem
{
Q_OBJECT
public:
SigningKeysSetupItem(QWidget *parent = 0);
protected:
virtual void validate();
virtual void fix();
private slots:
void defaultCertificateLoaded(int status);
};
class DeviceSetupItem : public SetupItem
{
Q_OBJECT
public:
DeviceSetupItem(QWidget *parent = 0);
protected:
virtual void validate();
virtual void fix();
};
class BlackBerrySetupWidget : public QWidget
{
Q_OBJECT
public:
explicit BlackBerrySetupWidget(QWidget *parent = 0);
};
} // namespace Internal
} // namespeace Qnx
#endif // BLACKBERRYSETUPWIDGET_H
......@@ -33,10 +33,12 @@
#include "blackberrycertificate.h"
#include "blackberryconfiguration.h"
#include "blackberryconfigurationmanager.h"
#include "blackberrycreatecertificatedialog.h"
#include "blackberrydebugtokenreader.h"
#include <coreplugin/icore.h>
#include <QDialog>
#include <QFileInfo>
#include <QString>
#include <QFile>
......@@ -59,7 +61,8 @@ BlackBerrySigningUtils & BlackBerrySigningUtils::instance()
BlackBerrySigningUtils::BlackBerrySigningUtils(QObject *parent) :
QObject(parent),
m_defaultCertificate(0)
m_defaultCertificate(0),
m_defaultCertificateStatus(NotOpened)
{
loadDebugTokens();
}
......@@ -118,22 +121,37 @@ const BlackBerryCertificate * BlackBerrySigningUtils::defaultCertificate() const
return m_defaultCertificate;
}
BlackBerrySigningUtils::Status BlackBerrySigningUtils::defaultCertificateOpeningStatus() const
{
return m_defaultCertificateStatus;
}
void BlackBerrySigningUtils::openDefaultCertificate(QWidget *passwordPromptParent)
{
if (m_defaultCertificate) {
switch (m_defaultCertificateStatus) {
case Opening:
return;
case Opened:
emit defaultCertificateLoaded(BlackBerryCertificate::Success);
return;
default:
m_defaultCertificateStatus = Opening;
}
bool ok;
const QString password = certificatePassword(passwordPromptParent, &ok);
// action has been canceled
if (!ok)
if (!ok) {
m_defaultCertificateStatus = NotOpened;
return;
}
BlackBerryConfigurationManager &configManager = BlackBerryConfigurationManager::instance();
if (m_defaultCertificate)
m_defaultCertificate->deleteLater();
m_defaultCertificate = new BlackBerryCertificate(configManager.defaultKeystorePath(),
QString(), password, this);
......@@ -149,6 +167,7 @@ void BlackBerrySigningUtils::setDefaultCertificate(BlackBerryCertificate *certif
certificate->setParent(this);
m_defaultCertificate = certificate;
m_defaultCertificateStatus = Opened;
}
void BlackBerrySigningUtils::clearCskPassword()
......@@ -166,6 +185,7 @@ void BlackBerrySigningUtils::deleteDefaultCertificate()
clearCertificatePassword();
m_defaultCertificate->deleteLater();
m_defaultCertificate = 0;
m_defaultCertificateStatus = NotOpened;
BlackBerryConfigurationManager &configuration = BlackBerryConfigurationManager::instance();
......@@ -192,15 +212,36 @@ void BlackBerrySigningUtils::removeDebugToken(const QString &dt)
emit debugTokenListChanged();
}
bool BlackBerrySigningUtils::createCertificate()
{
BlackBerryCreateCertificateDialog dialog;
const int result = dialog.exec();
if (result == QDialog::Rejected)
return false;
BlackBerryCertificate *certificate = dialog.certificate();
if (certificate)
setDefaultCertificate(certificate);
return certificate;
}
void BlackBerrySigningUtils::certificateLoaded(int status)
{
if (status != BlackBerryCertificate::Success) {
m_defaultCertificateStatus = NotOpened;
m_defaultCertificate->deleteLater();
m_defaultCertificate = 0;
if (status == BlackBerryCertificate::WrongPassword)
clearCertificatePassword();
}
// we have clear the password under any error since we are not able to distinquish
// if password is correct or not in case BlackBerryCertificate::Error status happens
clearCertificatePassword();
} else
m_defaultCertificateStatus = Opened;
emit defaultCertificateLoaded(status);
}
......
......@@ -50,6 +50,12 @@ class BlackBerrySigningUtils : public QObject
Q_OBJECT
public:
enum Status {
NotOpened,
Opening,
Opened
};
static BlackBerrySigningUtils &instance();
bool hasRegisteredKeys();
......@@ -60,12 +66,14 @@ public:
QString certificatePassword(QWidget *passwordPromptParent = 0, bool *ok = 0);
const BlackBerryCertificate *defaultCertificate() const;
Status defaultCertificateOpeningStatus() const;
void openDefaultCertificate(QWidget *passwordPromptParent = 0);
void setDefaultCertificate(BlackBerryCertificate *certificate);
void clearCskPassword();
void clearCertificatePassword();
void deleteDefaultCertificate();
bool createCertificate();
void addDebugToken(const QString &dt);
void removeDebugToken(const QString &dt);
......@@ -90,6 +98,7 @@ private:
QString promptPassword(const QString &message, QWidget *dialogParent = 0, bool *ok = 0) const;
BlackBerryCertificate *m_defaultCertificate;
Status m_defaultCertificateStatus;
QString m_cskPassword;
QString m_certificatePassword;
......
......@@ -102,7 +102,9 @@ SOURCES += qnxplugin.cpp \
blackberrycheckdevicestatusstep.cpp \
qnxattachdebugsupport.cpp \
qnxattachdebugdialog.cpp \
blackberrydeployqtlibrariesdialog.cpp
blackberrydeployqtlibrariesdialog.cpp \
blackberrysetuppage.cpp \
blackberrysetupwidget.cpp
HEADERS += qnxplugin.h\
qnxconstants.h \
......@@ -204,7 +206,9 @@ HEADERS += qnxplugin.h\
blackberrycheckdevicestatusstepconfigwidget.h \
qnxattachdebugsupport.h \
qnxattachdebugdialog.h \
blackberrydeployqtlibrariesdialog.h
blackberrydeployqtlibrariesdialog.h \
blackberrysetuppage.h \
blackberrysetupwidget.h
FORMS += \
blackberrydeviceconfigurationwizardsetuppage.ui \
......
......@@ -147,6 +147,10 @@ QtcPlugin {
"blackberryruncontrol.h",
"blackberryruncontrolfactory.cpp",
"blackberryruncontrolfactory.h",
"blackberrysetuppage.cpp",
"blackberrysetuppage.h",
"blackberrysetupwidget.cpp",
"blackberrysetupwidget.h",
"blackberrysigningpasswordsdialog.h",
"blackberrysigningpasswordsdialog.cpp",
"blackberrysigningpasswordsdialog.ui",
......
......@@ -2,5 +2,9 @@
<qresource prefix="/qnx">
<file>images/target-small.png</file>
<file>images/target.png</file>
<file>images/ok.png</file>
<file>images/info.png</file>
<file>images/warning.png</file>
<file>images/error.png</file>
</qresource>
</RCC>
......@@ -96,6 +96,7 @@ const char QNX_TOOLCHAIN_ID[] = "Qnx.QccToolChain";
const char QNX_BB_CATEGORY[] = "XF.BlackBerry";
const char QNX_BB_CATEGORY_TR[] = QT_TRANSLATE_NOOP("BlackBerry", "BlackBerry");
const char QNX_BB_CATEGORY_ICON[] = ":/qnx/images/target.png";
const char QNX_BB_SETUP_ID[] = "ZA.BlackBerry Setup";
const char QNX_BB_NDK_SETTINGS_ID[] = "ZZ.BlackBerry NDK Configuration";
const char QNX_BB_SIGNING_ID[] = "ZZ.BlackBerry Signing Infrastructure Configuration";
......@@ -119,6 +120,16 @@ const char QNX_DEBUGGING_GROUP[] = "Debugger.Group.Qnx";
const char QNX_BLACKBERRY_DEFAULT_DEPLOY_QT_BASEPATH[] = "/accounts/devuser/";
const char QNX_OK_ICON[] = ":/qnx/images/ok.png";
const char QNX_INFO_ICON[] = ":/qnx/images/info.png";
const char QNX_WARNING_ICON[] = ":/qnx/images/warning.png";
const char QNX_ERROR_ICON[] = ":/qnx/images/error.png";
const char QNX_BLACKBERRY_SETUP_URL[] = "http://qt-project.org/wiki/Qt-Creator-with-BlackBerry-10";
const char QNX_LEGACY_KEYS_URL[] = "https://developer.blackberry.com/native/documentation/core"
"/com.qnx.doc.native_sdk.devguide/topic/bbid_to_sa.html";
const char QNX_REGISTER_KEYS_URL[] = "https://www.blackberry.com/SignedKeys/codesigning.html";