From 047973c3558eb0b7e868486c78de04cf35dd1ccd Mon Sep 17 00:00:00 2001
From: hjk <qthjk@ovi.com>
Date: Wed, 25 Jul 2012 16:23:26 +0200
Subject: [PATCH] remotelinux: use IDevice base class when appropriate

Change-Id: I6f68f85d50500e4995ab51ee374f8ba5c31d334d
Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
---
 .../remotelinux/remotelinuxprocesslist.cpp    | 20 ++++++-------------
 .../remotelinux/remotelinuxprocesslist.h      |  9 ++++-----
 .../remotelinuxusedportsgatherer.cpp          |  6 +++---
 .../remotelinuxusedportsgatherer.h            |  5 +++--
 .../remotelinux/startgdbserverdialog.cpp      | 14 ++++++-------
 5 files changed, 22 insertions(+), 32 deletions(-)

diff --git a/src/plugins/remotelinux/remotelinuxprocesslist.cpp b/src/plugins/remotelinux/remotelinuxprocesslist.cpp
index a7f8380ee8e..6fa21394e6b 100644
--- a/src/plugins/remotelinux/remotelinuxprocesslist.cpp
+++ b/src/plugins/remotelinux/remotelinuxprocesslist.cpp
@@ -26,16 +26,13 @@
 **
 **
 **************************************************************************/
-#include "remotelinuxprocesslist.h"
 
-#include "linuxdeviceconfiguration.h"
+#include "remotelinuxprocesslist.h"
 
 #include <utils/qtcassert.h>
 #include <ssh/sshremoteprocessrunner.h>
 
-#include <QByteArray>
-#include <QString>
-
+using namespace ProjectExplorer;
 using namespace QSsh;
 
 namespace RemoteLinux {
@@ -55,14 +52,14 @@ static QString visualizeNull(QString s)
 class AbstractRemoteLinuxProcessListPrivate
 {
 public:
-    AbstractRemoteLinuxProcessListPrivate(const LinuxDeviceConfiguration::ConstPtr &devConf)
+    AbstractRemoteLinuxProcessListPrivate(const IDevice::ConstPtr &devConf)
         : deviceConfiguration(devConf),
           state(Inactive)
     {
     }
 
 
-    const LinuxDeviceConfiguration::ConstPtr deviceConfiguration;
+    const IDevice::ConstPtr deviceConfiguration;
     SshRemoteProcessRunner process;
     QList<RemoteProcess> remoteProcesses;
     QString errorMsg;
@@ -73,17 +70,12 @@ public:
 
 using namespace Internal;
 
-AbstractRemoteLinuxProcessList::AbstractRemoteLinuxProcessList(const LinuxDeviceConfiguration::ConstPtr &devConfig,
+AbstractRemoteLinuxProcessList::AbstractRemoteLinuxProcessList(const IDevice::ConstPtr &devConfig,
         QObject *parent)
     : QAbstractTableModel(parent), d(new AbstractRemoteLinuxProcessListPrivate(devConfig))
 {
 }
 
-LinuxDeviceConfiguration::ConstPtr AbstractRemoteLinuxProcessList::deviceConfiguration() const
-{
-    return d->deviceConfiguration;
-}
-
 AbstractRemoteLinuxProcessList::~AbstractRemoteLinuxProcessList()
 {
     delete d;
@@ -224,7 +216,7 @@ void AbstractRemoteLinuxProcessList::setFinished()
 }
 
 
-GenericRemoteLinuxProcessList::GenericRemoteLinuxProcessList(const LinuxDeviceConfiguration::ConstPtr &devConfig,
+GenericRemoteLinuxProcessList::GenericRemoteLinuxProcessList(const IDevice::ConstPtr &devConfig,
         QObject *parent)
     : AbstractRemoteLinuxProcessList(devConfig, parent)
 {
diff --git a/src/plugins/remotelinux/remotelinuxprocesslist.h b/src/plugins/remotelinux/remotelinuxprocesslist.h
index ac45532caa8..df7065373de 100644
--- a/src/plugins/remotelinux/remotelinuxprocesslist.h
+++ b/src/plugins/remotelinux/remotelinuxprocesslist.h
@@ -31,12 +31,13 @@
 
 #include "remotelinux_export.h"
 
+#include <projectexplorer/devicesupport/idevice.h>
+
 #include <QAbstractTableModel>
 #include <QList>
 #include <QSharedPointer>
 
 namespace RemoteLinux {
-class LinuxDeviceConfiguration;
 
 namespace Internal {
 class AbstractRemoteLinuxProcessListPrivate;
@@ -70,11 +71,9 @@ signals:
     void processKilled();
 
 protected:
-    AbstractRemoteLinuxProcessList(const QSharedPointer<const LinuxDeviceConfiguration> &devConfig,
+    AbstractRemoteLinuxProcessList(const ProjectExplorer::IDevice::ConstPtr &devConfig,
         QObject *parent = 0);
 
-    QSharedPointer<const LinuxDeviceConfiguration> deviceConfiguration() const;
-
 private slots:
     void handleConnectionError();
     void handleRemoteProcessFinished(int exitStatus);
@@ -101,7 +100,7 @@ class REMOTELINUX_EXPORT GenericRemoteLinuxProcessList : public AbstractRemoteLi
 {
     Q_OBJECT
 public:
-    GenericRemoteLinuxProcessList(const QSharedPointer<const LinuxDeviceConfiguration> &devConfig,
+    GenericRemoteLinuxProcessList(const ProjectExplorer::IDevice::ConstPtr &devConfig,
         QObject *parent = 0);
 
 protected:
diff --git a/src/plugins/remotelinux/remotelinuxusedportsgatherer.cpp b/src/plugins/remotelinux/remotelinuxusedportsgatherer.cpp
index b62ff2e0da4..557cb3909c4 100644
--- a/src/plugins/remotelinux/remotelinuxusedportsgatherer.cpp
+++ b/src/plugins/remotelinux/remotelinuxusedportsgatherer.cpp
@@ -26,9 +26,8 @@
 **
 **
 **************************************************************************/
-#include "remotelinuxusedportsgatherer.h"
 
-#include "linuxdeviceconfiguration.h"
+#include "remotelinuxusedportsgatherer.h"
 
 #include <utils/portlist.h>
 #include <utils/qtcassert.h>
@@ -38,6 +37,7 @@
 
 #include <QString>
 
+using namespace ProjectExplorer;
 using namespace QSsh;
 using namespace Utils;
 
@@ -72,7 +72,7 @@ RemoteLinuxUsedPortsGatherer::~RemoteLinuxUsedPortsGatherer()
     delete d;
 }
 
-void RemoteLinuxUsedPortsGatherer::start(const LinuxDeviceConfiguration::ConstPtr &devConf)
+void RemoteLinuxUsedPortsGatherer::start(const IDevice::ConstPtr &devConf)
 {
     QTC_ASSERT(!d->connection, return);
     d->portsToCheck = devConf->freePorts();
diff --git a/src/plugins/remotelinux/remotelinuxusedportsgatherer.h b/src/plugins/remotelinux/remotelinuxusedportsgatherer.h
index c2b260dfe8c..a19e3143755 100644
--- a/src/plugins/remotelinux/remotelinuxusedportsgatherer.h
+++ b/src/plugins/remotelinux/remotelinuxusedportsgatherer.h
@@ -31,6 +31,8 @@
 
 #include "remotelinux_export.h"
 
+#include <projectexplorer/devicesupport/idevice.h>
+
 #include <QList>
 #include <QObject>
 #include <QSharedPointer>
@@ -40,7 +42,6 @@ QT_FORWARD_DECLARE_CLASS(QString)
 namespace Utils { class PortList; }
 
 namespace RemoteLinux {
-class LinuxDeviceConfiguration;
 
 namespace Internal {
 class RemoteLinuxUsedPortsGathererPrivate;
@@ -53,7 +54,7 @@ class REMOTELINUX_EXPORT RemoteLinuxUsedPortsGatherer : public QObject
 public:
     explicit RemoteLinuxUsedPortsGatherer(QObject *parent = 0);
     ~RemoteLinuxUsedPortsGatherer();
-    void start(const QSharedPointer<const LinuxDeviceConfiguration> &devConf);
+    void start(const ProjectExplorer::IDevice::ConstPtr &devConf);
     void stop();
     int getNextFreePort(Utils::PortList *freePorts) const; // returns -1 if no more are left
     QList<int> usedPorts() const;
diff --git a/src/plugins/remotelinux/startgdbserverdialog.cpp b/src/plugins/remotelinux/startgdbserverdialog.cpp
index 135b480a20d..00ce4a53132 100644
--- a/src/plugins/remotelinux/startgdbserverdialog.cpp
+++ b/src/plugins/remotelinux/startgdbserverdialog.cpp
@@ -31,7 +31,6 @@
 #include "startgdbserverdialog.h"
 
 #include "remotelinuxprocesslist.h"
-#include "linuxdeviceconfiguration.h"
 #include "remotelinuxusedportsgatherer.h"
 
 #include <coreplugin/icore.h>
@@ -84,11 +83,10 @@ class StartGdbServerDialogPrivate
 public:
     StartGdbServerDialogPrivate(StartGdbServerDialog *q);
 
-    LinuxDeviceConfiguration::ConstPtr currentDevice() const
+    IDevice::ConstPtr currentDevice() const
     {
         Profile *profile = profileChooser->currentProfile();
-        IDevice::ConstPtr device = DeviceProfileInformation::device(profile);
-        return device.dynamicCast<const LinuxDeviceConfiguration>();
+        return DeviceProfileInformation::device(profile);
     }
 
     StartGdbServerDialog *q;
@@ -203,7 +201,7 @@ StartGdbServerDialog::~StartGdbServerDialog()
 
 void StartGdbServerDialog::attachToDevice()
 {
-    LinuxDeviceConfiguration::ConstPtr device = d->currentDevice();
+    IDevice::ConstPtr device = d->currentDevice();
     // TODO: display error on non-matching device.
     if (!device)
         return;
@@ -248,7 +246,7 @@ void StartGdbServerDialog::attachToProcess()
         return;
     d->attachProcessButton->setEnabled(false);
 
-    LinuxDeviceConfiguration::ConstPtr device = d->currentDevice();
+    IDevice::ConstPtr device = d->currentDevice();
     if (!device)
         return;
     PortList ports = device->freePorts();
@@ -352,7 +350,7 @@ void StartGdbServerDialog::handleProcessErrorOutput()
 void StartGdbServerDialog::reportOpenPort(int 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);
     logMessage(tr("Server started on %1").arg(channel));
 
@@ -375,7 +373,7 @@ void StartGdbServerDialog::handleProcessClosed(int status)
 
 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(processStarted()), SLOT(handleProcessStarted()));
     connect(&d->runner, SIGNAL(readyReadStandardOutput()), SLOT(handleProcessOutputAvailable()));
-- 
GitLab