forked from qt-creator/qt-creator
Qnx: Auto detect device PIN when requesting debugToken
Task-number: QTCREATORBUG-9062 Change-Id: Ib6bc2f2da6f6cfe9e78eb1d9d7e9d8f6abbd9948 Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com> Reviewed-by: Kevin Krammer <kevin.krammer@kdab.com>
This commit is contained in:
committed by
Rafael Roquetto
parent
8b07cc395d
commit
c6449e55ff
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include "blackberrydebugtokenrequestdialog.h"
|
#include "blackberrydebugtokenrequestdialog.h"
|
||||||
#include "blackberrydebugtokenrequester.h"
|
#include "blackberrydebugtokenrequester.h"
|
||||||
|
#include "blackberrydeviceinformation.h"
|
||||||
#include "blackberryconfiguration.h"
|
#include "blackberryconfiguration.h"
|
||||||
#include "blackberrycertificate.h"
|
#include "blackberrycertificate.h"
|
||||||
#include "ui_blackberrydebugtokenrequestdialog.h"
|
#include "ui_blackberrydebugtokenrequestdialog.h"
|
||||||
@@ -46,7 +47,8 @@ BlackBerryDebugTokenRequestDialog::BlackBerryDebugTokenRequestDialog(
|
|||||||
QWidget *parent, Qt::WindowFlags f) :
|
QWidget *parent, Qt::WindowFlags f) :
|
||||||
QDialog(parent, f),
|
QDialog(parent, f),
|
||||||
m_ui(new Ui_BlackBerryDebugTokenRequestDialog),
|
m_ui(new Ui_BlackBerryDebugTokenRequestDialog),
|
||||||
m_requester(new BlackBerryDebugTokenRequester)
|
m_requester(new BlackBerryDebugTokenRequester(this)),
|
||||||
|
m_deviceInfo(new BlackBerryDeviceInformation(this))
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
m_ui->progressBar->hide();
|
m_ui->progressBar->hide();
|
||||||
@@ -83,6 +85,13 @@ BlackBerryDebugTokenRequestDialog::BlackBerryDebugTokenRequestDialog(
|
|||||||
this, SLOT(checkBoxChanged(int)));
|
this, SLOT(checkBoxChanged(int)));
|
||||||
connect(m_requester, SIGNAL(finished(int)),
|
connect(m_requester, SIGNAL(finished(int)),
|
||||||
this, SLOT(debugTokenArrived(int)));
|
this, SLOT(debugTokenArrived(int)));
|
||||||
|
connect(m_deviceInfo, SIGNAL(finished(int)),
|
||||||
|
this, SLOT(setDevicePin(int)));
|
||||||
|
}
|
||||||
|
|
||||||
|
BlackBerryDebugTokenRequestDialog::~BlackBerryDebugTokenRequestDialog()
|
||||||
|
{
|
||||||
|
delete m_ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString BlackBerryDebugTokenRequestDialog::debugToken() const
|
QString BlackBerryDebugTokenRequestDialog::debugToken() const
|
||||||
@@ -90,6 +99,12 @@ QString BlackBerryDebugTokenRequestDialog::debugToken() const
|
|||||||
return m_ui->debugTokenPath->path();
|
return m_ui->debugTokenPath->path();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BlackBerryDebugTokenRequestDialog::setTargetDetails(const QString &deviceIp, const QString &password)
|
||||||
|
{
|
||||||
|
m_ui->devicePin->setPlaceholderText(tr("Requesting Device PIN..."));
|
||||||
|
m_deviceInfo->setDeviceTarget(deviceIp, password);
|
||||||
|
}
|
||||||
|
|
||||||
void BlackBerryDebugTokenRequestDialog::validate()
|
void BlackBerryDebugTokenRequestDialog::validate()
|
||||||
{
|
{
|
||||||
if (!m_ui->debugTokenPath->isValid()
|
if (!m_ui->debugTokenPath->isValid()
|
||||||
@@ -232,6 +247,19 @@ void BlackBerryDebugTokenRequestDialog::debugTokenArrived(int status)
|
|||||||
setBusy(false);
|
setBusy(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BlackBerryDebugTokenRequestDialog::setDevicePin(int status)
|
||||||
|
{
|
||||||
|
m_ui->devicePin->setPlaceholderText(QString());
|
||||||
|
if (status != BlackBerryDeviceInformation::Success)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const QString devicePin = m_deviceInfo->devicePin();
|
||||||
|
if (devicePin.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_ui->devicePin->setText(devicePin);
|
||||||
|
}
|
||||||
|
|
||||||
void BlackBerryDebugTokenRequestDialog::setBusy(bool busy)
|
void BlackBerryDebugTokenRequestDialog::setBusy(bool busy)
|
||||||
{
|
{
|
||||||
m_okButton->setEnabled(!busy);
|
m_okButton->setEnabled(!busy);
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ namespace Internal {
|
|||||||
|
|
||||||
class Ui_BlackBerryDebugTokenRequestDialog;
|
class Ui_BlackBerryDebugTokenRequestDialog;
|
||||||
class BlackBerryDebugTokenRequester;
|
class BlackBerryDebugTokenRequester;
|
||||||
|
class BlackBerryDeviceInformation;
|
||||||
|
|
||||||
class BlackBerryDebugTokenRequestDialog : public QDialog
|
class BlackBerryDebugTokenRequestDialog : public QDialog
|
||||||
{
|
{
|
||||||
@@ -51,8 +52,10 @@ Q_OBJECT
|
|||||||
public:
|
public:
|
||||||
explicit BlackBerryDebugTokenRequestDialog(QWidget *parent = 0,
|
explicit BlackBerryDebugTokenRequestDialog(QWidget *parent = 0,
|
||||||
Qt::WindowFlags f = 0);
|
Qt::WindowFlags f = 0);
|
||||||
|
~BlackBerryDebugTokenRequestDialog();
|
||||||
|
|
||||||
QString debugToken() const;
|
QString debugToken() const;
|
||||||
|
void setTargetDetails(const QString &deviceIp, const QString &password);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void validate();
|
void validate();
|
||||||
@@ -62,6 +65,7 @@ private slots:
|
|||||||
void expandPath();
|
void expandPath();
|
||||||
void checkBoxChanged(int state);
|
void checkBoxChanged(int state);
|
||||||
void debugTokenArrived(int status);
|
void debugTokenArrived(int status);
|
||||||
|
void setDevicePin(int status);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setBusy(bool busy);
|
void setBusy(bool busy);
|
||||||
@@ -70,6 +74,7 @@ private:
|
|||||||
Ui_BlackBerryDebugTokenRequestDialog *m_ui;
|
Ui_BlackBerryDebugTokenRequestDialog *m_ui;
|
||||||
|
|
||||||
BlackBerryDebugTokenRequester *m_requester;
|
BlackBerryDebugTokenRequester *m_requester;
|
||||||
|
BlackBerryDeviceInformation *m_deviceInfo;
|
||||||
|
|
||||||
QPushButton *m_cancelButton;
|
QPushButton *m_cancelButton;
|
||||||
QPushButton *m_okButton;
|
QPushButton *m_okButton;
|
||||||
|
|||||||
@@ -122,6 +122,9 @@ void BlackBerryDeviceConfigurationWidget::requestDebugToken()
|
|||||||
{
|
{
|
||||||
BlackBerryDebugTokenRequestDialog dialog;
|
BlackBerryDebugTokenRequestDialog dialog;
|
||||||
|
|
||||||
|
if (!ui->hostLineEdit->text().isEmpty() && !ui->pwdLineEdit->text().isEmpty())
|
||||||
|
dialog.setTargetDetails(ui->hostLineEdit->text(), ui->pwdLineEdit->text());
|
||||||
|
|
||||||
const int result = dialog.exec();
|
const int result = dialog.exec();
|
||||||
|
|
||||||
if (result != QDialog::Accepted)
|
if (result != QDialog::Accepted)
|
||||||
|
|||||||
@@ -133,6 +133,9 @@ void BlackBerryDeviceConfigurationWizardSetupPage::requestDebugToken()
|
|||||||
{
|
{
|
||||||
BlackBerryDebugTokenRequestDialog dialog;
|
BlackBerryDebugTokenRequestDialog dialog;
|
||||||
|
|
||||||
|
if (!m_ui->deviceHostIp->text().isEmpty() && !m_ui->password->text().isEmpty())
|
||||||
|
dialog.setTargetDetails(m_ui->deviceHostIp->text(), m_ui->password->text());
|
||||||
|
|
||||||
const int result = dialog.exec();
|
const int result = dialog.exec();
|
||||||
|
|
||||||
if (result != QDialog::Accepted)
|
if (result != QDialog::Accepted)
|
||||||
|
|||||||
91
src/plugins/qnx/blackberrydeviceinformation.cpp
Normal file
91
src/plugins/qnx/blackberrydeviceinformation.cpp
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** 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 "blackberrydeviceinformation.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
static const char PROCESS_NAME[] = "blackberry-deploy";
|
||||||
|
static const char ERR_NO_ROUTE_HOST[] = "Cannot connect";
|
||||||
|
static const char ERR_AUTH_FAILED[] = "Authentication failed";
|
||||||
|
static const char ERR_DEVELOPMENT_MODE_DISABLED[] = "Device is not in the Development Mode";
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Qnx {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
BlackBerryDeviceInformation::BlackBerryDeviceInformation(QObject *parent) :
|
||||||
|
BlackBerryNdkProcess(QLatin1String(PROCESS_NAME), parent)
|
||||||
|
{
|
||||||
|
addErrorStringMapping(QLatin1String(ERR_NO_ROUTE_HOST), NoRouteToHost);
|
||||||
|
addErrorStringMapping(QLatin1String(ERR_AUTH_FAILED), AuthenticationFailed);
|
||||||
|
addErrorStringMapping(QLatin1String(ERR_DEVELOPMENT_MODE_DISABLED), DevelopmentModeDisabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlackBerryDeviceInformation::setDeviceTarget(const QString &deviceIp, const QString &devicePassword)
|
||||||
|
{
|
||||||
|
QStringList arguments;
|
||||||
|
|
||||||
|
arguments << QLatin1String("-listDeviceInfo")
|
||||||
|
<< QLatin1String("-device")
|
||||||
|
<< deviceIp
|
||||||
|
<< QLatin1String("-password")
|
||||||
|
<< devicePassword;
|
||||||
|
|
||||||
|
start(arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BlackBerryDeviceInformation::devicePin() const
|
||||||
|
{
|
||||||
|
return m_devicePin;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BlackBerryDeviceInformation::deviceOS() const
|
||||||
|
{
|
||||||
|
return m_deviceOS;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BlackBerryDeviceInformation::hardwareId() const
|
||||||
|
{
|
||||||
|
return m_hardwareId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlackBerryDeviceInformation::processData(const QString &line)
|
||||||
|
{
|
||||||
|
if (line.startsWith(QLatin1String("devicepin::")))
|
||||||
|
m_devicePin = line.split(QLatin1String("::")).at(1).trimmed();
|
||||||
|
else if (line.startsWith(QLatin1String("device_os::")))
|
||||||
|
m_deviceOS = line.split(QLatin1String("::")).at(1).trimmed();
|
||||||
|
else if (line.startsWith(QLatin1String("hardwareid::")))
|
||||||
|
m_hardwareId = line.split(QLatin1String("::")).at(1).trimmed();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Qnx
|
||||||
76
src/plugins/qnx/blackberrydeviceinformation.h
Normal file
76
src/plugins/qnx/blackberrydeviceinformation.h
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** 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_BLACKBERRYDEVICEINFO_H
|
||||||
|
#define QNX_INTERNAL_BLACKBERRYDEVICEINFO_H
|
||||||
|
|
||||||
|
#include "blackberryndkprocess.h"
|
||||||
|
|
||||||
|
namespace Qnx {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class BlackBerryDeviceInformation : public BlackBerryNdkProcess
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum ReturnStatus
|
||||||
|
{
|
||||||
|
NoRouteToHost = UserStatus,
|
||||||
|
AuthenticationFailed,
|
||||||
|
DevelopmentModeDisabled,
|
||||||
|
FailedToStartInferiorProcess,
|
||||||
|
InferiorProcessTimedOut,
|
||||||
|
InferiorProcessCrashed,
|
||||||
|
InferiorProcessWriteError,
|
||||||
|
InferiorProcessReadError
|
||||||
|
};
|
||||||
|
|
||||||
|
explicit BlackBerryDeviceInformation(QObject *parent = 0);
|
||||||
|
|
||||||
|
void setDeviceTarget(const QString &deviceIp, const QString &devicePassword);
|
||||||
|
|
||||||
|
QString devicePin() const;
|
||||||
|
QString deviceOS() const;
|
||||||
|
QString hardwareId() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_devicePin;
|
||||||
|
QString m_deviceOS;
|
||||||
|
QString m_hardwareId;
|
||||||
|
|
||||||
|
void processData(const QString &line);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // QNX_INTERNAL_BLACKBERRYDEBUGTOKENUPLOADER_H
|
||||||
@@ -80,21 +80,18 @@ void BlackBerryNdkProcess::addErrorStringMapping(
|
|||||||
|
|
||||||
void BlackBerryNdkProcess::processFinished()
|
void BlackBerryNdkProcess::processFinished()
|
||||||
{
|
{
|
||||||
|
QTextStream processOutput(m_process);
|
||||||
if (m_process->exitCode() == 0) {
|
if (m_process->exitCode() == 0) {
|
||||||
|
while (!processOutput.atEnd())
|
||||||
|
processData(processOutput.readLine());
|
||||||
|
|
||||||
emit finished(Success);
|
emit finished(Success);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextStream processOutput(m_process);
|
|
||||||
|
|
||||||
QString errorString;
|
|
||||||
int returnStatus = UnknownError;
|
int returnStatus = UnknownError;
|
||||||
|
|
||||||
while (!processOutput.atEnd()) {
|
while (!processOutput.atEnd()) {
|
||||||
const QString line = processOutput.readLine();
|
returnStatus = errorLineToReturnStatus(processOutput.readLine());
|
||||||
|
|
||||||
returnStatus = errorLineToReturnStatus(line);
|
|
||||||
|
|
||||||
if (returnStatus >= 0)
|
if (returnStatus >= 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -144,5 +141,10 @@ int BlackBerryNdkProcess::errorLineToReturnStatus(const QString &line) const
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BlackBerryNdkProcess::processData(const QString &line)
|
||||||
|
{
|
||||||
|
Q_UNUSED(line);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Qnx
|
} // namespace Qnx
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int errorLineToReturnStatus(const QString &line) const;
|
int errorLineToReturnStatus(const QString &line) const;
|
||||||
|
virtual void processData(const QString &line);
|
||||||
|
|
||||||
QProcess *m_process;
|
QProcess *m_process;
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ SOURCES += qnxplugin.cpp \
|
|||||||
blackberrycheckdevmodestep.cpp \
|
blackberrycheckdevmodestep.cpp \
|
||||||
blackberrycheckdevmodestepconfigwidget.cpp \
|
blackberrycheckdevmodestepconfigwidget.cpp \
|
||||||
blackberrydeviceconnection.cpp \
|
blackberrydeviceconnection.cpp \
|
||||||
blackberrydeviceconnectionmanager.cpp
|
blackberrydeviceconnectionmanager.cpp \
|
||||||
|
blackberrydeviceinformation.cpp
|
||||||
|
|
||||||
HEADERS += qnxplugin.h\
|
HEADERS += qnxplugin.h\
|
||||||
qnxconstants.h \
|
qnxconstants.h \
|
||||||
@@ -150,7 +151,8 @@ HEADERS += qnxplugin.h\
|
|||||||
blackberrycheckdevmodestep.h \
|
blackberrycheckdevmodestep.h \
|
||||||
blackberrycheckdevmodestepconfigwidget.h \
|
blackberrycheckdevmodestepconfigwidget.h \
|
||||||
blackberrydeviceconnection.h \
|
blackberrydeviceconnection.h \
|
||||||
blackberrydeviceconnectionmanager.h
|
blackberrydeviceconnectionmanager.h \
|
||||||
|
blackberrydeviceinformation.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
blackberrydeviceconfigurationwizardsetuppage.ui \
|
blackberrydeviceconfigurationwizardsetuppage.ui \
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ QtcPlugin {
|
|||||||
"blackberrydebugtokenreader.h",
|
"blackberrydebugtokenreader.h",
|
||||||
"blackberrydeviceconfiguration.cpp",
|
"blackberrydeviceconfiguration.cpp",
|
||||||
"blackberrydeviceconfiguration.h",
|
"blackberrydeviceconfiguration.h",
|
||||||
|
"blackberrydeviceinformation.cpp",
|
||||||
|
"blackberrydeviceinformation.h",
|
||||||
"blackberrydeviceconfigurationfactory.cpp",
|
"blackberrydeviceconfigurationfactory.cpp",
|
||||||
"blackberrydeviceconfigurationfactory.h",
|
"blackberrydeviceconfigurationfactory.h",
|
||||||
"blackberrydeviceconfigurationwidget.cpp",
|
"blackberrydeviceconfigurationwidget.cpp",
|
||||||
|
|||||||
Reference in New Issue
Block a user