Commit db9437c2 authored by hjk's avatar hjk

Generalize IDevice::qmlProfilerHost

The idea is to have a way for tools to specify what kind of
control channel they would like to use to communicate with
a device without making the choice explicit dependent on
the exact kind of tool to further decouple device and tool
implementations.

The 'hint' values are there to help the device implementation
to decide on which channel to use exactly in case there are
multiple choices. In any case, the tool is responsible to
check that the returned channel is suitable for its operation.

Currently the only choice is "QmlControlChannel" yielding
a simple wrapper around the former IDevice::qmlProfilerHost()
return value.

Other enum values may potentially be {Tcp,LocalSocket}ControlChannel
(to specify a type of transport) AdbChannel (to specify some
generic helper mechanism). It might also turn out that something
more complex than an enum will be needed, e.g. to express
a set of values with priorities or such, but I'd rather
avoid overengineering for now.

Change-Id: Id386425eb3dd2bb395065f0bdb6f67217cd40a71
Reviewed-by: Ulf Hermann's avatarUlf Hermann <ulf.hermann@qt.io>
parent 1e909269
......@@ -27,6 +27,8 @@
#include "androidconstants.h"
#include "androidsignaloperation.h"
#include <projectexplorer/runconfiguration.h>
#include <QCoreApplication>
using namespace ProjectExplorer;
......@@ -96,9 +98,9 @@ IDevice::Ptr AndroidDevice::clone() const
return IDevice::Ptr(new AndroidDevice(*this));
}
QString AndroidDevice::qmlProfilerHost() const
Connection AndroidDevice::toolControlChannel(const ControlChannelHint &) const
{
return QLatin1String("localhost");
return HostName("localhost");
}
} // namespace Internal
......
......@@ -46,7 +46,7 @@ public:
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override;
ProjectExplorer::IDevice::Ptr clone() const override;
QString qmlProfilerHost() const override;
ProjectExplorer::Connection toolControlChannel(const ControlChannelHint &) const override;
protected:
friend class AndroidDeviceFactory;
......
......@@ -2156,7 +2156,9 @@ void DebuggerPluginPrivate::attachToQmlPort()
IDevice::ConstPtr device = DeviceKitInformation::device(kit);
if (device) {
rp.connParams = device->sshParameters();
rp.qmlServerAddress = device->qmlProfilerHost();
Connection toolControl = device->toolControlChannel(IDevice::QmlControlChannel);
QTC_ASSERT(toolControl.is<HostName>(), return);
rp.qmlServerAddress = toolControl.as<HostName>().host();
}
rp.qmlServerPort = Utils::Port(dlg.port());
rp.startMode = AttachToRemoteProcess;
......
......@@ -29,7 +29,9 @@
#include "localprocesslist.h"
#include "desktopdeviceconfigurationwidget.h"
#include "desktopprocesssignaloperation.h"
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/runconfiguration.h>
#include <ssh/sshconnection.h>
......@@ -134,9 +136,9 @@ DeviceEnvironmentFetcher::Ptr DesktopDevice::environmentFetcher() const
return DeviceEnvironmentFetcher::Ptr(new DesktopDeviceEnvironmentFetcher());
}
QString DesktopDevice::qmlProfilerHost() const
Connection DesktopDevice::toolControlChannel(const ControlChannelHint &) const
{
return QLatin1String("localhost");
return HostName("localhost");
}
IDevice::Ptr DesktopDevice::clone() const
......
......@@ -52,7 +52,7 @@ public:
DeviceProcess *createProcess(QObject *parent) const override;
DeviceProcessSignalOperation::Ptr signalOperation() const override;
DeviceEnvironmentFetcher::Ptr environmentFetcher() const override;
QString qmlProfilerHost() const override;
Connection toolControlChannel(const ControlChannelHint &) const override;
IDevice::Ptr clone() const override;
......
......@@ -30,6 +30,7 @@
#include "../kit.h"
#include "../kitinformation.h"
#include "../runconfiguration.h"
#include <ssh/sshconnection.h>
#include <utils/portlist.h>
......@@ -407,9 +408,9 @@ void IDevice::setSshParameters(const QSsh::SshConnectionParameters &sshParameter
d->sshParameters.hostKeyDatabase = DeviceManager::instance()->hostKeyDatabase();
}
QString IDevice::qmlProfilerHost() const
Connection IDevice::toolControlChannel(const ControlChannelHint &) const
{
return d->sshParameters.host;
return HostName(d->sshParameters.host);
}
void IDevice::setFreePorts(const Utils::PortList &freePorts)
......
......@@ -48,9 +48,10 @@ class Port;
} // Utils
namespace ProjectExplorer {
class Connection;
class DeviceProcess;
class DeviceProcessList;
class Kit;
namespace Internal { class IDevicePrivate; }
......@@ -107,6 +108,16 @@ public:
virtual QList<Utils::Port> usedPorts(const QByteArray &commandOutput) const = 0;
};
class PROJECTEXPLORER_EXPORT HostName
{
public:
explicit HostName(const QString &host) : m_host(host) {}
QString host() const { return m_host; }
private:
QString m_host;
};
// See cpp file for documentation.
class PROJECTEXPLORER_EXPORT IDevice
{
......@@ -178,7 +189,8 @@ public:
QSsh::SshConnectionParameters sshParameters() const;
void setSshParameters(const QSsh::SshConnectionParameters &sshParameters);
virtual QString qmlProfilerHost() const;
enum ControlChannelHint { QmlControlChannel };
virtual Connection toolControlChannel(const ControlChannelHint &) const;
Utils::PortList freePorts() const;
void setFreePorts(const Utils::PortList &freePorts);
......
......@@ -562,8 +562,10 @@ void QmlProfilerTool::startRemoteTool(ProjectExplorer::RunConfiguration *rc)
IDevice::ConstPtr device = DeviceKitInformation::device(kit);
if (device) {
Connection toolControl = device->toolControlChannel(IDevice::QmlControlChannel);
QTC_ASSERT(toolControl.is<HostName>(), return);
connection.analyzerHost = toolControl.as<HostName>().host();
connection.connParams = device->sshParameters();
connection.analyzerHost = device->qmlProfilerHost();
}
connection.analyzerPort = Utils::Port(port);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment