Introduce the concept of a "device process".

Provide a QProcess-like abstraction that can be used
to implement processes running locally or on a remote
device. Objects of a concrete class implementing the functionality
are created by IDevice objects.
Current implementations are:
     - Local execution (QProcess-based), provided via the DesktopDevice.
     - Remote execution via SSH.
     - A specialized case of the former for remote Linux systems (provided by
       LinuxDevice).
The latter is already being used in a number of places. As a result, lots of
code dealing with details such as setting the remote environment could be
moved to a central location. These things are no longer the concern of whoever
is wishing to run a remote process.

Change-Id: I919260ee6e77a020ca47226a4a534e7b8398106f
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
Christian Kandeler
2013-08-08 14:05:11 +02:00
parent dc07796c23
commit 22599094b0
48 changed files with 1214 additions and 208 deletions

View File

@@ -30,6 +30,7 @@
#include "linuxdevice.h"
#include "genericlinuxdeviceconfigurationwidget.h"
#include "linuxdeviceprocess.h"
#include "linuxdevicetester.h"
#include "publickeydeploymentdialog.h"
#include "remotelinux_constants.h"
@@ -122,14 +123,26 @@ QString LinuxDeviceProcessSupport::killProcessByPidCommandLine(int pid) const
return QLatin1String("kill -9 ") + QString::number(pid);
}
QString LinuxDeviceProcessSupport::killProcessByNameCommandLine(const QString &filePath) const
static QString signalProcessByNameCommandLine(const QString &filePath, int signal)
{
return QString::fromLatin1("cd /proc; for pid in `ls -d [0123456789]*`; "
"do "
"if [ \"`readlink /proc/$pid/exe`\" = \"%1\" ]; then "
" kill $pid; sleep 1; kill -9 $pid; "
" kill %2 $pid;"
"fi; "
"done").arg(filePath);
"done").arg(filePath).arg(signal);
}
QString LinuxDeviceProcessSupport::killProcessByNameCommandLine(const QString &filePath) const
{
return QString::fromLatin1("%1; %2").arg(signalProcessByNameCommandLine(filePath, 15),
signalProcessByNameCommandLine(filePath, 9));
}
QString LinuxDeviceProcessSupport::interruptProcessByNameCommandLine(const QString &filePath) const
{
return signalProcessByNameCommandLine(filePath, 2);
}
@@ -244,6 +257,11 @@ DeviceProcessSupport::Ptr LinuxDevice::processSupport() const
return DeviceProcessSupport::Ptr(new LinuxDeviceProcessSupport);
}
DeviceProcess *LinuxDevice::createProcess(QObject *parent) const
{
return new LinuxDeviceProcess(sharedFromThis(), parent);
}
bool LinuxDevice::canAutoDetectPorts() const
{
return true;