Commit 0b0f84c6 authored by Tobias Nätterlund's avatar Tobias Nätterlund Committed by Tobias Nätterlund

BlackBerry: Add possibility to sign packages when creating them

Change-Id: Ib0d776143b787b0862d6797aaca4a1edc9865da2
Reviewed-by: Nicolas Arnaud-Cormos's avatarNicolas Arnaud-Cormos <nicolas@kdab.com>
Reviewed-by: default avatarMehdi Fekari <mfekari@blackberry.com>
parent 42eeb6ec
......@@ -38,6 +38,7 @@
#include "blackberryqtversion.h"
#include "blackberrydeviceconfiguration.h"
#include "blackberrydeployinformation.h"
#include "blackberrysigningpasswordsdialog.h"
#include <debugger/debuggerrunconfigurationaspect.h>
#include <projectexplorer/projectexplorerconstants.h>
......@@ -66,19 +67,31 @@ const char QT_INSTALL_IMPORTS_VAR[] = "%QT_INSTALL_IMPORTS%";
const char QT_INSTALL_QML[] = "QT_INSTALL_QML";
const char QT_INSTALL_QML_VAR[] = "%QT_INSTALL_QML%";
const char SRC_DIR_VAR[] = "%SRC_DIR%";
const char PACKAGE_MODE_KEY[] = "Qt4ProjectManager.BlackBerryCreatePackageStep.PackageMode";
const char CSK_PASSWORD_KEY[] = "Qt4ProjectManager.BlackBerryCreatePackageStep.CskPassword";
const char KEYSTORE_PASSWORD_KEY[] = "Qt4ProjectManager.BlackBerryCreatePackageStep.KeystorePassword";
const char SAVE_PASSWORDS_KEY[] = "Qt4ProjectManager.BlackBerryCreatePackageStep.SavePasswords";
}
BlackBerryCreatePackageStep::BlackBerryCreatePackageStep(ProjectExplorer::BuildStepList *bsl)
: BlackBerryAbstractDeployStep(bsl, Core::Id(Constants::QNX_CREATE_PACKAGE_BS_ID))
{
setDisplayName(tr("Create BAR packages"));
ctor();
}
BlackBerryCreatePackageStep::BlackBerryCreatePackageStep(ProjectExplorer::BuildStepList *bsl,
BlackBerryCreatePackageStep *bs)
: BlackBerryAbstractDeployStep(bsl, bs)
{
setDisplayName(tr("Create BAR packages"));
ctor();
}
void BlackBerryCreatePackageStep::ctor()
{
setDisplayName(tr("Create packages"));
m_packageMode = DevelopmentMode;
}
bool BlackBerryCreatePackageStep::init()
......@@ -129,9 +142,32 @@ bool BlackBerryCreatePackageStep::init()
QStringList args;
args << QLatin1String("-devMode");
if (!debugToken().isEmpty())
args << QLatin1String("-debugToken") << QnxUtils::addQuotes(QDir::toNativeSeparators(debugToken()));
if (m_packageMode == DevelopmentMode) {
args << QLatin1String("-devMode");
if (!debugToken().isEmpty())
args << QLatin1String("-debugToken") << QnxUtils::addQuotes(QDir::toNativeSeparators(debugToken()));
} else if (m_packageMode == SigningPackageMode) {
if (m_cskPassword.isEmpty() || m_keystorePassword.isEmpty()) {
BlackBerrySigningPasswordsDialog dlg;
dlg.setCskPassword(m_cskPassword);
dlg.setStorePassword(m_keystorePassword);
if (dlg.exec() == QDialog::Rejected) {
raiseError(tr("Missing passwords for signing packages"));
return false;
}
m_cskPassword = dlg.cskPassword();
m_keystorePassword = dlg.storePassword();
emit cskPasswordChanged(m_cskPassword);
emit keystorePasswordChanged(m_keystorePassword);
}
args << QLatin1String("-sign");
args << QLatin1String("-cskpass");
args << m_cskPassword;
args << QLatin1String("-storepass");
args << m_keystorePassword;
}
args << QLatin1String("-package") << QnxUtils::addQuotes(QDir::toNativeSeparators(info.packagePath()));
args << QnxUtils::addQuotes(QDir::toNativeSeparators(preparedFilePath));
addCommand(packageCmd, args);
......@@ -142,7 +178,7 @@ bool BlackBerryCreatePackageStep::init()
ProjectExplorer::BuildStepConfigWidget *BlackBerryCreatePackageStep::createConfigWidget()
{
return new BlackBerryCreatePackageStepConfigWidget();
return new BlackBerryCreatePackageStepConfigWidget(this);
}
QString BlackBerryCreatePackageStep::debugToken() const
......@@ -154,6 +190,69 @@ QString BlackBerryCreatePackageStep::debugToken() const
return device->debugToken();
}
bool BlackBerryCreatePackageStep::fromMap(const QVariantMap &map)
{
m_packageMode = static_cast<PackageMode>(map.value(QLatin1String(PACKAGE_MODE_KEY), DevelopmentMode).toInt());
m_savePasswords = map.value(QLatin1String(SAVE_PASSWORDS_KEY), false).toBool();
if (m_savePasswords) {
m_cskPassword = map.value(QLatin1String(CSK_PASSWORD_KEY)).toString();
m_keystorePassword = map.value(QLatin1String(KEYSTORE_PASSWORD_KEY)).toString();
}
return BlackBerryAbstractDeployStep::fromMap(map);
}
QVariantMap BlackBerryCreatePackageStep::toMap() const
{
QVariantMap map = BlackBerryAbstractDeployStep::toMap();
map.insert(QLatin1String(PACKAGE_MODE_KEY), m_packageMode);
map.insert(QLatin1String(SAVE_PASSWORDS_KEY), m_savePasswords);
if (m_savePasswords) {
map.insert(QLatin1String(CSK_PASSWORD_KEY), m_cskPassword);
map.insert(QLatin1String(KEYSTORE_PASSWORD_KEY), m_keystorePassword);
}
return map;
}
BlackBerryCreatePackageStep::PackageMode BlackBerryCreatePackageStep::packageMode() const
{
return m_packageMode;
}
QString BlackBerryCreatePackageStep::cskPassword() const
{
return m_cskPassword;
}
QString BlackBerryCreatePackageStep::keystorePassword() const
{
return m_keystorePassword;
}
bool BlackBerryCreatePackageStep::savePasswords() const
{
return m_savePasswords;
}
void BlackBerryCreatePackageStep::setPackageMode(BlackBerryCreatePackageStep::PackageMode packageMode)
{
m_packageMode = packageMode;
}
void BlackBerryCreatePackageStep::setCskPassword(const QString &cskPassword)
{
m_cskPassword = cskPassword;
}
void BlackBerryCreatePackageStep::setKeystorePassword(const QString &storePassword)
{
m_keystorePassword = storePassword;
}
void BlackBerryCreatePackageStep::setSavePasswords(bool savePasswords)
{
m_savePasswords = savePasswords;
}
bool BlackBerryCreatePackageStep::prepareAppDescriptorFile(const QString &appDescriptorPath, const QString &preparedFilePath)
{
BlackBerryQtVersion *qtVersion = dynamic_cast<BlackBerryQtVersion *>(QtSupport::QtKitInformation::qtVersion(target()->kit()));
......@@ -213,3 +312,22 @@ bool BlackBerryCreatePackageStep::prepareAppDescriptorFile(const QString &appDes
return true;
}
void BlackBerryCreatePackageStep::processStarted(const ProjectExplorer::ProcessParameters &params)
{
if (m_packageMode == SigningPackageMode) {
QString arguments = params.prettyArguments();
const QString cskPasswordLine = QLatin1String(" -cskpass ") + m_cskPassword;
const QString hiddenCskPasswordLine = QLatin1String(" -cskpass <hidden>");
arguments.replace(cskPasswordLine, hiddenCskPasswordLine);
const QString storePasswordLine = QLatin1String(" -storepass ") + m_keystorePassword;
const QString hiddenStorePasswordLine = QLatin1String(" -storepass <hidden>");
arguments.replace(storePasswordLine, hiddenStorePasswordLine);
emitOutputInfo(params, arguments);
} else {
BlackBerryAbstractDeployStep::processStarted(params);
}
}
......@@ -47,6 +47,11 @@ class BlackBerryCreatePackageStep : public BlackBerryAbstractDeployStep
friend class BlackBerryCreatePackageStepFactory;
public:
enum PackageMode {
SigningPackageMode,
DevelopmentMode
};
explicit BlackBerryCreatePackageStep(ProjectExplorer::BuildStepList *bsl);
bool init();
......@@ -54,11 +59,38 @@ public:
QString debugToken() const;
bool fromMap(const QVariantMap &map);
QVariantMap toMap() const;
PackageMode packageMode() const;
QString cskPassword() const;
QString keystorePassword() const;
bool savePasswords() const;
public slots:
void setPackageMode(PackageMode packageMode);
void setCskPassword(const QString &cskPassword);
void setKeystorePassword(const QString &keystorePassword);
void setSavePasswords(bool savePasswords);
signals:
void cskPasswordChanged(QString);
void keystorePasswordChanged(QString);
protected:
BlackBerryCreatePackageStep(ProjectExplorer::BuildStepList *bsl, BlackBerryCreatePackageStep *bs);
void processStarted(const ProjectExplorer::ProcessParameters &params);
private:
void ctor();
bool prepareAppDescriptorFile(const QString &appDescriptorPath, const QString &preparedFilePath);
PackageMode m_packageMode;
QString m_cskPassword;
QString m_keystorePassword;
bool m_savePasswords;
};
} // namespace Internal
......
......@@ -30,13 +30,41 @@
****************************************************************************/
#include "blackberrycreatepackagestepconfigwidget.h"
#include "ui_blackberrycreatepackagestepconfigwidget.h"
#include "blackberrycreatepackagestep.h"
using namespace Qnx;
using namespace Qnx::Internal;
BlackBerryCreatePackageStepConfigWidget::BlackBerryCreatePackageStepConfigWidget()
BlackBerryCreatePackageStepConfigWidget::BlackBerryCreatePackageStepConfigWidget(BlackBerryCreatePackageStep *step)
: ProjectExplorer::BuildStepConfigWidget()
, m_step(step)
{
m_ui = new Ui::BlackBerryCreatePackageStepConfigWidget;
m_ui->setupUi(this);
m_ui->signPackages->setChecked(m_step->packageMode() == BlackBerryCreatePackageStep::SigningPackageMode);
m_ui->developmentMode->setChecked(m_step->packageMode() == BlackBerryCreatePackageStep::DevelopmentMode);
m_ui->cskPassword->setText(m_step->cskPassword());
m_ui->keystorePassword->setText(m_step->keystorePassword());
m_ui->savePasswords->setChecked(m_step->savePasswords());
connect(m_ui->signPackages, SIGNAL(toggled(bool)), this, SLOT(setPackageMode(bool)));
connect(m_ui->cskPassword, SIGNAL(textChanged(QString)), m_step, SLOT(setCskPassword(QString)));
connect(m_ui->keystorePassword, SIGNAL(textChanged(QString)), m_step, SLOT(setKeystorePassword(QString)));
connect(m_ui->showPasswords, SIGNAL(toggled(bool)), this, SLOT(showPasswords(bool)));
connect(m_ui->savePasswords, SIGNAL(toggled(bool)), m_step, SLOT(setSavePasswords(bool)));
connect(m_step, SIGNAL(cskPasswordChanged(QString)), m_ui->cskPassword, SLOT(setText(QString)));
connect(m_step, SIGNAL(keystorePasswordChanged(QString)), m_ui->keystorePassword, SLOT(setText(QString)));
m_ui->signPackagesWidget->setEnabled(m_ui->signPackages->isChecked());
}
BlackBerryCreatePackageStepConfigWidget::~BlackBerryCreatePackageStepConfigWidget()
{
delete m_ui;
m_ui = 0;
}
QString BlackBerryCreatePackageStepConfigWidget::displayName() const
......@@ -51,5 +79,16 @@ QString BlackBerryCreatePackageStepConfigWidget::summaryText() const
bool BlackBerryCreatePackageStepConfigWidget::showWidget() const
{
return false;
return true;
}
void BlackBerryCreatePackageStepConfigWidget::setPackageMode(bool signPackagesChecked)
{
m_step->setPackageMode(signPackagesChecked ? BlackBerryCreatePackageStep::SigningPackageMode : BlackBerryCreatePackageStep::DevelopmentMode);
}
void BlackBerryCreatePackageStepConfigWidget::showPasswords(bool show)
{
m_ui->cskPassword->setEchoMode(show ? QLineEdit::Normal : QLineEdit::Password);
m_ui->keystorePassword->setEchoMode(show ? QLineEdit::Normal : QLineEdit::Password);
}
......@@ -37,16 +37,31 @@
namespace Qnx {
namespace Internal {
namespace Ui {
class BlackBerryCreatePackageStepConfigWidget;
}
class BlackBerryCreatePackageStep;
class BlackBerryCreatePackageStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget
{
Q_OBJECT
public:
explicit BlackBerryCreatePackageStepConfigWidget();
explicit BlackBerryCreatePackageStepConfigWidget(BlackBerryCreatePackageStep *step);
~BlackBerryCreatePackageStepConfigWidget();
QString displayName() const;
QString summaryText() const;
bool showWidget() const;
private slots:
void setPackageMode(bool signPackagesChecked);
void showPasswords(bool show);
private:
BlackBerryCreatePackageStep *m_step;
Ui::BlackBerryCreatePackageStepConfigWidget *m_ui;
};
} // namespace Internal
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Qnx::Internal::BlackBerryCreatePackageStepConfigWidget</class>
<widget class="QWidget" name="Qnx::Internal::BlackBerryCreatePackageStepConfigWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>803</width>
<height>135</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="signPackages">
<property name="text">
<string>Sign packages</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="signPackagesWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>CSK password:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="cskPassword">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Keystore password:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="keystorePassword">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="savePasswords">
<property name="toolTip">
<string>Note: this will store the passwords in a world-readable file!</string>
</property>
<property name="text">
<string>Save passwords</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="showPasswords">
<property name="text">
<string>Show passwords</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QRadioButton" name="developmentMode">
<property name="text">
<string>Package in development mode</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>signPackages</sender>
<signal>toggled(bool)</signal>
<receiver>signPackagesWidget</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>40</x>
<y>12</y>
</hint>
<hint type="destinationlabel">
<x>12</x>
<y>62</y>
</hint>
</hints>
</connection>
</connections>
</ui>
/**************************************************************************
**
** 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 "blackberrysigningpasswordsdialog.h"
#include "ui_blackberrysigningpasswordsdialog.h"
using namespace Qnx;
using namespace Qnx::Internal;
BlackBerrySigningPasswordsDialog::BlackBerrySigningPasswordsDialog(QWidget *parent) :
QDialog(parent),
m_ui(new Ui::BlackBerrySigningPasswordsDialog)
{
m_ui->setupUi(this);
}
BlackBerrySigningPasswordsDialog::~BlackBerrySigningPasswordsDialog()
{
delete m_ui;
}
void BlackBerrySigningPasswordsDialog::setCskPassword(const QString &cskPassword)
{
m_ui->cskPassword->setText(cskPassword);
}
void BlackBerrySigningPasswordsDialog::setStorePassword(const QString &storePassword)
{
m_ui->storePassword->setText(storePassword);
}
QString BlackBerrySigningPasswordsDialog::cskPassword() const
{
return m_ui->cskPassword->text();
}
QString BlackBerrySigningPasswordsDialog::storePassword() const
{
return m_ui->storePassword->text();
}
/**************************************************************************
**
** 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_BLACKBERRYSIGNINGPASSWORDSDIALOG_H
#define QNX_INTERNAL_BLACKBERRYSIGNINGPASSWORDSDIALOG_H
#include <QDialog>
namespace Qnx {
namespace Internal {
namespace Ui {
class BlackBerrySigningPasswordsDialog;
}
class BlackBerrySigningPasswordsDialog : public QDialog
{
Q_OBJECT
public:
explicit BlackBerrySigningPasswordsDialog(QWidget *parent = 0);
~BlackBerrySigningPasswordsDialog();
void setCskPassword(const QString &cskPassword);
void setStorePassword(const QString &storePassword);
QString cskPassword() const;
QString storePassword() const;
private:
Ui::BlackBerrySigningPasswordsDialog *m_ui;
};
} // namespace Internal
} // namespace Qnx
#endif // QNX_INTERNAL_BLACKBERRYSIGNINGPASSWORDSDIALOG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Qnx::Internal::BlackBerrySigningPasswordsDialog</class>
<widget class="QDialog" name="Qnx::Internal::BlackBerrySigningPasswordsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>313</width>
<height>89</height>
</rect>
</property>
<property name="windowTitle">
<string>Package signing passwords</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>CSK password:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="cskPassword">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Keystore password:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="storePassword">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Qnx::Internal::BlackBerrySigningPasswordsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Qnx::Internal::BlackBerrySigningPasswordsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
......@@ -78,7 +78,8 @@ SOURCES += qnxplugin.cpp \
blackberrydeviceconnectionmanager.cpp \
blackberrydeviceinformation.cpp \