aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Nätterlund <tobias.naetterlund.qnx@kdab.com>2013-03-14 12:39:17 +0100
committerTobias Nätterlund <tobias.naetterlund@kdab.com>2013-03-28 12:00:51 +0100
commit5c36c594fe38f9825983584598b1bdf8a7351241 (patch)
tree7f9f6be60d0dd1a1972b1d18c73b749f6eb34628
parent44200e0feebab4f71bf6d5131905f002b4964137 (diff)
QNX: Refactored connection handling for BlackBerry devices
The blackberry-connect connection is now established at Qt Creator startup, and taken down when Qt Creator shuts down. The user also has the ability to disconnect manually in the Device settings widget. The connection status is shown in the Devices settings widget, as well as in the project selector. And it is impossible run or debug an application without having the device connected. Change-Id: I64f2e48a647e6d850851d2f20d0ec7bbd5980ea5 Reviewed-by: Christian Kandeler <christian.kandeler@digia.com> Reviewed-by: Nicolas Arnaud-Cormos <nicolas@kdab.com> Reviewed-by: Mehdi Fekari <mfekari@rim.com>
-rw-r--r--src/plugins/projectexplorer/devicesupport/devicemanager.cpp12
-rw-r--r--src/plugins/projectexplorer/devicesupport/devicemanagermodel.cpp3
-rw-r--r--src/plugins/qnx/blackberryconnect.cpp190
-rw-r--r--src/plugins/qnx/blackberrydebugsupport.cpp20
-rw-r--r--src/plugins/qnx/blackberrydebugsupport.h4
-rw-r--r--src/plugins/qnx/blackberrydeviceconfiguration.cpp27
-rw-r--r--src/plugins/qnx/blackberrydeviceconfigurationwidget.cpp25
-rw-r--r--src/plugins/qnx/blackberrydeviceconfigurationwidget.h2
-rw-r--r--src/plugins/qnx/blackberrydeviceconfigurationwidget.ui18
-rw-r--r--src/plugins/qnx/blackberrydeviceconnection.cpp145
-rw-r--r--src/plugins/qnx/blackberrydeviceconnection.h (renamed from src/plugins/qnx/blackberryconnect.h)62
-rw-r--r--src/plugins/qnx/blackberrydeviceconnectionmanager.cpp313
-rw-r--r--src/plugins/qnx/blackberrydeviceconnectionmanager.h99
-rw-r--r--src/plugins/qnx/blackberryruncontrol.cpp14
-rw-r--r--src/plugins/qnx/blackberryruncontrol.h2
-rw-r--r--src/plugins/qnx/blackberryruncontrolfactory.cpp9
-rw-r--r--src/plugins/qnx/qnx.pro10
-rw-r--r--src/plugins/qnx/qnx.qbs6
-rw-r--r--src/plugins/qnx/qnxplugin.cpp3
19 files changed, 692 insertions, 272 deletions
diff --git a/src/plugins/projectexplorer/devicesupport/devicemanager.cpp b/src/plugins/projectexplorer/devicesupport/devicemanager.cpp
index bbfd502ec7..c2eada0ef8 100644
--- a/src/plugins/projectexplorer/devicesupport/devicemanager.cpp
+++ b/src/plugins/projectexplorer/devicesupport/devicemanager.cpp
@@ -281,16 +281,18 @@ void DeviceManager::removeDevice(Core::Id id)
void DeviceManager::setDeviceState(Core::Id deviceId, IDevice::DeviceState deviceState)
{
+ // To see the state change in the DeviceSettingsWidget. This has to happen before
+ // the pos check below, in case the device is only present in the cloned instance.
+ if (this == instance() && d->clonedInstance)
+ d->clonedInstance->setDeviceState(deviceId, deviceState);
+
const int pos = d->indexForId(deviceId);
- QTC_ASSERT(pos != -1, return);
+ if (pos < 0)
+ return;
IDevice::Ptr &device = d->devices[pos];
if (device->deviceState() == deviceState)
return;
- // To see the state change in the DeviceSettingsWidget
- if (this == instance() && d->clonedInstance)
- d->clonedInstance->setDeviceState(deviceId, deviceState);
-
device->setDeviceState(deviceState);
emit deviceUpdated(deviceId);
emit updated();
diff --git a/src/plugins/projectexplorer/devicesupport/devicemanagermodel.cpp b/src/plugins/projectexplorer/devicesupport/devicemanagermodel.cpp
index aa8b9e55d1..c935d41af8 100644
--- a/src/plugins/projectexplorer/devicesupport/devicemanagermodel.cpp
+++ b/src/plugins/projectexplorer/devicesupport/devicemanagermodel.cpp
@@ -131,7 +131,8 @@ void DeviceManagerModel::handleDeviceRemoved(Core::Id id)
void DeviceManagerModel::handleDeviceUpdated(Core::Id id)
{
const int idx = indexForId(id);
- QTC_ASSERT(idx != -1, return);
+ if (idx < 0) // This occurs when a device not matching the type filter is updated
+ return;
d->devices[idx] = d->deviceManager->find(id);
const QModelIndex changedIndex = index(idx, 0);
emit dataChanged(changedIndex, changedIndex);
diff --git a/src/plugins/qnx/blackberryconnect.cpp b/src/plugins/qnx/blackberryconnect.cpp
deleted file mode 100644
index a782b69231..0000000000
--- a/src/plugins/qnx/blackberryconnect.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-/**************************************************************************
-**
-** 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 "blackberryconnect.h"
-#include "blackberryrunconfiguration.h"
-#include "blackberrydeployconfiguration.h"
-
-#include <projectexplorer/buildconfiguration.h>
-#include <projectexplorer/target.h>
-#include <ssh/sshconnection.h>
-#include <utils/qtcassert.h>
-
-#include <QProcess>
-#include <QApplication>
-
-using namespace ProjectExplorer;
-using namespace Qnx;
-using namespace Qnx::Internal;
-
-namespace {
-const char CONNECT_CMD[] = "java";
-const char CONNECT_SUCCESS_MSG[] = "Successfully connected";
-}
-
-QMap<QString, BlackBerryConnect *> BlackBerryConnect::m_instances = QMap<QString, BlackBerryConnect *>();
-QMap<QString, int> BlackBerryConnect::m_usageCount = QMap<QString, int>();
-
-BlackBerryConnect *BlackBerryConnect::instance(BlackBerryRunConfiguration *runConfig)
-{
-
- BlackBerryDeviceConfiguration::ConstPtr device
- = BlackBerryDeviceConfiguration::device(runConfig->target()->kit());
- QString deviceHost;
- if (device)
- deviceHost = device->sshParameters().host;
- if (!m_instances.contains(deviceHost)) {
- m_instances[deviceHost] = new BlackBerryConnect(runConfig);
- m_usageCount[deviceHost] = 1;
- } else {
- ++m_usageCount[deviceHost];
- }
-
- return m_instances[deviceHost];
-}
-
-void BlackBerryConnect::cleanup(BlackBerryConnect *instance)
-{
- const QString deviceHost = instance->m_deviceHost;
- QTC_ASSERT(m_usageCount.contains(deviceHost), return);
-
- --m_usageCount[deviceHost];
- QTC_ASSERT(m_usageCount[deviceHost] >= 0, return);
-
- if (m_usageCount[deviceHost] == 0) {
- m_instances.remove(deviceHost);
- m_usageCount.remove(deviceHost);
- instance->deleteLater();
- }
-}
-
-BlackBerryConnect::BlackBerryConnect(BlackBerryRunConfiguration *runConfig)
- : QObject()
- , m_connected(false)
-{
- m_process = new QProcess(this);
-
- Utils::Environment env;
- Target *target = runConfig->target();
- if (target->activeBuildConfiguration())
- env = target->activeBuildConfiguration()->environment();
-
- m_process->setEnvironment(env.toStringList());
- m_connectCmd = env.searchInPath(QLatin1String(CONNECT_CMD));
- m_qnxHost = env.value(QLatin1String("QNX_HOST"));
-
- BlackBerryDeviceConfiguration::ConstPtr device
- = BlackBerryDeviceConfiguration::device(target->kit());
- m_deviceHost = device->sshParameters().host;
- m_password = device->sshParameters().password;
- m_publicKeyFile = device->sshParameters().privateKeyFile + QLatin1String(".pub");
-
- connect(m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandardOutput()));
- connect(m_process, SIGNAL(readyReadStandardError()), this, SLOT(readStandardError()));
-}
-
-void BlackBerryConnect::connectToDevice()
-{
- if (m_connected) {
- emit connected();
- return;
- }
-
- QTC_ASSERT(!m_connectCmd.isEmpty() && !m_qnxHost.isEmpty(), return);
-
- // Since killing the blackberry-connect script won't kill the java process it launches, let's just call
- // the java process directly instead.
- QStringList connectArgs;
- connectArgs << QLatin1String("-Xmx512M");
- connectArgs << QLatin1String("-jar") << m_qnxHost + QLatin1String("/usr/lib/Connect.jar");
-
- connectArgs << QLatin1String("-targetHost") << m_deviceHost;
- if (!m_password.isEmpty())
- connectArgs << QLatin1String("-password") << m_password;
- connectArgs << QLatin1String("-sshPublicKey") << m_publicKeyFile;
-
- connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)),
- this, SLOT(handleProcessFinished(int,QProcess::ExitStatus)), Qt::UniqueConnection);
-
- m_process->start(m_connectCmd, connectArgs);
-}
-
-void BlackBerryConnect::disconnectFromDevice()
-{
- if (m_process->state() != QProcess::Running)
- return;
-
- if (m_usageCount[m_deviceHost] == 1) {
- disconnect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)),
- this, SLOT(handleProcessFinished(int,QProcess::ExitStatus)));
- m_process->terminate();
- if (!m_process->waitForFinished(5000))
- m_process->kill();
- m_connected = false;
- }
-}
-
-void BlackBerryConnect::handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
-{
- m_connected = false;
- if (exitCode != 0 || exitStatus != QProcess::NormalExit)
- emit error(m_process->errorString());
-}
-
-void BlackBerryConnect::readStandardOutput()
-{
- m_process->setReadChannel(QProcess::StandardOutput);
- while (m_process->canReadLine()) {
- const QString line = QString::fromLocal8Bit(m_process->readLine());
- emit output(line, Utils::StdOutFormat);
- if (line.contains(QLatin1String(CONNECT_SUCCESS_MSG))) {
- m_connected = true;
- emit connected();
- }
- }
-}
-
-void BlackBerryConnect::readStandardError()
-{
- m_process->setReadChannel(QProcess::StandardError);
- QStringList errorLines;
-
- while (m_process->canReadLine()) {
- const QString line = QString::fromLocal8Bit(m_process->readLine());
- emit output(line, Utils::StdErrFormat);
- if (line.contains(QLatin1String("Error:")))
- errorLines << line.mid(7);
- }
-
- // TODO: Handle error messages better
- if (!errorLines.isEmpty())
- emit error(errorLines.join(QLatin1String("\n")));
-}
diff --git a/src/plugins/qnx/blackberrydebugsupport.cpp b/src/plugins/qnx/blackberrydebugsupport.cpp
index 968f49c1d5..c7c493573a 100644
--- a/src/plugins/qnx/blackberrydebugsupport.cpp
+++ b/src/plugins/qnx/blackberrydebugsupport.cpp
@@ -31,7 +31,6 @@
#include "blackberrydebugsupport.h"
#include "blackberryapplicationrunner.h"
-#include "blackberryconnect.h"
#include <debugger/debuggerrunner.h>
#include <debugger/debuggerengine.h>
@@ -46,36 +45,24 @@ BlackBerryDebugSupport::BlackBerryDebugSupport(BlackBerryRunConfiguration *runCo
, m_engine(runControl->engine())
{
m_runner = new BlackBerryApplicationRunner(true, runConfig, this);
- m_connector = BlackBerryConnect::instance(runConfig);
connect(m_engine, SIGNAL(requestRemoteSetup()), this, SLOT(launchRemoteApplication()));
connect(m_engine, SIGNAL(stateChanged(Debugger::DebuggerState)),
this, SLOT(handleDebuggerStateChanged(Debugger::DebuggerState)));
- connect(m_connector, SIGNAL(error(QString)), this, SLOT(handleConnectorError(QString)));
- connect(m_connector, SIGNAL(connected()), m_runner, SLOT(start()));
- connect(m_connector, SIGNAL(output(QString,Utils::OutputFormat)),
- runControl, SLOT(appendMessage(QString,Utils::OutputFormat)));
-
connect(m_runner, SIGNAL(started()), this, SLOT(handleStarted()));
connect(m_runner, SIGNAL(started()), m_runner, SLOT(checkSlog2Info()));
connect(m_runner, SIGNAL(startFailed(QString)), this, SLOT(handleStartFailed(QString)));
connect(m_runner, SIGNAL(output(QString,Utils::OutputFormat)),
this, SLOT(handleApplicationOutput(QString,Utils::OutputFormat)));
- connect(m_runner, SIGNAL(finished()), m_connector, SLOT(disconnectFromDevice()));
connect(this, SIGNAL(output(QString,Utils::OutputFormat)),
runControl, SLOT(appendMessage(QString,Utils::OutputFormat)));
}
-BlackBerryDebugSupport::~BlackBerryDebugSupport()
-{
- BlackBerryConnect::cleanup(m_connector);
-}
-
void BlackBerryDebugSupport::launchRemoteApplication()
{
- m_connector->connectToDevice();
+ m_runner->start();
}
void BlackBerryDebugSupport::handleStarted()
@@ -97,11 +84,6 @@ void BlackBerryDebugSupport::handleDebuggerStateChanged(Debugger::DebuggerState
}
}
-void BlackBerryDebugSupport::handleConnectorError(const QString &message)
-{
- m_engine->notifyEngineRemoteSetupFailed(message);
-}
-
void BlackBerryDebugSupport::handleApplicationOutput(const QString &msg, Utils::OutputFormat format)
{
Q_UNUSED(format)
diff --git a/src/plugins/qnx/blackberrydebugsupport.h b/src/plugins/qnx/blackberrydebugsupport.h
index d0c9a5beed..6e0a795b5e 100644
--- a/src/plugins/qnx/blackberrydebugsupport.h
+++ b/src/plugins/qnx/blackberrydebugsupport.h
@@ -57,7 +57,6 @@ class BlackBerryDebugSupport : public QObject
public:
explicit BlackBerryDebugSupport(BlackBerryRunConfiguration *runConfig,
Debugger::DebuggerRunControl *runControl);
- ~BlackBerryDebugSupport();
signals:
void output(const QString &msg, Utils::OutputFormat format);
@@ -70,15 +69,12 @@ private slots:
void handleDebuggerStateChanged(Debugger::DebuggerState state);
- void handleConnectorError(const QString &message);
-
void handleApplicationOutput(const QString &msg, Utils::OutputFormat format);
private:
Debugger::DebuggerEngine *m_engine;
BlackBerryApplicationRunner *m_runner;
- BlackBerryConnect *m_connector;
};
} // namespace Internal
diff --git a/src/plugins/qnx/blackberrydeviceconfiguration.cpp b/src/plugins/qnx/blackberrydeviceconfiguration.cpp
index 3013f321e4..7fd5ac0474 100644
--- a/src/plugins/qnx/blackberrydeviceconfiguration.cpp
+++ b/src/plugins/qnx/blackberrydeviceconfiguration.cpp
@@ -33,6 +33,7 @@
#include "qnxconstants.h"
#include "blackberrydeviceconfigurationwidget.h"
+#include "blackberrydeviceconnectionmanager.h"
#include "blackberrydeviceprocesssupport.h"
#include <projectexplorer/kitinformation.h>
@@ -41,6 +42,11 @@ using namespace Qnx;
using namespace Qnx::Internal;
using namespace ProjectExplorer;
+namespace {
+const char ConnectToDeviceActionId[] = "Qnx.BlackBerry.ConnectToDeviceAction";
+const char DisconnectFromDeviceActionId[] = "Qnx.BlackBerry.DisconnectFromDeviceAction";
+}
+
BlackBerryDeviceConfiguration::BlackBerryDeviceConfiguration()
: RemoteLinux::LinuxDevice()
{
@@ -116,19 +122,34 @@ IDeviceWidget *BlackBerryDeviceConfiguration::createWidget()
QList<Core::Id> BlackBerryDeviceConfiguration::actionIds() const
{
- return QList<Core::Id>();
+ return QList<Core::Id>() << Core::Id(ConnectToDeviceActionId)
+ << Core::Id(DisconnectFromDeviceActionId);
}
QString BlackBerryDeviceConfiguration::displayNameForActionId(Core::Id actionId) const
{
- Q_UNUSED(actionId);
+ if (actionId == Core::Id(ConnectToDeviceActionId))
+ return tr("Connect to device");
+ else if (actionId == Core::Id(DisconnectFromDeviceActionId))
+ return tr("Disconnect from device");
+
return QString();
}
void BlackBerryDeviceConfiguration::executeAction(Core::Id actionId, QWidget *parent) const
{
- Q_UNUSED(actionId);
Q_UNUSED(parent);
+
+ const BlackBerryDeviceConfiguration::ConstPtr device =
+ sharedFromThis().staticCast<const BlackBerryDeviceConfiguration>();
+
+ BlackBerryDeviceConnectionManager *connectionManager =
+ BlackBerryDeviceConnectionManager::instance();
+ if (actionId == Core::Id(ConnectToDeviceActionId))
+ connectionManager->connectDevice(device);
+ else if (actionId == Core::Id(DisconnectFromDeviceActionId)
+ && connectionManager->isConnected(id()))
+ connectionManager->disconnectDevice(device);
}
QVariantMap BlackBerryDeviceConfiguration::toMap() const
diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwidget.cpp b/src/plugins/qnx/blackberrydeviceconfigurationwidget.cpp
index 870eb69519..0641e09263 100644
--- a/src/plugins/qnx/blackberrydeviceconfigurationwidget.cpp
+++ b/src/plugins/qnx/blackberrydeviceconfigurationwidget.cpp
@@ -33,9 +33,12 @@
#include "blackberrydebugtokenuploader.h"
#include "blackberrydebugtokenrequestdialog.h"
#include "ui_blackberrydeviceconfigurationwidget.h"
+#include "blackberrydeviceconnectionmanager.h"
#include "qnxconstants.h"
#include <ssh/sshconnection.h>
+#include <texteditor/texteditorsettings.h>
+#include <texteditor/fontsettings.h>
#include <utils/pathchooser.h>
#include <utils/fancylineedit.h>
@@ -53,6 +56,9 @@ BlackBerryDeviceConfigurationWidget::BlackBerryDeviceConfigurationWidget(const I
uploader(new BlackBerryDebugTokenUploader(this))
{
ui->setupUi(this);
+
+ ui->connectionLog->setFont(TextEditor::TextEditorSettings::instance()->fontSettings().font());
+
connect(ui->hostLineEdit, SIGNAL(editingFinished()), this, SLOT(hostNameEditingFinished()));
connect(ui->pwdLineEdit, SIGNAL(editingFinished()), this, SLOT(passwordEditingFinished()));
connect(ui->keyFileLineEdit, SIGNAL(editingFinished()), this, SLOT(keyFileEditingFinished()));
@@ -63,6 +69,11 @@ BlackBerryDeviceConfigurationWidget::BlackBerryDeviceConfigurationWidget(const I
connect(ui->debugToken, SIGNAL(browsingFinished()), this, SLOT(debugTokenEditingFinished()));
connect(uploader, SIGNAL(finished(int)), this, SLOT(uploadFinished(int)));
+ connect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(connectionOutput(Core::Id, QString)),
+ this, SLOT(appendConnectionLog(Core::Id, QString)));
+ connect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(deviceAboutToConnect(Core::Id)),
+ this, SLOT(clearConnectionLog(Core::Id)));
+
ui->debugToken->addButton(tr("Request"), this, SLOT(requestDebugToken()));
ui->debugToken->addButton(tr("Upload"), this, SLOT(uploadDebugToken()));
uploadButton = ui->debugToken->buttonAtIndex(2);
@@ -173,6 +184,18 @@ void BlackBerryDeviceConfigurationWidget::uploadFinished(int status)
QMessageBox::critical(this, tr("Error"), errorString);
}
+void BlackBerryDeviceConfigurationWidget::appendConnectionLog(Core::Id deviceId, const QString &line)
+{
+ if (deviceId == device()->id())
+ ui->connectionLog->appendPlainText(line.trimmed());
+}
+
+void BlackBerryDeviceConfigurationWidget::clearConnectionLog(Core::Id deviceId)
+{
+ if (deviceId == device()->id())
+ ui->connectionLog->clear();
+}
+
void BlackBerryDeviceConfigurationWidget::updateDeviceFromUi()
{
hostNameEditingFinished();
@@ -210,6 +233,8 @@ void BlackBerryDeviceConfigurationWidget::initGui()
progressDialog->setLabelText(tr("Uploading debug token"));
progressDialog->setMinimum(0);
progressDialog->setMaximum(0);
+
+ ui->connectionLog->setPlainText(BlackBerryDeviceConnectionManager::instance()->connectionLog(device()->id()).trimmed());
}
BlackBerryDeviceConfiguration::Ptr BlackBerryDeviceConfigurationWidget::deviceConfiguration() const
diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwidget.h b/src/plugins/qnx/blackberrydeviceconfigurationwidget.h
index 18a77b1e9c..214fa4a378 100644
--- a/src/plugins/qnx/blackberrydeviceconfigurationwidget.h
+++ b/src/plugins/qnx/blackberrydeviceconfigurationwidget.h
@@ -69,6 +69,8 @@ private slots:
void uploadDebugToken();
void updateUploadButton();
void uploadFinished(int status);
+ void appendConnectionLog(Core::Id deviceId, const QString &line);
+ void clearConnectionLog(Core::Id deviceId);
private:
void updateDeviceFromUi();
diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwidget.ui b/src/plugins/qnx/blackberrydeviceconfigurationwidget.ui
index 084ca5d409..f0b583ce21 100644
--- a/src/plugins/qnx/blackberrydeviceconfigurationwidget.ui
+++ b/src/plugins/qnx/blackberrydeviceconfigurationwidget.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>334</width>
- <height>131</height>
+ <height>208</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
@@ -79,6 +79,20 @@
<item row="3" column="1">
<widget class="Utils::PathChooser" name="keyFileLineEdit" native="true"/>
</item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Connection log:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" colspan="2">
+ <widget class="QPlainTextEdit" name="connectionLog">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
</layout>
<zorder>keyFileLineEdit</zorder>
<zorder>hostNameLabel</zorder>
@@ -86,6 +100,8 @@
<zorder>passwordLabel</zorder>
<zorder>keyLabel</zorder>
<zorder>debugTokenLabel</zorder>
+ <zorder>label</zorder>
+ <zorder>connectionLog</zorder>
</widget>
<customwidgets>
<customwidget>
diff --git a/src/plugins/qnx/blackberrydeviceconnection.cpp b/src/plugins/qnx/blackberrydeviceconnection.cpp
new file mode 100644
index 0000000000..77ad6723de
--- /dev/null
+++ b/src/plugins/qnx/blackberrydeviceconnection.cpp
@@ -0,0 +1,145 @@
+/**************************************************************************
+**
+** 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 "blackberrydeviceconnection.h"
+
+#include "blackberryconfiguration.h"
+#include "qnxutils.h"
+
+#include <projectexplorer/devicesupport/devicemanager.h>
+#include <ssh/sshconnection.h>
+#include <utils/environment.h>
+
+#include <QProcess>
+
+using namespace Qnx;
+using namespace Qnx::Internal;
+
+namespace {
+const char CONNECT_SUCCESS_MSG[] = "Successfully connected";
+}
+
+BlackBerryDeviceConnection::BlackBerryDeviceConnection() :
+ QObject(),
+ m_connectionState(Disconnected),
+ m_process(new QProcess(this))
+{
+ connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished()));
+ connect(m_process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processFinished()));
+ connect(m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandardOutput()));
+ connect(m_process, SIGNAL(readyReadStandardError()), this, SLOT(readStandardError()));
+}
+
+void BlackBerryDeviceConnection::connectDevice(const ProjectExplorer::IDevice::ConstPtr &device)
+{
+ Utils::Environment env = Utils::Environment::systemEnvironment();
+ QnxUtils::prependQnxMapToEnvironment(BlackBerryConfiguration::instance().qnxEnv(), env);
+ m_process->setEnvironment(env.toStringList());
+
+ m_host = device->sshParameters().host;
+ const QString password = device->sshParameters().password;
+ const QString publicKeyFile = device->sshParameters().privateKeyFile + QLatin1String(".pub");
+
+ // Since killing the blackberry-connect script won't kill the java process it launches,
+ // let's just call the java process directly instead.
+ QString command = env.searchInPath(QLatin1String("java"));
+
+ QStringList args;
+ args << QLatin1String("-Xmx512M");
+ args << QLatin1String("-jar");
+ args << env.value(QLatin1String("QNX_HOST")) + QLatin1String("/usr/lib/Connect.jar");
+
+ args << QLatin1String("-targetHost") << m_host;
+ if (!password.isEmpty())
+ args << QLatin1String("-password") << password;
+ args << QLatin1String("-sshPublicKey") << publicKeyFile;
+
+ m_connectionState = Connecting;
+ m_process->start(command, args);
+ m_messageLog.clear();
+ emit deviceAboutToConnect();
+}
+
+void BlackBerryDeviceConnection::disconnectDevice()
+{
+ m_process->terminate();
+ if (!m_process->waitForFinished(5000))
+ m_process->kill();
+ m_connectionState = Disconnected;
+}
+
+QString BlackBerryDeviceConnection::host() const
+{
+ return m_host;
+}
+
+BlackBerryDeviceConnection::State BlackBerryDeviceConnection::connectionState()
+{
+ return m_connectionState;
+}
+
+QString BlackBerryDeviceConnection::messageLog() const
+{
+ return m_messageLog;
+}
+
+void BlackBerryDeviceConnection::processFinished()
+{
+ m_connectionState = Disconnected;
+ emit deviceDisconnected();
+}
+
+void BlackBerryDeviceConnection::readStandardOutput()
+{
+ m_process->setReadChannel(QProcess::StandardOutput);
+ while (m_process->canReadLine()) {
+ const QString line = QString::fromLocal8Bit(m_process->readLine());
+
+ emit processOutput(line);
+ m_messageLog.append(line);
+
+ if (line.contains(QLatin1String(CONNECT_SUCCESS_MSG))) {
+ m_connectionState = Connected;
+ emit deviceConnected();
+ }
+ }
+}
+
+void BlackBerryDeviceConnection::readStandardError()
+{
+ m_process->setReadChannel(QProcess::StandardError);
+ while (m_process->canReadLine()) {
+ const QString line = QString::fromLocal8Bit(m_process->readLine());
+
+ emit processOutput(line);
+ m_messageLog.append(line);
+ }
+}
diff --git a/src/plugins/qnx/blackberryconnect.h b/src/plugins/qnx/blackberrydeviceconnection.h
index 520ef18d68..87b069901e 100644
--- a/src/plugins/qnx/blackberryconnect.h
+++ b/src/plugins/qnx/blackberrydeviceconnection.h
@@ -29,57 +29,63 @@
**
****************************************************************************/
-#ifndef QNX_INTERNAL_BLACKBERRYCONNECT_H
-#define QNX_INTERNAL_BLACKBERRYCONNECT_H
-
-#include <utils/outputformat.h>
+#ifndef QNX_INTERNAL_BLACKBERRYDEVICECONNECTION_H
+#define QNX_INTERNAL_BLACKBERRYDEVICECONNECTION_H
#include <QObject>
-#include <QProcess>
+
+#include <coreplugin/id.h>
+#include <projectexplorer/devicesupport/idevice.h>
+
+QT_BEGIN_NAMESPACE
+class QProcess;
+QT_END_NAMESPACE
namespace Qnx {
namespace Internal {
-class BlackBerryRunConfiguration;
-
-class BlackBerryConnect : public QObject
+class BlackBerryDeviceConnection : public QObject
{
Q_OBJECT
public:
- static BlackBerryConnect *instance(BlackBerryRunConfiguration *runConfig);
- static void cleanup(BlackBerryConnect *instance);
+ enum State {
+ Disconnected,
+ Connecting,
+ Connected
+ };
+
+ explicit BlackBerryDeviceConnection();
+
+ void connectDevice(const ProjectExplorer::IDevice::ConstPtr &device);
+ void disconnectDevice();
+
+ QString host() const;
+ State connectionState();
+
+ QString messageLog() const;
signals:
- void connected();
- void error(const QString &msg);
- void output(const QString &msg, Utils::OutputFormat format);
+ void deviceAboutToConnect();
+ void deviceConnected();
+ void deviceDisconnected();
-public slots:
- void connectToDevice();
- void disconnectFromDevice();
+ void processOutput(const QString &output);
private slots:
- void handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
+ void processFinished();
void readStandardOutput();
void readStandardError();
private:
- explicit BlackBerryConnect(BlackBerryRunConfiguration *runConfig);
+ QString m_host;
+ State m_connectionState;
- static QMap<QString, BlackBerryConnect *> m_instances;
- static QMap<QString, int> m_usageCount;
+ QString m_messageLog;
QProcess *m_process;
- QString m_connectCmd;
- QString m_deviceHost;
- QString m_password;
- QString m_publicKeyFile;
- QString m_qnxHost;
-
- bool m_connected;
};
} // namespace Internal
} // namespace Qnx
-#endif // QNX_INTERNAL_BLACKBERRYCONNECT_H
+#endif // QNX_INTERNAL_BLACKBERRYDEVICECONNECTION_H
diff --git a/src/plugins/qnx/blackberrydeviceconnectionmanager.cpp b/src/plugins/qnx/blackberrydeviceconnectionmanager.cpp
new file mode 100644
index 0000000000..d351d660db
--- /dev/null
+++ b/src/plugins/qnx/blackberrydeviceconnectionmanager.cpp
@@ -0,0 +1,313 @@
+/**************************************************************************
+**
+** 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 "blackberrydeviceconnectionmanager.h"
+
+#include "blackberrydeviceconfiguration.h"
+#include "blackberrydeviceconnection.h"
+#include "qnxconstants.h"
+
+#include <projectexplorer/devicesupport/devicemanager.h>
+#include <ssh/sshconnection.h>
+#include <utils/qtcassert.h>
+
+using namespace Qnx;
+using namespace Qnx::Internal;
+
+BlackBerryDeviceConnectionManager *BlackBerryDeviceConnectionManager::m_instance = 0;
+
+BlackBerryDeviceConnectionManager::BlackBerryDeviceConnectionManager() :
+ QObject()
+{
+}
+
+BlackBerryDeviceConnectionManager::~BlackBerryDeviceConnectionManager()
+{
+ killAllConnections();
+}
+
+void BlackBerryDeviceConnectionManager::initialize()
+{
+ ProjectExplorer::DeviceManager *deviceManager = ProjectExplorer::DeviceManager::instance();
+ connect(deviceManager, SIGNAL(deviceAdded(Core::Id)), this, SLOT(connectDevice(Core::Id)));
+ connect(deviceManager, SIGNAL(deviceRemoved(Core::Id)), this, SLOT(disconnectDevice(Core::Id)));
+ connect(deviceManager, SIGNAL(deviceListChanged()), this, SLOT(handleDeviceListChanged()));
+}
+
+void BlackBerryDeviceConnectionManager::killAllConnections()
+{
+ QList<BlackBerryDeviceConnection*> connections = m_connections.uniqueKeys();
+ foreach (BlackBerryDeviceConnection *connection, connections) {
+ connection->disconnect();
+ connection->disconnectDevice();
+ delete connection;
+ }
+}
+
+BlackBerryDeviceConnectionManager *BlackBerryDeviceConnectionManager::instance()
+{
+ if (m_instance == 0)
+ m_instance = new BlackBerryDeviceConnectionManager();
+ return m_instance;
+}
+
+bool BlackBerryDeviceConnectionManager::isConnected(Core::Id deviceId)
+{
+ BlackBerryDeviceConnection *connection = m_connections.key(deviceId);
+ if (!connection)
+ return false;
+
+ return connection->connectionState() == BlackBerryDeviceConnection::Connected;
+}
+
+QString BlackBerryDeviceConnectionManager::connectionLog(Core::Id deviceId) const
+{
+ BlackBerryDeviceConnection *connection = m_connections.key(deviceId);
+ if (!connection)
+ return QString();
+
+ return connection->messageLog();
+}
+
+void BlackBerryDeviceConnectionManager::connectDevice(Core::Id deviceId)
+{
+ ProjectExplorer::IDevice::ConstPtr device =
+ ProjectExplorer::DeviceManager::instance()->find(deviceId);
+ if (device.isNull())
+ return;
+
+ connectDevice(device);
+}
+
+void BlackBerryDeviceConnectionManager::connectDevice(const ProjectExplorer::IDevice::ConstPtr &device)
+{
+ if (device->type() != Core::Id(Constants::QNX_BB_OS_TYPE))
+ return;
+
+ ProjectExplorer::DeviceManager::instance()->setDeviceState(device->id(),
+ ProjectExplorer::IDevice::DeviceStateUnknown);
+
+ // Disconnect existing connection if it only belongs to this device,
+ // and if the host has changed
+ BlackBerryDeviceConnection *connection = m_connections.key(device->id());
+ if (connection && connection->host() != device->sshParameters().host) {
+ if (connectionUsageCount(device->id()) == 1)
+ disconnectDevice(device);
+
+ m_connections.remove(connection, device->id());
+ connection = 0;
+ }
+
+ if (!connection)
+ connection = connectionForHost(device->sshParameters().host);
+
+ if (!connection) {
+ connection = new BlackBerryDeviceConnection();
+ m_connections.insertMulti(connection, device->id());
+
+ connect(connection, SIGNAL(deviceConnected()), this, SLOT(handleDeviceConnected()));
+ connect(connection, SIGNAL(deviceDisconnected()), this, SLOT(handleDeviceDisconnected()));
+ connect(connection, SIGNAL(processOutput(QString)), this, SLOT(handleProcessOutput(QString)));
+ connect(connection, SIGNAL(deviceAboutToConnect()), this, SLOT(handleDeviceAboutToConnect()));
+
+ connection->connectDevice(device);
+ } else {
+ if (!m_connections.values(connection).contains(device->id()))
+ m_connections.insertMulti(connection, device->id());
+
+ switch (connection->connectionState()) {
+ case BlackBerryDeviceConnection::Connected:
+ ProjectExplorer::DeviceManager::instance()->setDeviceState(device->id(),
+ ProjectExplorer::IDevice::DeviceReadyToUse);
+ break;
+ case BlackBerryDeviceConnection::Connecting:
+ ProjectExplorer::DeviceManager::instance()->setDeviceState(device->id(),
+ ProjectExplorer::IDevice::DeviceStateUnknown);
+ break;
+ case BlackBerryDeviceConnection::Disconnected:
+ connection->connectDevice(device);
+ break;
+ }
+ }
+}
+
+void BlackBerryDeviceConnectionManager::disconnectDevice(const ProjectExplorer::IDevice::ConstPtr &device)
+{
+ disconnectDevice(device->id());
+}
+
+void BlackBerryDeviceConnectionManager::disconnectDevice(Core::Id deviceId)
+{
+ BlackBerryDeviceConnection *connection = m_connections.key(deviceId);
+ if (!connection)
+ return;
+
+ connection->disconnectDevice();
+}
+
+void BlackBerryDeviceConnectionManager::handleDeviceListChanged()
+{
+ disconnectRemovedDevices();
+ reconnectChangedDevices();
+ connectAddedDevices();
+}
+
+void BlackBerryDeviceConnectionManager::handleDeviceConnected()
+{
+ BlackBerryDeviceConnection *connection = qobject_cast<BlackBerryDeviceConnection*>(sender());
+ QTC_ASSERT(connection, return);
+
+ QList<Core::Id> knownDevices = m_connections.values(connection);
+ foreach (Core::Id id, knownDevices)
+ ProjectExplorer::DeviceManager::instance()->setDeviceState(id,
+ ProjectExplorer::IDevice::DeviceReadyToUse);
+
+ QList<Core::Id> sameHostDevices = devicesForHost(connection->host());
+ foreach (Core::Id id, sameHostDevices) {
+ if (!knownDevices.contains(id)) {
+ m_connections.insertMulti(connection, id);
+ ProjectExplorer::DeviceManager::instance()->setDeviceState(id,
+ ProjectExplorer::IDevice::DeviceReadyToUse);
+ }
+ }
+}
+
+void BlackBerryDeviceConnectionManager::handleDeviceDisconnected()
+{
+ BlackBerryDeviceConnection *connection = qobject_cast<BlackBerryDeviceConnection*>(sender());
+ QTC_ASSERT(connection, return);
+
+ QList<Core::Id> disconnectedDevices = m_connections.values(connection);
+ foreach (Core::Id id, disconnectedDevices)
+ ProjectExplorer::DeviceManager::instance()->setDeviceState(id,
+ ProjectExplorer::IDevice::DeviceDisconnected);
+}
+
+void BlackBerryDeviceConnectionManager::handleDeviceAboutToConnect()
+{
+ BlackBerryDeviceConnection *connection = qobject_cast<BlackBerryDeviceConnection*>(sender());
+ QTC_ASSERT(connection, return);
+
+ QList<Core::Id> deviceIds = m_connections.values(connection);
+ foreach (Core::Id deviceId, deviceIds)
+ emit deviceAboutToConnect(deviceId);
+}
+
+void BlackBerryDeviceConnectionManager::handleProcessOutput(const QString &output)
+{
+ BlackBerryDeviceConnection *connection = qobject_cast<BlackBerryDeviceConnection*>(sender());
+ QTC_ASSERT(connection, return);
+
+ QList<Core::Id> deviceIds = m_connections.values(connection);
+ foreach (Core::Id deviceId, deviceIds)
+ emit connectionOutput(deviceId, output);
+}
+
+BlackBerryDeviceConnection *BlackBerryDeviceConnectionManager::connectionForHost(const QString &host) const
+{
+ QList<BlackBerryDeviceConnection*> connections = m_connections.uniqueKeys();
+
+ foreach (BlackBerryDeviceConnection *connection, connections) {
+ if (connection->host() == host)
+ return connection;
+ }
+
+ return 0;
+}
+
+QList<Core::Id> BlackBerryDeviceConnectionManager::devicesForHost(const QString &host) const
+{
+ QList<Core::Id> result;
+ ProjectExplorer::DeviceManager *deviceManager = ProjectExplorer::DeviceManager::instance();
+
+ for (int i = 0; i < deviceManager->deviceCount(); ++i) {
+ ProjectExplorer::IDevice::ConstPtr device = deviceManager->deviceAt(i);
+ if (device->type() == Core::Id(Constants::QNX_BB_OS_TYPE)
+ && device->sshParameters().host == host)
+ result << device->id();
+ }
+
+ return result;
+}
+
+int BlackBerryDeviceConnectionManager::connectionUsageCount(Core::Id deviceId)
+{
+ BlackBerryDeviceConnection *connection = m_connections.key(deviceId);
+ return m_connections.count(connection);
+}
+
+void BlackBerryDeviceConnectionManager::disconnectRemovedDevices()
+{
+ ProjectExplorer::DeviceManager *deviceManager = ProjectExplorer::DeviceManager::instance();
+
+ QList<Core::Id> knownDevices = m_connections.values();
+ foreach (Core::Id id, knownDevices) {
+ ProjectExplorer::IDevice::ConstPtr device = deviceManager->find(id);
+ if (device.isNull() && connectionUsageCount(id) <= 1)
+ disconnectDevice(id);
+ }
+}
+
+void BlackBerryDeviceConnectionManager::reconnectChangedDevices()
+{
+ ProjectExplorer::DeviceManager *deviceManager = ProjectExplorer::DeviceManager::instance();
+ QList<Core::Id> connectedDevices = m_connections.values();
+
+ for (int i = 0; i < deviceManager->deviceCount(); ++i) {
+ ProjectExplorer::IDevice::ConstPtr device = deviceManager->deviceAt(i);
+ if (!connectedDevices.contains(device->id()))
+ continue;
+
+ BlackBerryDeviceConnection *connection = m_connections.key(device->id());
+ QTC_ASSERT(connection, continue);
+
+ if (connection->host() == device->sshParameters().host)
+ continue;
+
+ if (connectionUsageCount(device->id()) <= 1)
+ disconnectDevice(device->id());
+
+ m_connections.remove(connection, device->id());
+ connectDevice(device->id());
+ }
+}
+
+void BlackBerryDeviceConnectionManager::connectAddedDevices()
+{
+ ProjectExplorer::DeviceManager *deviceManager = ProjectExplorer::DeviceManager::instance();
+
+ QList<Core::Id> knownDevices = m_connections.values();
+ for (int i = 0; i < deviceManager->deviceCount(); ++i) {
+ Core::Id deviceId = deviceManager->deviceAt(i)->id();
+ if (!knownDevices.contains(deviceId))
+ connectDevice(deviceId);
+ }
+}
diff --git a/src/plugins/qnx/blackberrydeviceconnectionmanager.h b/src/plugins/qnx/blackberrydeviceconnectionmanager.h
new file mode 100644
index 0000000000..3a16cdcdd2
--- /dev/null
+++ b/src/plugins/qnx/blackberrydeviceconnectionmanager.h
@@ -0,0 +1,99 @@
+/**************************************************************************
+**
+** 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_BLACKBERRYDEVICECONNECTIONMANAGER_H
+#define QNX_INTERNAL_BLACKBERRYDEVICECONNECTIONMANAGER_H
+
+#include <QObject>
+
+#include <coreplugin/id.h>
+#include <projectexplorer/devicesupport/idevice.h>
+
+namespace Qnx {
+namespace Internal {
+
+class BlackBerryDeviceConnection;
+
+class BlackBerryDeviceConnectionManager : public QObject
+{
+ Q_OBJECT
+public:
+ ~BlackBerryDeviceConnectionManager();
+
+ void initialize();
+ void killAllConnections();
+
+ static BlackBerryDeviceConnectionManager *instance();
+
+ bool isConnected(Core::Id deviceId);
+
+ QString connectionLog(Core::Id deviceId) const;
+
+ void connectDevice(const ProjectExplorer::IDevice::ConstPtr &device);
+ void disconnectDevice(const ProjectExplorer::IDevice::ConstPtr &device);
+
+signals:
+ void connectionOutput(Core::Id deviceId, const QString &output);
+ void deviceAboutToConnect(Core::Id deviceId);
+
+public slots:
+ void connectDevice(Core::Id deviceId);
+ void disconnectDevice(Core::Id deviceId);
+
+private slots:
+ void handleDeviceListChanged();
+
+ void handleDeviceAboutToConnect();
+ void handleDeviceConnected();
+ void handleDeviceDisconnected();
+
+ void handleProcessOutput(const QString &output);
+
+private:
+ explicit BlackBerryDeviceConnectionManager();
+
+ BlackBerryDeviceConnection *connectionForHost(const QString &host) const;
+ QList<Core::Id> devicesForHost(const QString &host) const;
+
+ int connectionUsageCount(Core::Id deviceId);
+
+ void disconnectRemovedDevices();
+ void reconnectChangedDevices();
+ void connectAddedDevices();
+
+ static BlackBerryDeviceConnectionManager *m_instance;
+ QMultiMap<BlackBerryDeviceConnection*, Core::Id> m_connections;
+};
+
+} // namespace Internal
+} // namespace Qnx
+
+#endif // QNX_INTERNAL_BLACKBERRYDEVICECONNECTIONMANAGER_H
diff --git a/src/plugins/qnx/blackberryruncontrol.cpp b/src/plugins/qnx/blackberryruncontrol.cpp
index 81bdd79afb..a8d87b85c5 100644
--- a/src/plugins/qnx/blackberryruncontrol.cpp
+++ b/src/plugins/qnx/blackberryruncontrol.cpp
@@ -32,7 +32,6 @@
#include "blackberryruncontrol.h"
#include "blackberryapplicationrunner.h"
#include "blackberryrunconfiguration.h"
-#include "blackberryconnect.h"
#include <QIcon>
#include <QTimer>
@@ -44,28 +43,17 @@ BlackBerryRunControl::BlackBerryRunControl(BlackBerryRunConfiguration *runConfig
: ProjectExplorer::RunControl(runConfiguration, ProjectExplorer::NormalRunMode)
{
m_runner = new BlackBerryApplicationRunner(false, runConfiguration, this);
- m_connector = BlackBerryConnect::instance(runConfiguration);
connect(m_runner, SIGNAL(started()), this, SIGNAL(started()));
connect(m_runner, SIGNAL(finished()), this, SIGNAL(finished()));
- connect(m_runner, SIGNAL(finished()), m_connector, SLOT(disconnectFromDevice()));
connect(m_runner, SIGNAL(output(QString,Utils::OutputFormat)),
this, SLOT(appendMessage(QString,Utils::OutputFormat)));
connect(m_runner, SIGNAL(startFailed(QString)), this, SLOT(handleStartFailed(QString)));
-
- connect(m_connector, SIGNAL(connected()), m_runner, SLOT(start()));
- connect(m_connector, SIGNAL(output(QString,Utils::OutputFormat)),
- this, SLOT(appendMessage(QString,Utils::OutputFormat)));
-}
-
-BlackBerryRunControl::~BlackBerryRunControl()
-{
- BlackBerryConnect::cleanup(m_connector);
}
void BlackBerryRunControl::start()
{
- m_connector->connectToDevice();
+ m_runner->start();
}
ProjectExplorer::RunControl::StopResult BlackBerryRunControl::stop()
diff --git a/src/plugins/qnx/blackberryruncontrol.h b/src/plugins/qnx/blackberryruncontrol.h
index 25a304e403..540599240a 100644
--- a/src/plugins/qnx/blackberryruncontrol.h
+++ b/src/plugins/qnx/blackberryruncontrol.h
@@ -50,7 +50,6 @@ class BlackBerryRunControl : public ProjectExplorer::RunControl
Q_OBJECT
public:
explicit BlackBerryRunControl(BlackBerryRunConfiguration *runConfiguration);
- ~BlackBerryRunControl();
void start();
ProjectExplorer::RunControl::StopResult stop();
@@ -62,7 +61,6 @@ private slots:
private:
BlackBerryApplicationRunner *m_runner;
- BlackBerryConnect *m_connector;
};
} // namespace Internal
diff --git a/src/plugins/qnx/blackberryruncontrolfactory.cpp b/src/plugins/qnx/blackberryruncontrolfactory.cpp
index eb8cafd7ff..62ef7629f3 100644
--- a/src/plugins/qnx/blackberryruncontrolfactory.cpp
+++ b/src/plugins/qnx/blackberryruncontrolfactory.cpp
@@ -35,6 +35,7 @@
#include "blackberrydeployconfiguration.h"
#include "blackberrydebugsupport.h"
#include "blackberryqtversion.h"
+#include "blackberrydeviceconnectionmanager.h"
#include "qnxutils.h"
#include <debugger/debuggerplugin.h>
@@ -99,6 +100,14 @@ ProjectExplorer::RunControl *BlackBerryRunControlFactory::create(ProjectExplorer
return 0;
}
+ BlackBerryDeviceConfiguration::ConstPtr device =
+ BlackBerryDeviceConfiguration::device(rc->target()->kit());
+ if (!BlackBerryDeviceConnectionManager::instance()->isConnected(device->id())) {
+ if (errorMessage)
+ *errorMessage = tr("Device not connected");
+ return 0;
+ }
+
if (mode == ProjectExplorer::NormalRunMode) {
BlackBerryRunControl *runControl = new BlackBerryRunControl(rc);
m_activeRunControls[rc->key()] = runControl;
diff --git a/src/plugins/qnx/qnx.pro b/src/plugins/qnx/qnx.pro
index ad6dff7435..a833a1ffcc 100644
--- a/src/plugins/qnx/qnx.pro
+++ b/src/plugins/qnx/qnx.pro
@@ -29,7 +29,6 @@ SOURCES += qnxplugin.cpp \
blackberryruncontrol.cpp \
blackberrydebugsupport.cpp \
blackberryapplicationrunner.cpp \
- blackberryconnect.cpp \
qnxutils.cpp \
blackberrydeviceconfigurationwidget.cpp \
qnxdeviceconfigurationfactory.cpp \
@@ -77,7 +76,9 @@ SOURCES += qnxplugin.cpp \
blackberrydeviceprocesssupport.cpp \
blackberrycheckdevmodestepfactory.cpp \
blackberrycheckdevmodestep.cpp \
- blackberrycheckdevmodestepconfigwidget.cpp
+ blackberrycheckdevmodestepconfigwidget.cpp \
+ blackberrydeviceconnection.cpp \
+ blackberrydeviceconnectionmanager.cpp
HEADERS += qnxplugin.h\
qnxconstants.h \
@@ -103,7 +104,6 @@ HEADERS += qnxplugin.h\
blackberryruncontrol.h \
blackberrydebugsupport.h \
blackberryapplicationrunner.h \
- blackberryconnect.h \
qnxutils.h \
blackberrydeviceconfigurationwidget.h \
qnxdeviceconfigurationfactory.h \
@@ -151,7 +151,9 @@ HEADERS += qnxplugin.h\
blackberrydeviceprocesssupport.h \
blackberrycheckdevmodestepfactory.h \
blackberrycheckdevmodestep.h \
- blackberrycheckdevmodestepconfigwidget.h
+ blackberrycheckdevmodestepconfigwidget.h \
+ blackberrydeviceconnection.h \
+ blackberrydeviceconnectionmanager.h
FORMS += \
blackberrydeviceconfigurationwizardsetuppage.ui \
diff --git a/src/plugins/qnx/qnx.qbs b/src/plugins/qnx/qnx.qbs
index 5c41359e97..fb66565191 100644
--- a/src/plugins/qnx/qnx.qbs
+++ b/src/plugins/qnx/qnx.qbs
@@ -43,8 +43,6 @@ QtcPlugin {
"blackberrycheckdevmodestepconfigwidget.h",
"blackberrycheckdevmodestepfactory.cpp",
"blackberrycheckdevmodestepfactory.h",
- "blackberryconnect.cpp",
- "blackberryconnect.h",
"blackberrycreatepackagestep.cpp",
"blackberrycreatepackagestep.h",
"blackberrycreatepackagestepconfigwidget.cpp",
@@ -83,6 +81,10 @@ QtcPlugin {
"blackberrydeviceconfigurationwizardpages.h",
"blackberrydeviceconfigurationwizardsetuppage.ui",
"blackberrydeviceconfigurationwizardsshkeypage.ui",
+ "blackberrydeviceconnection.cpp",
+ "blackberrydeviceconnection.h",
+ "blackberrydeviceconnectionmanager.cpp",
+ "blackberrydeviceconnectionmanager.h",
"blackberrydeviceprocesssupport.h",
"blackberrydeviceprocesssupport.cpp",
"blackberryqtversion.cpp",
diff --git a/src/plugins/qnx/qnxplugin.cpp b/src/plugins/qnx/qnxplugin.cpp
index 71df9e7982..972146c170 100644
--- a/src/plugins/qnx/qnxplugin.cpp
+++ b/src/plugins/qnx/qnxplugin.cpp
@@ -50,6 +50,7 @@
#include "bardescriptormagicmatcher.h"
#include "blackberrykeyspage.h"
#include "blackberrycheckdevmodestepfactory.h"
+#include "blackberrydeviceconnectionmanager.h"
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
@@ -64,6 +65,7 @@ QNXPlugin::QNXPlugin()
QNXPlugin::~QNXPlugin()
{
+ delete BlackBerryDeviceConnectionManager::instance();
}
bool QNXPlugin::initialize(const QStringList &arguments, QString *errorString)
@@ -82,6 +84,7 @@ bool QNXPlugin::initialize(const QStringList &arguments, QString *errorString)
addAutoReleasedObject(new BlackBerryNDKSettingsPage);
addAutoReleasedObject(new BlackBerryKeysPage);
addAutoReleasedObject(new BlackBerryCheckDevModeStepFactory);
+ BlackBerryDeviceConnectionManager::instance()->initialize();
// Handles QNX
addAutoReleasedObject(new QnxQtVersionFactory);