forked from qt-creator/qt-creator
Maemo: Give users access to remote process list.
This commit is contained in:
@@ -0,0 +1,130 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
** All rights reserved.
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL$
|
||||||
|
** No Commercial Usage
|
||||||
|
** This file contains pre-release code and may not be distributed.
|
||||||
|
** You may use this file in accordance with the terms and conditions
|
||||||
|
** contained in the Technology Preview License Agreement accompanying
|
||||||
|
** this package.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Nokia gives you certain additional
|
||||||
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** If you have questions regarding the use of this file, please contact
|
||||||
|
** Nokia at qt-info@nokia.com.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
#include "maemoremoteprocessesdialog.h"
|
||||||
|
#include "ui_maemoremoteprocessesdialog.h"
|
||||||
|
|
||||||
|
#include "maemoremoteprocesslist.h"
|
||||||
|
|
||||||
|
#include <QtGui/QMessageBox>
|
||||||
|
#include <QtGui/QSortFilterProxyModel>
|
||||||
|
|
||||||
|
namespace Qt4ProjectManager {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
MaemoRemoteProcessesDialog::MaemoRemoteProcessesDialog(const Core::SshConnectionParameters ¶ms,
|
||||||
|
QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
m_ui(new Ui::MaemoRemoteProcessesDialog),
|
||||||
|
m_processList(new MaemoRemoteProcessList(params, this)),
|
||||||
|
m_proxyModel(new QSortFilterProxyModel(this))
|
||||||
|
{
|
||||||
|
m_ui->setupUi(this);
|
||||||
|
m_ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
|
m_proxyModel->setSourceModel(m_processList);
|
||||||
|
m_proxyModel->setDynamicSortFilter(true);
|
||||||
|
m_ui->tableView->setModel(m_proxyModel);
|
||||||
|
connect(m_ui->tableView->selectionModel(),
|
||||||
|
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
|
||||||
|
SLOT(handleSelectionChanged()));
|
||||||
|
connect(m_ui->updateListButton, SIGNAL(clicked()),
|
||||||
|
SLOT(updateProcessList()));
|
||||||
|
connect(m_ui->killProcessButton, SIGNAL(clicked()), SLOT(killProcess()));
|
||||||
|
connect(m_processList, SIGNAL(error(QString)),
|
||||||
|
SLOT(handleRemoteError(QString)));
|
||||||
|
connect(m_processList, SIGNAL(modelReset()),
|
||||||
|
SLOT(handleProcessListUpdated()));
|
||||||
|
connect(m_processList, SIGNAL(processKilled()),
|
||||||
|
SLOT(handleProcessKilled()), Qt::QueuedConnection);
|
||||||
|
connect(m_proxyModel, SIGNAL(layoutChanged()),
|
||||||
|
SLOT(handleProcessListUpdated()));
|
||||||
|
handleSelectionChanged();
|
||||||
|
updateProcessList();
|
||||||
|
}
|
||||||
|
|
||||||
|
MaemoRemoteProcessesDialog::~MaemoRemoteProcessesDialog()
|
||||||
|
{
|
||||||
|
delete m_ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaemoRemoteProcessesDialog::handleRemoteError(const QString &errorMsg)
|
||||||
|
{
|
||||||
|
QMessageBox::critical(this, tr("Remote error"), errorMsg);
|
||||||
|
m_ui->updateListButton->setEnabled(true);
|
||||||
|
handleSelectionChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaemoRemoteProcessesDialog::handleProcessListUpdated()
|
||||||
|
{
|
||||||
|
m_ui->updateListButton->setEnabled(true);
|
||||||
|
m_ui->tableView->resizeRowsToContents();
|
||||||
|
handleSelectionChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaemoRemoteProcessesDialog::updateProcessList()
|
||||||
|
{
|
||||||
|
m_ui->updateListButton->setEnabled(false);
|
||||||
|
m_ui->killProcessButton->setEnabled(false);
|
||||||
|
m_processList->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaemoRemoteProcessesDialog::killProcess()
|
||||||
|
{
|
||||||
|
const QModelIndexList &indexes
|
||||||
|
= m_ui->tableView->selectionModel()->selectedIndexes();
|
||||||
|
if (indexes.empty())
|
||||||
|
return;
|
||||||
|
m_ui->updateListButton->setEnabled(false);
|
||||||
|
m_ui->killProcessButton->setEnabled(false);
|
||||||
|
m_processList->killProcess(m_proxyModel->mapToSource(indexes.first()).row());
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaemoRemoteProcessesDialog::handleProcessKilled()
|
||||||
|
{
|
||||||
|
updateProcessList();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaemoRemoteProcessesDialog::handleSelectionChanged()
|
||||||
|
{
|
||||||
|
m_ui->killProcessButton->setEnabled(m_ui->tableView->selectionModel()->hasSelection());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Qt4ProjectManager
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
** All rights reserved.
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL$
|
||||||
|
** No Commercial Usage
|
||||||
|
** This file contains pre-release code and may not be distributed.
|
||||||
|
** You may use this file in accordance with the terms and conditions
|
||||||
|
** contained in the Technology Preview License Agreement accompanying
|
||||||
|
** this package.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Nokia gives you certain additional
|
||||||
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** If you have questions regarding the use of this file, please contact
|
||||||
|
** Nokia at qt-info@nokia.com.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef MAEMOREMOTEPROCESSDIALOG_H
|
||||||
|
#define MAEMOREMOTEPROCESSDIALOG_H
|
||||||
|
|
||||||
|
#include <QtGui/QDialog>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
namespace Ui {
|
||||||
|
class MaemoRemoteProcessesDialog;
|
||||||
|
}
|
||||||
|
class QSortFilterProxyModel;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Core { class SshConnectionParameters; }
|
||||||
|
|
||||||
|
namespace Qt4ProjectManager {
|
||||||
|
namespace Internal {
|
||||||
|
class MaemoRemoteProcessList;
|
||||||
|
|
||||||
|
class MaemoRemoteProcessesDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit MaemoRemoteProcessesDialog(const Core::SshConnectionParameters ¶ms,
|
||||||
|
QWidget *parent = 0);
|
||||||
|
~MaemoRemoteProcessesDialog();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void updateProcessList();
|
||||||
|
void killProcess();
|
||||||
|
void handleRemoteError(const QString &errorMsg);
|
||||||
|
void handleProcessListUpdated();
|
||||||
|
void handleProcessKilled();
|
||||||
|
void handleSelectionChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::MaemoRemoteProcessesDialog *m_ui;
|
||||||
|
MaemoRemoteProcessList *const m_processList;
|
||||||
|
QSortFilterProxyModel *const m_proxyModel;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Qt4ProjectManager
|
||||||
|
|
||||||
|
#endif // MAEMOREMOTEPROCESSDIALOG_H
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>MaemoRemoteProcessesDialog</class>
|
||||||
|
<widget class="QDialog" name="MaemoRemoteProcessesDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>766</width>
|
||||||
|
<height>684</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Processes running on remote host:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QTableView" name="tableView">
|
||||||
|
<property name="showGrid">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="sortingEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="horizontalHeaderDefaultSectionSize">
|
||||||
|
<number>100</number>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="horizontalHeaderStretchLastSection">
|
||||||
|
<bool>true</bool>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="verticalHeaderVisible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="updateListButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Update List</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="killProcessButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Kill Selected Process</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Close</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>MaemoRemoteProcessesDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>257</x>
|
||||||
|
<y>290</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>MaemoRemoteProcessesDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
||||||
@@ -0,0 +1,248 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
** All rights reserved.
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL$
|
||||||
|
** No Commercial Usage
|
||||||
|
** This file contains pre-release code and may not be distributed.
|
||||||
|
** You may use this file in accordance with the terms and conditions
|
||||||
|
** contained in the Technology Preview License Agreement accompanying
|
||||||
|
** this package.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Nokia gives you certain additional
|
||||||
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** If you have questions regarding the use of this file, please contact
|
||||||
|
** Nokia at qt-info@nokia.com.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "maemoremoteprocesslist.h"
|
||||||
|
|
||||||
|
#include <coreplugin/ssh/sshremoteprocessrunner.h>
|
||||||
|
|
||||||
|
#include <QtCore/QStringList>
|
||||||
|
|
||||||
|
using namespace Core;
|
||||||
|
|
||||||
|
namespace Qt4ProjectManager {
|
||||||
|
namespace Internal {
|
||||||
|
namespace {
|
||||||
|
const QByteArray LineSeparator1("---");
|
||||||
|
const QByteArray LineSeparator2("QTCENDOFLINE---");
|
||||||
|
const QByteArray LineSeparator = LineSeparator1 + LineSeparator2;
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
|
MaemoRemoteProcessList::MaemoRemoteProcessList(const Core::SshConnectionParameters ¶ms,
|
||||||
|
QObject *parent)
|
||||||
|
: QAbstractTableModel(parent),
|
||||||
|
m_process(SshRemoteProcessRunner::create(params)),
|
||||||
|
m_state(Inactive)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
MaemoRemoteProcessList::~MaemoRemoteProcessList() {}
|
||||||
|
|
||||||
|
void MaemoRemoteProcessList::update()
|
||||||
|
{
|
||||||
|
if (m_state != Inactive) {
|
||||||
|
qDebug("%s: Did not expect state to be %d.", Q_FUNC_INFO, m_state);
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
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 ''";
|
||||||
|
startProcess(command, Listing);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaemoRemoteProcessList::killProcess(int row)
|
||||||
|
{
|
||||||
|
Q_ASSERT(row >= 0 && row < m_remoteProcs.count());
|
||||||
|
const QByteArray command
|
||||||
|
= "kill -9 " + QByteArray::number(m_remoteProcs.at(row).pid);
|
||||||
|
startProcess(command, Killing);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaemoRemoteProcessList::startProcess(const QByteArray &cmdLine,
|
||||||
|
State newState)
|
||||||
|
{
|
||||||
|
if (m_state != Inactive) {
|
||||||
|
qDebug("%s: Did not expect state to be %d.", Q_FUNC_INFO, m_state);
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
m_state = newState;
|
||||||
|
connect(m_process.data(), SIGNAL(connectionError(Core::SshError)),
|
||||||
|
SLOT(handleConnectionError()));
|
||||||
|
connect(m_process.data(), SIGNAL(processOutputAvailable(QByteArray)),
|
||||||
|
SLOT(handleRemoteStdOut(QByteArray)));
|
||||||
|
connect(m_process.data(),
|
||||||
|
SIGNAL(processErrorOutputAvailable(QByteArray)),
|
||||||
|
SLOT(handleRemoteStdErr(QByteArray)));
|
||||||
|
connect(m_process.data(), SIGNAL(processClosed(int)),
|
||||||
|
SLOT(handleRemoteProcessFinished(int)));
|
||||||
|
m_remoteStdout.clear();
|
||||||
|
m_remoteStderr.clear();
|
||||||
|
m_errorMsg.clear();
|
||||||
|
m_process->run(cmdLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaemoRemoteProcessList::handleConnectionError()
|
||||||
|
{
|
||||||
|
if (m_state == Inactive)
|
||||||
|
return;
|
||||||
|
|
||||||
|
emit error(tr("Connection failure: %1")
|
||||||
|
.arg(m_process->connection()->errorString()));
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaemoRemoteProcessList::handleRemoteStdOut(const QByteArray &output)
|
||||||
|
{
|
||||||
|
if (m_state == Listing)
|
||||||
|
m_remoteStdout += output;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaemoRemoteProcessList::handleRemoteStdErr(const QByteArray &output)
|
||||||
|
{
|
||||||
|
if (m_state != Inactive)
|
||||||
|
m_remoteStderr += output;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaemoRemoteProcessList::handleRemoteProcessFinished(int exitStatus)
|
||||||
|
{
|
||||||
|
if (m_state == Inactive)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (exitStatus) {
|
||||||
|
case SshRemoteProcess::FailedToStart:
|
||||||
|
m_errorMsg = tr("Error: Remote process failed to start: %1")
|
||||||
|
.arg(m_process->process()->errorString());
|
||||||
|
break;
|
||||||
|
case SshRemoteProcess::KilledBySignal:
|
||||||
|
m_errorMsg = tr("Error: Remote process crashed: %1")
|
||||||
|
.arg(m_process->process()->errorString());
|
||||||
|
break;
|
||||||
|
case SshRemoteProcess::ExitedNormally:
|
||||||
|
if (m_process->process()->exitCode() == 0) {
|
||||||
|
if (m_state == Listing)
|
||||||
|
buildProcessList();
|
||||||
|
} else {
|
||||||
|
m_errorMsg = tr("Remote process failed.");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid exit status");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_errorMsg.isEmpty()) {
|
||||||
|
if (!m_remoteStderr.isEmpty()) {
|
||||||
|
m_errorMsg += tr("\nRemote stderr was: %1")
|
||||||
|
.arg(QString::fromUtf8(m_remoteStderr));
|
||||||
|
}
|
||||||
|
emit error(m_errorMsg);
|
||||||
|
}
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaemoRemoteProcessList::stop()
|
||||||
|
{
|
||||||
|
if (m_state == Inactive)
|
||||||
|
return;
|
||||||
|
|
||||||
|
disconnect(m_process.data(), 0, this, 0);
|
||||||
|
if (m_state == Listing)
|
||||||
|
endResetModel();
|
||||||
|
else if (m_errorMsg.isEmpty())
|
||||||
|
emit processKilled();
|
||||||
|
m_state = Inactive;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaemoRemoteProcessList::buildProcessList()
|
||||||
|
{
|
||||||
|
const QString remoteOutput = QString::fromUtf8(m_remoteStdout);
|
||||||
|
const QStringList &lines
|
||||||
|
= remoteOutput.split(QString::fromUtf8(LineSeparator));
|
||||||
|
foreach (const QString &line, lines) {
|
||||||
|
const int pidEndPos = line.indexOf(' ');
|
||||||
|
if (pidEndPos == -1)
|
||||||
|
continue;
|
||||||
|
bool isNumber;
|
||||||
|
const int pid = line.left(pidEndPos).toInt(&isNumber);
|
||||||
|
if (!isNumber) {
|
||||||
|
qDebug("%s: Non-integer value where pid was expected. Line was: '%s'",
|
||||||
|
Q_FUNC_INFO, qPrintable(line));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
m_remoteProcs << RemoteProc(pid, line.mid(pidEndPos));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int MaemoRemoteProcessList::rowCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
return parent.isValid() ? 0 : m_remoteProcs.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
int MaemoRemoteProcessList::columnCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(parent);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant MaemoRemoteProcessList::headerData(int section,
|
||||||
|
Qt::Orientation orientation, int role) const
|
||||||
|
{
|
||||||
|
if (orientation != Qt::Horizontal || role != Qt::DisplayRole
|
||||||
|
|| section < 0 || section >= columnCount())
|
||||||
|
return QVariant();
|
||||||
|
if (section == 0)
|
||||||
|
return tr("PID");
|
||||||
|
else
|
||||||
|
return tr("Command Line");
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant MaemoRemoteProcessList::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
if (!index.isValid() || index.row() >= rowCount(index.parent())
|
||||||
|
|| index.column() >= columnCount() || role != Qt::DisplayRole)
|
||||||
|
return QVariant();
|
||||||
|
const RemoteProc &proc = m_remoteProcs.at(index.row());
|
||||||
|
if (index.column() == 0)
|
||||||
|
return proc.pid;
|
||||||
|
else
|
||||||
|
return proc.cmdLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Qt4ProjectManager
|
||||||
111
src/plugins/qt4projectmanager/qt-maemo/maemoremoteprocesslist.h
Normal file
111
src/plugins/qt4projectmanager/qt-maemo/maemoremoteprocesslist.h
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
** All rights reserved.
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL$
|
||||||
|
** No Commercial Usage
|
||||||
|
** This file contains pre-release code and may not be distributed.
|
||||||
|
** You may use this file in accordance with the terms and conditions
|
||||||
|
** contained in the Technology Preview License Agreement accompanying
|
||||||
|
** this package.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Nokia gives you certain additional
|
||||||
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** If you have questions regarding the use of this file, please contact
|
||||||
|
** Nokia at qt-info@nokia.com.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef MAEMOREMOTEPROCESSLIST_H
|
||||||
|
#define MAEMOREMOTEPROCESSLIST_H
|
||||||
|
|
||||||
|
#include <QtCore/QAbstractTableModel>
|
||||||
|
#include <QtCore/QByteArray>
|
||||||
|
#include <QtCore/QList>
|
||||||
|
#include <QtCore/QSharedPointer>
|
||||||
|
#include <QtCore/QString>
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class SshConnectionParameters;
|
||||||
|
class SshRemoteProcessRunner;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Qt4ProjectManager {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class MaemoRemoteProcessList : public QAbstractTableModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit MaemoRemoteProcessList(const Core::SshConnectionParameters ¶ms,
|
||||||
|
QObject *parent = 0);
|
||||||
|
~MaemoRemoteProcessList();
|
||||||
|
void update();
|
||||||
|
void killProcess(int row);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void error(const QString &errorMsg);
|
||||||
|
void processKilled();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void handleRemoteStdOut(const QByteArray &output);
|
||||||
|
void handleRemoteStdErr(const QByteArray &output);
|
||||||
|
void handleConnectionError();
|
||||||
|
void handleRemoteProcessFinished(int exitStatus);
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum State { Inactive, Listing, Killing };
|
||||||
|
|
||||||
|
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
virtual QVariant data(const QModelIndex &index,
|
||||||
|
int role = Qt::DisplayRole) const;
|
||||||
|
virtual QVariant headerData(int section, Qt::Orientation orientation,
|
||||||
|
int role = Qt::DisplayRole) const;
|
||||||
|
|
||||||
|
void buildProcessList();
|
||||||
|
void stop();
|
||||||
|
void startProcess(const QByteArray &cmdLine, State newState);
|
||||||
|
|
||||||
|
const QSharedPointer<Core::SshRemoteProcessRunner> m_process;
|
||||||
|
QByteArray m_remoteStdout;
|
||||||
|
QByteArray m_remoteStderr;
|
||||||
|
QString m_errorMsg;
|
||||||
|
State m_state;
|
||||||
|
|
||||||
|
struct RemoteProc {
|
||||||
|
RemoteProc(int pid, const QString &cmdLine)
|
||||||
|
: pid(pid), cmdLine(cmdLine) {}
|
||||||
|
int pid;
|
||||||
|
QString cmdLine;
|
||||||
|
};
|
||||||
|
QList<RemoteProc> m_remoteProcs;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Qt4ProjectManager
|
||||||
|
|
||||||
|
#endif // MAEMOREMOTEPROCESSLIST_H
|
||||||
@@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
#include "maemoconfigtestdialog.h"
|
#include "maemoconfigtestdialog.h"
|
||||||
#include "maemodeviceconfigurations.h"
|
#include "maemodeviceconfigurations.h"
|
||||||
|
#include "maemoremoteprocessesdialog.h"
|
||||||
#include "maemosshconfigdialog.h"
|
#include "maemosshconfigdialog.h"
|
||||||
|
|
||||||
#include <coreplugin/ssh/sshremoteprocessrunner.h>
|
#include <coreplugin/ssh/sshremoteprocessrunner.h>
|
||||||
@@ -342,6 +343,12 @@ void MaemoSettingsWidget::showGenerateSshKeyDialog()
|
|||||||
dialog.exec();
|
dialog.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MaemoSettingsWidget::showRemoteProcesses()
|
||||||
|
{
|
||||||
|
MaemoRemoteProcessesDialog dlg(currentConfig().server, this);
|
||||||
|
dlg.exec();
|
||||||
|
}
|
||||||
|
|
||||||
void MaemoSettingsWidget::setPrivateKey(const QString &path)
|
void MaemoSettingsWidget::setPrivateKey(const QString &path)
|
||||||
{
|
{
|
||||||
m_ui->keyFileLineEdit->setPath(path);
|
m_ui->keyFileLineEdit->setPath(path);
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ private slots:
|
|||||||
void keyFileEditingFinished();
|
void keyFileEditingFinished();
|
||||||
void showPassword(bool showClearText);
|
void showPassword(bool showClearText);
|
||||||
void handleFreePortsChanged();
|
void handleFreePortsChanged();
|
||||||
|
void showRemoteProcesses();
|
||||||
|
|
||||||
// For configuration testing.
|
// For configuration testing.
|
||||||
void testConfig();
|
void testConfig();
|
||||||
|
|||||||
@@ -368,6 +368,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="remoteProcessesButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Remote Processes ...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@@ -438,7 +445,7 @@
|
|||||||
<slot>userNameEditingFinished()</slot>
|
<slot>userNameEditingFinished()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>425</x>
|
<x>384</x>
|
||||||
<y>302</y>
|
<y>302</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
@@ -454,7 +461,7 @@
|
|||||||
<slot>passwordEditingFinished()</slot>
|
<slot>passwordEditingFinished()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>297</x>
|
<x>256</x>
|
||||||
<y>334</y>
|
<y>334</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
@@ -534,7 +541,7 @@
|
|||||||
<slot>keyFileEditingFinished()</slot>
|
<slot>keyFileEditingFinished()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>425</x>
|
<x>384</x>
|
||||||
<y>356</y>
|
<y>356</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
@@ -550,7 +557,7 @@
|
|||||||
<slot>keyFileEditingFinished()</slot>
|
<slot>keyFileEditingFinished()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>425</x>
|
<x>384</x>
|
||||||
<y>356</y>
|
<y>356</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
@@ -710,7 +717,7 @@
|
|||||||
<slot>showPassword(bool)</slot>
|
<slot>showPassword(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>424</x>
|
<x>383</x>
|
||||||
<y>332</y>
|
<y>332</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
@@ -735,6 +742,22 @@
|
|||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>remoteProcessesButton</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>MaemoSettingsWidget</receiver>
|
||||||
|
<slot>showRemoteProcesses()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>443</x>
|
||||||
|
<y>183</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>598</x>
|
||||||
|
<y>378</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
<slots>
|
<slots>
|
||||||
<slot>configNameEditingFinished()</slot>
|
<slot>configNameEditingFinished()</slot>
|
||||||
@@ -756,5 +779,6 @@
|
|||||||
<slot>showGenerateSshKeyDialog()</slot>
|
<slot>showGenerateSshKeyDialog()</slot>
|
||||||
<slot>showPassword(bool)</slot>
|
<slot>showPassword(bool)</slot>
|
||||||
<slot>handleFreePortsChanged()</slot>
|
<slot>handleFreePortsChanged()</slot>
|
||||||
|
<slot>showRemoteProcesses()</slot>
|
||||||
</slots>
|
</slots>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ HEADERS += \
|
|||||||
$$PWD/maemomountspecification.h \
|
$$PWD/maemomountspecification.h \
|
||||||
$$PWD/maemoremotemounter.h \
|
$$PWD/maemoremotemounter.h \
|
||||||
$$PWD/maemoprofilesupdatedialog.h \
|
$$PWD/maemoprofilesupdatedialog.h \
|
||||||
$$PWD/maemousedportsgatherer.h
|
$$PWD/maemousedportsgatherer.h \
|
||||||
|
$$PWD/maemoremoteprocesslist.h \
|
||||||
|
$$PWD/maemoremoteprocessesdialog.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/maemoconfigtestdialog.cpp \
|
$$PWD/maemoconfigtestdialog.cpp \
|
||||||
@@ -66,7 +68,9 @@ SOURCES += \
|
|||||||
$$PWD/maemomountspecification.cpp \
|
$$PWD/maemomountspecification.cpp \
|
||||||
$$PWD/maemoremotemounter.cpp \
|
$$PWD/maemoremotemounter.cpp \
|
||||||
$$PWD/maemoprofilesupdatedialog.cpp \
|
$$PWD/maemoprofilesupdatedialog.cpp \
|
||||||
$$PWD/maemousedportsgatherer.cpp
|
$$PWD/maemousedportsgatherer.cpp \
|
||||||
|
$$PWD/maemoremoteprocesslist.cpp \
|
||||||
|
$$PWD/maemoremoteprocessesdialog.cpp
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
$$PWD/maemoconfigtestdialog.ui \
|
$$PWD/maemoconfigtestdialog.ui \
|
||||||
@@ -74,6 +78,7 @@ FORMS += \
|
|||||||
$$PWD/maemosshconfigdialog.ui \
|
$$PWD/maemosshconfigdialog.ui \
|
||||||
$$PWD/maemopackagecreationwidget.ui \
|
$$PWD/maemopackagecreationwidget.ui \
|
||||||
$$PWD/maemodeploystepwidget.ui \
|
$$PWD/maemodeploystepwidget.ui \
|
||||||
$$PWD/maemoprofilesupdatedialog.ui
|
$$PWD/maemoprofilesupdatedialog.ui \
|
||||||
|
$$PWD/maemoremoteprocessesdialog.ui
|
||||||
|
|
||||||
RESOURCES += $$PWD/qt-maemo.qrc
|
RESOURCES += $$PWD/qt-maemo.qrc
|
||||||
|
|||||||
Reference in New Issue
Block a user