2012-06-29 07:23:13 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2011 - 2013 Research In Motion
|
2012-06-29 07:23:13 +02:00
|
|
|
**
|
|
|
|
|
** Contact: Research In Motion (blackberry-qt@qnx.com)
|
|
|
|
|
** Contact: KDAB (info@kdab.com)
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-06-29 07:23:13 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
2012-06-29 07:23:13 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2012-06-29 07:23:13 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-06-29 07:23:13 +02:00
|
|
|
|
|
|
|
|
#include "blackberrydeviceconfigurationwizardpages.h"
|
2013-04-16 14:53:24 +02:00
|
|
|
#include "blackberryconfiguration.h"
|
2013-03-12 12:04:07 +01:00
|
|
|
#include "blackberrydebugtokenrequestdialog.h"
|
2013-04-23 10:39:05 +02:00
|
|
|
#include "blackberrysshkeysgenerator.h"
|
2013-08-12 15:22:55 +02:00
|
|
|
#include "blackberrydeviceinformation.h"
|
2012-06-29 07:23:13 +02:00
|
|
|
#include "ui_blackberrydeviceconfigurationwizardsetuppage.h"
|
2013-08-12 15:22:55 +02:00
|
|
|
#include "ui_blackberrydeviceconfigurationwizardquerypage.h"
|
2012-06-29 07:23:13 +02:00
|
|
|
#include "ui_blackberrydeviceconfigurationwizardsshkeypage.h"
|
2013-08-12 15:22:55 +02:00
|
|
|
#include "ui_blackberrydeviceconfigurationwizardconfigpage.h"
|
2013-04-30 07:49:37 +02:00
|
|
|
#include "blackberryconfiguration.h"
|
2013-06-12 14:09:01 +02:00
|
|
|
#include "qnxutils.h"
|
2012-06-29 07:23:13 +02:00
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <ssh/sshkeygenerator.h>
|
|
|
|
|
|
2013-04-30 07:49:37 +02:00
|
|
|
#include <QDir>
|
2012-06-29 07:23:13 +02:00
|
|
|
#include <QFormLayout>
|
|
|
|
|
#include <QMessageBox>
|
2013-04-16 14:53:24 +02:00
|
|
|
#include <QFileDialog>
|
2013-03-18 14:47:33 +01:00
|
|
|
#include <QFileInfo>
|
2013-04-16 14:53:24 +02:00
|
|
|
#include <QHostInfo>
|
2013-08-08 16:27:47 +02:00
|
|
|
#include <QAbstractItemModel>
|
2012-06-29 07:23:13 +02:00
|
|
|
|
2012-07-25 17:41:01 +02:00
|
|
|
using namespace ProjectExplorer;
|
2012-06-29 07:23:13 +02:00
|
|
|
using namespace Qnx;
|
|
|
|
|
using namespace Qnx::Internal;
|
|
|
|
|
|
|
|
|
|
namespace {
|
2013-08-12 15:22:55 +02:00
|
|
|
const char DEVICEHOSTNAME_FIELD_ID[] = "DeviceHostName";
|
|
|
|
|
const char DEVICEPASSWORD_FIELD_ID[] = "DevicePassword";
|
|
|
|
|
const char CONFIGURATIONNAME_FIELD_ID[] = "ConfigurationName";
|
|
|
|
|
const char DEBUGTOKENPATH_FIELD_ID[] = "DebugTokenPath";
|
2012-12-21 08:36:06 -05:00
|
|
|
|
2013-08-08 16:27:47 +02:00
|
|
|
enum DeviceListUserRole
|
2012-12-21 08:36:06 -05:00
|
|
|
{
|
2013-08-08 16:27:47 +02:00
|
|
|
ItemKindRole = Qt::UserRole, DeviceNameRole, DeviceIpRole, DeviceTypeRole
|
|
|
|
|
};
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BlackBerryDeviceConfigurationWizardSetupPage::BlackBerryDeviceConfigurationWizardSetupPage(QWidget *parent)
|
|
|
|
|
: QWizardPage(parent)
|
|
|
|
|
, m_ui(new Ui::BlackBerryDeviceConfigurationWizardSetupPage)
|
2013-08-08 16:27:47 +02:00
|
|
|
, m_deviceListDetector(new BlackBerryDeviceListDetector(this))
|
|
|
|
|
|
2012-06-29 07:23:13 +02:00
|
|
|
{
|
|
|
|
|
m_ui->setupUi(this);
|
|
|
|
|
setTitle(tr("Connection Details"));
|
|
|
|
|
|
2013-08-08 16:27:47 +02:00
|
|
|
connect(m_ui->deviceListWidget, SIGNAL(itemSelectionChanged()), this, SLOT(onDeviceSelectionChanged()));
|
2013-08-08 18:31:44 +02:00
|
|
|
connect(m_deviceListDetector, SIGNAL(deviceDetected(QString,QString,bool)),
|
|
|
|
|
this, SLOT(onDeviceDetected(QString,QString,bool)));
|
2013-08-08 16:27:47 +02:00
|
|
|
connect(m_deviceListDetector, SIGNAL(finished()), this, SLOT(onDeviceListDetectorFinished()));
|
2012-06-29 07:23:13 +02:00
|
|
|
connect(m_ui->deviceHostIp, SIGNAL(textChanged(QString)), this, SIGNAL(completeChanged()));
|
|
|
|
|
|
2013-08-12 15:22:55 +02:00
|
|
|
registerField(QLatin1String(DEVICEHOSTNAME_FIELD_ID), m_ui->deviceHostIp);
|
|
|
|
|
registerField(QLatin1String(DEVICEPASSWORD_FIELD_ID), m_ui->password);
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BlackBerryDeviceConfigurationWizardSetupPage::~BlackBerryDeviceConfigurationWizardSetupPage()
|
|
|
|
|
{
|
|
|
|
|
delete m_ui;
|
|
|
|
|
m_ui = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlackBerryDeviceConfigurationWizardSetupPage::initializePage()
|
|
|
|
|
{
|
2013-08-08 16:27:47 +02:00
|
|
|
m_ui->password->clear();
|
|
|
|
|
refreshDeviceList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlackBerryDeviceConfigurationWizardSetupPage::refreshDeviceList()
|
|
|
|
|
{
|
|
|
|
|
m_ui->deviceListWidget->clear();
|
|
|
|
|
|
|
|
|
|
QListWidgetItem *manual = createDeviceListItem(tr("Specify device manually"), SpecifyManually);
|
|
|
|
|
m_ui->deviceListWidget->addItem(manual);
|
|
|
|
|
manual->setSelected(true);
|
|
|
|
|
|
|
|
|
|
QListWidgetItem *pleaseWait =
|
|
|
|
|
createDeviceListItem(tr("Auto-detecting devices - please wait..."), PleaseWait);
|
|
|
|
|
m_ui->deviceListWidget->addItem(pleaseWait);
|
|
|
|
|
|
|
|
|
|
m_deviceListDetector->detectDeviceList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlackBerryDeviceConfigurationWizardSetupPage::onDeviceListDetectorFinished()
|
|
|
|
|
{
|
|
|
|
|
QListWidgetItem *pleaseWait = findDeviceListItem(PleaseWait);
|
|
|
|
|
if (pleaseWait) {
|
|
|
|
|
m_ui->deviceListWidget->removeItemWidget(pleaseWait);
|
|
|
|
|
delete pleaseWait;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!findDeviceListItem(Autodetected)) {
|
|
|
|
|
QListWidgetItem *note = createDeviceListItem(tr("No device has been auto-detected."), Note);
|
|
|
|
|
note->setToolTip(tr("Device auto-detection is available in BB NDK 10.2. "
|
|
|
|
|
"Make sure that your device is in Development Mode."));
|
|
|
|
|
m_ui->deviceListWidget->addItem(note);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlackBerryDeviceConfigurationWizardSetupPage::onDeviceDetected(
|
2013-08-08 18:31:44 +02:00
|
|
|
const QString &deviceName, const QString &hostName, bool isSimulator)
|
2013-08-08 16:27:47 +02:00
|
|
|
{
|
|
|
|
|
QString displayName(deviceName);
|
|
|
|
|
if (displayName != hostName)
|
|
|
|
|
displayName.append(QLatin1String(" (")).append(hostName).append(QLatin1String(")"));
|
|
|
|
|
|
|
|
|
|
QListWidgetItem *device = createDeviceListItem(displayName, Autodetected);
|
|
|
|
|
device->setData(DeviceNameRole, displayName);
|
|
|
|
|
device->setData(DeviceIpRole, hostName);
|
2013-08-08 18:31:44 +02:00
|
|
|
device->setData(DeviceTypeRole, isSimulator);
|
2013-08-08 16:27:47 +02:00
|
|
|
QListWidgetItem *pleaseWait = findDeviceListItem(PleaseWait);
|
|
|
|
|
int row = pleaseWait ? m_ui->deviceListWidget->row(pleaseWait) : m_ui->deviceListWidget->count();
|
|
|
|
|
m_ui->deviceListWidget->insertItem(row, device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlackBerryDeviceConfigurationWizardSetupPage::onDeviceSelectionChanged()
|
|
|
|
|
{
|
|
|
|
|
QList<QListWidgetItem *> selectedItems = m_ui->deviceListWidget->selectedItems();
|
|
|
|
|
const QListWidgetItem *selected = selectedItems.count() == 1 ? selectedItems[0] : 0;
|
|
|
|
|
const ItemKind itemKind = selected ? selected->data(ItemKindRole).value<ItemKind>() : Note;
|
2013-08-08 18:31:44 +02:00
|
|
|
const bool isSimulator = selected && itemKind == Autodetected
|
|
|
|
|
? selected->data(DeviceTypeRole).toBool() : false;
|
2013-08-08 16:27:47 +02:00
|
|
|
switch (itemKind) {
|
|
|
|
|
case SpecifyManually:
|
|
|
|
|
m_ui->deviceHostIp->setEnabled(true);
|
|
|
|
|
m_ui->deviceHostIp->setText(QLatin1String("169.254.0.1"));
|
2013-08-12 15:22:55 +02:00
|
|
|
m_ui->password->setEnabled(true);
|
2013-08-08 16:27:47 +02:00
|
|
|
m_ui->deviceHostIp->selectAll();
|
|
|
|
|
m_ui->deviceHostIp->setFocus();
|
|
|
|
|
break;
|
|
|
|
|
case Autodetected:
|
|
|
|
|
m_ui->deviceHostIp->setEnabled(false);
|
|
|
|
|
m_ui->deviceHostIp->setText(selected->data(DeviceIpRole).toString());
|
2013-08-12 15:22:55 +02:00
|
|
|
m_ui->password->setEnabled(true);
|
2013-08-08 16:27:47 +02:00
|
|
|
m_ui->password->setFocus();
|
|
|
|
|
break;
|
|
|
|
|
case PleaseWait:
|
|
|
|
|
case Note:
|
|
|
|
|
m_ui->deviceHostIp->setEnabled(false);
|
|
|
|
|
m_ui->deviceHostIp->clear();
|
2013-08-12 15:22:55 +02:00
|
|
|
m_ui->password->setEnabled(false);
|
2013-08-08 16:27:47 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QListWidgetItem *BlackBerryDeviceConfigurationWizardSetupPage::createDeviceListItem(
|
|
|
|
|
const QString &displayName, ItemKind itemKind) const
|
|
|
|
|
{
|
|
|
|
|
QListWidgetItem *item = new QListWidgetItem(displayName);
|
|
|
|
|
if (itemKind == PleaseWait || itemKind == Note) {
|
|
|
|
|
item->setFlags(item->flags() & ~Qt::ItemIsSelectable);
|
|
|
|
|
QFont font = item->font();
|
|
|
|
|
font.setItalic(true);
|
|
|
|
|
item->setFont(font);
|
|
|
|
|
}
|
|
|
|
|
item->setData(ItemKindRole, QVariant::fromValue(itemKind));
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QListWidgetItem *BlackBerryDeviceConfigurationWizardSetupPage::findDeviceListItem(ItemKind itemKind) const
|
|
|
|
|
{
|
|
|
|
|
int count = m_ui->deviceListWidget->count();
|
|
|
|
|
for (int i = 0; i < count; ++i) {
|
|
|
|
|
QListWidgetItem *item = m_ui->deviceListWidget->item(i);
|
|
|
|
|
if (item->data(ItemKindRole).value<ItemKind>() == itemKind) {
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BlackBerryDeviceConfigurationWizardSetupPage::isComplete() const
|
|
|
|
|
{
|
2013-08-12 15:22:55 +02:00
|
|
|
return !m_ui->deviceHostIp->text().isEmpty();
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BlackBerryDeviceConfigurationWizardSetupPage::hostName() const
|
|
|
|
|
{
|
|
|
|
|
return m_ui->deviceHostIp->text();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BlackBerryDeviceConfigurationWizardSetupPage::password() const
|
|
|
|
|
{
|
|
|
|
|
return m_ui->password->text();
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-12 15:22:55 +02:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
BlackBerryDeviceConfigurationWizardQueryPage::BlackBerryDeviceConfigurationWizardQueryPage
|
|
|
|
|
(BlackBerryDeviceConfigurationWizardHolder &holder, QWidget *parent)
|
|
|
|
|
: QWizardPage(parent)
|
|
|
|
|
, m_ui(new Ui::BlackBerryDeviceConfigurationWizardQueryPage)
|
|
|
|
|
, m_holder(holder)
|
|
|
|
|
, m_deviceInformation(new BlackBerryDeviceInformation(this))
|
2012-06-29 07:23:13 +02:00
|
|
|
{
|
2013-08-12 15:22:55 +02:00
|
|
|
m_ui->setupUi(this);
|
|
|
|
|
setTitle(tr("Query Device Information"));
|
|
|
|
|
|
|
|
|
|
connect(m_deviceInformation,SIGNAL(finished(int)),this,SLOT(processQueryFinished(int)));
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-12 15:22:55 +02:00
|
|
|
BlackBerryDeviceConfigurationWizardQueryPage::~BlackBerryDeviceConfigurationWizardQueryPage()
|
2012-06-29 07:23:13 +02:00
|
|
|
{
|
2013-08-12 15:22:55 +02:00
|
|
|
delete m_ui;
|
|
|
|
|
m_ui = 0;
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-12 15:22:55 +02:00
|
|
|
void BlackBerryDeviceConfigurationWizardQueryPage::initializePage()
|
2013-02-18 19:22:21 -03:00
|
|
|
{
|
2013-08-12 15:22:55 +02:00
|
|
|
m_ui->statusLabel->setText(tr("Querying device information. Please wait..."));
|
|
|
|
|
m_ui->progressBar->setVisible(true);
|
2013-02-18 19:22:21 -03:00
|
|
|
|
2013-08-12 15:22:55 +02:00
|
|
|
m_holder.deviceInfoRetrieved = false;
|
2013-04-09 14:32:39 +02:00
|
|
|
|
2013-08-12 15:22:55 +02:00
|
|
|
m_deviceInformation->setDeviceTarget(
|
|
|
|
|
field(QLatin1String(DEVICEHOSTNAME_FIELD_ID)).toString(),
|
|
|
|
|
field(QLatin1String(DEVICEPASSWORD_FIELD_ID)).toString());
|
|
|
|
|
}
|
2013-02-18 19:22:21 -03:00
|
|
|
|
2013-08-12 15:22:55 +02:00
|
|
|
void BlackBerryDeviceConfigurationWizardQueryPage::processQueryFinished(int status)
|
|
|
|
|
{
|
|
|
|
|
m_holder.deviceInfoRetrieved = status == BlackBerryDeviceInformation::Success;
|
|
|
|
|
m_holder.devicePin = m_deviceInformation->devicePin();
|
|
|
|
|
m_holder.scmBundle = m_deviceInformation->scmBundle();
|
|
|
|
|
m_holder.deviceName = m_deviceInformation->hostName();
|
|
|
|
|
m_holder.debugTokenAuthor = m_deviceInformation->debugTokenAuthor();
|
|
|
|
|
m_holder.debugTokenValid = m_deviceInformation->debugTokenValid();
|
|
|
|
|
m_holder.isSimulator = m_deviceInformation->isSimulator();
|
|
|
|
|
|
|
|
|
|
if (m_holder.deviceInfoRetrieved)
|
|
|
|
|
m_ui->statusLabel->setText(tr("Device information retrieved successfully."));
|
|
|
|
|
else
|
|
|
|
|
m_ui->statusLabel->setText(tr("Cannot connect to the device. Check if the device is in development mode and has matching host name and password."));
|
|
|
|
|
m_ui->progressBar->setVisible(false);
|
|
|
|
|
emit completeChanged();
|
2013-02-18 19:22:21 -03:00
|
|
|
|
2013-08-12 15:22:55 +02:00
|
|
|
if (m_holder.deviceInfoRetrieved)
|
|
|
|
|
wizard()->next();
|
2013-02-18 19:22:21 -03:00
|
|
|
}
|
2012-06-29 07:23:13 +02:00
|
|
|
|
2013-08-12 15:22:55 +02:00
|
|
|
bool BlackBerryDeviceConfigurationWizardQueryPage::isComplete() const
|
|
|
|
|
{
|
|
|
|
|
return m_holder.deviceInfoRetrieved;
|
|
|
|
|
}
|
2012-06-29 07:23:13 +02:00
|
|
|
|
2013-08-12 15:22:55 +02:00
|
|
|
// ----------------------------------------------------------------------------
|
2012-06-29 07:23:13 +02:00
|
|
|
|
|
|
|
|
BlackBerryDeviceConfigurationWizardSshKeyPage::BlackBerryDeviceConfigurationWizardSshKeyPage(QWidget *parent)
|
|
|
|
|
: QWizardPage(parent)
|
|
|
|
|
, m_ui(new Ui::BlackBerryDeviceConfigurationWizardSshKeyPage)
|
|
|
|
|
{
|
|
|
|
|
m_ui->setupUi(this);
|
|
|
|
|
|
|
|
|
|
m_ui->privateKey->setExpectedKind(Utils::PathChooser::File);
|
2013-04-23 10:39:05 +02:00
|
|
|
m_ui->progressBar->hide();
|
2012-06-29 07:23:13 +02:00
|
|
|
|
2013-06-12 14:09:01 +02:00
|
|
|
QString initialBrowsePath = QnxUtils::dataDirPath();
|
2013-04-16 14:53:24 +02:00
|
|
|
if (!QFileInfo(initialBrowsePath).exists())
|
|
|
|
|
initialBrowsePath = QDir::homePath();
|
|
|
|
|
m_ui->privateKey->setInitialBrowsePathBackup(initialBrowsePath);
|
|
|
|
|
|
2012-06-29 07:23:13 +02:00
|
|
|
setTitle(tr("SSH Key Setup"));
|
|
|
|
|
setSubTitle(tr("Please select an existing <b>4096</b>-bit key or click <b>Generate</b> to create a new one."));
|
|
|
|
|
|
|
|
|
|
connect(m_ui->privateKey, SIGNAL(changed(QString)), this, SLOT(findMatchingPublicKey(QString)));
|
|
|
|
|
connect(m_ui->privateKey, SIGNAL(changed(QString)), this, SIGNAL(completeChanged()));
|
2013-04-23 10:39:05 +02:00
|
|
|
connect(m_ui->generate, SIGNAL(clicked()), this, SLOT(generateSshKeys()));
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BlackBerryDeviceConfigurationWizardSshKeyPage::~BlackBerryDeviceConfigurationWizardSshKeyPage()
|
|
|
|
|
{
|
|
|
|
|
delete m_ui;
|
|
|
|
|
m_ui = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlackBerryDeviceConfigurationWizardSshKeyPage::initializePage()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BlackBerryDeviceConfigurationWizardSshKeyPage::isComplete() const
|
|
|
|
|
{
|
|
|
|
|
QFileInfo privateKeyFi(m_ui->privateKey->fileName().toString());
|
|
|
|
|
QFileInfo publicKeyFi(m_ui->publicKey->text());
|
|
|
|
|
|
2013-04-16 14:53:24 +02:00
|
|
|
return privateKeyFi.exists() && publicKeyFi.exists();
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BlackBerryDeviceConfigurationWizardSshKeyPage::privateKey() const
|
|
|
|
|
{
|
|
|
|
|
return m_ui->privateKey->fileName().toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BlackBerryDeviceConfigurationWizardSshKeyPage::publicKey() const
|
|
|
|
|
{
|
|
|
|
|
return m_ui->publicKey->text();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlackBerryDeviceConfigurationWizardSshKeyPage::findMatchingPublicKey(const QString &privateKeyPath)
|
|
|
|
|
{
|
|
|
|
|
const QString candidate = privateKeyPath + QLatin1String(".pub");
|
|
|
|
|
if (QFileInfo(candidate).exists())
|
2013-07-18 18:31:44 +02:00
|
|
|
m_ui->publicKey->setText(QDir::toNativeSeparators(candidate));
|
2013-04-16 14:53:24 +02:00
|
|
|
else
|
|
|
|
|
m_ui->publicKey->clear();
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-26 16:55:12 +02:00
|
|
|
void BlackBerryDeviceConfigurationWizardSshKeyPage::sshKeysGenerationFailed(const QString &error)
|
2012-06-29 07:23:13 +02:00
|
|
|
{
|
2013-04-16 14:53:24 +02:00
|
|
|
setBusy(false);
|
2013-07-26 16:55:12 +02:00
|
|
|
QMessageBox::critical(this, tr("Key Generation Failed"), error);
|
|
|
|
|
}
|
2013-04-16 14:53:24 +02:00
|
|
|
|
2013-07-26 16:55:12 +02:00
|
|
|
void BlackBerryDeviceConfigurationWizardSshKeyPage::processSshKeys(const QString &privateKeyPath, const QByteArray &privateKey, const QByteArray &publicKey)
|
|
|
|
|
{
|
|
|
|
|
setBusy(false);
|
2012-06-29 07:23:13 +02:00
|
|
|
|
2013-07-26 16:55:12 +02:00
|
|
|
const QString publicKeyPath = privateKeyPath + QLatin1String(".pub");
|
2012-06-29 07:23:13 +02:00
|
|
|
|
2013-07-26 16:55:12 +02:00
|
|
|
if (!saveKeys(privateKey, publicKey, privateKeyPath, publicKeyPath)) // saveKeys(..) will show an error message if necessary
|
2013-04-16 14:53:24 +02:00
|
|
|
return;
|
2013-04-23 10:39:05 +02:00
|
|
|
|
2013-07-26 16:55:12 +02:00
|
|
|
m_ui->privateKey->setFileName(Utils::FileName::fromString(privateKeyPath));
|
2013-07-18 18:31:44 +02:00
|
|
|
m_ui->publicKey->setText(QDir::toNativeSeparators(publicKeyPath));
|
2013-04-16 14:53:24 +02:00
|
|
|
|
|
|
|
|
emit completeChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-26 16:55:12 +02:00
|
|
|
bool BlackBerryDeviceConfigurationWizardSshKeyPage::saveKeys(const QByteArray &privateKey, const QByteArray &publicKey, const QString &privateKeyPath, const QString &publicKeyPath)
|
2013-04-16 14:53:24 +02:00
|
|
|
{
|
2013-07-26 16:55:12 +02:00
|
|
|
Utils::FileSaver privSaver(privateKeyPath);
|
|
|
|
|
privSaver.write(privateKey);
|
2013-04-16 14:53:24 +02:00
|
|
|
if (!privSaver.finalize(this))
|
|
|
|
|
return false; // finalize shows an error message if necessary
|
2013-07-26 16:55:12 +02:00
|
|
|
QFile::setPermissions(privateKeyPath, QFile::ReadOwner | QFile::WriteOwner);
|
2013-04-16 14:53:24 +02:00
|
|
|
|
2013-07-26 16:55:12 +02:00
|
|
|
Utils::FileSaver pubSaver(publicKeyPath);
|
2013-04-16 14:53:24 +02:00
|
|
|
|
2013-07-26 16:55:12 +02:00
|
|
|
pubSaver.write(publicKey);
|
2013-04-16 14:53:24 +02:00
|
|
|
if (!pubSaver.finalize(this))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
|
2013-04-23 10:39:05 +02:00
|
|
|
void BlackBerryDeviceConfigurationWizardSshKeyPage::generateSshKeys()
|
|
|
|
|
{
|
2013-06-12 14:09:01 +02:00
|
|
|
QString lookInDir = QnxUtils::dataDirPath();
|
2013-04-16 14:53:24 +02:00
|
|
|
if (!QFileInfo(lookInDir).exists())
|
|
|
|
|
lookInDir = QDir::homePath();
|
|
|
|
|
|
|
|
|
|
QString privateKeyPath = QFileDialog::getSaveFileName(this, tr("Choose Private Key File Name"), lookInDir);
|
|
|
|
|
if (privateKeyPath.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
2013-04-23 10:39:05 +02:00
|
|
|
setBusy(true);
|
2013-07-26 16:55:12 +02:00
|
|
|
BlackBerrySshKeysGenerator *sshKeysGenerator = new BlackBerrySshKeysGenerator(privateKeyPath);
|
|
|
|
|
connect(sshKeysGenerator, SIGNAL(sshKeysGenerationFailed(QString)), this, SLOT(sshKeysGenerationFailed(QString)), Qt::QueuedConnection);
|
|
|
|
|
connect(sshKeysGenerator, SIGNAL(sshKeysGenerationFinished(QString,QByteArray,QByteArray)), this, SLOT(processSshKeys(QString,QByteArray,QByteArray)), Qt::QueuedConnection);
|
|
|
|
|
sshKeysGenerator->start();
|
2013-04-23 10:39:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlackBerryDeviceConfigurationWizardSshKeyPage::setBusy(bool busy)
|
|
|
|
|
{
|
|
|
|
|
m_ui->privateKey->setEnabled(!busy);
|
2013-04-16 14:53:24 +02:00
|
|
|
m_ui->publicKey->setEnabled(!busy);
|
2013-04-23 10:39:05 +02:00
|
|
|
m_ui->generate->setEnabled(!busy);
|
|
|
|
|
m_ui->progressBar->setVisible(busy);
|
|
|
|
|
|
|
|
|
|
wizard()->button(QWizard::BackButton)->setEnabled(!busy);
|
|
|
|
|
wizard()->button(QWizard::NextButton)->setEnabled(!busy);
|
|
|
|
|
wizard()->button(QWizard::FinishButton)->setEnabled(!busy);
|
|
|
|
|
wizard()->button(QWizard::CancelButton)->setEnabled(!busy);
|
|
|
|
|
}
|
2013-08-12 15:22:55 +02:00
|
|
|
|
2012-06-29 07:23:13 +02:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
2013-08-12 15:22:55 +02:00
|
|
|
BlackBerryDeviceConfigurationWizardConfigPage::BlackBerryDeviceConfigurationWizardConfigPage
|
|
|
|
|
(BlackBerryDeviceConfigurationWizardHolder &holder, QWidget *parent)
|
|
|
|
|
: QWizardPage(parent)
|
|
|
|
|
, m_ui(new Ui::BlackBerryDeviceConfigurationWizardConfigPage)
|
|
|
|
|
, m_holder(holder)
|
|
|
|
|
{
|
|
|
|
|
m_ui->setupUi(this);
|
|
|
|
|
setTitle(tr("Configuration"));
|
|
|
|
|
|
|
|
|
|
m_ui->debugTokenField->setExpectedKind(Utils::PathChooser::File);
|
|
|
|
|
m_ui->debugTokenField->setPromptDialogFilter(QLatin1String("*.bar"));
|
|
|
|
|
|
|
|
|
|
QString debugTokenBrowsePath = QnxUtils::dataDirPath();
|
|
|
|
|
if (!QFileInfo(debugTokenBrowsePath).exists())
|
|
|
|
|
debugTokenBrowsePath = QDir::homePath();
|
|
|
|
|
m_ui->debugTokenField->setInitialBrowsePathBackup(debugTokenBrowsePath);
|
|
|
|
|
|
|
|
|
|
connect(m_ui->configurationNameField, SIGNAL(textChanged(QString)), this, SIGNAL(completeChanged()));
|
|
|
|
|
connect(m_ui->debugTokenField, SIGNAL(changed(QString)), this, SIGNAL(completeChanged()));
|
|
|
|
|
connect(m_ui->generateButton, SIGNAL(clicked()), this, SLOT(generateDebugToken()));
|
|
|
|
|
|
|
|
|
|
registerField(QLatin1String(CONFIGURATIONNAME_FIELD_ID), m_ui->configurationNameField);
|
|
|
|
|
registerField(QLatin1String(DEBUGTOKENPATH_FIELD_ID), m_ui->debugTokenField);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BlackBerryDeviceConfigurationWizardConfigPage::~BlackBerryDeviceConfigurationWizardConfigPage()
|
|
|
|
|
{
|
|
|
|
|
delete m_ui;
|
|
|
|
|
m_ui = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlackBerryDeviceConfigurationWizardConfigPage::initializePage()
|
|
|
|
|
{
|
|
|
|
|
QString deviceHostName = field(QLatin1String(DEVICEHOSTNAME_FIELD_ID)).toString();
|
|
|
|
|
m_ui->configurationNameField->setText(m_holder.deviceName);
|
|
|
|
|
m_ui->deviceHostNameField->setText(deviceHostName);
|
|
|
|
|
m_ui->deviceTypeField->setText(QLatin1String (m_holder.isSimulator ? "Simulator" : "Device"));
|
|
|
|
|
m_ui->debugTokenField->setEnabled(!m_holder.isSimulator);
|
|
|
|
|
m_ui->generateButton->setEnabled(!m_holder.isSimulator);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BlackBerryDeviceConfigurationWizardConfigPage::isComplete() const
|
|
|
|
|
{
|
|
|
|
|
bool configurationNameComplete = !m_ui->configurationNameField->text().isEmpty();
|
|
|
|
|
Utils::FileName fileName = m_ui->debugTokenField->fileName();
|
|
|
|
|
bool debugTokenComplete = m_holder.isSimulator
|
|
|
|
|
|| (!fileName.isEmpty() && QFileInfo(fileName.toString()).exists());
|
|
|
|
|
|
|
|
|
|
return configurationNameComplete && debugTokenComplete;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlackBerryDeviceConfigurationWizardConfigPage::generateDebugToken()
|
|
|
|
|
{
|
|
|
|
|
BlackBerryDebugTokenRequestDialog dialog;
|
|
|
|
|
dialog.setDevicePin(m_holder.devicePin);
|
|
|
|
|
|
|
|
|
|
const int result = dialog.exec();
|
|
|
|
|
|
|
|
|
|
if (result != QDialog::Accepted)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_ui->debugTokenField->setPath(dialog.debugToken());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BlackBerryDeviceConfigurationWizardConfigPage::configurationName() const
|
|
|
|
|
{
|
|
|
|
|
return m_ui->configurationNameField->text();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BlackBerryDeviceConfigurationWizardConfigPage::debugToken() const
|
|
|
|
|
{
|
|
|
|
|
return m_ui->debugTokenField->fileName().toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2012-06-29 07:23:13 +02:00
|
|
|
|
|
|
|
|
BlackBerryDeviceConfigurationWizardFinalPage::BlackBerryDeviceConfigurationWizardFinalPage(QWidget *parent)
|
|
|
|
|
: QWizardPage(parent)
|
|
|
|
|
{
|
|
|
|
|
setTitle(tr("Setup Finished"));
|
|
|
|
|
|
|
|
|
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
2013-08-12 15:22:55 +02:00
|
|
|
QLabel *label = new QLabel(tr("The new device configuration will be created now."), this);
|
2012-06-29 07:23:13 +02:00
|
|
|
layout->addWidget(label);
|
|
|
|
|
}
|