Commit 11f5c813 authored by hjk's avatar hjk
Browse files

processlist: prepare for all desktop devices having a processlist



Change-Id: I0b1a7c51bfcfcd53efa87b678da513b6b546c55c
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent da0b6b81
......@@ -31,19 +31,11 @@
#include "desktopdevice.h"
#include "projectexplorerconstants.h"
#include "deviceprocesslist.h"
#ifdef Q_OS_UNIX
#include "localunixprocesslist.h"
#endif
#include "localprocesslist.h"
#include <QCoreApplication>
namespace ProjectExplorer {
namespace Internal {
} // namespace Internal
using namespace Internal;
DesktopDevice::DesktopDevice() : IDevice(Core::Id(Constants::DESKTOP_DEVICE_TYPE),
IDevice::AutoDetected,
......@@ -91,20 +83,12 @@ void DesktopDevice::executeAction(Core::Id actionId, QWidget *parent) const
bool DesktopDevice::canCreateProcessModel() const
{
#ifdef Q_OS_UNIX
return true;
#else
return false;
#endif
}
DeviceProcessList *DesktopDevice::createProcessListModel(QObject *parent) const
{
#ifdef Q_OS_UNIX
return new Internal::LocalUnixProcessList(sharedFromThis(), parent);
#else
return 0;
#endif
return new Internal::LocalProcessList(sharedFromThis(), parent);
}
IDevice::Ptr DesktopDevice::clone() const
......
......@@ -26,7 +26,8 @@
**
**
**************************************************************************/
#include "localunixprocesslist.h"
#include "localprocesslist.h"
#include <QProcess>
#include <QTimer>
......@@ -34,14 +35,16 @@
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#ifdef Q_OS_UNIX
//#include <sys/types.h>
#include <signal.h>
#endif
namespace ProjectExplorer {
namespace Internal {
const int PsFieldWidth = 50;
LocalUnixProcessList::LocalUnixProcessList(const IDevice::ConstPtr &device, QObject *parent)
LocalProcessList::LocalProcessList(const IDevice::ConstPtr &device, QObject *parent)
: DeviceProcessList(device, parent),
m_psProcess(new QProcess(this))
{
......@@ -49,7 +52,7 @@ LocalUnixProcessList::LocalUnixProcessList(const IDevice::ConstPtr &device, QObj
connect(m_psProcess, SIGNAL(finished(int)), SLOT(handlePsFinished()));
}
void LocalUnixProcessList::doUpdate()
void LocalProcessList::doUpdate()
{
// We assume Desktop Unix systems to have a POSIX-compliant ps.
// We need the padding because the command field can contain spaces, so we cannot split on those.
......@@ -57,7 +60,7 @@ void LocalUnixProcessList::doUpdate()
.arg(QString(PsFieldWidth, QChar('x'))));
}
void LocalUnixProcessList::handlePsFinished()
void LocalProcessList::handlePsFinished()
{
QString errorString;
if (m_psProcess->exitStatus() == QProcess::CrashExit) {
......@@ -84,7 +87,7 @@ void LocalUnixProcessList::handlePsFinished()
return;
}
const QByteArray &stderrData = m_psProcess->readAllStandardError();
const QByteArray stderrData = m_psProcess->readAllStandardError();
if (!stderrData.isEmpty()) {
errorString += QLatin1Char('\n') + tr("The stderr output was: '%1'")
.arg(QString::fromLocal8Bit(stderrData));
......@@ -92,23 +95,25 @@ void LocalUnixProcessList::handlePsFinished()
reportError(errorString);
}
void LocalUnixProcessList::handlePsError()
void LocalProcessList::handlePsError()
{
// Other errors are handled in the finished() handler.
if (m_psProcess->error() == QProcess::FailedToStart)
reportError(m_psProcess->errorString());
}
void LocalUnixProcessList::doKillProcess(const DeviceProcess &process)
void LocalProcessList::doKillProcess(const DeviceProcess &process)
{
#ifdef Q_OS_UNIX
if (kill(process.pid, SIGKILL) == -1)
m_error = QString::fromLocal8Bit(strerror(errno));
else
m_error.clear();
QTimer::singleShot(0, this, SLOT(reportDelayedKillStatus()));
#endif
}
void LocalUnixProcessList::reportDelayedKillStatus()
void LocalProcessList::reportDelayedKillStatus()
{
if (m_error.isEmpty())
reportProcessKilled();
......
......@@ -26,8 +26,9 @@
**
**
**************************************************************************/
#ifndef LOCALUNIXPROCESSLIST_H
#define LOCALUNIXPROCESSLIST_H
#ifndef LOCALPROCESSLIST_H
#define LOCALPROCESSLIST_H
#include "deviceprocesslist.h"
......@@ -40,11 +41,12 @@ QT_END_NAMESPACE
namespace ProjectExplorer {
namespace Internal {
class LocalUnixProcessList : public DeviceProcessList
class LocalProcessList : public DeviceProcessList
{
Q_OBJECT
Q_OBJECT
public:
LocalUnixProcessList(const IDevice::ConstPtr &device, QObject *parent = 0);
LocalProcessList(const IDevice::ConstPtr &device, QObject *parent = 0);
private slots:
void handlePsError();
......@@ -62,4 +64,4 @@ private:
} // namespace Internal
} // namespace RemoteLinux
#endif // LOCALUNIXPROCESSLIST_H
#endif // LOCALPROCESSLIST_H
......@@ -273,8 +273,8 @@ equals(TEST, 1) {
}
unix {
SOURCES += devicesupport/localunixprocesslist.cpp
HEADERS += devicesupport/localunixprocesslist.h
SOURCES += devicesupport/localprocesslist.cpp
HEADERS += devicesupport/localprocesslist.h
}
macx:LIBS += -framework Carbon
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment