forked from qt-creator/qt-creator
ProjectExplorer: Introduce a DeviceEnvironmentFetcher
Also, provide implementations for desktop and remote linux. Change-Id: Ib02202bf1829367334035a361ac73317338cd7a6 Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
This commit is contained in:
@@ -32,6 +32,8 @@
|
|||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
|
|
||||||
#include <ssh/sshconnection.h>
|
#include <ssh/sshconnection.h>
|
||||||
|
|
||||||
|
#include <utils/environment.h>
|
||||||
#include <utils/portlist.h>
|
#include <utils/portlist.h>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
@@ -116,6 +118,22 @@ DeviceProcessSignalOperation::Ptr DesktopDevice::signalOperation() const
|
|||||||
return DeviceProcessSignalOperation::Ptr(new DesktopProcessSignalOperation());
|
return DeviceProcessSignalOperation::Ptr(new DesktopProcessSignalOperation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class DesktopDeviceEnvironmentFetcher : public DeviceEnvironmentFetcher
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DesktopDeviceEnvironmentFetcher() {}
|
||||||
|
|
||||||
|
void start() override
|
||||||
|
{
|
||||||
|
emit finished(Utils::Environment::systemEnvironment(), true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
DeviceEnvironmentFetcher::Ptr DesktopDevice::environmentFetcher() const
|
||||||
|
{
|
||||||
|
return DeviceEnvironmentFetcher::Ptr(new DesktopDeviceEnvironmentFetcher());
|
||||||
|
}
|
||||||
|
|
||||||
QString DesktopDevice::qmlProfilerHost() const
|
QString DesktopDevice::qmlProfilerHost() const
|
||||||
{
|
{
|
||||||
return QLatin1String("localhost");
|
return QLatin1String("localhost");
|
||||||
|
@@ -51,6 +51,7 @@ public:
|
|||||||
bool canCreateProcess() const override { return true; }
|
bool canCreateProcess() const override { return true; }
|
||||||
DeviceProcess *createProcess(QObject *parent) const override;
|
DeviceProcess *createProcess(QObject *parent) const override;
|
||||||
DeviceProcessSignalOperation::Ptr signalOperation() const override;
|
DeviceProcessSignalOperation::Ptr signalOperation() const override;
|
||||||
|
DeviceEnvironmentFetcher::Ptr environmentFetcher() const override;
|
||||||
QString qmlProfilerHost() const override;
|
QString qmlProfilerHost() const override;
|
||||||
|
|
||||||
IDevice::Ptr clone() const override;
|
IDevice::Ptr clone() const override;
|
||||||
|
@@ -277,6 +277,11 @@ DeviceProcess *IDevice::createProcess(QObject * /* parent */) const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeviceEnvironmentFetcher::Ptr IDevice::environmentFetcher() const
|
||||||
|
{
|
||||||
|
return DeviceEnvironmentFetcher::Ptr();
|
||||||
|
}
|
||||||
|
|
||||||
IDevice::DeviceState IDevice::deviceState() const
|
IDevice::DeviceState IDevice::deviceState() const
|
||||||
{
|
{
|
||||||
return d->deviceState;
|
return d->deviceState;
|
||||||
@@ -457,4 +462,8 @@ DeviceProcessSignalOperation::DeviceProcessSignalOperation()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeviceEnvironmentFetcher::DeviceEnvironmentFetcher()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -40,7 +40,11 @@ class QWidget;
|
|||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace QSsh { class SshConnectionParameters; }
|
namespace QSsh { class SshConnectionParameters; }
|
||||||
namespace Utils { class PortList; }
|
|
||||||
|
namespace Utils {
|
||||||
|
class Environment;
|
||||||
|
class PortList;
|
||||||
|
} // Utils
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
class DeviceProcess;
|
class DeviceProcess;
|
||||||
@@ -77,6 +81,21 @@ protected:
|
|||||||
QString m_errorMessage;
|
QString m_errorMessage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PROJECTEXPLORER_EXPORT DeviceEnvironmentFetcher : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
typedef QSharedPointer<DeviceEnvironmentFetcher> Ptr;
|
||||||
|
|
||||||
|
virtual void start() = 0;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void finished(const Utils::Environment &env, bool success);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
explicit DeviceEnvironmentFetcher();
|
||||||
|
};
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT PortsGatheringMethod
|
class PROJECTEXPLORER_EXPORT PortsGatheringMethod
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -138,6 +157,7 @@ public:
|
|||||||
virtual bool canCreateProcess() const { return false; }
|
virtual bool canCreateProcess() const { return false; }
|
||||||
virtual DeviceProcess *createProcess(QObject *parent) const;
|
virtual DeviceProcess *createProcess(QObject *parent) const;
|
||||||
virtual DeviceProcessSignalOperation::Ptr signalOperation() const = 0;
|
virtual DeviceProcessSignalOperation::Ptr signalOperation() const = 0;
|
||||||
|
virtual DeviceEnvironmentFetcher::Ptr environmentFetcher() const;
|
||||||
|
|
||||||
enum DeviceState { DeviceReadyToUse, DeviceConnected, DeviceDisconnected, DeviceStateUnknown };
|
enum DeviceState { DeviceReadyToUse, DeviceConnected, DeviceDisconnected, DeviceStateUnknown };
|
||||||
DeviceState deviceState() const;
|
DeviceState deviceState() const;
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include "publickeydeploymentdialog.h"
|
#include "publickeydeploymentdialog.h"
|
||||||
#include "remotelinux_constants.h"
|
#include "remotelinux_constants.h"
|
||||||
#include "remotelinuxsignaloperation.h"
|
#include "remotelinuxsignaloperation.h"
|
||||||
|
#include "remotelinuxenvironmentreader.h"
|
||||||
|
|
||||||
#include <coreplugin/id.h>
|
#include <coreplugin/id.h>
|
||||||
#include <projectexplorer/devicesupport/sshdeviceprocesslist.h>
|
#include <projectexplorer/devicesupport/sshdeviceprocesslist.h>
|
||||||
@@ -254,4 +255,29 @@ DeviceProcessSignalOperation::Ptr LinuxDevice::signalOperation() const
|
|||||||
return DeviceProcessSignalOperation::Ptr(new RemoteLinuxSignalOperation(sshParameters()));
|
return DeviceProcessSignalOperation::Ptr(new RemoteLinuxSignalOperation(sshParameters()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class LinuxDeviceEnvironmentFetcher : public DeviceEnvironmentFetcher
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LinuxDeviceEnvironmentFetcher(const IDevice::ConstPtr &device)
|
||||||
|
: m_reader(device)
|
||||||
|
{
|
||||||
|
connect(&m_reader, &Internal::RemoteLinuxEnvironmentReader::finished,
|
||||||
|
this, &LinuxDeviceEnvironmentFetcher::readerFinished);
|
||||||
|
connect(&m_reader, &Internal::RemoteLinuxEnvironmentReader::error,
|
||||||
|
this, &LinuxDeviceEnvironmentFetcher::readerError);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void start() override { m_reader.start(); }
|
||||||
|
void readerFinished() { emit finished(m_reader.remoteEnvironment(), true); }
|
||||||
|
void readerError() { emit finished(Utils::Environment(), false); }
|
||||||
|
|
||||||
|
Internal::RemoteLinuxEnvironmentReader m_reader;
|
||||||
|
};
|
||||||
|
|
||||||
|
DeviceEnvironmentFetcher::Ptr LinuxDevice::environmentFetcher() const
|
||||||
|
{
|
||||||
|
return DeviceEnvironmentFetcher::Ptr(new LinuxDeviceEnvironmentFetcher(sharedFromThis()));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace RemoteLinux
|
} // namespace RemoteLinux
|
||||||
|
@@ -66,6 +66,7 @@ public:
|
|||||||
bool hasDeviceTester() const { return true; }
|
bool hasDeviceTester() const { return true; }
|
||||||
ProjectExplorer::DeviceTester *createDeviceTester() const;
|
ProjectExplorer::DeviceTester *createDeviceTester() const;
|
||||||
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const;
|
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const;
|
||||||
|
ProjectExplorer::DeviceEnvironmentFetcher::Ptr environmentFetcher() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
LinuxDevice() {}
|
LinuxDevice() {}
|
||||||
|
@@ -28,10 +28,16 @@
|
|||||||
#include "remotelinuxrunconfiguration.h"
|
#include "remotelinuxrunconfiguration.h"
|
||||||
#include "remotelinuxenvironmentreader.h"
|
#include "remotelinuxenvironmentreader.h"
|
||||||
|
|
||||||
|
#include <projectexplorer/target.h>
|
||||||
|
#include <projectexplorer/kitinformation.h>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
|
using namespace ProjectExplorer;
|
||||||
|
using namespace RemoteLinux::Internal;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const QString FetchEnvButtonText
|
const QString FetchEnvButtonText
|
||||||
= QCoreApplication::translate("RemoteLinux::RemoteLinuxEnvironmentAspectWidget",
|
= QCoreApplication::translate("RemoteLinux::RemoteLinuxEnvironmentAspectWidget",
|
||||||
@@ -41,15 +47,22 @@ const QString FetchEnvButtonText
|
|||||||
namespace RemoteLinux {
|
namespace RemoteLinux {
|
||||||
|
|
||||||
RemoteLinuxEnvironmentAspectWidget::RemoteLinuxEnvironmentAspectWidget(RemoteLinuxEnvironmentAspect *aspect) :
|
RemoteLinuxEnvironmentAspectWidget::RemoteLinuxEnvironmentAspectWidget(RemoteLinuxEnvironmentAspect *aspect) :
|
||||||
ProjectExplorer::EnvironmentAspectWidget(aspect, new QPushButton),
|
EnvironmentAspectWidget(aspect, new QPushButton)
|
||||||
deviceEnvReader(new Internal::RemoteLinuxEnvironmentReader(aspect->runConfiguration(), this))
|
|
||||||
{
|
{
|
||||||
|
RunConfiguration *runConfiguration = aspect->runConfiguration();
|
||||||
|
Target *target = runConfiguration->target();
|
||||||
|
IDevice::ConstPtr device = DeviceKitInformation::device(target->kit());
|
||||||
|
|
||||||
|
deviceEnvReader = new RemoteLinuxEnvironmentReader(device, this);
|
||||||
|
connect(target, &ProjectExplorer::Target::kitChanged,
|
||||||
|
deviceEnvReader, &RemoteLinuxEnvironmentReader::handleCurrentDeviceConfigChanged);
|
||||||
|
|
||||||
QPushButton *button = fetchButton();
|
QPushButton *button = fetchButton();
|
||||||
button->setText(FetchEnvButtonText);
|
button->setText(FetchEnvButtonText);
|
||||||
connect(button, &QPushButton::clicked, this, &RemoteLinuxEnvironmentAspectWidget::fetchEnvironment);
|
connect(button, &QPushButton::clicked, this, &RemoteLinuxEnvironmentAspectWidget::fetchEnvironment);
|
||||||
connect(deviceEnvReader, &Internal::RemoteLinuxEnvironmentReader::finished,
|
connect(deviceEnvReader, &RemoteLinuxEnvironmentReader::finished,
|
||||||
this, &RemoteLinuxEnvironmentAspectWidget::fetchEnvironmentFinished);
|
this, &RemoteLinuxEnvironmentAspectWidget::fetchEnvironmentFinished);
|
||||||
connect(deviceEnvReader, &Internal::RemoteLinuxEnvironmentReader::error,
|
connect(deviceEnvReader, &RemoteLinuxEnvironmentReader::error,
|
||||||
this, &RemoteLinuxEnvironmentAspectWidget::fetchEnvironmentError);
|
this, &RemoteLinuxEnvironmentAspectWidget::fetchEnvironmentError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,9 +27,6 @@
|
|||||||
|
|
||||||
#include <projectexplorer/devicesupport/deviceprocess.h>
|
#include <projectexplorer/devicesupport/deviceprocess.h>
|
||||||
#include <projectexplorer/devicesupport/idevice.h>
|
#include <projectexplorer/devicesupport/idevice.h>
|
||||||
#include <projectexplorer/kitinformation.h>
|
|
||||||
#include <projectexplorer/runconfiguration.h>
|
|
||||||
#include <projectexplorer/target.h>
|
|
||||||
#include <projectexplorer/runnables.h>
|
#include <projectexplorer/runnables.h>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
@@ -37,24 +34,25 @@ using namespace ProjectExplorer;
|
|||||||
namespace RemoteLinux {
|
namespace RemoteLinux {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
RemoteLinuxEnvironmentReader::RemoteLinuxEnvironmentReader(RunConfiguration *config, QObject *parent)
|
RemoteLinuxEnvironmentReader::RemoteLinuxEnvironmentReader(const IDevice::ConstPtr &device,
|
||||||
|
QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_stop(false)
|
, m_stop(false)
|
||||||
, m_env(Utils::OsTypeLinux)
|
, m_env(Utils::OsTypeLinux)
|
||||||
, m_kit(config->target()->kit())
|
, m_device(device)
|
||||||
, m_deviceProcess(0)
|
, m_deviceProcess(0)
|
||||||
{
|
{
|
||||||
connect(config->target(), SIGNAL(kitChanged()),
|
|
||||||
this, SLOT(handleCurrentDeviceConfigChanged()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteLinuxEnvironmentReader::start()
|
void RemoteLinuxEnvironmentReader::start()
|
||||||
{
|
{
|
||||||
IDevice::ConstPtr device = DeviceKitInformation::device(m_kit);
|
if (!m_device) {
|
||||||
if (!device)
|
emit error(tr("Error: No device"));
|
||||||
|
setFinished();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
m_stop = false;
|
m_stop = false;
|
||||||
m_deviceProcess = device->createProcess(this);
|
m_deviceProcess = m_device->createProcess(this);
|
||||||
connect(m_deviceProcess, &DeviceProcess::error,
|
connect(m_deviceProcess, &DeviceProcess::error,
|
||||||
this, &RemoteLinuxEnvironmentReader::handleError);
|
this, &RemoteLinuxEnvironmentReader::handleError);
|
||||||
connect(m_deviceProcess, &DeviceProcess::finished,
|
connect(m_deviceProcess, &DeviceProcess::finished,
|
||||||
|
@@ -26,15 +26,12 @@
|
|||||||
#ifndef REMOTELINUXENVIRONMENTREADER_H
|
#ifndef REMOTELINUXENVIRONMENTREADER_H
|
||||||
#define REMOTELINUXENVIRONMENTREADER_H
|
#define REMOTELINUXENVIRONMENTREADER_H
|
||||||
|
|
||||||
|
#include <projectexplorer/devicesupport/idevice.h>
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer { class DeviceProcess; }
|
||||||
class DeviceProcess;
|
|
||||||
class Kit;
|
|
||||||
class RunConfiguration;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace RemoteLinux {
|
namespace RemoteLinux {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -44,29 +41,27 @@ class RemoteLinuxEnvironmentReader : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RemoteLinuxEnvironmentReader(ProjectExplorer::RunConfiguration *config, QObject *parent = 0);
|
RemoteLinuxEnvironmentReader(const ProjectExplorer::IDevice::ConstPtr &device,
|
||||||
|
QObject *parent = 0);
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
Utils::Environment remoteEnvironment() const { return m_env; }
|
Utils::Environment remoteEnvironment() const { return m_env; }
|
||||||
|
void handleCurrentDeviceConfigChanged();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void finished();
|
void finished();
|
||||||
void error(const QString &error);
|
void error(const QString &error);
|
||||||
|
|
||||||
private slots:
|
|
||||||
void handleError();
|
|
||||||
void handleCurrentDeviceConfigChanged();
|
|
||||||
void remoteProcessFinished();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void handleError();
|
||||||
|
void remoteProcessFinished();
|
||||||
void setFinished();
|
void setFinished();
|
||||||
void destroyProcess();
|
void destroyProcess();
|
||||||
|
|
||||||
bool m_stop;
|
bool m_stop;
|
||||||
Utils::Environment m_env;
|
Utils::Environment m_env;
|
||||||
ProjectExplorer::Kit *m_kit;
|
ProjectExplorer::IDevice::ConstPtr m_device;
|
||||||
ProjectExplorer::DeviceProcess *m_deviceProcess;
|
ProjectExplorer::DeviceProcess *m_deviceProcess;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user