forked from qt-creator/qt-creator
projectexplorer: move kill/list to IDevice
Change-Id: Ic4cbf62a61f7d0bf72e700a77c08788850cde85b Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
This commit is contained in:
@@ -33,11 +33,13 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
|
||||
AndroidDevice::AndroidDevice():
|
||||
ProjectExplorer::IDevice(Core::Id(Constants::ANDROID_DEVICE_TYPE),
|
||||
AndroidDevice::AndroidDevice()
|
||||
: IDevice(Core::Id(Constants::ANDROID_DEVICE_TYPE),
|
||||
IDevice::AutoDetected,
|
||||
IDevice::Hardware,
|
||||
Core::Id(Constants::ANDROID_DEVICE_ID))
|
||||
@@ -46,14 +48,14 @@ AndroidDevice::AndroidDevice():
|
||||
setDeviceState(DeviceReadyToUse);
|
||||
}
|
||||
|
||||
AndroidDevice::AndroidDevice(const AndroidDevice &other):
|
||||
ProjectExplorer::IDevice(other)
|
||||
AndroidDevice::AndroidDevice(const AndroidDevice &other)
|
||||
: ProjectExplorer::IDevice(other)
|
||||
{ }
|
||||
|
||||
|
||||
ProjectExplorer::IDevice::DeviceInfo AndroidDevice::deviceInformation() const
|
||||
IDevice::DeviceInfo AndroidDevice::deviceInformation() const
|
||||
{
|
||||
return ProjectExplorer::IDevice::DeviceInfo();
|
||||
return IDevice::DeviceInfo();
|
||||
}
|
||||
|
||||
QString AndroidDevice::displayType() const
|
||||
@@ -61,7 +63,7 @@ QString AndroidDevice::displayType() const
|
||||
return QCoreApplication::translate("ProjectExplorer::AndroidDevice", "Android");
|
||||
}
|
||||
|
||||
ProjectExplorer::IDeviceWidget *AndroidDevice::createWidget()
|
||||
IDeviceWidget *AndroidDevice::createWidget()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -83,9 +85,26 @@ void AndroidDevice::executeAction(Core::Id actionId, QWidget *parent) const
|
||||
Q_UNUSED(parent)
|
||||
}
|
||||
|
||||
ProjectExplorer::IDevice::Ptr AndroidDevice::clone() const
|
||||
IDevice::Ptr AndroidDevice::clone() const
|
||||
{
|
||||
return ProjectExplorer::IDevice::Ptr(new AndroidDevice(*this));
|
||||
return IDevice::Ptr(new AndroidDevice(*this));
|
||||
}
|
||||
|
||||
QString AndroidDevice::listProcessesCommandLine() const
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString AndroidDevice::killProcessCommandLine(const DeviceProcess &process) const
|
||||
{
|
||||
Q_UNUSED(process);
|
||||
return QString();
|
||||
}
|
||||
|
||||
QList<DeviceProcess> AndroidDevice::buildProcessList(const QString &listProcessesReply) const
|
||||
{
|
||||
Q_UNUSED(listProcessesReply);
|
||||
return QList<DeviceProcess>();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -41,17 +41,19 @@ namespace Internal {
|
||||
class AndroidDevice : public ProjectExplorer::IDevice
|
||||
{
|
||||
public:
|
||||
|
||||
ProjectExplorer::IDevice::DeviceInfo deviceInformation() const;
|
||||
|
||||
virtual QString displayType() const;
|
||||
virtual ProjectExplorer::IDeviceWidget *createWidget();
|
||||
virtual QList<Core::Id> actionIds() const;
|
||||
virtual QString displayNameForActionId(Core::Id actionId) const;
|
||||
virtual void executeAction(Core::Id actionId, QWidget *parent = 0) const;
|
||||
QString displayType() const;
|
||||
ProjectExplorer::IDeviceWidget *createWidget();
|
||||
QList<Core::Id> actionIds() const;
|
||||
QString displayNameForActionId(Core::Id actionId) const;
|
||||
void executeAction(Core::Id actionId, QWidget *parent = 0) const;
|
||||
|
||||
virtual ProjectExplorer::IDevice::Ptr clone() const;
|
||||
ProjectExplorer::IDevice::Ptr clone() const;
|
||||
|
||||
QString listProcessesCommandLine() const;
|
||||
QString killProcessCommandLine(const ProjectExplorer::DeviceProcess &process) const;
|
||||
QList<ProjectExplorer::DeviceProcess> buildProcessList(const QString &listProcessesReply) const;
|
||||
|
||||
protected:
|
||||
friend class AndroidDeviceFactory;
|
||||
|
@@ -111,7 +111,7 @@ void MaddeDevice::executeAction(Core::Id actionId, QWidget *parent) const
|
||||
if (actionId == Core::Id(MaddeDeviceTestActionId))
|
||||
d = new LinuxDeviceTestDialog(device, new MaddeDeviceTester, parent);
|
||||
else if (actionId == Core::Id(MaddeRemoteProcessesActionId))
|
||||
d = new DeviceProcessesDialog(new GenericLinuxProcessList(device), parent);
|
||||
d = new DeviceProcessesDialog(new DeviceProcessList(device), parent);
|
||||
else if (actionId == Core::Id(Constants::GenericDeployKeyToDeviceActionId))
|
||||
d = PublicKeyDeploymentDialog::createDialog(device, parent);
|
||||
// FIXME: Leak?
|
||||
|
@@ -30,11 +30,24 @@
|
||||
|
||||
#include "desktopdevice.h"
|
||||
#include "projectexplorerconstants.h"
|
||||
#include "deviceprocesslist.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
DesktopDevice::DesktopDevice() : IDevice(Core::Id(Constants::DESKTOP_DEVICE_TYPE),
|
||||
IDevice::AutoDetected,
|
||||
IDevice::Hardware,
|
||||
Core::Id(Constants::DESKTOP_DEVICE_ID))
|
||||
{
|
||||
setDisplayName(QCoreApplication::translate("ProjectExplorer::DesktopDevice", "Run locally"));
|
||||
}
|
||||
|
||||
DesktopDevice::DesktopDevice(const DesktopDevice &other) :
|
||||
IDevice(other)
|
||||
{ }
|
||||
|
||||
IDevice::DeviceInfo DesktopDevice::deviceInformation() const
|
||||
{
|
||||
return DeviceInfo();
|
||||
@@ -44,6 +57,7 @@ QString DesktopDevice::displayType() const
|
||||
{
|
||||
return QCoreApplication::translate("ProjectExplorer::DesktopDevice", "Desktop");
|
||||
}
|
||||
|
||||
IDeviceWidget *DesktopDevice::createWidget()
|
||||
{
|
||||
return 0;
|
||||
@@ -71,16 +85,21 @@ IDevice::Ptr DesktopDevice::clone() const
|
||||
return Ptr(new DesktopDevice(*this));
|
||||
}
|
||||
|
||||
DesktopDevice::DesktopDevice() : IDevice(Core::Id(Constants::DESKTOP_DEVICE_TYPE),
|
||||
IDevice::AutoDetected,
|
||||
IDevice::Hardware,
|
||||
Core::Id(Constants::DESKTOP_DEVICE_ID))
|
||||
QString DesktopDevice::listProcessesCommandLine() const
|
||||
{
|
||||
setDisplayName(QCoreApplication::translate("ProjectExplorer::DesktopDevice", "Run locally"));
|
||||
return QString();
|
||||
}
|
||||
|
||||
DesktopDevice::DesktopDevice(const DesktopDevice &other) :
|
||||
IDevice(other)
|
||||
{ }
|
||||
QString DesktopDevice::killProcessCommandLine(const DeviceProcess &process) const
|
||||
{
|
||||
Q_UNUSED(process);
|
||||
return QString();
|
||||
}
|
||||
|
||||
QList<DeviceProcess> DesktopDevice::buildProcessList(const QString &listProcessesReply) const
|
||||
{
|
||||
Q_UNUSED(listProcessesReply);
|
||||
return QList<DeviceProcess>();
|
||||
}
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
@@ -54,6 +54,10 @@ public:
|
||||
|
||||
IDevice::Ptr clone() const;
|
||||
|
||||
QString listProcessesCommandLine() const;
|
||||
QString killProcessCommandLine(const DeviceProcess &process) const;
|
||||
QList<DeviceProcess> buildProcessList(const QString &listProcessesReply) const;
|
||||
|
||||
protected:
|
||||
DesktopDevice();
|
||||
DesktopDevice(const DesktopDevice &other);
|
||||
|
@@ -38,23 +38,16 @@ namespace ProjectExplorer {
|
||||
namespace Internal {
|
||||
|
||||
enum State { Inactive, Listing, Killing };
|
||||
const char Delimiter0[] = "x--";
|
||||
const char Delimiter1[] = "---";
|
||||
|
||||
static QString visualizeNull(QString s)
|
||||
{
|
||||
return s.replace(QLatin1Char('\0'), QLatin1String("<null>"));
|
||||
}
|
||||
|
||||
class DeviceProcessListPrivate
|
||||
{
|
||||
public:
|
||||
DeviceProcessListPrivate(const IDevice::ConstPtr &devConf)
|
||||
: deviceConfiguration(devConf),
|
||||
: device(devConf),
|
||||
state(Inactive)
|
||||
{ }
|
||||
|
||||
const IDevice::ConstPtr deviceConfiguration;
|
||||
const IDevice::ConstPtr device;
|
||||
SshRemoteProcessRunner process;
|
||||
QList<DeviceProcess> remoteProcesses;
|
||||
QString errorMsg;
|
||||
@@ -85,7 +78,7 @@ void DeviceProcessList::update()
|
||||
endRemoveRows();
|
||||
}
|
||||
d->state = Listing;
|
||||
startProcess(listProcessesCommandLine());
|
||||
startProcess(d->device->listProcessesCommandLine());
|
||||
}
|
||||
|
||||
void DeviceProcessList::killProcess(int row)
|
||||
@@ -94,7 +87,7 @@ void DeviceProcessList::killProcess(int row)
|
||||
QTC_ASSERT(d->state == Inactive, return);
|
||||
|
||||
d->state = Killing;
|
||||
startProcess(killProcessCommandLine(d->remoteProcesses.at(row)));
|
||||
startProcess(d->device->killProcessCommandLine(d->remoteProcesses.at(row)));
|
||||
}
|
||||
|
||||
DeviceProcess DeviceProcessList::at(int row) const
|
||||
@@ -102,6 +95,11 @@ DeviceProcess DeviceProcessList::at(int row) const
|
||||
return d->remoteProcesses.at(row);
|
||||
}
|
||||
|
||||
IDevice::ConstPtr DeviceProcessList::device() const
|
||||
{
|
||||
return d->device;
|
||||
}
|
||||
|
||||
int DeviceProcessList::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return parent.isValid() ? 0 : d->remoteProcesses.count();
|
||||
@@ -163,7 +161,7 @@ void DeviceProcessList::handleRemoteProcessFinished(int exitStatus)
|
||||
if (d->state == Listing) {
|
||||
beginResetModel();
|
||||
const QByteArray remoteStdout = d->process.readAllStandardOutput();
|
||||
QList<DeviceProcess> processes = buildProcessList(QString::fromUtf8(remoteStdout.data(),
|
||||
QList<DeviceProcess> processes = d->device->buildProcessList(QString::fromUtf8(remoteStdout.data(),
|
||||
remoteStdout.count()));
|
||||
if (!processes.isEmpty()) {
|
||||
beginInsertRows(QModelIndex(), 0, processes.count()-1);
|
||||
@@ -200,7 +198,7 @@ void DeviceProcessList::startProcess(const QString &cmdLine)
|
||||
connect(&d->process, SIGNAL(processClosed(int)),
|
||||
SLOT(handleRemoteProcessFinished(int)));
|
||||
d->errorMsg.clear();
|
||||
d->process.run(cmdLine.toUtf8(), d->deviceConfiguration->sshParameters());
|
||||
d->process.run(cmdLine.toUtf8(), d->device->sshParameters());
|
||||
}
|
||||
|
||||
void DeviceProcessList::setFinished()
|
||||
@@ -210,73 +208,6 @@ void DeviceProcessList::setFinished()
|
||||
}
|
||||
|
||||
|
||||
GenericLinuxProcessList::GenericLinuxProcessList(const IDevice::ConstPtr &devConfig,
|
||||
QObject *parent)
|
||||
: DeviceProcessList(devConfig, parent)
|
||||
{
|
||||
}
|
||||
|
||||
QString GenericLinuxProcessList::listProcessesCommandLine() const
|
||||
{
|
||||
return QString::fromLatin1(
|
||||
"for dir in `ls -d /proc/[0123456789]*`; do "
|
||||
"test -d $dir || continue;" // Decrease the likelihood of a race condition.
|
||||
"echo $dir;"
|
||||
"cat $dir/cmdline;echo;" // cmdline does not end in newline
|
||||
"cat $dir/stat;"
|
||||
"readlink $dir/exe;"
|
||||
"printf '%1''%2';"
|
||||
"done").arg(Delimiter0).arg(Delimiter1);
|
||||
}
|
||||
|
||||
QString GenericLinuxProcessList::killProcessCommandLine(const DeviceProcess &process) const
|
||||
{
|
||||
return QLatin1String("kill -9 ") + QString::number(process.pid);
|
||||
}
|
||||
|
||||
QList<DeviceProcess> GenericLinuxProcessList::buildProcessList(const QString &listProcessesReply) const
|
||||
{
|
||||
QList<DeviceProcess> processes;
|
||||
const QStringList lines = listProcessesReply.split(QString::fromLatin1(Delimiter0)
|
||||
+ QString::fromLatin1(Delimiter1), QString::SkipEmptyParts);
|
||||
foreach (const QString &line, lines) {
|
||||
const QStringList elements = line.split(QLatin1Char('\n'));
|
||||
if (elements.count() < 4) {
|
||||
qDebug("%s: Expected four list elements, got %d. Line was '%s'.", Q_FUNC_INFO,
|
||||
elements.count(), qPrintable(visualizeNull(line)));
|
||||
continue;
|
||||
}
|
||||
bool ok;
|
||||
const int pid = elements.first().mid(6).toInt(&ok);
|
||||
if (!ok) {
|
||||
qDebug("%s: Expected number in %s. Line was '%s'.", Q_FUNC_INFO,
|
||||
qPrintable(elements.first()), qPrintable(visualizeNull(line)));
|
||||
continue;
|
||||
}
|
||||
QString command = elements.at(1);
|
||||
command.replace(QLatin1Char('\0'), QLatin1Char(' '));
|
||||
if (command.isEmpty()) {
|
||||
const QString &statString = elements.at(2);
|
||||
const int openParenPos = statString.indexOf(QLatin1Char('('));
|
||||
const int closedParenPos = statString.indexOf(QLatin1Char(')'), openParenPos);
|
||||
if (openParenPos == -1 || closedParenPos == -1)
|
||||
continue;
|
||||
command = QLatin1Char('[')
|
||||
+ statString.mid(openParenPos + 1, closedParenPos - openParenPos - 1)
|
||||
+ QLatin1Char(']');
|
||||
}
|
||||
|
||||
DeviceProcess process;
|
||||
process.pid = pid;
|
||||
process.cmdLine = command;
|
||||
process.exe = elements.at(3);
|
||||
processes.append(process);
|
||||
}
|
||||
|
||||
qSort(processes);
|
||||
return processes;
|
||||
}
|
||||
|
||||
bool DeviceProcess::operator <(const DeviceProcess &other) const
|
||||
{
|
||||
if (pid != other.pid)
|
||||
|
@@ -38,40 +38,26 @@
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
namespace Internal {
|
||||
class DeviceProcessListPrivate;
|
||||
}
|
||||
|
||||
class PROJECTEXPLORER_EXPORT DeviceProcess
|
||||
{
|
||||
public:
|
||||
DeviceProcess() : pid(0) {}
|
||||
bool operator<(const DeviceProcess &other) const;
|
||||
|
||||
int pid;
|
||||
QString cmdLine;
|
||||
QString exe;
|
||||
};
|
||||
namespace Internal { class DeviceProcessListPrivate; }
|
||||
|
||||
class PROJECTEXPLORER_EXPORT DeviceProcessList : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class Internal::DeviceProcessListPrivate;
|
||||
|
||||
public:
|
||||
DeviceProcessList(const IDevice::ConstPtr &devConfig, QObject *parent = 0);
|
||||
~DeviceProcessList();
|
||||
|
||||
void update();
|
||||
void killProcess(int row);
|
||||
DeviceProcess at(int row) const;
|
||||
IDevice::ConstPtr device() const;
|
||||
|
||||
signals:
|
||||
void processListUpdated();
|
||||
void error(const QString &errorMsg);
|
||||
void processKilled();
|
||||
|
||||
protected:
|
||||
DeviceProcessList(const IDevice::ConstPtr &devConfig, QObject *parent = 0);
|
||||
|
||||
private slots:
|
||||
void handleConnectionError();
|
||||
void handleRemoteProcessFinished(int exitStatus);
|
||||
@@ -83,31 +69,12 @@ private:
|
||||
int role = Qt::DisplayRole) const;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||
|
||||
virtual QString listProcessesCommandLine() const = 0;
|
||||
virtual QString killProcessCommandLine(const DeviceProcess &process) const = 0;
|
||||
virtual QList<DeviceProcess> buildProcessList(const QString &listProcessesReply) const = 0;
|
||||
|
||||
void startProcess(const QString &cmdLine);
|
||||
void setFinished();
|
||||
|
||||
Internal::DeviceProcessListPrivate * const d;
|
||||
};
|
||||
|
||||
|
||||
class PROJECTEXPLORER_EXPORT GenericLinuxProcessList : public DeviceProcessList
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GenericLinuxProcessList(const IDevice::ConstPtr &devConfig,
|
||||
QObject *parent = 0);
|
||||
|
||||
protected:
|
||||
QString listProcessesCommandLine() const;
|
||||
QString killProcessCommandLine(const DeviceProcess &process) const;
|
||||
QList<DeviceProcess> buildProcessList(const QString &listProcessesReply) const;
|
||||
};
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
||||
#endif // DEVICEPROCESSLIST_H
|
||||
|
@@ -46,9 +46,22 @@ namespace QSsh { class SshConnectionParameters; }
|
||||
namespace Utils { class PortList; }
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
namespace Internal { class IDevicePrivate; }
|
||||
|
||||
class IDeviceWidget;
|
||||
|
||||
class PROJECTEXPLORER_EXPORT DeviceProcess
|
||||
{
|
||||
public:
|
||||
DeviceProcess() : pid(0) {}
|
||||
bool operator<(const DeviceProcess &other) const;
|
||||
|
||||
int pid;
|
||||
QString cmdLine;
|
||||
QString exe;
|
||||
};
|
||||
|
||||
// See cpp file for documentation.
|
||||
class PROJECTEXPLORER_EXPORT IDevice
|
||||
{
|
||||
@@ -86,6 +99,10 @@ public:
|
||||
virtual QString displayNameForActionId(Core::Id actionId) const = 0;
|
||||
virtual void executeAction(Core::Id actionId, QWidget *parent = 0) const = 0;
|
||||
|
||||
virtual QString listProcessesCommandLine() const = 0;
|
||||
virtual QString killProcessCommandLine(const DeviceProcess &process) const = 0;
|
||||
virtual QList<DeviceProcess> buildProcessList(const QString &listProcessesReply) const = 0;
|
||||
|
||||
enum DeviceState { DeviceReadyToUse, DeviceConnected, DeviceDisconnected, DeviceStateUnknown };
|
||||
DeviceState deviceState() const;
|
||||
void setDeviceState(const DeviceState state);
|
||||
|
@@ -37,6 +37,8 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace {
|
||||
const char SERIAL_PORT_NAME_KEY[] = "Qt4ProjectManager.S60DeployConfiguration.SerialPortName";
|
||||
const char DEVICE_ADDRESS_KEY[] = "Qt4ProjectManager.S60DeployConfiguration.DeviceAddress";
|
||||
@@ -49,9 +51,9 @@ const char DEFAULT_CODA_TCP_PORT[] = "65029";
|
||||
namespace Qt4ProjectManager {
|
||||
|
||||
SymbianIDevice::SymbianIDevice() :
|
||||
ProjectExplorer::IDevice(Internal::SymbianIDeviceFactory::deviceType(),
|
||||
ProjectExplorer::IDevice::AutoDetected,
|
||||
ProjectExplorer::IDevice::Hardware,
|
||||
IDevice(Internal::SymbianIDeviceFactory::deviceType(),
|
||||
IDevice::AutoDetected,
|
||||
IDevice::Hardware,
|
||||
Core::Id("Symbian Device")),
|
||||
m_port(QLatin1String(DEFAULT_CODA_TCP_PORT)),
|
||||
m_communicationChannel(CommunicationCodaSerialConnection)
|
||||
@@ -65,21 +67,21 @@ SymbianIDevice::SymbianIDevice(const QVariantMap &map)
|
||||
fromMap(map);
|
||||
}
|
||||
|
||||
ProjectExplorer::IDevice::DeviceInfo SymbianIDevice::deviceInformation() const
|
||||
IDevice::DeviceInfo SymbianIDevice::deviceInformation() const
|
||||
{
|
||||
ProjectExplorer::IDevice::DeviceInfo result;
|
||||
IDevice::DeviceInfo result;
|
||||
switch (communicationChannel()) {
|
||||
case SymbianIDevice::CommunicationCodaSerialConnection: {
|
||||
const SymbianUtils::SymbianDeviceManager *sdm = SymbianUtils::SymbianDeviceManager::instance();
|
||||
const int deviceIndex = sdm->findByPortName(serialPortName());
|
||||
if (deviceIndex == -1) {
|
||||
result << ProjectExplorer::IDevice::DeviceInfoItem(
|
||||
result << IDevice::DeviceInfoItem(
|
||||
QCoreApplication::translate("Qt4ProjectManager::SymbianIDevice", "Device"),
|
||||
QCoreApplication::translate("Qt4ProjectManager::SymbianIDevice", "Not connected"));
|
||||
} else {
|
||||
// device connected
|
||||
const SymbianUtils::SymbianDevice device = sdm->devices().at(deviceIndex);
|
||||
result << ProjectExplorer::IDevice::DeviceInfoItem(
|
||||
result << IDevice::DeviceInfoItem(
|
||||
QCoreApplication::translate("Qt4ProjectManager::SymbianIDevice", "Device"),
|
||||
//: %1 device friendly name, %2 additional information
|
||||
QCoreApplication::translate("Qt4ProjectManager::SymbianIDevice", "%1, %2")
|
||||
@@ -89,7 +91,7 @@ ProjectExplorer::IDevice::DeviceInfo SymbianIDevice::deviceInformation() const
|
||||
break;
|
||||
case SymbianIDevice::CommunicationCodaTcpConnection: {
|
||||
if (!address().isEmpty() && !port().isEmpty()) {
|
||||
result << ProjectExplorer::IDevice::DeviceInfoItem(
|
||||
result << IDevice::DeviceInfoItem(
|
||||
QCoreApplication::translate("Qt4ProjectManager::SymbianIDevice", "IP address"),
|
||||
QCoreApplication::translate("Qt4ProjectManager::SymbianIDevice", "%1:%2")
|
||||
.arg(address(), port()));
|
||||
@@ -103,7 +105,7 @@ ProjectExplorer::IDevice::DeviceInfo SymbianIDevice::deviceInformation() const
|
||||
}
|
||||
|
||||
SymbianIDevice::SymbianIDevice(const SymbianIDevice &other) :
|
||||
ProjectExplorer::IDevice(other)
|
||||
IDevice(other)
|
||||
{
|
||||
m_address = other.m_address;
|
||||
m_communicationChannel = other.m_communicationChannel;
|
||||
@@ -111,7 +113,7 @@ SymbianIDevice::SymbianIDevice(const SymbianIDevice &other) :
|
||||
m_serialPortName = other.m_serialPortName;
|
||||
}
|
||||
|
||||
ProjectExplorer::IDevice::Ptr SymbianIDevice::clone() const
|
||||
IDevice::Ptr SymbianIDevice::clone() const
|
||||
{
|
||||
return Ptr(new SymbianIDevice(*this));
|
||||
}
|
||||
@@ -176,7 +178,7 @@ void SymbianIDevice::setCommunicationChannel(CommunicationChannel channel)
|
||||
|
||||
void SymbianIDevice::fromMap(const QVariantMap &map)
|
||||
{
|
||||
ProjectExplorer::IDevice::fromMap(map);
|
||||
IDevice::fromMap(map);
|
||||
m_serialPortName = map.value(QLatin1String(SERIAL_PORT_NAME_KEY)).toString().trimmed();
|
||||
m_address = map.value(QLatin1String(DEVICE_ADDRESS_KEY)).toString();
|
||||
m_port = map.value(QLatin1String(DEVICE_PORT_KEY), QString(QLatin1String(DEFAULT_CODA_TCP_PORT))).toString();
|
||||
@@ -190,7 +192,7 @@ QString SymbianIDevice::displayType() const
|
||||
return QCoreApplication::translate("Qt4ProjectManager::SymbianIDevice", "Symbian Device");
|
||||
}
|
||||
|
||||
ProjectExplorer::IDeviceWidget *SymbianIDevice::createWidget()
|
||||
IDeviceWidget *SymbianIDevice::createWidget()
|
||||
{
|
||||
return new Internal::SymbianIDeviceConfigurationWidget(sharedFromThis());
|
||||
}
|
||||
@@ -214,7 +216,7 @@ void SymbianIDevice::executeAction(Core::Id actionId, QWidget *parent) const
|
||||
|
||||
QVariantMap SymbianIDevice::toMap() const
|
||||
{
|
||||
QVariantMap map(ProjectExplorer::IDevice::toMap());
|
||||
QVariantMap map = IDevice::toMap();
|
||||
map.insert(QLatin1String(SERIAL_PORT_NAME_KEY), m_serialPortName);
|
||||
map.insert(QLatin1String(DEVICE_ADDRESS_KEY), QVariant(m_address));
|
||||
map.insert(QLatin1String(DEVICE_PORT_KEY), m_port);
|
||||
@@ -240,11 +242,28 @@ void SymbianIDevice::updateState()
|
||||
}
|
||||
|
||||
setDeviceState(sdm->findByPortName(m_serialPortName) >= 0
|
||||
? ProjectExplorer::IDevice::DeviceReadyToUse
|
||||
: ProjectExplorer::IDevice::DeviceDisconnected);
|
||||
? IDevice::DeviceReadyToUse
|
||||
: IDevice::DeviceDisconnected);
|
||||
} else {
|
||||
setDeviceState(ProjectExplorer::IDevice::DeviceStateUnknown);
|
||||
setDeviceState(IDevice::DeviceStateUnknown);
|
||||
}
|
||||
}
|
||||
|
||||
QString SymbianIDevice::listProcessesCommandLine() const
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString SymbianIDevice::killProcessCommandLine(const DeviceProcess &process) const
|
||||
{
|
||||
Q_UNUSED(process);
|
||||
return QString();
|
||||
}
|
||||
|
||||
QList<DeviceProcess> SymbianIDevice::buildProcessList(const QString &listProcessesReply) const
|
||||
{
|
||||
Q_UNUSED(listProcessesReply);
|
||||
return QList<DeviceProcess>();
|
||||
}
|
||||
|
||||
} // namespace qt4projectmanager
|
||||
|
@@ -78,6 +78,10 @@ public:
|
||||
QString displayNameForActionId(Core::Id actionId) const;
|
||||
void executeAction(Core::Id actionId, QWidget*parent) const;
|
||||
|
||||
QString listProcessesCommandLine() const;
|
||||
QString killProcessCommandLine(const ProjectExplorer::DeviceProcess &process) const;
|
||||
QList<ProjectExplorer::DeviceProcess> buildProcessList(const QString &listProcessesReply) const;
|
||||
|
||||
protected:
|
||||
SymbianIDevice(const SymbianIDevice &other);
|
||||
SymbianIDevice &operator=(const SymbianIDevice &); // no impl.
|
||||
|
@@ -46,6 +46,14 @@ using namespace ProjectExplorer;
|
||||
|
||||
namespace RemoteLinux {
|
||||
|
||||
const char Delimiter0[] = "x--";
|
||||
const char Delimiter1[] = "---";
|
||||
|
||||
static QString visualizeNull(QString s)
|
||||
{
|
||||
return s.replace(QLatin1Char('\0'), QLatin1String("<null>"));
|
||||
}
|
||||
|
||||
LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::create(const QString &name,
|
||||
Core::Id type, MachineType machineType, Origin origin, Core::Id id)
|
||||
{
|
||||
@@ -59,8 +67,7 @@ QString LinuxDeviceConfiguration::displayType() const
|
||||
|
||||
ProjectExplorer::IDeviceWidget *LinuxDeviceConfiguration::createWidget()
|
||||
{
|
||||
return new GenericLinuxDeviceConfigurationWidget(sharedFromThis()
|
||||
.staticCast<LinuxDeviceConfiguration>());
|
||||
return new GenericLinuxDeviceConfigurationWidget(sharedFromThis());
|
||||
}
|
||||
|
||||
QList<Core::Id> LinuxDeviceConfiguration::actionIds() const
|
||||
@@ -93,7 +100,7 @@ void LinuxDeviceConfiguration::executeAction(Core::Id actionId, QWidget *parent)
|
||||
if (actionId == Core::Id(Constants::GenericTestDeviceActionId))
|
||||
d = new LinuxDeviceTestDialog(device, new GenericLinuxDeviceTester, parent);
|
||||
else if (actionId == Core::Id(Constants::GenericRemoteProcessesActionId))
|
||||
d = new DeviceProcessesDialog(new GenericLinuxProcessList(device, parent));
|
||||
d = new DeviceProcessesDialog(new DeviceProcessList(device, parent));
|
||||
else if (actionId == Core::Id(Constants::GenericDeployKeyToDeviceActionId))
|
||||
d = PublicKeyDeploymentDialog::createDialog(device, parent);
|
||||
if (d)
|
||||
@@ -122,4 +129,65 @@ ProjectExplorer::IDevice::Ptr LinuxDeviceConfiguration::clone() const
|
||||
return Ptr(new LinuxDeviceConfiguration(*this));
|
||||
}
|
||||
|
||||
QString LinuxDeviceConfiguration::listProcessesCommandLine() const
|
||||
{
|
||||
return QString::fromLatin1(
|
||||
"for dir in `ls -d /proc/[0123456789]*`; do "
|
||||
"test -d $dir || continue;" // Decrease the likelihood of a race condition.
|
||||
"echo $dir;"
|
||||
"cat $dir/cmdline;echo;" // cmdline does not end in newline
|
||||
"cat $dir/stat;"
|
||||
"readlink $dir/exe;"
|
||||
"printf '%1''%2';"
|
||||
"done").arg(Delimiter0).arg(Delimiter1);
|
||||
}
|
||||
|
||||
QString LinuxDeviceConfiguration::killProcessCommandLine(const DeviceProcess &process) const
|
||||
{
|
||||
return QLatin1String("kill -9 ") + QString::number(process.pid);
|
||||
}
|
||||
|
||||
QList<DeviceProcess> LinuxDeviceConfiguration::buildProcessList(const QString &listProcessesReply) const
|
||||
{
|
||||
QList<DeviceProcess> processes;
|
||||
const QStringList lines = listProcessesReply.split(QString::fromLatin1(Delimiter0)
|
||||
+ QString::fromLatin1(Delimiter1), QString::SkipEmptyParts);
|
||||
foreach (const QString &line, lines) {
|
||||
const QStringList elements = line.split(QLatin1Char('\n'));
|
||||
if (elements.count() < 4) {
|
||||
qDebug("%s: Expected four list elements, got %d. Line was '%s'.", Q_FUNC_INFO,
|
||||
elements.count(), qPrintable(visualizeNull(line)));
|
||||
continue;
|
||||
}
|
||||
bool ok;
|
||||
const int pid = elements.first().mid(6).toInt(&ok);
|
||||
if (!ok) {
|
||||
qDebug("%s: Expected number in %s. Line was '%s'.", Q_FUNC_INFO,
|
||||
qPrintable(elements.first()), qPrintable(visualizeNull(line)));
|
||||
continue;
|
||||
}
|
||||
QString command = elements.at(1);
|
||||
command.replace(QLatin1Char('\0'), QLatin1Char(' '));
|
||||
if (command.isEmpty()) {
|
||||
const QString &statString = elements.at(2);
|
||||
const int openParenPos = statString.indexOf(QLatin1Char('('));
|
||||
const int closedParenPos = statString.indexOf(QLatin1Char(')'), openParenPos);
|
||||
if (openParenPos == -1 || closedParenPos == -1)
|
||||
continue;
|
||||
command = QLatin1Char('[')
|
||||
+ statString.mid(openParenPos + 1, closedParenPos - openParenPos - 1)
|
||||
+ QLatin1Char(']');
|
||||
}
|
||||
|
||||
DeviceProcess process;
|
||||
process.pid = pid;
|
||||
process.cmdLine = command;
|
||||
process.exe = elements.at(3);
|
||||
processes.append(process);
|
||||
}
|
||||
|
||||
qSort(processes);
|
||||
return processes;
|
||||
}
|
||||
|
||||
} // namespace RemoteLinux
|
||||
|
@@ -62,6 +62,10 @@ public:
|
||||
void executeAction(Core::Id actionId, QWidget *parent) const;
|
||||
ProjectExplorer::IDevice::Ptr clone() const;
|
||||
|
||||
QString listProcessesCommandLine() const;
|
||||
QString killProcessCommandLine(const ProjectExplorer::DeviceProcess &process) const;
|
||||
QList<ProjectExplorer::DeviceProcess> buildProcessList(const QString &listProcessesReply) const;
|
||||
|
||||
protected:
|
||||
LinuxDeviceConfiguration() {}
|
||||
LinuxDeviceConfiguration(const QString &name, Core::Id type,
|
||||
|
@@ -206,7 +206,7 @@ void StartGdbServerDialog::attachToDevice()
|
||||
if (!device)
|
||||
return;
|
||||
delete d->processList;
|
||||
d->processList = new GenericLinuxProcessList(device);
|
||||
d->processList = new DeviceProcessList(device);
|
||||
d->proxyModel.setSourceModel(d->processList);
|
||||
connect(d->processList, SIGNAL(error(QString)),
|
||||
SLOT(handleRemoteError(QString)));
|
||||
|
Reference in New Issue
Block a user