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 "blackberrydebugtokenrequester.h"
|
||||
#include "blackberrydeviceinformation.h"
|
||||
#include "blackberryconfiguration.h"
|
||||
#include "blackberrycertificate.h"
|
||||
#include "ui_blackberrydebugtokenrequestdialog.h"
|
||||
@@ -46,7 +47,8 @@ BlackBerryDebugTokenRequestDialog::BlackBerryDebugTokenRequestDialog(
|
||||
QWidget *parent, Qt::WindowFlags f) :
|
||||
QDialog(parent, f),
|
||||
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->progressBar->hide();
|
||||
@@ -83,6 +85,13 @@ BlackBerryDebugTokenRequestDialog::BlackBerryDebugTokenRequestDialog(
|
||||
this, SLOT(checkBoxChanged(int)));
|
||||
connect(m_requester, SIGNAL(finished(int)),
|
||||
this, SLOT(debugTokenArrived(int)));
|
||||
connect(m_deviceInfo, SIGNAL(finished(int)),
|
||||
this, SLOT(setDevicePin(int)));
|
||||
}
|
||||
|
||||
BlackBerryDebugTokenRequestDialog::~BlackBerryDebugTokenRequestDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
QString BlackBerryDebugTokenRequestDialog::debugToken() const
|
||||
@@ -90,6 +99,12 @@ QString BlackBerryDebugTokenRequestDialog::debugToken() const
|
||||
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()
|
||||
{
|
||||
if (!m_ui->debugTokenPath->isValid()
|
||||
@@ -232,6 +247,19 @@ void BlackBerryDebugTokenRequestDialog::debugTokenArrived(int status)
|
||||
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)
|
||||
{
|
||||
m_okButton->setEnabled(!busy);
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace Internal {
|
||||
|
||||
class Ui_BlackBerryDebugTokenRequestDialog;
|
||||
class BlackBerryDebugTokenRequester;
|
||||
class BlackBerryDeviceInformation;
|
||||
|
||||
class BlackBerryDebugTokenRequestDialog : public QDialog
|
||||
{
|
||||
@@ -51,8 +52,10 @@ Q_OBJECT
|
||||
public:
|
||||
explicit BlackBerryDebugTokenRequestDialog(QWidget *parent = 0,
|
||||
Qt::WindowFlags f = 0);
|
||||
~BlackBerryDebugTokenRequestDialog();
|
||||
|
||||
QString debugToken() const;
|
||||
void setTargetDetails(const QString &deviceIp, const QString &password);
|
||||
|
||||
private slots:
|
||||
void validate();
|
||||
@@ -62,6 +65,7 @@ private slots:
|
||||
void expandPath();
|
||||
void checkBoxChanged(int state);
|
||||
void debugTokenArrived(int status);
|
||||
void setDevicePin(int status);
|
||||
|
||||
private:
|
||||
void setBusy(bool busy);
|
||||
@@ -70,6 +74,7 @@ private:
|
||||
Ui_BlackBerryDebugTokenRequestDialog *m_ui;
|
||||
|
||||
BlackBerryDebugTokenRequester *m_requester;
|
||||
BlackBerryDeviceInformation *m_deviceInfo;
|
||||
|
||||
QPushButton *m_cancelButton;
|
||||
QPushButton *m_okButton;
|
||||
|
||||
@@ -122,6 +122,9 @@ void BlackBerryDeviceConfigurationWidget::requestDebugToken()
|
||||
{
|
||||
BlackBerryDebugTokenRequestDialog dialog;
|
||||
|
||||
if (!ui->hostLineEdit->text().isEmpty() && !ui->pwdLineEdit->text().isEmpty())
|
||||
dialog.setTargetDetails(ui->hostLineEdit->text(), ui->pwdLineEdit->text());
|
||||
|
||||
const int result = dialog.exec();
|
||||
|
||||
if (result != QDialog::Accepted)
|
||||
|
||||
@@ -133,6 +133,9 @@ void BlackBerryDeviceConfigurationWizardSetupPage::requestDebugToken()
|
||||
{
|
||||
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();
|
||||
|
||||
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()
|
||||
{
|
||||
QTextStream processOutput(m_process);
|
||||
if (m_process->exitCode() == 0) {
|
||||
while (!processOutput.atEnd())
|
||||
processData(processOutput.readLine());
|
||||
|
||||
emit finished(Success);
|
||||
return;
|
||||
}
|
||||
|
||||
QTextStream processOutput(m_process);
|
||||
|
||||
QString errorString;
|
||||
int returnStatus = UnknownError;
|
||||
|
||||
while (!processOutput.atEnd()) {
|
||||
const QString line = processOutput.readLine();
|
||||
|
||||
returnStatus = errorLineToReturnStatus(line);
|
||||
|
||||
returnStatus = errorLineToReturnStatus(processOutput.readLine());
|
||||
if (returnStatus >= 0)
|
||||
break;
|
||||
}
|
||||
@@ -144,5 +141,10 @@ int BlackBerryNdkProcess::errorLineToReturnStatus(const QString &line) const
|
||||
return -1;
|
||||
}
|
||||
|
||||
void BlackBerryNdkProcess::processData(const QString &line)
|
||||
{
|
||||
Q_UNUSED(line);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
||||
|
||||
@@ -73,6 +73,7 @@ private slots:
|
||||
|
||||
private:
|
||||
int errorLineToReturnStatus(const QString &line) const;
|
||||
virtual void processData(const QString &line);
|
||||
|
||||
QProcess *m_process;
|
||||
|
||||
|
||||
@@ -75,7 +75,8 @@ SOURCES += qnxplugin.cpp \
|
||||
blackberrycheckdevmodestep.cpp \
|
||||
blackberrycheckdevmodestepconfigwidget.cpp \
|
||||
blackberrydeviceconnection.cpp \
|
||||
blackberrydeviceconnectionmanager.cpp
|
||||
blackberrydeviceconnectionmanager.cpp \
|
||||
blackberrydeviceinformation.cpp
|
||||
|
||||
HEADERS += qnxplugin.h\
|
||||
qnxconstants.h \
|
||||
@@ -150,7 +151,8 @@ HEADERS += qnxplugin.h\
|
||||
blackberrycheckdevmodestep.h \
|
||||
blackberrycheckdevmodestepconfigwidget.h \
|
||||
blackberrydeviceconnection.h \
|
||||
blackberrydeviceconnectionmanager.h
|
||||
blackberrydeviceconnectionmanager.h \
|
||||
blackberrydeviceinformation.h
|
||||
|
||||
FORMS += \
|
||||
blackberrydeviceconfigurationwizardsetuppage.ui \
|
||||
|
||||
@@ -70,6 +70,8 @@ QtcPlugin {
|
||||
"blackberrydebugtokenreader.h",
|
||||
"blackberrydeviceconfiguration.cpp",
|
||||
"blackberrydeviceconfiguration.h",
|
||||
"blackberrydeviceinformation.cpp",
|
||||
"blackberrydeviceinformation.h",
|
||||
"blackberrydeviceconfigurationfactory.cpp",
|
||||
"blackberrydeviceconfigurationfactory.h",
|
||||
"blackberrydeviceconfigurationwidget.cpp",
|
||||
|
||||
Reference in New Issue
Block a user