remotelinux: use IDevice base class when appropriate

Change-Id: I6f68f85d50500e4995ab51ee374f8ba5c31d334d
Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
This commit is contained in:
hjk
2012-07-25 16:23:26 +02:00
parent 5ae9f32d0b
commit 047973c355
5 changed files with 22 additions and 32 deletions

View File

@@ -26,16 +26,13 @@
** **
** **
**************************************************************************/ **************************************************************************/
#include "remotelinuxprocesslist.h"
#include "linuxdeviceconfiguration.h" #include "remotelinuxprocesslist.h"
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <ssh/sshremoteprocessrunner.h> #include <ssh/sshremoteprocessrunner.h>
#include <QByteArray> using namespace ProjectExplorer;
#include <QString>
using namespace QSsh; using namespace QSsh;
namespace RemoteLinux { namespace RemoteLinux {
@@ -55,14 +52,14 @@ static QString visualizeNull(QString s)
class AbstractRemoteLinuxProcessListPrivate class AbstractRemoteLinuxProcessListPrivate
{ {
public: public:
AbstractRemoteLinuxProcessListPrivate(const LinuxDeviceConfiguration::ConstPtr &devConf) AbstractRemoteLinuxProcessListPrivate(const IDevice::ConstPtr &devConf)
: deviceConfiguration(devConf), : deviceConfiguration(devConf),
state(Inactive) state(Inactive)
{ {
} }
const LinuxDeviceConfiguration::ConstPtr deviceConfiguration; const IDevice::ConstPtr deviceConfiguration;
SshRemoteProcessRunner process; SshRemoteProcessRunner process;
QList<RemoteProcess> remoteProcesses; QList<RemoteProcess> remoteProcesses;
QString errorMsg; QString errorMsg;
@@ -73,17 +70,12 @@ public:
using namespace Internal; using namespace Internal;
AbstractRemoteLinuxProcessList::AbstractRemoteLinuxProcessList(const LinuxDeviceConfiguration::ConstPtr &devConfig, AbstractRemoteLinuxProcessList::AbstractRemoteLinuxProcessList(const IDevice::ConstPtr &devConfig,
QObject *parent) QObject *parent)
: QAbstractTableModel(parent), d(new AbstractRemoteLinuxProcessListPrivate(devConfig)) : QAbstractTableModel(parent), d(new AbstractRemoteLinuxProcessListPrivate(devConfig))
{ {
} }
LinuxDeviceConfiguration::ConstPtr AbstractRemoteLinuxProcessList::deviceConfiguration() const
{
return d->deviceConfiguration;
}
AbstractRemoteLinuxProcessList::~AbstractRemoteLinuxProcessList() AbstractRemoteLinuxProcessList::~AbstractRemoteLinuxProcessList()
{ {
delete d; delete d;
@@ -224,7 +216,7 @@ void AbstractRemoteLinuxProcessList::setFinished()
} }
GenericRemoteLinuxProcessList::GenericRemoteLinuxProcessList(const LinuxDeviceConfiguration::ConstPtr &devConfig, GenericRemoteLinuxProcessList::GenericRemoteLinuxProcessList(const IDevice::ConstPtr &devConfig,
QObject *parent) QObject *parent)
: AbstractRemoteLinuxProcessList(devConfig, parent) : AbstractRemoteLinuxProcessList(devConfig, parent)
{ {

View File

@@ -31,12 +31,13 @@
#include "remotelinux_export.h" #include "remotelinux_export.h"
#include <projectexplorer/devicesupport/idevice.h>
#include <QAbstractTableModel> #include <QAbstractTableModel>
#include <QList> #include <QList>
#include <QSharedPointer> #include <QSharedPointer>
namespace RemoteLinux { namespace RemoteLinux {
class LinuxDeviceConfiguration;
namespace Internal { namespace Internal {
class AbstractRemoteLinuxProcessListPrivate; class AbstractRemoteLinuxProcessListPrivate;
@@ -70,11 +71,9 @@ signals:
void processKilled(); void processKilled();
protected: protected:
AbstractRemoteLinuxProcessList(const QSharedPointer<const LinuxDeviceConfiguration> &devConfig, AbstractRemoteLinuxProcessList(const ProjectExplorer::IDevice::ConstPtr &devConfig,
QObject *parent = 0); QObject *parent = 0);
QSharedPointer<const LinuxDeviceConfiguration> deviceConfiguration() const;
private slots: private slots:
void handleConnectionError(); void handleConnectionError();
void handleRemoteProcessFinished(int exitStatus); void handleRemoteProcessFinished(int exitStatus);
@@ -101,7 +100,7 @@ class REMOTELINUX_EXPORT GenericRemoteLinuxProcessList : public AbstractRemoteLi
{ {
Q_OBJECT Q_OBJECT
public: public:
GenericRemoteLinuxProcessList(const QSharedPointer<const LinuxDeviceConfiguration> &devConfig, GenericRemoteLinuxProcessList(const ProjectExplorer::IDevice::ConstPtr &devConfig,
QObject *parent = 0); QObject *parent = 0);
protected: protected:

View File

@@ -26,9 +26,8 @@
** **
** **
**************************************************************************/ **************************************************************************/
#include "remotelinuxusedportsgatherer.h"
#include "linuxdeviceconfiguration.h" #include "remotelinuxusedportsgatherer.h"
#include <utils/portlist.h> #include <utils/portlist.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -38,6 +37,7 @@
#include <QString> #include <QString>
using namespace ProjectExplorer;
using namespace QSsh; using namespace QSsh;
using namespace Utils; using namespace Utils;
@@ -72,7 +72,7 @@ RemoteLinuxUsedPortsGatherer::~RemoteLinuxUsedPortsGatherer()
delete d; delete d;
} }
void RemoteLinuxUsedPortsGatherer::start(const LinuxDeviceConfiguration::ConstPtr &devConf) void RemoteLinuxUsedPortsGatherer::start(const IDevice::ConstPtr &devConf)
{ {
QTC_ASSERT(!d->connection, return); QTC_ASSERT(!d->connection, return);
d->portsToCheck = devConf->freePorts(); d->portsToCheck = devConf->freePorts();

View File

@@ -31,6 +31,8 @@
#include "remotelinux_export.h" #include "remotelinux_export.h"
#include <projectexplorer/devicesupport/idevice.h>
#include <QList> #include <QList>
#include <QObject> #include <QObject>
#include <QSharedPointer> #include <QSharedPointer>
@@ -40,7 +42,6 @@ QT_FORWARD_DECLARE_CLASS(QString)
namespace Utils { class PortList; } namespace Utils { class PortList; }
namespace RemoteLinux { namespace RemoteLinux {
class LinuxDeviceConfiguration;
namespace Internal { namespace Internal {
class RemoteLinuxUsedPortsGathererPrivate; class RemoteLinuxUsedPortsGathererPrivate;
@@ -53,7 +54,7 @@ class REMOTELINUX_EXPORT RemoteLinuxUsedPortsGatherer : public QObject
public: public:
explicit RemoteLinuxUsedPortsGatherer(QObject *parent = 0); explicit RemoteLinuxUsedPortsGatherer(QObject *parent = 0);
~RemoteLinuxUsedPortsGatherer(); ~RemoteLinuxUsedPortsGatherer();
void start(const QSharedPointer<const LinuxDeviceConfiguration> &devConf); void start(const ProjectExplorer::IDevice::ConstPtr &devConf);
void stop(); void stop();
int getNextFreePort(Utils::PortList *freePorts) const; // returns -1 if no more are left int getNextFreePort(Utils::PortList *freePorts) const; // returns -1 if no more are left
QList<int> usedPorts() const; QList<int> usedPorts() const;

View File

@@ -31,7 +31,6 @@
#include "startgdbserverdialog.h" #include "startgdbserverdialog.h"
#include "remotelinuxprocesslist.h" #include "remotelinuxprocesslist.h"
#include "linuxdeviceconfiguration.h"
#include "remotelinuxusedportsgatherer.h" #include "remotelinuxusedportsgatherer.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
@@ -84,11 +83,10 @@ class StartGdbServerDialogPrivate
public: public:
StartGdbServerDialogPrivate(StartGdbServerDialog *q); StartGdbServerDialogPrivate(StartGdbServerDialog *q);
LinuxDeviceConfiguration::ConstPtr currentDevice() const IDevice::ConstPtr currentDevice() const
{ {
Profile *profile = profileChooser->currentProfile(); Profile *profile = profileChooser->currentProfile();
IDevice::ConstPtr device = DeviceProfileInformation::device(profile); return DeviceProfileInformation::device(profile);
return device.dynamicCast<const LinuxDeviceConfiguration>();
} }
StartGdbServerDialog *q; StartGdbServerDialog *q;
@@ -203,7 +201,7 @@ StartGdbServerDialog::~StartGdbServerDialog()
void StartGdbServerDialog::attachToDevice() void StartGdbServerDialog::attachToDevice()
{ {
LinuxDeviceConfiguration::ConstPtr device = d->currentDevice(); IDevice::ConstPtr device = d->currentDevice();
// TODO: display error on non-matching device. // TODO: display error on non-matching device.
if (!device) if (!device)
return; return;
@@ -248,7 +246,7 @@ void StartGdbServerDialog::attachToProcess()
return; return;
d->attachProcessButton->setEnabled(false); d->attachProcessButton->setEnabled(false);
LinuxDeviceConfiguration::ConstPtr device = d->currentDevice(); IDevice::ConstPtr device = d->currentDevice();
if (!device) if (!device)
return; return;
PortList ports = device->freePorts(); PortList ports = device->freePorts();
@@ -352,7 +350,7 @@ void StartGdbServerDialog::handleProcessErrorOutput()
void StartGdbServerDialog::reportOpenPort(int port) void StartGdbServerDialog::reportOpenPort(int port)
{ {
logMessage(tr("Port %1 is now accessible.").arg(port)); logMessage(tr("Port %1 is now accessible.").arg(port));
LinuxDeviceConfiguration::ConstPtr device = d->currentDevice(); IDevice::ConstPtr device = d->currentDevice();
QString channel = QString("%1:%2").arg(device->sshParameters().host).arg(port); QString channel = QString("%1:%2").arg(device->sshParameters().host).arg(port);
logMessage(tr("Server started on %1").arg(channel)); logMessage(tr("Server started on %1").arg(channel));
@@ -375,7 +373,7 @@ void StartGdbServerDialog::handleProcessClosed(int status)
void StartGdbServerDialog::startGdbServerOnPort(int port, int pid) void StartGdbServerDialog::startGdbServerOnPort(int port, int pid)
{ {
LinuxDeviceConfiguration::ConstPtr device = d->currentDevice(); IDevice::ConstPtr device = d->currentDevice();
connect(&d->runner, SIGNAL(connectionError()), SLOT(handleConnectionError())); connect(&d->runner, SIGNAL(connectionError()), SLOT(handleConnectionError()));
connect(&d->runner, SIGNAL(processStarted()), SLOT(handleProcessStarted())); connect(&d->runner, SIGNAL(processStarted()), SLOT(handleProcessStarted()));
connect(&d->runner, SIGNAL(readyReadStandardOutput()), SLOT(handleProcessOutputAvailable())); connect(&d->runner, SIGNAL(readyReadStandardOutput()), SLOT(handleProcessOutputAvailable()));