forked from qt-creator/qt-creator
Qnx: Device auto-detection in Add BlackBerry Device wizard
BlackBerryDeviceConfigurationWizardSetupPage auto-detects devices that are reachable from a host machine and allows an user to choose one of them to pre-fill the fields on the page. DeviceListDectector class added for auto-detecting devices. BlackBerryNdkProcess::resolveNdkToolPath() method added to allow resolve cmd-line tools fill path. Change-Id: I58287b40a5f20662fc09665c3a3c492294bb57f3 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com> Reviewed-by: David Kaspar <dkaspar@blackberry.com>
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QHostInfo>
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Qnx;
|
||||
@@ -55,15 +56,17 @@ using namespace Qnx::Internal;
|
||||
namespace {
|
||||
const char DEVICENAME_FIELD_ID[] = "DeviceName";
|
||||
|
||||
QString defaultDeviceHostIp(IDevice::MachineType type)
|
||||
enum DeviceListUserRole
|
||||
{
|
||||
return type == IDevice::Hardware ? QLatin1String("169.254.0.1") : QString();
|
||||
}
|
||||
ItemKindRole = Qt::UserRole, DeviceNameRole, DeviceIpRole, DeviceTypeRole
|
||||
};
|
||||
}
|
||||
|
||||
BlackBerryDeviceConfigurationWizardSetupPage::BlackBerryDeviceConfigurationWizardSetupPage(QWidget *parent)
|
||||
: QWizardPage(parent)
|
||||
, m_ui(new Ui::BlackBerryDeviceConfigurationWizardSetupPage)
|
||||
, m_deviceListDetector(new BlackBerryDeviceListDetector(this))
|
||||
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setTitle(tr("Connection Details"));
|
||||
@@ -76,9 +79,12 @@ BlackBerryDeviceConfigurationWizardSetupPage::BlackBerryDeviceConfigurationWizar
|
||||
debugTokenBrowsePath = QDir::homePath();
|
||||
m_ui->debugToken->setInitialBrowsePathBackup(debugTokenBrowsePath);
|
||||
|
||||
connect(m_ui->deviceListWidget, SIGNAL(itemSelectionChanged()), this, SLOT(onDeviceSelectionChanged()));
|
||||
connect(m_deviceListDetector, SIGNAL(deviceDetected(QString,QString,BlackBerryDeviceListDetector::DeviceType)),
|
||||
this, SLOT(onDeviceDetected(QString,QString,BlackBerryDeviceListDetector::DeviceType)));
|
||||
connect(m_deviceListDetector, SIGNAL(finished()), this, SLOT(onDeviceListDetectorFinished()));
|
||||
connect(m_ui->deviceName, SIGNAL(textChanged(QString)), this, SIGNAL(completeChanged()));
|
||||
connect(m_ui->deviceHostIp, SIGNAL(textChanged(QString)), this, SIGNAL(completeChanged()));
|
||||
connect(m_ui->physicalDevice, SIGNAL(toggled(bool)), this, SLOT(handleMachineTypeChanged()));
|
||||
connect(m_ui->physicalDevice, SIGNAL(toggled(bool)), this, SIGNAL(completeChanged()));
|
||||
connect(m_ui->debugToken, SIGNAL(changed(QString)), this, SIGNAL(completeChanged()));
|
||||
connect(m_ui->requestButton, SIGNAL(clicked()), this, SLOT(requestDebugToken()));
|
||||
@@ -94,10 +100,128 @@ BlackBerryDeviceConfigurationWizardSetupPage::~BlackBerryDeviceConfigurationWiza
|
||||
|
||||
void BlackBerryDeviceConfigurationWizardSetupPage::initializePage()
|
||||
{
|
||||
m_ui->deviceName->setText(tr("BlackBerry Device"));
|
||||
m_ui->password->setText(QString());
|
||||
m_ui->physicalDevice->setChecked(true);
|
||||
m_ui->deviceHostIp->setText(defaultDeviceHostIp(machineType()));
|
||||
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(
|
||||
const QString &deviceName, const QString &hostName,
|
||||
const BlackBerryDeviceListDetector::DeviceType deviceType)
|
||||
{
|
||||
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);
|
||||
device->setData(DeviceTypeRole, QVariant::fromValue(deviceType));
|
||||
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;
|
||||
const BlackBerryDeviceListDetector::DeviceType deviceType = selected && itemKind == Autodetected
|
||||
? selected->data(DeviceTypeRole).value<BlackBerryDeviceListDetector::DeviceType>()
|
||||
: BlackBerryDeviceListDetector::Device;
|
||||
switch (itemKind) {
|
||||
case SpecifyManually:
|
||||
m_ui->deviceName->setEnabled(true);
|
||||
m_ui->deviceName->setText(tr("BlackBerry Device"));
|
||||
m_ui->deviceHostIp->setEnabled(true);
|
||||
m_ui->deviceHostIp->setText(QLatin1String("169.254.0.1"));
|
||||
m_ui->physicalDevice->setEnabled(true);
|
||||
m_ui->physicalDevice->setChecked(true);
|
||||
m_ui->simulator->setEnabled(true);
|
||||
m_ui->simulator->setChecked(false);
|
||||
m_ui->deviceHostIp->selectAll();
|
||||
m_ui->deviceHostIp->setFocus();
|
||||
break;
|
||||
case Autodetected:
|
||||
m_ui->deviceName->setEnabled(true);
|
||||
m_ui->deviceName->setText(selected->data(DeviceNameRole).toString());
|
||||
m_ui->deviceHostIp->setEnabled(false);
|
||||
m_ui->deviceHostIp->setText(selected->data(DeviceIpRole).toString());
|
||||
m_ui->physicalDevice->setEnabled(false);
|
||||
m_ui->physicalDevice->setChecked(deviceType == BlackBerryDeviceListDetector::Device);
|
||||
m_ui->simulator->setEnabled(false);
|
||||
m_ui->simulator->setChecked(deviceType == BlackBerryDeviceListDetector::Simulator);
|
||||
m_ui->password->setFocus();
|
||||
break;
|
||||
case PleaseWait:
|
||||
case Note:
|
||||
m_ui->deviceName->setEnabled(false);
|
||||
m_ui->deviceName->clear();
|
||||
m_ui->deviceHostIp->setEnabled(false);
|
||||
m_ui->deviceHostIp->clear();
|
||||
m_ui->physicalDevice->setEnabled(false);
|
||||
m_ui->physicalDevice->setChecked(false);
|
||||
m_ui->simulator->setEnabled(false);
|
||||
m_ui->simulator->setChecked(false);
|
||||
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;
|
||||
}
|
||||
|
||||
bool BlackBerryDeviceConfigurationWizardSetupPage::isComplete() const
|
||||
@@ -135,12 +259,6 @@ IDevice::MachineType BlackBerryDeviceConfigurationWizardSetupPage::machineType()
|
||||
return m_ui->physicalDevice->isChecked() ? IDevice::Hardware : IDevice::Emulator;
|
||||
}
|
||||
|
||||
void BlackBerryDeviceConfigurationWizardSetupPage::handleMachineTypeChanged()
|
||||
{
|
||||
if (m_ui->deviceHostIp->text().isEmpty())
|
||||
m_ui->deviceHostIp->setText(defaultDeviceHostIp(machineType()));
|
||||
}
|
||||
|
||||
void BlackBerryDeviceConfigurationWizardSetupPage::requestDebugToken()
|
||||
{
|
||||
BlackBerryDebugTokenRequestDialog dialog;
|
||||
|
@@ -32,9 +32,12 @@
|
||||
#ifndef QNX_INTERNAL_BLACKBERRYDEVICECONFIGURATIONWIZARDPAGES_H
|
||||
#define QNX_INTERNAL_BLACKBERRYDEVICECONFIGURATIONWIZARDPAGES_H
|
||||
|
||||
#include "blackberrydevicelistdetector.h"
|
||||
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
|
||||
#include <QWizardPage>
|
||||
#include <QListWidgetItem>
|
||||
|
||||
namespace QSsh {
|
||||
class SshKeyGenerator;
|
||||
@@ -52,6 +55,10 @@ class BlackBerryDeviceConfigurationWizardSetupPage : public QWizardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum ItemKind {
|
||||
SpecifyManually, Autodetected, PleaseWait, Note
|
||||
};
|
||||
|
||||
explicit BlackBerryDeviceConfigurationWizardSetupPage(QWidget *parent = 0);
|
||||
~BlackBerryDeviceConfigurationWizardSetupPage();
|
||||
|
||||
@@ -63,13 +70,19 @@ public:
|
||||
QString password() const;
|
||||
QString debugToken() const;
|
||||
ProjectExplorer::IDevice::MachineType machineType() const;
|
||||
|
||||
private slots:
|
||||
void handleMachineTypeChanged();
|
||||
void requestDebugToken();
|
||||
void onDeviceSelectionChanged();
|
||||
void onDeviceDetected(const QString &deviceName, const QString &hostName, const BlackBerryDeviceListDetector::DeviceType deviceType);
|
||||
void onDeviceListDetectorFinished();
|
||||
|
||||
private:
|
||||
void refreshDeviceList();
|
||||
QListWidgetItem *createDeviceListItem(const QString &displayName, ItemKind itemKind) const;
|
||||
QListWidgetItem *findDeviceListItem(ItemKind itemKind) const;
|
||||
|
||||
Ui::BlackBerryDeviceConfigurationWizardSetupPage *m_ui;
|
||||
BlackBerryDeviceListDetector *m_deviceListDetector;
|
||||
};
|
||||
|
||||
class BlackBerryDeviceConfigurationWizardSshKeyPage : public QWizardPage
|
||||
@@ -109,4 +122,6 @@ public:
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
||||
|
||||
Q_DECLARE_METATYPE(Qnx::Internal::BlackBerryDeviceConfigurationWizardSetupPage::ItemKind)
|
||||
|
||||
#endif // QNX_INTERNAL_BLACKBERRYDEVICECONFIGURATIONWIZARDPAGES_H
|
||||
|
@@ -6,126 +6,119 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>546</width>
|
||||
<height>170</height>
|
||||
<width>612</width>
|
||||
<height>303</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>WizardPage</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>The name to identify this configuration:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="deviceListWidget"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="deviceName"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Device type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="physicalDevice">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Physical device</string>
|
||||
<string>Configuration name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="simulator">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="deviceName"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Simulator</string>
|
||||
<string>Device type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>The device's host name or IP address:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="physicalDevice">
|
||||
<property name="text">
|
||||
<string>Physical device</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="simulator">
|
||||
<property name="text">
|
||||
<string>Simulator</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>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Device host name or IP address:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="deviceHostIp"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Device password:</string>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Device password:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="password">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</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>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Debug token:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="Utils::PathChooser" name="debugToken" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="requestButton">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Request</string>
|
||||
<string>Debug token:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="Utils::PathChooser" name="debugToken" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="requestButton">
|
||||
<property name="text">
|
||||
<string>Request</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
92
src/plugins/qnx/blackberrydevicelistdetector.cpp
Normal file
92
src/plugins/qnx/blackberrydevicelistdetector.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 - 2013 Research In Motion
|
||||
**
|
||||
** Contact: Research In Motion (blackberry-qt@qnx.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 "blackberrydevicelistdetector.h"
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
|
||||
BlackBerryDeviceListDetector::BlackBerryDeviceListDetector(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_process(new QProcess(this))
|
||||
{
|
||||
m_process->setProcessChannelMode(QProcess::MergedChannels);
|
||||
|
||||
connect(m_process, SIGNAL(readyRead()), this, SLOT(processReadyRead()));
|
||||
connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished()));
|
||||
connect(m_process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processFinished()));
|
||||
}
|
||||
|
||||
void BlackBerryDeviceListDetector::detectDeviceList()
|
||||
{
|
||||
if (m_process->state() != QProcess::NotRunning)
|
||||
return;
|
||||
|
||||
const QString command = BlackBerryNdkProcess::resolveNdkToolPath(QLatin1String("blackberry-deploy"));
|
||||
QStringList arguments;
|
||||
arguments << QLatin1String("-devices");
|
||||
|
||||
m_process->start(command, arguments, QIODevice::ReadWrite | QIODevice::Unbuffered);
|
||||
}
|
||||
|
||||
void BlackBerryDeviceListDetector::processReadyRead()
|
||||
{
|
||||
while (m_process->canReadLine())
|
||||
processData(readProcessLine());
|
||||
}
|
||||
|
||||
void BlackBerryDeviceListDetector::processFinished()
|
||||
{
|
||||
while (!m_process->atEnd())
|
||||
processData(readProcessLine());
|
||||
emit finished();
|
||||
}
|
||||
|
||||
const QString BlackBerryDeviceListDetector::readProcessLine()
|
||||
{
|
||||
QByteArray bytes = m_process->readLine();
|
||||
while (bytes.endsWith('\r') || bytes.endsWith('\n'))
|
||||
bytes.chop(1);
|
||||
return QString::fromLocal8Bit(bytes);
|
||||
}
|
||||
|
||||
void BlackBerryDeviceListDetector::processData(const QString &line)
|
||||
{
|
||||
// line format is: deviceName,deviceHostName,deviceType,deviceDisplayName
|
||||
QStringList list = line.split(QLatin1String(","));
|
||||
if (list.count() == 4) {
|
||||
emit deviceDetected (list[3].isEmpty() ? list[0] : list[3], list[1], QLatin1String("Simulator") == list[2] ? Simulator : Device);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
78
src/plugins/qnx/blackberrydevicelistdetector.h
Normal file
78
src/plugins/qnx/blackberrydevicelistdetector.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 - 2013 Research In Motion
|
||||
**
|
||||
** Contact: Research In Motion (blackberry-qt@qnx.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_BLACKBERRYDEVICELISTDETECTOR_H
|
||||
#define QNX_INTERNAL_BLACKBERRYDEVICELISTDETECTOR_H
|
||||
|
||||
#include "blackberryndkprocess.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
namespace Qnx {
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class BlackBerryDeviceListDetector : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum DeviceType {
|
||||
Device,
|
||||
Simulator
|
||||
};
|
||||
|
||||
explicit BlackBerryDeviceListDetector(QObject *parent = 0);
|
||||
|
||||
void detectDeviceList();
|
||||
|
||||
signals:
|
||||
void deviceDetected(
|
||||
const QString &deviceName, const QString &deviceHostName,
|
||||
const BlackBerryDeviceListDetector::DeviceType deviceType);
|
||||
void finished();
|
||||
|
||||
private slots:
|
||||
void processReadyRead();
|
||||
void processFinished();
|
||||
|
||||
private:
|
||||
const QString readProcessLine();
|
||||
void processData(const QString &line);
|
||||
|
||||
QProcess *m_process;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
||||
|
||||
Q_DECLARE_METATYPE(Qnx::Internal::BlackBerryDeviceListDetector::DeviceType)
|
||||
|
||||
#endif // QNX_INTERNAL_BLACKBERRYDEVICELISTDETECTOR_H
|
@@ -53,19 +53,24 @@ BlackBerryNdkProcess::BlackBerryNdkProcess(const QString &command, QObject *pare
|
||||
this, SLOT(processError(QProcess::ProcessError)));
|
||||
}
|
||||
|
||||
QString BlackBerryNdkProcess::command() const
|
||||
const QString BlackBerryNdkProcess::resolveNdkToolPath(const QString &tool)
|
||||
{
|
||||
QString command;
|
||||
QString toolPath;
|
||||
QMultiMap<QString, QString> qnxEnv = BlackBerryConfigurationManager::instance().defaultQnxEnv();
|
||||
if (!qnxEnv.isEmpty()) {
|
||||
command = qnxEnv.value(QLatin1String("QNX_HOST"))
|
||||
+ (QLatin1String("/usr/bin/")) + m_command;
|
||||
toolPath = qnxEnv.value(QLatin1String("QNX_HOST"))
|
||||
+ (QLatin1String("/usr/bin/")) + tool;
|
||||
|
||||
if (Utils::HostOsInfo::isWindowsHost())
|
||||
command += QLatin1String(".bat");
|
||||
toolPath += QLatin1String(".bat");
|
||||
}
|
||||
|
||||
return command;
|
||||
return toolPath;
|
||||
}
|
||||
|
||||
QString BlackBerryNdkProcess::command() const
|
||||
{
|
||||
return resolveNdkToolPath(m_command);
|
||||
}
|
||||
|
||||
void BlackBerryNdkProcess::start(const QStringList &arguments)
|
||||
|
@@ -56,6 +56,13 @@ public:
|
||||
UserStatus
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Resolves full path to an NDK cmd-line tool.
|
||||
* @return a full-path to the NDK cmd-line tool;
|
||||
* or empty QString when no default QNX configuration is found.
|
||||
*/
|
||||
static const QString resolveNdkToolPath(const QString &tool);
|
||||
|
||||
signals:
|
||||
void finished(int status);
|
||||
|
||||
|
@@ -94,7 +94,8 @@ SOURCES += qnxplugin.cpp \
|
||||
blackberrysetupwizardpages.cpp \
|
||||
blackberryutils.cpp \
|
||||
qnxdevicetester.cpp \
|
||||
blackberryconfigurationmanager.cpp
|
||||
blackberryconfigurationmanager.cpp \
|
||||
blackberrydevicelistdetector.cpp
|
||||
|
||||
HEADERS += qnxplugin.h\
|
||||
qnxconstants.h \
|
||||
@@ -188,7 +189,8 @@ HEADERS += qnxplugin.h\
|
||||
blackberrysetupwizardpages.h \
|
||||
blackberryutils.h \
|
||||
qnxdevicetester.h \
|
||||
blackberryconfigurationmanager.h
|
||||
blackberryconfigurationmanager.h \
|
||||
blackberrydevicelistdetector.h
|
||||
|
||||
FORMS += \
|
||||
blackberrydeviceconfigurationwizardsetuppage.ui \
|
||||
|
@@ -113,6 +113,8 @@ QtcPlugin {
|
||||
"blackberrydeviceconnection.h",
|
||||
"blackberrydeviceconnectionmanager.cpp",
|
||||
"blackberrydeviceconnectionmanager.h",
|
||||
"blackberrydevicelistdetector.cpp",
|
||||
"blackberrydevicelistdetector.h",
|
||||
"blackberrydeviceprocesssupport.h",
|
||||
"blackberrydeviceprocesssupport.cpp",
|
||||
"blackberryqtversion.cpp",
|
||||
|
Reference in New Issue
Block a user