summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEl Mehdi Fekari <mfekari@rim.com>2013-07-18 18:08:42 +0200
committerMehdi Fekari <mfekari@blackberry.com>2013-07-25 12:34:47 +0200
commit04c45c395b6bd74b31cf5a8d6920a4b700828053 (patch)
treed526f1ad1933595b35c247a7464963d0a6e28e4b /src
parent87b1ea2af7c80e3bd7e513b34f721cdbbee0ea1e (diff)
downloadqt-creator-04c45c395b6bd74b31cf5a8d6920a4b700828053.tar.gz
Qnx: Automatically connect to device when running an app
Task-number: QTCREATORBUG-9839 Change-Id: Iac6e6bd8d4f16d09c82658b9cd02518ee6300e1b Reviewed-by: Wolfgang Bremer <wbremer@blackberry.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/qnx/blackberrydeviceconnectionmanager.cpp2
-rw-r--r--src/plugins/qnx/blackberrydeviceconnectionmanager.h1
-rw-r--r--src/plugins/qnx/blackberryruncontrol.cpp35
-rw-r--r--src/plugins/qnx/blackberryruncontrol.h6
-rw-r--r--src/plugins/qnx/blackberryruncontrolfactory.cpp8
5 files changed, 43 insertions, 9 deletions
diff --git a/src/plugins/qnx/blackberrydeviceconnectionmanager.cpp b/src/plugins/qnx/blackberrydeviceconnectionmanager.cpp
index 788f18d061..da19bc810d 100644
--- a/src/plugins/qnx/blackberrydeviceconnectionmanager.cpp
+++ b/src/plugins/qnx/blackberrydeviceconnectionmanager.cpp
@@ -198,6 +198,8 @@ void BlackBerryDeviceConnectionManager::handleDeviceConnected()
ProjectExplorer::IDevice::DeviceReadyToUse);
}
}
+
+ emit deviceConnected();
}
void BlackBerryDeviceConnectionManager::handleDeviceDisconnected()
diff --git a/src/plugins/qnx/blackberrydeviceconnectionmanager.h b/src/plugins/qnx/blackberrydeviceconnectionmanager.h
index 3a16cdcdd2..36569c6c32 100644
--- a/src/plugins/qnx/blackberrydeviceconnectionmanager.h
+++ b/src/plugins/qnx/blackberrydeviceconnectionmanager.h
@@ -63,6 +63,7 @@ public:
signals:
void connectionOutput(Core::Id deviceId, const QString &output);
void deviceAboutToConnect(Core::Id deviceId);
+ void deviceConnected();
public slots:
void connectDevice(Core::Id deviceId);
diff --git a/src/plugins/qnx/blackberryruncontrol.cpp b/src/plugins/qnx/blackberryruncontrol.cpp
index a8d87b85c5..15a0766c40 100644
--- a/src/plugins/qnx/blackberryruncontrol.cpp
+++ b/src/plugins/qnx/blackberryruncontrol.cpp
@@ -32,6 +32,9 @@
#include "blackberryruncontrol.h"
#include "blackberryapplicationrunner.h"
#include "blackberryrunconfiguration.h"
+#include "blackberrydeviceconnectionmanager.h"
+
+#include <projectexplorer/target.h>
#include <QIcon>
#include <QTimer>
@@ -42,6 +45,7 @@ using namespace Qnx::Internal;
BlackBerryRunControl::BlackBerryRunControl(BlackBerryRunConfiguration *runConfiguration)
: ProjectExplorer::RunControl(runConfiguration, ProjectExplorer::NormalRunMode)
{
+ m_device = BlackBerryDeviceConfiguration::device(runConfiguration->target()->kit());
m_runner = new BlackBerryApplicationRunner(false, runConfiguration, this);
connect(m_runner, SIGNAL(started()), this, SIGNAL(started()));
@@ -53,7 +57,7 @@ BlackBerryRunControl::BlackBerryRunControl(BlackBerryRunConfiguration *runConfig
void BlackBerryRunControl::start()
{
- m_runner->start();
+ checkDeviceConnection();
}
ProjectExplorer::RunControl::StopResult BlackBerryRunControl::stop()
@@ -75,3 +79,32 @@ void BlackBerryRunControl::handleStartFailed(const QString &message)
{
appendMessage(message, Utils::StdErrFormat);
}
+
+void BlackBerryRunControl::handleDeviceConnected()
+{
+ m_runner->start();
+}
+
+void BlackBerryRunControl::displayConnectionOutput(Core::Id deviceId, const QString &output)
+{
+ if (deviceId != m_device->id())
+ return;
+
+ if (output.contains(QLatin1String("Info:")))
+ appendMessage(output, Utils::StdOutFormat);
+ else if (output.contains(QLatin1String("Error:")))
+ appendMessage(output, Utils::StdErrFormat);
+}
+
+void BlackBerryRunControl::checkDeviceConnection()
+{
+ if (!BlackBerryDeviceConnectionManager::instance()->isConnected(m_device->id())) {
+ connect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(deviceConnected()),
+ this, SLOT(handleDeviceConnected()));
+ connect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(connectionOutput(Core::Id,QString)),
+ this, SLOT(displayConnectionOutput(Core::Id,QString)));
+ BlackBerryDeviceConnectionManager::instance()->connectDevice(m_device->id());
+ } else {
+ m_runner->start();
+ }
+}
diff --git a/src/plugins/qnx/blackberryruncontrol.h b/src/plugins/qnx/blackberryruncontrol.h
index 540599240a..9539dd1349 100644
--- a/src/plugins/qnx/blackberryruncontrol.h
+++ b/src/plugins/qnx/blackberryruncontrol.h
@@ -32,6 +32,8 @@
#ifndef QNX_INTERNAL_BLACKBERRYRUNCONTROL_H
#define QNX_INTERNAL_BLACKBERRYRUNCONTROL_H
+#include "blackberrydeviceconfiguration.h"
+
#include <projectexplorer/runconfiguration.h>
namespace Qt4ProjectManager {
@@ -58,9 +60,13 @@ public:
private slots:
void handleStartFailed(const QString &message);
+ void handleDeviceConnected();
+ void displayConnectionOutput(Core::Id deviceId, const QString &output);
+ void checkDeviceConnection();
private:
BlackBerryApplicationRunner *m_runner;
+ BlackBerryDeviceConfiguration::ConstPtr m_device;
};
} // namespace Internal
diff --git a/src/plugins/qnx/blackberryruncontrolfactory.cpp b/src/plugins/qnx/blackberryruncontrolfactory.cpp
index 3db7911f9d..0e56535343 100644
--- a/src/plugins/qnx/blackberryruncontrolfactory.cpp
+++ b/src/plugins/qnx/blackberryruncontrolfactory.cpp
@@ -101,14 +101,6 @@ 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;