Commit 4d4ae95b authored by Christian Kandeler's avatar Christian Kandeler
Browse files

Maemo: Nicer process list for non-Fremantle systems.

parent aa2ab949
......@@ -340,7 +340,7 @@ void MaemoDeviceConfigurationsSettingsWidget::showGenerateSshKeyDialog()
void MaemoDeviceConfigurationsSettingsWidget::showRemoteProcesses()
{
MaemoRemoteProcessesDialog dlg(currentConfig()->sshParameters(), this);
MaemoRemoteProcessesDialog dlg(currentConfig(), this);
dlg.exec();
}
......
......@@ -41,6 +41,7 @@
#include "maemoremoteprocessesdialog.h"
#include "ui_maemoremoteprocessesdialog.h"
#include "maemodeviceconfigurations.h"
#include "maemoremoteprocesslist.h"
#include <QtGui/QMessageBox>
......@@ -49,11 +50,11 @@
namespace Qt4ProjectManager {
namespace Internal {
MaemoRemoteProcessesDialog::MaemoRemoteProcessesDialog(const Core::SshConnectionParameters &params,
QWidget *parent) :
MaemoRemoteProcessesDialog::MaemoRemoteProcessesDialog(const MaemoDeviceConfig::ConstPtr &devConfig,
QWidget *parent):
QDialog(parent),
m_ui(new Ui::MaemoRemoteProcessesDialog),
m_processList(new MaemoRemoteProcessList(params, this)),
m_processList(new MaemoRemoteProcessList(devConfig, this)),
m_proxyModel(new QSortFilterProxyModel(this))
{
m_ui->setupUi(this);
......@@ -64,7 +65,12 @@ MaemoRemoteProcessesDialog::MaemoRemoteProcessesDialog(const Core::SshConnection
m_ui->tableView->setModel(m_proxyModel);
connect(m_ui->processFilterLineEdit, SIGNAL(textChanged(QString)),
m_proxyModel, SLOT(setFilterRegExp(QString)));
m_ui->processFilterLineEdit->setText(QLatin1String("[^ ]+"));
// Manually gathered process information is missing the command line for
// some system processes. Dont's show these lines by default.
if (devConfig->osVersion() == MaemoGlobal::Maemo5)
m_ui->processFilterLineEdit->setText(QLatin1String("[^ ]+"));
connect(m_ui->tableView->selectionModel(),
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
SLOT(handleSelectionChanged()));
......
......@@ -41,8 +41,8 @@
#ifndef MAEMOREMOTEPROCESSDIALOG_H
#define MAEMOREMOTEPROCESSDIALOG_H
#include <QtCore/QSharedPointer>
#include <QtGui/QDialog>
#include <coreplugin/ssh/sshconnection.h>
QT_BEGIN_NAMESPACE
namespace Ui {
......@@ -53,6 +53,7 @@ QT_END_NAMESPACE
namespace Qt4ProjectManager {
namespace Internal {
class MaemoDeviceConfig;
class MaemoRemoteProcessList;
class MaemoRemoteProcessesDialog : public QDialog
......@@ -60,7 +61,7 @@ class MaemoRemoteProcessesDialog : public QDialog
Q_OBJECT
public:
explicit MaemoRemoteProcessesDialog(const Core::SshConnectionParameters &params,
explicit MaemoRemoteProcessesDialog(const QSharedPointer<const MaemoDeviceConfig> &devConfig,
QWidget *parent = 0);
~MaemoRemoteProcessesDialog();
......
......@@ -41,6 +41,8 @@
#include "maemoremoteprocesslist.h"
#include "maemodeviceconfigurations.h"
#include <coreplugin/ssh/sshremoteprocessrunner.h>
#include <QtCore/QStringList>
......@@ -55,11 +57,12 @@ const QByteArray LineSeparator2("QTCENDOFLINE---");
const QByteArray LineSeparator = LineSeparator1 + LineSeparator2;
} // anonymous namespace
MaemoRemoteProcessList::MaemoRemoteProcessList(const Core::SshConnectionParameters &params,
MaemoRemoteProcessList::MaemoRemoteProcessList(const MaemoDeviceConfig::ConstPtr &devConfig,
QObject *parent)
: QAbstractTableModel(parent),
m_process(SshRemoteProcessRunner::create(params)),
m_state(Inactive)
: QAbstractTableModel(parent),
m_process(SshRemoteProcessRunner::create(devConfig->sshParameters())),
m_state(Inactive),
m_devConfig(devConfig)
{
}
......@@ -73,17 +76,25 @@ void MaemoRemoteProcessList::update()
}
beginResetModel();
m_remoteProcs.clear();
const QByteArray command = QByteArray()
+ "sep1=" + LineSeparator1 + '\n'
+ "sep2=" + LineSeparator2 + '\n'
+ "pidlist=`ls /proc |grep -E '^[[:digit:]]+$' |sort -n`; "
+ "for pid in $pidlist\n"
+ "do\n"
+ " echo -n \"$pid \"\n"
+ " tr '\\0' ' ' < /proc/$pid/cmdline\n"
+ " echo -n \"$sep1$sep2\"\n"
+ "done\n"
+ "echo ''";
QByteArray command;
// The ps command on Fremantle ignores all command line options, so
// we have to collect the information in /proc manually.
if (m_devConfig->osVersion() == MaemoGlobal::Maemo5) {
command = "sep1=" + LineSeparator1 + '\n'
+ "sep2=" + LineSeparator2 + '\n'
+ "pidlist=`ls /proc |grep -E '^[[:digit:]]+$' |sort -n`; "
+ "for pid in $pidlist\n"
+ "do\n"
+ " echo -n \"$pid \"\n"
+ " tr '\\0' ' ' < /proc/$pid/cmdline\n"
+ " echo -n \"$sep1$sep2\"\n"
+ "done\n"
+ "echo ''";
} else {
command = "ps -eo pid,args";
}
startProcess(command, Listing);
}
......@@ -191,21 +202,25 @@ void MaemoRemoteProcessList::stop()
void MaemoRemoteProcessList::buildProcessList()
{
const bool isFremantle = m_devConfig->osVersion() == MaemoGlobal::Maemo5;
const QString remoteOutput = QString::fromUtf8(m_remoteStdout);
const QStringList &lines
= remoteOutput.split(QString::fromUtf8(LineSeparator));
const QByteArray lineSeparator = isFremantle ? LineSeparator : "\n";
QStringList lines = remoteOutput.split(QString::fromUtf8(lineSeparator));
if (!isFremantle)
lines.removeFirst(); // column headers
foreach (const QString &line, lines) {
const int pidEndPos = line.indexOf(' ');
const QString &trimmedLine = line.trimmed();
const int pidEndPos = trimmedLine.indexOf(' ');
if (pidEndPos == -1)
continue;
bool isNumber;
const int pid = line.left(pidEndPos).toInt(&isNumber);
const int pid = trimmedLine.left(pidEndPos).toInt(&isNumber);
if (!isNumber) {
qDebug("%s: Non-integer value where pid was expected. Line was: '%s'",
Q_FUNC_INFO, qPrintable(line));
Q_FUNC_INFO, qPrintable(trimmedLine));
continue;
}
m_remoteProcs << RemoteProc(pid, line.mid(pidEndPos));
m_remoteProcs << RemoteProc(pid, trimmedLine.mid(pidEndPos));
}
}
......
......@@ -47,17 +47,17 @@
#include <QtCore/QList>
#include <QtCore/QSharedPointer>
#include <QtCore/QString>
#include <coreplugin/ssh/sshconnection.h>
#include <coreplugin/ssh/sshremoteprocessrunner.h>
namespace Qt4ProjectManager {
namespace Internal {
class MaemoDeviceConfig;
class MaemoRemoteProcessList : public QAbstractTableModel
{
Q_OBJECT
public:
explicit MaemoRemoteProcessList(const Core::SshConnectionParameters &params,
explicit MaemoRemoteProcessList(const QSharedPointer<const MaemoDeviceConfig> &devConfig,
QObject *parent = 0);
~MaemoRemoteProcessList();
void update();
......@@ -100,6 +100,7 @@ private:
QString cmdLine;
};
QList<RemoteProc> m_remoteProcs;
const QSharedPointer<const MaemoDeviceConfig> m_devConfig;
};
} // namespace Internal
......
Markdown is supported
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