diff options
| author | Chris Craig <craig@ics.com> | 2013-03-06 17:49:11 -0500 |
|---|---|---|
| committer | Chris Craig <craig@ics.com> | 2013-03-08 20:43:33 +0100 |
| commit | ea4c35542e7b3bf4ef92d1e38a4acf77cf9ec7fd (patch) | |
| tree | 926d319885cd69cfd421fbaafa569052192e6c34 | |
| parent | b3c127ab0d29f9d245a9639c216caedf4a41ca69 (diff) | |
Rename files and classes to begin with [Qq]
Change-Id: I68b75ef640f96671b6b8a9a169056c31e8d47443
Reviewed-by: Chris Craig <craig@ics.com>
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | src/processmanager-declarative/declarativeprocessmanager.cpp | 362 | ||||
| -rw-r--r-- | src/processmanager-declarative/processmanager-declarative-lib.pri | 16 | ||||
| -rw-r--r-- | src/processmanager-declarative/qdeclarativematchdelegate.cpp (renamed from src/processmanager-declarative/declarativematchdelegate.cpp) | 32 | ||||
| -rw-r--r-- | src/processmanager-declarative/qdeclarativematchdelegate.h (renamed from src/processmanager-declarative/declarativematchdelegate.h) | 10 | ||||
| -rw-r--r-- | src/processmanager-declarative/qdeclarativeprocessmanager.cpp | 362 | ||||
| -rw-r--r-- | src/processmanager-declarative/qdeclarativeprocessmanager.h (renamed from src/processmanager-declarative/declarativeprocessmanager.h) | 18 | ||||
| -rw-r--r-- | src/processmanager-declarative/qdeclarativerewritedelegate.cpp (renamed from src/processmanager-declarative/declarativerewritedelegate.cpp) | 32 | ||||
| -rw-r--r-- | src/processmanager-declarative/qdeclarativerewritedelegate.h (renamed from src/processmanager-declarative/declarativerewritedelegate.h) | 10 | ||||
| -rw-r--r-- | src/processmanager-declarative/qdeclarativesocketlauncher.cpp (renamed from src/processmanager-declarative/declarativesocketlauncher.cpp) | 32 | ||||
| -rw-r--r-- | src/processmanager-declarative/qdeclarativesocketlauncher.h (renamed from src/processmanager-declarative/declarativesocketlauncher.h) | 16 | ||||
| -rw-r--r-- | src/processmanager/doc/doc.pri (renamed from doc/doc.pri) | 0 | ||||
| -rw-r--r-- | src/processmanager/doc/images/process_structs.png (renamed from doc/images/process_structs.png) | bin | 10306 -> 10306 bytes | |||
| -rw-r--r-- | src/processmanager/doc/images/processbackend_hierarchy.png (renamed from doc/images/processbackend_hierarchy.png) | bin | 9517 -> 9517 bytes | |||
| -rw-r--r-- | src/processmanager/doc/images/processbackendfactory_hierarchy.png (renamed from doc/images/processbackendfactory_hierarchy.png) | bin | 9562 -> 9562 bytes | |||
| -rw-r--r-- | src/processmanager/doc/images/processbackendmanager_hierarchy.png (renamed from doc/images/processbackendmanager_hierarchy.png) | bin | 7665 -> 7665 bytes | |||
| -rw-r--r-- | src/processmanager/doc/processmanager.qdocconf (renamed from doc/processmanager.qdocconf) | 26 | ||||
| -rw-r--r-- | src/processmanager/doc/src/basicpm.qdoc (renamed from doc/src/basicpm.qdoc) | 88 | ||||
| -rw-r--r-- | src/processmanager/doc/src/index.qdoc (renamed from doc/src/index.qdoc) | 6 | ||||
| -rw-r--r-- | src/processmanager/doc/src/intro.qdoc (renamed from doc/src/intro.qdoc) | 12 | ||||
| -rw-r--r-- | src/processmanager/doc/src/namespace.qdoc (renamed from doc/src/namespace.qdoc) | 24 | ||||
| -rw-r--r-- | src/processmanager/doc/src/processinfo.qdoc (renamed from doc/src/processinfo.qdoc) | 12 | ||||
| -rw-r--r-- | src/processmanager/doc/src/qmlpm.qdoc (renamed from doc/src/qmlpm.qdoc) | 2 | ||||
| -rw-r--r-- | src/processmanager/doc/src/standardpm.qdoc (renamed from doc/src/standardpm.qdoc) | 64 | ||||
| -rw-r--r-- | src/processmanager/doc/style/style.css (renamed from doc/style/style.css) | 0 | ||||
| -rw-r--r-- | src/processmanager/launcherclient.cpp | 212 | ||||
| -rw-r--r-- | src/processmanager/processmanager-lib.pri | 138 | ||||
| -rw-r--r-- | src/processmanager/processmanager.pro | 2 | ||||
| -rw-r--r-- | src/processmanager/qcpuidledelegate.cpp (renamed from src/processmanager/cpuidledelegate.cpp) | 41 | ||||
| -rw-r--r-- | src/processmanager/qcpuidledelegate.h (renamed from src/processmanager/cpuidledelegate.h) | 10 | ||||
| -rw-r--r-- | src/processmanager/qforklauncher.cpp (renamed from src/processmanager/forklauncher.cpp) | 142 | ||||
| -rw-r--r-- | src/processmanager/qforklauncher.h (renamed from src/processmanager/forklauncher.h) | 6 | ||||
| -rw-r--r-- | src/processmanager/qgdbrewritedelegate.cpp (renamed from src/processmanager/gdbrewritedelegate.cpp) | 23 | ||||
| -rw-r--r-- | src/processmanager/qgdbrewritedelegate.h (renamed from src/processmanager/gdbrewritedelegate.h) | 10 | ||||
| -rw-r--r-- | src/processmanager/qidledelegate.cpp (renamed from src/processmanager/idledelegate.cpp) | 39 | ||||
| -rw-r--r-- | src/processmanager/qidledelegate.h (renamed from src/processmanager/idledelegate.h) | 8 | ||||
| -rw-r--r-- | src/processmanager/qinfomatchdelegate.cpp (renamed from src/processmanager/infomatchdelegate.cpp) | 31 | ||||
| -rw-r--r-- | src/processmanager/qinfomatchdelegate.h (renamed from src/processmanager/infomatchdelegate.h) | 20 | ||||
| -rw-r--r-- | src/processmanager/qioidledelegate.cpp (renamed from src/processmanager/ioidledelegate.cpp) | 55 | ||||
| -rw-r--r-- | src/processmanager/qioidledelegate.h (renamed from src/processmanager/ioidledelegate.h) | 10 | ||||
| -rw-r--r-- | src/processmanager/qkeymatchdelegate.cpp (renamed from src/processmanager/keymatchdelegate.cpp) | 47 | ||||
| -rw-r--r-- | src/processmanager/qkeymatchdelegate.h (renamed from src/processmanager/keymatchdelegate.h) | 10 | ||||
| -rw-r--r-- | src/processmanager/qlauncherclient.cpp | 213 | ||||
| -rw-r--r-- | src/processmanager/qlauncherclient.h (renamed from src/processmanager/launcherclient.h) | 16 | ||||
| -rw-r--r-- | src/processmanager/qmatchdelegate.cpp (renamed from src/processmanager/matchdelegate.cpp) | 15 | ||||
| -rw-r--r-- | src/processmanager/qmatchdelegate.h (renamed from src/processmanager/matchdelegate.h) | 12 | ||||
| -rw-r--r-- | src/processmanager/qpipelauncher.cpp (renamed from src/processmanager/pipelauncher.cpp) | 55 | ||||
| -rw-r--r-- | src/processmanager/qpipelauncher.h (renamed from src/processmanager/pipelauncher.h) | 10 | ||||
| -rw-r--r-- | src/processmanager/qpipeprocessbackendfactory.cpp (renamed from src/processmanager/pipeprocessbackendfactory.cpp) | 77 | ||||
| -rw-r--r-- | src/processmanager/qpipeprocessbackendfactory.h (renamed from src/processmanager/pipeprocessbackendfactory.h) | 22 | ||||
| -rw-r--r-- | src/processmanager/qpmprocess.cpp (renamed from src/processmanager/process.cpp) | 15 | ||||
| -rw-r--r-- | src/processmanager/qpmprocess.h (renamed from src/processmanager/process.h) | 4 | ||||
| -rw-r--r-- | src/processmanager/qprefork.cpp (renamed from src/processmanager/prefork.cpp) | 60 | ||||
| -rw-r--r-- | src/processmanager/qprefork.h (renamed from src/processmanager/prefork.h) | 14 | ||||
| -rw-r--r-- | src/processmanager/qpreforkprocessbackendfactory.cpp (renamed from src/processmanager/preforkprocessbackendfactory.cpp) | 62 | ||||
| -rw-r--r-- | src/processmanager/qpreforkprocessbackendfactory.h (renamed from src/processmanager/preforkprocessbackendfactory.h) | 10 | ||||
| -rw-r--r-- | src/processmanager/qprelaunchprocessbackend.cpp (renamed from src/processmanager/prelaunchprocessbackend.cpp) | 59 | ||||
| -rw-r--r-- | src/processmanager/qprelaunchprocessbackend.h (renamed from src/processmanager/prelaunchprocessbackend.h) | 12 | ||||
| -rw-r--r-- | src/processmanager/qprelaunchprocessbackendfactory.cpp (renamed from src/processmanager/prelaunchprocessbackendfactory.cpp) | 91 | ||||
| -rw-r--r-- | src/processmanager/qprelaunchprocessbackendfactory.h (renamed from src/processmanager/prelaunchprocessbackendfactory.h) | 32 | ||||
| -rw-r--r-- | src/processmanager/qprocessbackend.cpp (renamed from src/processmanager/processbackend.cpp) | 107 | ||||
| -rw-r--r-- | src/processmanager/qprocessbackend.h (renamed from src/processmanager/processbackend.h) | 16 | ||||
| -rw-r--r-- | src/processmanager/qprocessbackendfactory.cpp (renamed from src/processmanager/processbackendfactory.cpp) | 99 | ||||
| -rw-r--r-- | src/processmanager/qprocessbackendfactory.h (renamed from src/processmanager/processbackendfactory.h) | 48 | ||||
| -rw-r--r-- | src/processmanager/qprocessbackendmanager.cpp (renamed from src/processmanager/processbackendmanager.cpp) | 117 | ||||
| -rw-r--r-- | src/processmanager/qprocessbackendmanager.h (renamed from src/processmanager/processbackendmanager.h) | 40 | ||||
| -rw-r--r-- | src/processmanager/qprocessfrontend.cpp (renamed from src/processmanager/processfrontend.cpp) | 131 | ||||
| -rw-r--r-- | src/processmanager/qprocessfrontend.h (renamed from src/processmanager/processfrontend.h) | 22 | ||||
| -rw-r--r-- | src/processmanager/qprocessinfo.cpp (renamed from src/processmanager/processinfo.cpp) | 232 | ||||
| -rw-r--r-- | src/processmanager/qprocessinfo.h (renamed from src/processmanager/processinfo.h) | 16 | ||||
| -rw-r--r-- | src/processmanager/qprocesslist.h (renamed from src/processmanager/processlist.h) | 12 | ||||
| -rw-r--r-- | src/processmanager/qprocessmanager-global.h (renamed from src/processmanager/processmanager-global.h) | 16 | ||||
| -rw-r--r-- | src/processmanager/qprocessmanager.cpp (renamed from src/processmanager/processmanager.cpp) | 113 | ||||
| -rw-r--r-- | src/processmanager/qprocessmanager.h (renamed from src/processmanager/processmanager.h) | 48 | ||||
| -rw-r--r-- | src/processmanager/qprocutils.cpp (renamed from src/processmanager/procutils.cpp) | 60 | ||||
| -rw-r--r-- | src/processmanager/qprocutils.h (renamed from src/processmanager/procutils.h) | 12 | ||||
| -rw-r--r-- | src/processmanager/qremoteprocessbackend.cpp (renamed from src/processmanager/remoteprocessbackend.cpp) | 137 | ||||
| -rw-r--r-- | src/processmanager/qremoteprocessbackend.h (renamed from src/processmanager/remoteprocessbackend.h) | 16 | ||||
| -rw-r--r-- | src/processmanager/qremoteprocessbackendfactory.cpp (renamed from src/processmanager/remoteprocessbackendfactory.cpp) | 71 | ||||
| -rw-r--r-- | src/processmanager/qremoteprocessbackendfactory.h (renamed from src/processmanager/remoteprocessbackendfactory.h) | 18 | ||||
| -rw-r--r-- | src/processmanager/qremoteprotocol.h (renamed from src/processmanager/remoteprotocol.h) | 4 | ||||
| -rw-r--r-- | src/processmanager/qrewritedelegate.cpp (renamed from src/processmanager/rewritedelegate.cpp) | 17 | ||||
| -rw-r--r-- | src/processmanager/qrewritedelegate.h (renamed from src/processmanager/rewritedelegate.h) | 12 | ||||
| -rw-r--r-- | src/processmanager/qsocketlauncher.cpp (renamed from src/processmanager/socketlauncher.cpp) | 87 | ||||
| -rw-r--r-- | src/processmanager/qsocketlauncher.h (renamed from src/processmanager/socketlauncher.h) | 16 | ||||
| -rw-r--r-- | src/processmanager/qsocketprocessbackendfactory.cpp (renamed from src/processmanager/socketprocessbackendfactory.cpp) | 41 | ||||
| -rw-r--r-- | src/processmanager/qsocketprocessbackendfactory.h (renamed from src/processmanager/socketprocessbackendfactory.h) | 10 | ||||
| -rw-r--r-- | src/processmanager/qstandardprocessbackend.cpp (renamed from src/processmanager/standardprocessbackend.cpp) | 33 | ||||
| -rw-r--r-- | src/processmanager/qstandardprocessbackend.h (renamed from src/processmanager/standardprocessbackend.h) | 8 | ||||
| -rw-r--r-- | src/processmanager/qstandardprocessbackendfactory.cpp (renamed from src/processmanager/standardprocessbackendfactory.cpp) | 23 | ||||
| -rw-r--r-- | src/processmanager/qstandardprocessbackendfactory.h (renamed from src/processmanager/standardprocessbackendfactory.h) | 10 | ||||
| -rw-r--r-- | src/processmanager/qtimeoutidledelegate.cpp (renamed from src/processmanager/timeoutidledelegate.cpp) | 27 | ||||
| -rw-r--r-- | src/processmanager/qtimeoutidledelegate.h (renamed from src/processmanager/timeoutidledelegate.h) | 10 | ||||
| -rw-r--r-- | src/processmanager/qunixprocessbackend.cpp (renamed from src/processmanager/unixprocessbackend.cpp) | 101 | ||||
| -rw-r--r-- | src/processmanager/qunixprocessbackend.h (renamed from src/processmanager/unixprocessbackend.h) | 10 | ||||
| -rw-r--r-- | src/processmanager/qunixsandboxprocess.cpp (renamed from src/processmanager/unixsandboxprocess.cpp) | 40 | ||||
| -rw-r--r-- | src/processmanager/qunixsandboxprocess_p.h (renamed from src/processmanager/unixsandboxprocess.h) | 6 | ||||
| -rw-r--r-- | tests/auto/declarative/testSocketLauncher/main.cpp | 12 | ||||
| -rw-r--r-- | tests/auto/declarative/tst_declarative.cpp | 38 | ||||
| -rw-r--r-- | tests/auto/matcher/tst_matcher.cpp | 26 | ||||
| -rw-r--r-- | tests/auto/processmanager/testForkLauncher/testForkLauncher.cpp | 4 | ||||
| -rw-r--r-- | tests/auto/processmanager/testPipeLauncher/testPipeLauncher.cpp | 16 | ||||
| -rw-r--r-- | tests/auto/processmanager/testPrefork/testPrefork.cpp | 4 | ||||
| -rw-r--r-- | tests/auto/processmanager/testPreforkLauncher/testPreforkLauncher.cpp | 8 | ||||
| -rw-r--r-- | tests/auto/processmanager/testPrelaunch/testPrelaunch.cpp | 8 | ||||
| -rw-r--r-- | tests/auto/processmanager/testSocketLauncher/testSocketLauncher.cpp | 16 | ||||
| -rw-r--r-- | tests/auto/processmanager/tst_processmanager.cpp | 266 | ||||
| -rw-r--r-- | tests/auto/rewrite/tst_rewrite.cpp | 8 |
108 files changed, 2470 insertions, 2430 deletions
@@ -21,3 +21,4 @@ Makefile.Debug Makefile.Release examples/plugin/lib* mkspecs +doc diff --git a/src/processmanager-declarative/declarativeprocessmanager.cpp b/src/processmanager-declarative/declarativeprocessmanager.cpp deleted file mode 100644 index 4025f00..0000000 --- a/src/processmanager-declarative/declarativeprocessmanager.cpp +++ /dev/null @@ -1,362 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "declarativeprocessmanager.h" -#include "processbackendfactory.h" -#include "processfrontend.h" - -#include "prelaunchprocessbackend.h" -#include "remoteprocessbackend.h" -#include "standardprocessbackend.h" - -#include "cpuidledelegate.h" -#include "timeoutidledelegate.h" -#include "gdbrewritedelegate.h" -#include "infomatchdelegate.h" -#include "keymatchdelegate.h" -#include "pipelauncher.h" -#include "pipeprocessbackendfactory.h" -#include "preforkprocessbackendfactory.h" -#include "prelaunchprocessbackendfactory.h" -#include "socketlauncher.h" -#include "standardprocessbackendfactory.h" -#include "socketprocessbackendfactory.h" - -#include "declarativematchdelegate.h" -#include "declarativesocketlauncher.h" -#include "declarativerewritedelegate.h" - -#include <QDebug> - -QT_BEGIN_NAMESPACE_PROCESSMANAGER - -/*! - \qmlclass PmManager DeclarativeProcessManager - \brief The PmManager class encapsulates ways of creating and tracking processes - suitable for QtQml programs. - - Only a single PmManager object should be loaded at one time. - - Typical use of the PmManager class is as follows: - - \code - import QtQuick 2.0 - import ProcessManager 1.0 - - PmManager { - id: myProcessManager - - factories: [ - GdbProcessBackendFactory {}, - StandardProcessBackendFactory {} - ] - } - \endcode -*/ - -/*! - \qmlproperty list<ProcessBackendFactory> PmManager::factories - List of ProcessBackendFactory objects. - - The order of the list is important. When launching a new - process, each factory will be consulted in order to select - the factory that will launch the process. - */ - -/*! - \class DeclarativeProcessManager - \brief The DeclarativeProcessManager class is a ProcessManager designed to be embedded - in a QML context. - */ - -/*! - \fn DeclarativeProcessManager::registerTypes(const char *uri) - \brief Register all QML data types for the process manager - - Register all types with the QML object system. Pass the name the - library to register as \a uri. - */ - -void DeclarativeProcessManager::registerTypes(const char *uri) -{ - // Non-creatable types - qmlRegisterType<IdleDelegate>(); - qmlRegisterType<MatchDelegate>(); - qmlRegisterType<PrelaunchProcessBackend>(); - qmlRegisterType<ProcessBackend>(); - qmlRegisterType<ProcessFrontend>(); - qmlRegisterType<ProcessBackendFactory>(); - qmlRegisterType<RemoteProcessBackend>(); - qmlRegisterType<RemoteProcessBackendFactory>(); - qmlRegisterType<RewriteDelegate>(); - qmlRegisterType<StandardProcessBackend>(); - qmlRegisterType<UnixProcessBackend>(); - - qRegisterMetaType<ProcessFrontend*>("ProcessFrontend*"); - qRegisterMetaType<ProcessInfo*>("ProcessInfo*"); - qRegisterMetaType<MatchDelegate*>("MatchDelegate*"); - qRegisterMetaType<RewriteDelegate*>("RewriteDelegate*"); - - // Non-creatable, with enum values - qmlRegisterUncreatableType<Process>(uri, 1, 0, "Process", QStringLiteral("Don't try to make this")); - - // Types registered from the Core library - qmlRegisterType<CpuIdleDelegate>(uri, 1, 0, "CpuIdleDelegate"); - qmlRegisterType<GdbRewriteDelegate>(uri, 1, 0, "GdbRewriteDelegate"); - qmlRegisterType<InfoMatchDelegate>(uri, 1, 0, "InfoMatchDelegate"); - qmlRegisterType<KeyMatchDelegate>(uri, 1, 0, "KeyMatchDelegate"); - qmlRegisterType<PipeLauncher>(uri, 1, 0, "PipeLauncher"); - qmlRegisterType<PipeProcessBackendFactory>(uri, 1, 0, "PipeProcessBackendFactory"); - qmlRegisterType<PreforkProcessBackendFactory>(uri, 1, 0, "PreforkProcessBackendFactory"); - qmlRegisterType<PrelaunchProcessBackendFactory>(uri, 1, 0, "PrelaunchProcessBackendFactory"); - qmlRegisterType<ProcessBackendManager>(uri, 1, 0, "ProcessBackendManager"); - qmlRegisterType<ProcessInfo>(uri, 1, 0, "ProcessInfo"); - qmlRegisterType<ProcessManager>(uri, 1, 0, "ProcessManager"); - qmlRegisterType<SocketLauncher>(uri, 1, 0, "SocketLauncher"); - qmlRegisterType<SocketProcessBackendFactory>(uri, 1, 0, "SocketProcessBackendFactory"); - qmlRegisterType<StandardProcessBackendFactory>(uri, 1, 0, "StandardProcessBackendFactory"); - qmlRegisterType<TimeoutIdleDelegate>(uri, 1, 0, "TimeoutIdleDelegate"); - - // Types registered from the Declarative library - qmlRegisterType<DeclarativeMatchDelegate>(uri, 1, 0, "PmScriptMatch"); - qmlRegisterType<DeclarativeProcessManager>(uri, 1, 0, "PmManager"); - qmlRegisterType<DeclarativeSocketLauncher>(uri, 1, 0, "PmLauncher"); - qmlRegisterType<DeclarativeRewriteDelegate>(uri, 1, 0, "PmScriptRewrite"); -} - -/*! - Construct a DeclarativeProcessManager with an optional \a parent -*/ - -DeclarativeProcessManager::DeclarativeProcessManager(QObject *parent) - : ProcessManager(parent) -{ -} - -/*! - \internal -*/ -void DeclarativeProcessManager::classBegin() -{ -} - -/*! - \internal -*/ -void DeclarativeProcessManager::componentComplete() -{ -} - -/*! - \internal -*/ -void DeclarativeProcessManager::append_factory(QQmlListProperty<ProcessBackendFactory> *list, - ProcessBackendFactory *factory) -{ - DeclarativeProcessManager *manager = static_cast<DeclarativeProcessManager *>(list->object); - if (factory && manager) - manager->addBackendFactory(factory); -} - -/*! - \internal - */ - -QQmlListProperty<ProcessBackendFactory> DeclarativeProcessManager::factories() -{ - return QQmlListProperty<ProcessBackendFactory>(this, NULL, append_factory, 0, 0, 0); -} - -/*! - Raise the processAboutToStart() signal. -*/ - -void DeclarativeProcessManager::processFrontendAboutToStart() -{ - ProcessFrontend *frontend = static_cast<ProcessFrontend *>(sender()); - if (frontend) - emit processAboutToStart(frontend->name()); - ProcessManager::processFrontendAboutToStart(); -} - -/*! - Raise the processAboutToStop() signal. -*/ - -void DeclarativeProcessManager::processFrontendAboutToStop() -{ - ProcessFrontend *frontend = static_cast<ProcessFrontend *>(sender()); - if (frontend) - emit processAboutToStop(frontend->name()); - ProcessManager::processFrontendAboutToStop(); -} - -/*! - Raise the processStarted() signal. -*/ - -void DeclarativeProcessManager::processFrontendStarted() -{ - ProcessFrontend *frontend = static_cast<ProcessFrontend *>(sender()); - if (frontend) - emit processStarted(frontend->name()); - ProcessManager::processFrontendStarted(); -} - -/*! - Raise the processError() signal. - Pass through the \a error value. -*/ - -void DeclarativeProcessManager::processFrontendError(QProcess::ProcessError error) -{ - ProcessFrontend *frontend = static_cast<ProcessFrontend *>(sender()); - if (frontend) - emit processError(frontend->name(), static_cast<int>(error)); - ProcessManager::processFrontendError(error); -} - -/*! - Raise the processFinished() signal. Pass through the - \a exitCode and \a exitStatus values. -*/ - -void DeclarativeProcessManager::processFrontendFinished(int exitCode, QProcess::ExitStatus exitStatus) -{ - ProcessFrontend *frontend = static_cast<ProcessFrontend *>(sender()); - if (frontend) - emit processFinished(frontend->name(), exitCode, exitStatus); - ProcessManager::processFrontendFinished(exitCode, exitStatus); -} - -/*! - Raise the processStateChanged() signal. Pass through the - \a state value. -*/ - -void DeclarativeProcessManager::processFrontendStateChanged(QProcess::ProcessState state) -{ - ProcessFrontend *frontend = static_cast<ProcessFrontend *>(sender()); - if (frontend) - emit processStateChanged(frontend->name(), state); - ProcessManager::processFrontendStateChanged(state); -} - -/*! - Raise the processFrontendDestroyed() signal. -*/ - -void DeclarativeProcessManager::processFrontendDestroyed() -{ - ProcessFrontend *frontend = static_cast<ProcessFrontend *>(sender()); - if (frontend) - emit processDestroyed(frontend->name()); - ProcessManager::processFrontendDestroyed(); -} - -/*! - \fn void DeclarativeProcessManager::processAboutToStart(const QString& name) - This signal is emitted when a process is about to start. - The \a name may be used to retrieve the ProcessFrontend - object. - - \sa processForName() -*/ - -/*! - \fn void DeclarativeProcessManager::processAboutToStop(const QString& name) - This signal is emitted when a process is about to stop - The \a name may be used to retrieve the ProcessFrontend - object. - - \sa processForName() -*/ - -/*! - \fn void DeclarativeProcessManager::processStarted(const QString& name) - This signal is emitted once a process has started. - The \a name may be used to retrieve the ProcessFrontend - object. - - \sa processForName() -*/ - -/*! - \fn void DeclarativeProcessManager::processError(const QString& name, int error) - This signal is emitted when a process experiences an \a error. - The \a name may be used to retrieve the ProcessFrontend - object. The \a error value can be compared to the QProcess::ProcessError - enumeration (it has been cast to an integer to resolve a QML issue). - - \sa processForName() -*/ - -/*! - \fn void DeclarativeProcessManager::processFinished(const QString& name, int exitCode, int exitStatus) - This signal is emitted when a process finishes. The \a exitCode - and \a exitStatus match the QProcess values. - The \a name may be used to retrieve the ProcessFrontend - object. The \a exitStatus value can be compared with a QProcess::ExitStatus - enumeration (it has been cast to an integer to resolve a QML issue). - - \sa processForName() -*/ - -/*! - \fn void DeclarativeProcessManager::processStateChanged(const QString& name, int state) - This signal is emitted when a process has a state change to \a state. - The \a name may be used to retrieve the ProcessFrontend - object. The \a state value can be compared with QProcess::ProcessState values - (it has been cast to an integer to resolve a QML issue). - - \sa processForName() -*/ - -/*! - \fn void DeclarativeProcessManager::processDestroyed(const QString &name) - This signal is emitted when a process has been destroyed - The \a name cannot be used to retrieve the ProcessFrontend - object because it no longer exists. -*/ - - - -#include "moc_declarativeprocessmanager.cpp" - -QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager-declarative/processmanager-declarative-lib.pri b/src/processmanager-declarative/processmanager-declarative-lib.pri index 0279325..1185231 100644 --- a/src/processmanager-declarative/processmanager-declarative-lib.pri +++ b/src/processmanager-declarative/processmanager-declarative-lib.pri @@ -5,13 +5,13 @@ CONFIG += network INCLUDEPATH += $$PWD HEADERS += \ - $$PWD/declarativeprocessmanager.h \ - $$PWD/declarativesocketlauncher.h \ - $$PWD/declarativematchdelegate.h \ - $$PWD/declarativerewritedelegate.h + $$PWD/qdeclarativeprocessmanager.h \ + $$PWD/qdeclarativesocketlauncher.h \ + $$PWD/qdeclarativematchdelegate.h \ + $$PWD/qdeclarativerewritedelegate.h SOURCES += \ - $$PWD/declarativeprocessmanager.cpp \ - $$PWD/declarativesocketlauncher.cpp \ - $$PWD/declarativematchdelegate.cpp \ - $$PWD/declarativerewritedelegate.cpp + $$PWD/qdeclarativeprocessmanager.cpp \ + $$PWD/qdeclarativesocketlauncher.cpp \ + $$PWD/qdeclarativematchdelegate.cpp \ + $$PWD/qdeclarativerewritedelegate.cpp diff --git a/src/processmanager-declarative/declarativematchdelegate.cpp b/src/processmanager-declarative/qdeclarativematchdelegate.cpp index b444e68..e44d2fd 100644 --- a/src/processmanager-declarative/declarativematchdelegate.cpp +++ b/src/processmanager-declarative/qdeclarativematchdelegate.cpp @@ -37,13 +37,13 @@ ** ****************************************************************************/ -#include "declarativematchdelegate.h" -#include "processinfo.h" +#include "qdeclarativematchdelegate.h" +#include "qprocessinfo.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \qmlclass PmScriptMatch DeclarativeMatchDelegate + \qmlclass PmScriptMatch QDeclarativeMatchDelegate \brief The PmScriptMatch class allows a factory to use a Javascript function for matching The PmScriptMatch object can be used in factory objects @@ -72,19 +72,19 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER */ /*! - \class DeclarativeMatchDelegate - \brief The DeclarativeMatchDelegate class allows a factory to use Javascript functions for matching. + \class QDeclarativeMatchDelegate + \brief The QDeclarativeMatchDelegate class allows a factory to use Javascript functions for matching. - The DeclarativeMatchDelegate class can be used in factory objects to + The QDeclarativeMatchDelegate class can be used in factory objects to specify match conditions. */ /*! - Construct a DeclarativeMatchDelegate with optional \a parent. + Construct a QDeclarativeMatchDelegate with optional \a parent. */ -DeclarativeMatchDelegate::DeclarativeMatchDelegate(QObject *parent) - : MatchDelegate(parent) +QDeclarativeMatchDelegate::QDeclarativeMatchDelegate(QObject *parent) + : QMatchDelegate(parent) , m_modelContext(0) { } @@ -93,7 +93,7 @@ DeclarativeMatchDelegate::DeclarativeMatchDelegate(QObject *parent) \internal */ -void DeclarativeMatchDelegate::classBegin() +void QDeclarativeMatchDelegate::classBegin() { } @@ -101,7 +101,7 @@ void DeclarativeMatchDelegate::classBegin() \internal */ -void DeclarativeMatchDelegate::componentComplete() +void QDeclarativeMatchDelegate::componentComplete() { } @@ -111,7 +111,7 @@ void DeclarativeMatchDelegate::componentComplete() bound to the \c{model} object property. */ -bool DeclarativeMatchDelegate::matches(const ProcessInfo& info) +bool QDeclarativeMatchDelegate::matches(const QProcessInfo& info) { if (m_script.isEmpty()) return false; @@ -129,7 +129,7 @@ bool DeclarativeMatchDelegate::matches(const ProcessInfo& info) Return the script object. */ -QQmlScriptString DeclarativeMatchDelegate::script() const +QQmlScriptString QDeclarativeMatchDelegate::script() const { return m_script; } @@ -138,19 +138,19 @@ QQmlScriptString DeclarativeMatchDelegate::script() const Set the script object to \a script */ -void DeclarativeMatchDelegate::setScript(const QQmlScriptString& script) +void QDeclarativeMatchDelegate::setScript(const QQmlScriptString& script) { m_script = script; emit scriptChanged(); } /*! - \fn void DeclarativeMatchDelegate::scriptChanged() + \fn void QDeclarativeMatchDelegate::scriptChanged() This signal is emitted when the script object is changed. \sa setScript() */ -#include "moc_declarativematchdelegate.cpp" +#include "moc_qdeclarativematchdelegate.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager-declarative/declarativematchdelegate.h b/src/processmanager-declarative/qdeclarativematchdelegate.h index d8ddb86..1c2062b 100644 --- a/src/processmanager-declarative/declarativematchdelegate.h +++ b/src/processmanager-declarative/qdeclarativematchdelegate.h @@ -41,11 +41,11 @@ #define DECLARATIVE_MATCH_DELEGATE_H #include <QtQml> -#include "matchdelegate.h" +#include "qmatchdelegate.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class Q_ADDON_PROCESSMANAGER_EXPORT DeclarativeMatchDelegate : public MatchDelegate, +class Q_ADDON_PROCESSMANAGER_EXPORT QDeclarativeMatchDelegate : public QMatchDelegate, public QQmlParserStatus { Q_OBJECT @@ -53,8 +53,8 @@ class Q_ADDON_PROCESSMANAGER_EXPORT DeclarativeMatchDelegate : public MatchDeleg Q_PROPERTY(QQmlScriptString script READ script WRITE setScript NOTIFY scriptChanged) public: - DeclarativeMatchDelegate(QObject *parent=0); - virtual bool matches(const ProcessInfo& info); + QDeclarativeMatchDelegate(QObject *parent=0); + virtual bool matches(const QProcessInfo& info); QQmlScriptString script() const; void setScript(const QQmlScriptString&); @@ -72,6 +72,6 @@ private: QT_END_NAMESPACE_PROCESSMANAGER -QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE_PROCESSMANAGER(DeclarativeMatchDelegate)) +QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE_PROCESSMANAGER(QDeclarativeMatchDelegate)) #endif // DECLARATIVE_MATCH_DELEGATE_H diff --git a/src/processmanager-declarative/qdeclarativeprocessmanager.cpp b/src/processmanager-declarative/qdeclarativeprocessmanager.cpp new file mode 100644 index 0000000..7d732db --- /dev/null +++ b/src/processmanager-declarative/qdeclarativeprocessmanager.cpp @@ -0,0 +1,362 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qdeclarativeprocessmanager.h" +#include "qprocessbackendfactory.h" +#include "qprocessfrontend.h" + +#include "qprelaunchprocessbackend.h" +#include "qremoteprocessbackend.h" +#include "qstandardprocessbackend.h" + +#include "qcpuidledelegate.h" +#include "qtimeoutidledelegate.h" +#include "qgdbrewritedelegate.h" +#include "qinfomatchdelegate.h" +#include "qkeymatchdelegate.h" +#include "qpipelauncher.h" +#include "qpipeprocessbackendfactory.h" +#include "qpreforkprocessbackendfactory.h" +#include "qprelaunchprocessbackendfactory.h" +#include "qsocketlauncher.h" +#include "qstandardprocessbackendfactory.h" +#include "qsocketprocessbackendfactory.h" + +#include "qdeclarativematchdelegate.h" +#include "qdeclarativesocketlauncher.h" +#include "qdeclarativerewritedelegate.h" + +#include <QDebug> + +QT_BEGIN_NAMESPACE_PROCESSMANAGER + +/*! + \qmlclass PmManager QDeclarativeProcessManager + \brief The PmManager class encapsulates ways of creating and tracking processes + suitable for QtQml programs. + + Only a single PmManager object should be loaded at one time. + + Typical use of the PmManager class is as follows: + + \code + import QtQuick 2.0 + import ProcessManager 1.0 + + PmManager { + id: myProcessManager + + factories: [ + GdbProcessBackendFactory {}, + StandardProcessBackendFactory {} + ] + } + \endcode +*/ + +/*! + \qmlproperty list<ProcessBackendFactory> PmManager::factories + List of ProcessBackendFactory objects. + + The order of the list is important. When launching a new + process, each factory will be consulted in order to select + the factory that will launch the process. + */ + +/*! + \class QDeclarativeProcessManager + \brief The QDeclarativeProcessManager class is a ProcessManager designed to be embedded + in a QML context. + */ + +/*! + \fn QDeclarativeProcessManager::registerTypes(const char *uri) + \brief Register all QML data types for the process manager + + Register all types with the QML object system. Pass the name the + library to register as \a uri. + */ + +void QDeclarativeProcessManager::registerTypes(const char *uri) +{ + // Non-creatable types + qmlRegisterType<QIdleDelegate>(); + qmlRegisterType<QMatchDelegate>(); + qmlRegisterType<QPrelaunchProcessBackend>(); + qmlRegisterType<QProcessBackend>(); + qmlRegisterType<QProcessFrontend>(); + qmlRegisterType<QProcessBackendFactory>(); + qmlRegisterType<QRemoteProcessBackend>(); + qmlRegisterType<QRemoteProcessBackendFactory>(); + qmlRegisterType<QRewriteDelegate>(); + qmlRegisterType<QStandardProcessBackend>(); + qmlRegisterType<QUnixProcessBackend>(); + + qRegisterMetaType<QProcessFrontend*>("QProcessFrontend*"); + qRegisterMetaType<QProcessInfo*>("QProcessInfo*"); + qRegisterMetaType<QMatchDelegate*>("QMatchDelegate*"); + qRegisterMetaType<QRewriteDelegate*>("QRewriteDelegate*"); + + // Non-creatable, with enum values + qmlRegisterUncreatableType<QPmProcess>(uri, 1, 0, "QPmProcess", QStringLiteral("Don't try to make this")); + + // Types registered from the Core library + qmlRegisterType<QCpuIdleDelegate>(uri, 1, 0, "CpuIdleDelegate"); + qmlRegisterType<QGdbRewriteDelegate>(uri, 1, 0, "GdbRewriteDelegate"); + qmlRegisterType<QInfoMatchDelegate>(uri, 1, 0, "InfoMatchDelegate"); + qmlRegisterType<QKeyMatchDelegate>(uri, 1, 0, "KeyMatchDelegate"); + qmlRegisterType<QPipeLauncher>(uri, 1, 0, "PipeLauncher"); + qmlRegisterType<QPipeProcessBackendFactory>(uri, 1, 0, "PipeProcessBackendFactory"); + qmlRegisterType<QPreforkProcessBackendFactory>(uri, 1, 0, "PreforkProcessBackendFactory"); + qmlRegisterType<QPrelaunchProcessBackendFactory>(uri, 1, 0, "PrelaunchProcessBackendFactory"); + qmlRegisterType<QProcessBackendManager>(uri, 1, 0, "ProcessBackendManager"); + qmlRegisterType<QProcessInfo>(uri, 1, 0, "ProcessInfo"); + qmlRegisterType<QProcessManager>(uri, 1, 0, "ProcessManager"); + qmlRegisterType<QSocketLauncher>(uri, 1, 0, "SocketLauncher"); + qmlRegisterType<QSocketProcessBackendFactory>(uri, 1, 0, "SocketProcessBackendFactory"); + qmlRegisterType<QStandardProcessBackendFactory>(uri, 1, 0, "StandardProcessBackendFactory"); + qmlRegisterType<QTimeoutIdleDelegate>(uri, 1, 0, "TimeoutIdleDelegate"); + + // Types registered from the Declarative library + qmlRegisterType<QDeclarativeMatchDelegate>(uri, 1, 0, "PmScriptMatch"); + qmlRegisterType<QDeclarativeProcessManager>(uri, 1, 0, "PmManager"); + qmlRegisterType<QDeclarativeSocketLauncher>(uri, 1, 0, "PmLauncher"); + qmlRegisterType<QDeclarativeRewriteDelegate>(uri, 1, 0, "PmScriptRewrite"); +} + +/*! + Construct a QDeclarativeProcessManager with an optional \a parent +*/ + +QDeclarativeProcessManager::QDeclarativeProcessManager(QObject *parent) + : QProcessManager(parent) +{ +} + +/*! + \internal +*/ +void QDeclarativeProcessManager::classBegin() +{ +} + +/*! + \internal +*/ +void QDeclarativeProcessManager::componentComplete() +{ +} + +/*! + \internal +*/ +void QDeclarativeProcessManager::append_factory(QQmlListProperty<QProcessBackendFactory> *list, + QProcessBackendFactory *factory) +{ + QDeclarativeProcessManager *manager = static_cast<QDeclarativeProcessManager *>(list->object); + if (factory && manager) + manager->addBackendFactory(factory); +} + +/*! + \internal + */ + +QQmlListProperty<QProcessBackendFactory> QDeclarativeProcessManager::factories() +{ + return QQmlListProperty<QProcessBackendFactory>(this, NULL, append_factory, 0, 0, 0); +} + +/*! + Raise the processAboutToStart() signal. +*/ + +void QDeclarativeProcessManager::processFrontendAboutToStart() +{ + QProcessFrontend *frontend = static_cast<QProcessFrontend *>(sender()); + if (frontend) + emit processAboutToStart(frontend->name()); + QProcessManager::processFrontendAboutToStart(); +} + +/*! + Raise the processAboutToStop() signal. +*/ + +void QDeclarativeProcessManager::processFrontendAboutToStop() +{ + QProcessFrontend *frontend = static_cast<QProcessFrontend *>(sender()); + if (frontend) + emit processAboutToStop(frontend->name()); + QProcessManager::processFrontendAboutToStop(); +} + +/*! + Raise the processStarted() signal. +*/ + +void QDeclarativeProcessManager::processFrontendStarted() +{ + QProcessFrontend *frontend = static_cast<QProcessFrontend *>(sender()); + if (frontend) + emit processStarted(frontend->name()); + QProcessManager::processFrontendStarted(); +} + +/*! + Raise the processError() signal. + Pass through the \a error value. +*/ + +void QDeclarativeProcessManager::processFrontendError(QProcess::ProcessError error) +{ + QProcessFrontend *frontend = static_cast<QProcessFrontend *>(sender()); + if (frontend) + emit processError(frontend->name(), static_cast<int>(error)); + QProcessManager::processFrontendError(error); +} + +/*! + Raise the processFinished() signal. Pass through the + \a exitCode and \a exitStatus values. +*/ + +void QDeclarativeProcessManager::processFrontendFinished(int exitCode, QProcess::ExitStatus exitStatus) +{ + QProcessFrontend *frontend = static_cast<QProcessFrontend *>(sender()); + if (frontend) + emit processFinished(frontend->name(), exitCode, exitStatus); + QProcessManager::processFrontendFinished(exitCode, exitStatus); +} + +/*! + Raise the processStateChanged() signal. Pass through the + \a state value. +*/ + +void QDeclarativeProcessManager::processFrontendStateChanged(QProcess::ProcessState state) +{ + QProcessFrontend *frontend = static_cast<QProcessFrontend *>(sender()); + if (frontend) + emit processStateChanged(frontend->name(), state); + QProcessManager::processFrontendStateChanged(state); +} + +/*! + Raise the processFrontendDestroyed() signal. +*/ + +void QDeclarativeProcessManager::processFrontendDestroyed() +{ + QProcessFrontend *frontend = static_cast<QProcessFrontend *>(sender()); + if (frontend) + emit processDestroyed(frontend->name()); + QProcessManager::processFrontendDestroyed(); +} + +/*! + \fn void QDeclarativeProcessManager::processAboutToStart(const QString& name) + This signal is emitted when a process is about to start. + The \a name may be used to retrieve the ProcessFrontend + object. + + \sa processForName() +*/ + +/*! + \fn void QDeclarativeProcessManager::processAboutToStop(const QString& name) + This signal is emitted when a process is about to stop + The \a name may be used to retrieve the ProcessFrontend + object. + + \sa processForName() +*/ + +/*! + \fn void QDeclarativeProcessManager::processStarted(const QString& name) + This signal is emitted once a process has started. + The \a name may be used to retrieve the ProcessFrontend + object. + + \sa processForName() +*/ + +/*! + \fn void QDeclarativeProcessManager::processError(const QString& name, int error) + This signal is emitted when a process experiences an \a error. + The \a name may be used to retrieve the ProcessFrontend + object. The \a error value can be compared to the QProcess::ProcessError + enumeration (it has been cast to an integer to resolve a QML issue). + + \sa processForName() +*/ + +/*! + \fn void QDeclarativeProcessManager::processFinished(const QString& name, int exitCode, int exitStatus) + This signal is emitted when a process finishes. The \a exitCode + and \a exitStatus match the QProcess values. + The \a name may be used to retrieve the ProcessFrontend + object. The \a exitStatus value can be compared with a QProcess::ExitStatus + enumeration (it has been cast to an integer to resolve a QML issue). + + \sa processForName() +*/ + +/*! + \fn void QDeclarativeProcessManager::processStateChanged(const QString& name, int state) + This signal is emitted when a process has a state change to \a state. + The \a name may be used to retrieve the ProcessFrontend + object. The \a state value can be compared with QProcess::ProcessState values + (it has been cast to an integer to resolve a QML issue). + + \sa processForName() +*/ + +/*! + \fn void QDeclarativeProcessManager::processDestroyed(const QString &name) + This signal is emitted when a process has been destroyed + The \a name cannot be used to retrieve the ProcessFrontend + object because it no longer exists. +*/ + + + +#include "moc_qdeclarativeprocessmanager.cpp" + +QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager-declarative/declarativeprocessmanager.h b/src/processmanager-declarative/qdeclarativeprocessmanager.h index 14c2311..7bce91e 100644 --- a/src/processmanager-declarative/declarativeprocessmanager.h +++ b/src/processmanager-declarative/qdeclarativeprocessmanager.h @@ -40,27 +40,27 @@ #ifndef DECLARATIVE_PROCESS_MANAGER_H #define DECLARATIVE_PROCESS_MANAGER_H -#include "processmanager.h" +#include "qprocessmanager.h" #include <QQmlListProperty> #include <QQmlParserStatus> #include <qqml.h> -#include "processmanager-global.h" +#include "qprocessmanager-global.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class Q_ADDON_PROCESSMANAGER_EXPORT DeclarativeProcessManager : public ProcessManager, +class Q_ADDON_PROCESSMANAGER_EXPORT QDeclarativeProcessManager : public QProcessManager, public QQmlParserStatus { Q_OBJECT Q_INTERFACES(QQmlParserStatus) - Q_PROPERTY(QQmlListProperty<QtAddOn::ProcessManager::ProcessBackendFactory> factories READ factories) + Q_PROPERTY(QQmlListProperty<QtAddOn::QtProcessManager::QProcessBackendFactory> factories READ factories) public: static void registerTypes(const char *uri); - DeclarativeProcessManager(QObject *parent=0); - QQmlListProperty<ProcessBackendFactory> factories(); + QDeclarativeProcessManager(QObject *parent=0); + QQmlListProperty<QProcessBackendFactory> factories(); void classBegin(); void componentComplete(); @@ -84,12 +84,12 @@ protected slots: virtual void processFrontendDestroyed(); private: - static void append_factory(QQmlListProperty<ProcessBackendFactory>*, - ProcessBackendFactory*); + static void append_factory(QQmlListProperty<QProcessBackendFactory>*, + QProcessBackendFactory*); }; QT_END_NAMESPACE_PROCESSMANAGER -QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE_PROCESSMANAGER(DeclarativeProcessManager)) +QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE_PROCESSMANAGER(QDeclarativeProcessManager)) #endif // DECLARATIVE_PROCESS_MANAGER_H diff --git a/src/processmanager-declarative/declarativerewritedelegate.cpp b/src/processmanager-declarative/qdeclarativerewritedelegate.cpp index e6cd819..807c40f 100644 --- a/src/processmanager-declarative/declarativerewritedelegate.cpp +++ b/src/processmanager-declarative/qdeclarativerewritedelegate.cpp @@ -38,13 +38,13 @@ ****************************************************************************/ #include <QDebug> -#include "declarativerewritedelegate.h" -#include "processinfo.h" +#include "qdeclarativerewritedelegate.h" +#include "qprocessinfo.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \qmlclass PmScriptRewrite DeclarativeRewriteDelegate + \qmlclass PmScriptRewrite QDeclarativeRewriteDelegate \brief The PmScriptRewrite class allows a factory to use a Javascript function for rewriting ProcessInfo objects. @@ -76,19 +76,19 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER */ /*! - \class DeclarativeRewriteDelegate - \brief The DeclarativeRewriteDelegate class is a lightweight wrapper around a RewriteDelegate. + \class QDeclarativeRewriteDelegate + \brief The QDeclarativeRewriteDelegate class is a lightweight wrapper around a RewriteDelegate. - The DeclarativeRewriteDelegate class rewrites ProcessInfo objects by + The QDeclarativeRewriteDelegate class rewrites ProcessInfo objects by passing them to a script object containing Javascript code. */ /*! - Construct a DeclarativeRewriteDelegate object with optional \a parent. + Construct a QDeclarativeRewriteDelegate object with optional \a parent. */ -DeclarativeRewriteDelegate::DeclarativeRewriteDelegate(QObject *parent) - : RewriteDelegate(parent) +QDeclarativeRewriteDelegate::QDeclarativeRewriteDelegate(QObject *parent) + : QRewriteDelegate(parent) , m_modelContext(0) { } @@ -97,7 +97,7 @@ DeclarativeRewriteDelegate::DeclarativeRewriteDelegate(QObject *parent) \internal */ -void DeclarativeRewriteDelegate::classBegin() +void QDeclarativeRewriteDelegate::classBegin() { } @@ -105,7 +105,7 @@ void DeclarativeRewriteDelegate::classBegin() \internal */ -void DeclarativeRewriteDelegate::componentComplete() +void QDeclarativeRewriteDelegate::componentComplete() { } @@ -115,7 +115,7 @@ void DeclarativeRewriteDelegate::componentComplete() stored Javascript. */ -void DeclarativeRewriteDelegate::rewrite(ProcessInfo& info) +void QDeclarativeRewriteDelegate::rewrite(QProcessInfo& info) { if (!m_script.isEmpty()) { if (!m_modelContext) @@ -131,7 +131,7 @@ void DeclarativeRewriteDelegate::rewrite(ProcessInfo& info) Return a copy of the Javascript. */ -QQmlScriptString DeclarativeRewriteDelegate::script() const +QQmlScriptString QDeclarativeRewriteDelegate::script() const { return m_script; } @@ -140,17 +140,17 @@ QQmlScriptString DeclarativeRewriteDelegate::script() const Set the Javascript object to \a script. */ -void DeclarativeRewriteDelegate::setScript(const QQmlScriptString& script) +void QDeclarativeRewriteDelegate::setScript(const QQmlScriptString& script) { m_script = script; emit scriptChanged(); } /*! - \fn void DeclarativeRewriteDelegate::scriptChanged() + \fn void QDeclarativeRewriteDelegate::scriptChanged() This signal is emitted when the internal script object is changed. */ -#include "moc_declarativerewritedelegate.cpp" +#include "moc_qdeclarativerewritedelegate.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager-declarative/declarativerewritedelegate.h b/src/processmanager-declarative/qdeclarativerewritedelegate.h index 6330723..7235bed 100644 --- a/src/processmanager-declarative/declarativerewritedelegate.h +++ b/src/processmanager-declarative/qdeclarativerewritedelegate.h @@ -41,11 +41,11 @@ #define DECLARATIVE_REWRITE_DELEGATE_H #include <QtQml> -#include "rewritedelegate.h" +#include "qrewritedelegate.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class Q_ADDON_PROCESSMANAGER_EXPORT DeclarativeRewriteDelegate : public RewriteDelegate, +class Q_ADDON_PROCESSMANAGER_EXPORT QDeclarativeRewriteDelegate : public QRewriteDelegate, public QQmlParserStatus { Q_OBJECT @@ -53,8 +53,8 @@ class Q_ADDON_PROCESSMANAGER_EXPORT DeclarativeRewriteDelegate : public RewriteD Q_PROPERTY(QQmlScriptString script READ script WRITE setScript NOTIFY scriptChanged) public: - DeclarativeRewriteDelegate(QObject *parent=0); - virtual void rewrite(ProcessInfo& info); + QDeclarativeRewriteDelegate(QObject *parent=0); + virtual void rewrite(QProcessInfo& info); QQmlScriptString script() const; void setScript(const QQmlScriptString&); @@ -72,6 +72,6 @@ private: QT_END_NAMESPACE_PROCESSMANAGER -QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE_PROCESSMANAGER(DeclarativeRewriteDelegate)) +QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE_PROCESSMANAGER(QDeclarativeRewriteDelegate)) #endif // DECLARATIVE_REWRITE_DELEGATE_H diff --git a/src/processmanager-declarative/declarativesocketlauncher.cpp b/src/processmanager-declarative/qdeclarativesocketlauncher.cpp index 039a106..7ce9a0b 100644 --- a/src/processmanager-declarative/declarativesocketlauncher.cpp +++ b/src/processmanager-declarative/qdeclarativesocketlauncher.cpp @@ -37,12 +37,12 @@ ** ****************************************************************************/ -#include "declarativesocketlauncher.h" +#include "qdeclarativesocketlauncher.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \qmlclass PmLauncher DeclarativeSocketLauncher + \qmlclass PmLauncher QDeclarativeSocketLauncher \brief The PmLauncher class encapsulates ways of creating and tracking processes suitable for QtQml programs. @@ -103,16 +103,16 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER */ /*! - \class DeclarativeSocketLauncher - \brief The DeclarativeSocketLauncher class is a lightweight wrapper around a SocketLauncher object. + \class QDeclarativeSocketLauncher + \brief The QDeclarativeSocketLauncher class is a lightweight wrapper around a SocketLauncher object. */ /*! - Create a DeclarativeSocketLauncher object with optional parent \a parent. + Create a QDeclarativeSocketLauncher object with optional parent \a parent. */ -DeclarativeSocketLauncher::DeclarativeSocketLauncher(QObject *parent) - : SocketLauncher(parent) +QDeclarativeSocketLauncher::QDeclarativeSocketLauncher(QObject *parent) + : QSocketLauncher(parent) { } @@ -120,7 +120,7 @@ DeclarativeSocketLauncher::DeclarativeSocketLauncher(QObject *parent) \internal */ -void DeclarativeSocketLauncher::classBegin() +void QDeclarativeSocketLauncher::classBegin() { } @@ -128,7 +128,7 @@ void DeclarativeSocketLauncher::classBegin() \internal */ -void DeclarativeSocketLauncher::componentComplete() +void QDeclarativeSocketLauncher::componentComplete() { } @@ -136,10 +136,10 @@ void DeclarativeSocketLauncher::componentComplete() \internal */ -void DeclarativeSocketLauncher::append_factory(QQmlListProperty<ProcessBackendFactory> *list, - ProcessBackendFactory *factory) +void QDeclarativeSocketLauncher::append_factory(QQmlListProperty<QProcessBackendFactory> *list, + QProcessBackendFactory *factory) { - DeclarativeSocketLauncher *launcher = static_cast<DeclarativeSocketLauncher *>(list->object); + QDeclarativeSocketLauncher *launcher = static_cast<QDeclarativeSocketLauncher *>(list->object); if (factory && launcher) launcher->addFactory(factory); } @@ -148,20 +148,20 @@ void DeclarativeSocketLauncher::append_factory(QQmlListProperty<ProcessBackendFa \internal */ -QQmlListProperty<ProcessBackendFactory> DeclarativeSocketLauncher::factories() +QQmlListProperty<QProcessBackendFactory> QDeclarativeSocketLauncher::factories() { - return QQmlListProperty<ProcessBackendFactory>(this, NULL, append_factory, NULL, NULL, NULL); + return QQmlListProperty<QProcessBackendFactory>(this, NULL, append_factory, NULL, NULL, NULL); } /*! \internal */ -QQmlListProperty<QObject> DeclarativeSocketLauncher::children() +QQmlListProperty<QObject> QDeclarativeSocketLauncher::children() { return QQmlListProperty<QObject>(this, m_children); } -#include "moc_declarativesocketlauncher.cpp" +#include "moc_qdeclarativesocketlauncher.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager-declarative/declarativesocketlauncher.h b/src/processmanager-declarative/qdeclarativesocketlauncher.h index cd5fb31..77604f7 100644 --- a/src/processmanager-declarative/declarativesocketlauncher.h +++ b/src/processmanager-declarative/qdeclarativesocketlauncher.h @@ -41,35 +41,35 @@ #define DECLARATIVE_SOCKET_LAUNCHER_H #include <QtQml> -#include "socketlauncher.h" +#include "qsocketlauncher.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class Q_ADDON_PROCESSMANAGER_EXPORT DeclarativeSocketLauncher : public SocketLauncher, +class Q_ADDON_PROCESSMANAGER_EXPORT QDeclarativeSocketLauncher : public QSocketLauncher, public QQmlParserStatus { Q_OBJECT Q_INTERFACES(QQmlParserStatus) - Q_PROPERTY(QQmlListProperty<QtAddOn::ProcessManager::ProcessBackendFactory> factories READ factories) + Q_PROPERTY(QQmlListProperty<QtAddOn::QtProcessManager::QProcessBackendFactory> factories READ factories) Q_PROPERTY(QQmlListProperty<QObject> children READ children) Q_CLASSINFO("DefaultProperty", "children") public: - DeclarativeSocketLauncher(QObject *parent=0); - QQmlListProperty<ProcessBackendFactory> factories(); + QDeclarativeSocketLauncher(QObject *parent=0); + QQmlListProperty<QProcessBackendFactory> factories(); QQmlListProperty<QObject> children(); void classBegin(); void componentComplete(); private: - static void append_factory(QQmlListProperty<ProcessBackendFactory>*, - ProcessBackendFactory*); + static void append_factory(QQmlListProperty<QProcessBackendFactory>*, + QProcessBackendFactory*); QList<QObject *> m_children; }; QT_END_NAMESPACE_PROCESSMANAGER -QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE_PROCESSMANAGER(DeclarativeSocketLauncher)) +QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE_PROCESSMANAGER(QDeclarativeSocketLauncher)) #endif // DECLARATIVE_SOCKET_LAUNCHER_H diff --git a/doc/doc.pri b/src/processmanager/doc/doc.pri index b0126b1..b0126b1 100644 --- a/doc/doc.pri +++ b/src/processmanager/doc/doc.pri diff --git a/doc/images/process_structs.png b/src/processmanager/doc/images/process_structs.png Binary files differindex e3b112d..e3b112d 100644 --- a/doc/images/process_structs.png +++ b/src/processmanager/doc/images/process_structs.png diff --git a/doc/images/processbackend_hierarchy.png b/src/processmanager/doc/images/processbackend_hierarchy.png Binary files differindex be8334f..be8334f 100644 --- a/doc/images/processbackend_hierarchy.png +++ b/src/processmanager/doc/images/processbackend_hierarchy.png diff --git a/doc/images/processbackendfactory_hierarchy.png b/src/processmanager/doc/images/processbackendfactory_hierarchy.png Binary files differindex 52be0a9..52be0a9 100644 --- a/doc/images/processbackendfactory_hierarchy.png +++ b/src/processmanager/doc/images/processbackendfactory_hierarchy.png diff --git a/doc/images/processbackendmanager_hierarchy.png b/src/processmanager/doc/images/processbackendmanager_hierarchy.png Binary files differindex 722f5f9..722f5f9 100644 --- a/doc/images/processbackendmanager_hierarchy.png +++ b/src/processmanager/doc/images/processbackendmanager_hierarchy.png diff --git a/doc/processmanager.qdocconf b/src/processmanager/doc/processmanager.qdocconf index e7c2da6..5bdda76 100644 --- a/doc/processmanager.qdocconf +++ b/src/processmanager/doc/processmanager.qdocconf @@ -2,14 +2,14 @@ # alias.i = e # Name of the project. -project = ProcessManager +project = QtProcessManager # Directories in which to search for files to document. # Paths are relative to the location of this file. -exampledirs += ../examples -headerdirs += ./src ../src/core ../src/declarative ../examples/plugin +exampledirs += ../../../examples +headerdirs += .. ../processmanager-declarative imagedirs += images -sourcedirs += ./src ../src/core ../src/declarative ../examples/plugin +sourcedirs += .. ../processmanager-declarative Cpp.ignoretokens = \ QT_BEGIN_HEADER \ @@ -28,20 +28,20 @@ Cpp.ignoretokens = \ # Defines the name of the project. You cannot use operators (+, =, -) in # the name. Properties for this project are set using a qhp.<projectname>.property # format. -qhp.projects = ProcessManager +qhp.projects = QtProcessManager # Sets the name of the output qhp file. -qhp.ProcessManager.file = ProcessManager.qhp +qhp.QtProcessManager.file = processmanager.qhp # Namespace for the output file. This namespace is used to distinguish between # different documentation files in Creator/Assistant. The namespace ends with # a version being a number containing a major, minor and revision element. # E.g. version 1.0 becomes 100. -qhp.ProcessManager.namespace = com.nokia.processmanager.100 +qhp.QtProcessManager.namespace = org.qt-project.qtprocessmanager.100 # Title for the package, will be the main title for the package in # Assistant/Creator. -qhp.ProcessManager.indexTitle = Process Manager Reference Documentation +qhp.QtProcessManager.indexTitle = Process Manager Reference Documentation # Extra files to add to the output which are not linked to from anywhere # using a qdoc \l command. @@ -49,11 +49,11 @@ qhp.ProcessManager.extraFiles = style/style.css \ index.html # Only update the name of the project for the next variables. -qhp.ProcessManager.virtualFolder = qdoc -qhp.ProcessManager.subprojects = classes -qhp.ProcessManager.subprojects.classes.title = Classes -qhp.ProcessManager.subprojects.classes.selectors = class fake:headerfile -qhp.ProcessManager.subprojects.classes.sortPages = true +qhp.QtProcessManager.virtualFolder = qdoc +qhp.QtProcessManager.subprojects = classes +qhp.QtProcessManager.subprojects.classes.title = Classes +qhp.QtProcessManager.subprojects.classes.selectors = class fake:headerfile +qhp.QtProcessManager.subprojects.classes.sortPages = true # Do NOT change the variables after this line unless you know what you are doing. diff --git a/doc/src/basicpm.qdoc b/src/processmanager/doc/src/basicpm.qdoc index 5ae2c8f..858ed71 100644 --- a/doc/src/basicpm.qdoc +++ b/src/processmanager/doc/src/basicpm.qdoc @@ -28,28 +28,28 @@ /*! \page basicpm.html -\previouspage Understanding ProcessInfo +\previouspage Understanding QProcessInfo \contentspage {Backend Process Manager} {Contents} \nextpage Standard Process Manager \title Backend Process Manager -The basic C++ API for controlling processes uses the ProcessBackendManager. -The ProcessBackendManager contains an ordered list of ProcessBackendFactory objects, -which are used to convert ProcessInfo objects into executable processes. +The basic C++ API for controlling processes uses the QProcessBackendManager. +The QProcessBackendManager contains an ordered list of QProcessBackendFactory objects, +which are used to convert QProcessInfo objects into executable processes. -The ProcessBackendManager can be used as follows: +The QProcessBackendManager can be used as follows: \code - ProcessBackendManager *manager = new ProcessBackendManager; - manager->add(new UnixProcessBackendFactory); + QProcessBackendManager *manager = new QProcessBackendManager; + manager->add(new QUnixProcessBackendFactory); - ProcessInfo info; + QProcessInfo info; info.setName("lstest"); info.setProgram("/bin/ls"); info.setWorkingDirectory("/root"); - ProcessBackend *backend = manager->create(info); + QProcessBackend *backend = manager->create(info); if (backend) { connect(backend, SIGNAL(started()), this, SLOT(processStarted())); connect(backend, SIGNAL(finished(int, QProcess::ExitStatus)), @@ -58,47 +58,47 @@ The ProcessBackendManager can be used as follows: } \endcode -The first step of initializing the ProcessBackendManager is to assign -ProcessBackendFactory objects. The order of the factories is important. -The ProcessBackendManager::create() function asks each factory in turn -if it can handle the ProcessInfo object. The first factory to match -is the one that creates the ProcessBackend object. +The first step of initializing the QProcessBackendManager is to assign +QProcessBackendFactory objects. The order of the factories is important. +The QProcessBackendManager::create() function asks each factory in turn +if it can handle the QProcessInfo object. The first factory to match +is the one that creates the QProcessBackend object. The backend object behaves similarly to a QProcess object; one normally attaches a few signal handlers and then starts the backend running. Please note the it is the user's responsibility to correctly delete the backend object. In the next example, we'd like to be able to launch certain processes -under GDB. To do this, we add a new StandardProcessBackendFactory and -set a custom MatchDelegate and RewriteDelegate. A KeyMatchDelegate will -match ProcessInfo records that contain a particular key value. We +under GDB. To do this, we add a new QStandardProcessBackendFactory and +set a custom QMatchDelegate and QRewriteDelegate. A QKeyMatchDelegate will +match QProcessInfo records that contain a particular key value. We set the delegate to match records containing a "gdb" key. We also -add a GdbRewritedDelegate which rewrites the ProcessInfo record to +add a QGdbRewriteDelegate which rewrites the QProcessInfo record to execute the process under gdb. Note that the order of the factories is important; the normal -StandardProcessBackendFactory will match anything, so it must go last. +QStandardProcessBackendFactory will match anything, so it must go last. \code - ProcessBackendManager *manager = new ProcessBackendManager; + QProcessBackendManager *manager = new QProcessBackendManager; - StandardProcessBackendFactory *gdb_factory = new StandardProcessBackendFactory; + QStandardProcessBackendFactory *gdb_factory = new QStandardProcessBackendFactory; - KeyMatchDelegate *keymatch = new KeyMatchDelegate; + QKeyMatchDelegate *keymatch = new QKeyMatchDelegate; keymatch->setKey("gdb"); gdb_factory->setMatchDelegate(keymatch); - gdb_factory->setRewriteDelegate(new GdbRewriteDelegate); + gdb_factory->setRewriteDelegate(new QGdbRewriteDelegate); manager->add(gdb_factory); - manager->add(new StandardProcessBackendFactory); + manager->add(new QStandardProcessBackendFactory); - ProcessInfo info; + QProcessInfo info; info.setName("lstest"); info.setProgram("/bin/ls"); info.setWorkingDirectory("/root"); info.setValue("gdb", "true"); - ProcessBackend *backend = manager->create(info); + QProcessBackend *backend = manager->create(info); if (backend) { connect(backend, SIGNAL(started()), this, SLOT(processStarted())); connect(backend, SIGNAL(finished(int, QProcess::ExitStatus)), @@ -107,47 +107,47 @@ StandardProcessBackendFactory will match anything, so it must go last. } \endcode -\section1 Inheritence Hierarchy +\section1 Inheritance Hierarchy \image processbackend_hierarchy.png {Process Backend Hierarchy} -\caption \e{ProcessBackend Inheritence Hierarchy} +\caption \e{QProcessBackend Inheritance Hierarchy} -The virtual ProcessBackend object hierarchy is divided into two -sections: the UnixProcessBackend objects contain a QProcess internally -and the RemoteProcessBackend objects communicate with a separate process +The virtual QProcessBackend object hierarchy is divided into two +sections: the QUnixProcessBackend objects contain a QProcess internally +and the QRemoteProcessBackend objects communicate with a separate process "launcher" program. It may sound odd that a process manager would not launch its own processes, but this mechanism allows the process manager to not run with setuid privileges. \image processbackendfactory_hierarchy.png -\caption \e{ProcessBackendFactory Inheritence Hierarchy} +\caption \e{QProcessBackendFactory Inheritance Hierarchy} -The ProcessBackendFactory hierarchy closely matches the ProcessBackend +The QProcessBackendFactory hierarchy closely matches the QProcessBackend hierarchy. The standard and prelaunch subclasses create standard and prelaunch process backend objects. The remote subclass is divided by how it connects to the remote "launcher" program; either over a pipe connection or a socket connection. \image processbackendmanager_hierarchy.png -\caption \e{ProcessBackendManager Inheritence Hierarchy} +\caption \e{QProcessBackendManager Inheritance Hierarchy} -The ProcessBackendManager hierachy is relatively simple. The standard -ProcessBackendManager is designed to be embedded in an application and -take commands directly from the application or from a ProcessManager. +The QProcessBackendManager hierarchy is relatively simple. The standard +QProcessBackendManager is designed to be embedded in an application and +take commands directly from the application or from a QProcessManager. -The PipeLauncher is a subclass that takes JSON-formatted commands over +The QPipeLauncher is a subclass that takes JSON-formatted commands over a pipe connection. It is designed to be embedded into a separate application that is launched from your main process, and then -connected to via a PipeProcessBackendFactory or a -PreforkProcessBackendFactory (depending on how it is launched). +connected to via a QPipeProcessBackendFactory or a +QPreforkProcessBackendFactory (depending on how it is launched). -The SocketLauncher is a subclass that takes JSON-formatted commands +The QSocketLauncher is a subclass that takes JSON-formatted commands over Unix local socket connections. It is designed to be used in a separate application that may be started at any time in the system launch (in many cases, by \c{upstart} or \c{/etc/init.d} scripts. It -uses the \l{JsonStream::JsonServer} class to accept socket -connections. You connect to a SocketLauncher application using the -SocketProcessBackendFactory object. +uses the \l{QtJsonStream::QJsonServer} class to accept socket +connections. You connect to a QSocketLauncher application using the +QSocketProcessBackendFactory object. diff --git a/doc/src/index.qdoc b/src/processmanager/doc/src/index.qdoc index 5d3998c..5e13603 100644 --- a/doc/src/index.qdoc +++ b/src/processmanager/doc/src/index.qdoc @@ -45,7 +45,7 @@ Table of contents: \list \li \l {Introduction} -\li \l {Understanding ProcessInfo} +\li \l {Understanding QProcessInfo} \li \l {Backend Process Manager} \li \l {Standard Process Manager} \li \l {Declarative Process Manager} @@ -59,8 +59,8 @@ Table of contents: \section1 Header files \list -\li \l{Global ProcessManager declarations} -\li \l{Forklauncher} +\li \l{Global QtProcessManager declarations} +\li \l{QForklauncher} \endlist \section1 QML Elements diff --git a/doc/src/intro.qdoc b/src/processmanager/doc/src/intro.qdoc index 4576fe7..0094e9f 100644 --- a/doc/src/intro.qdoc +++ b/src/processmanager/doc/src/intro.qdoc @@ -29,7 +29,7 @@ \page intro.html \contentspage {Introduction} {Contents} -\nextpage Understanding ProcessInfo +\nextpage Understanding QProcessInfo \title Introduction @@ -39,16 +39,16 @@ There are four basic types of objects to work with in the process manager. \list - \li ProcessInfo objects specify what program to run, environment variables + \li QProcessInfo objects specify what program to run, environment variables to pass to the program, working directory, and permissions. - \li ProcessBackendFactory objects convert ProcessInfo objects into executing + \li QProcessBackendFactory objects convert QProcessInfo objects into executing processes. - \li ProcessFrontend / ProcessBackend objects wrap executing processes. They + \li QProcessFrontend / QProcessBackend objects wrap executing processes. They bear a strong resemblence to QProcess objects, but in fact may not contain a QProcess. - \li ProcessManager / ProcessBackendManager are singleton objects that + \li QProcessManager / QProcessBackendManager are singleton objects that hold a list of factories and provide convenience interfaces for interacting - with ProcessFrontend/ProcessBackend objects. + with QProcessFrontend/QProcessBackend objects. \endlist */ diff --git a/doc/src/namespace.qdoc b/src/processmanager/doc/src/namespace.qdoc index 576ec73..080faf8 100644 --- a/doc/src/namespace.qdoc +++ b/src/processmanager/doc/src/namespace.qdoc @@ -27,31 +27,31 @@ /*! \headerfile <processmanager-global.h> - \title Global ProcessManager declarations + \title Global QtProcessManager declarations - \brief The <processmanager-global.h> file provides namespace declarations and - global enumerations for ProcessManager + \brief The <qprocessmanager-global.h> file provides namespace declarations and + global enumerations for QtProcessManager */ /*! \macro QT_USE_NAMESPACE_PROCESSMANAGER - \relates <processmanager-global.h> - \inmodule ProcessManager + \relates <qprocessmanager-global.h> + \inmodule QtProcessManager This macro expands to using processmanager namespace and makes processmanager namespace visible to C++ source code. \code - #include <processmanager-global.h> + #include <qprocessmanager-global.h> QT_USE_NAMESPACE_PROCESSMANAGER \endcode To declare the class without including the declaration of the class: \code - #include <processmanager-global.h> + #include <qprocessmanager-global.h> QT_BEGIN_NAMESPACE_PROCESSMANAGER - class ProcessManager; + class QProcessManager; QT_END_NAMESPACE_PROCESSMANAGER QT_USE_NAMESPACE_PROCESSMANAGER \endcode @@ -59,10 +59,10 @@ /*! \macro QT_BEGIN_NAMESPACE_PROCESSMANAGER - \relates <processmanager-global.h> - \inmodule ProcessManager + \relates <qprocessmanager-global.h> + \inmodule QtProcessManager - This macro begins a ProcessManager namespace. All forward declarations of ProcessManager classes need to + This macro begins a QtProcessManager namespace. All forward declarations of QtProcessManager classes need to be wrapped in \c QT_BEGIN_NAMESPACE_PROCESSMANAGER and \c QT_END_NAMESPACE_PROCESSMANAGER. \sa QT_USE_NAMESPACE_PROCESSMANAGER, QT_END_NAMESPACE_PROCESSMANAGER @@ -73,7 +73,7 @@ \relates <processmanager-global.h> \inmodule ProcessManager - This macro ends a ProcessManager namespace. All forward declarations of ProcessManager classes need to + This macro ends a QProcessManager namespace. All forward declarations of QtProcessManager classes need to be wrapped in \c QT_BEGIN_NAMESPACE_PROCESSMANAGER and \c QT_END_NAMESPACE_PROCESSMANAGER. \sa QT_USE_NAMESPACE_PROCESSMANAGER, QT_BEGIN_NAMESPACE_PROCESSMANAGER diff --git a/doc/src/processinfo.qdoc b/src/processmanager/doc/src/processinfo.qdoc index f5f052a..91e5492 100644 --- a/doc/src/processinfo.qdoc +++ b/src/processmanager/doc/src/processinfo.qdoc @@ -29,13 +29,13 @@ \page understandprocessinfo.html \previouspage Introduction -\contentspage {Understanding ProcessInfo} {Contents} +\contentspage {Understanding QProcessInfo} {Contents} \nextpage Backend Process Manager -\title Understanding ProcessInfo +\title Understanding QProcessInfo An individual Unix process has a large number of properties that can be -set upon process creation. The ProcessInfo object is a ligthweight wrapper +set upon process creation. The QProcessInfo object is a lightweight wrapper for a QVariantMap containing the more common properties including: \list @@ -58,13 +58,13 @@ for a QVariantMap containing the more common properties including: memory/CPU/resource use. \endlist -The ProcessInfo object provides accessor functions for accessing the +The QProcessInfo object provides accessor functions for accessing the more common properties along with named string constants. Because it is based on a QVariantMap, additional properties can be easily added to the -structure. From C++ code, a ProcessInfo object is typically created as follows: +structure. From C++ code, a QProcessInfo object is typically created as follows: \code - ProcessInfo info; + QProcessInfo info; info.setName("myprocess"); info.setProgram("/bin/ls"); info.setWorkingDirectory("/root"); diff --git a/doc/src/qmlpm.qdoc b/src/processmanager/doc/src/qmlpm.qdoc index 1b28ad0..96eab12 100644 --- a/doc/src/qmlpm.qdoc +++ b/src/processmanager/doc/src/qmlpm.qdoc @@ -33,7 +33,7 @@ \title Declarative Process Manager -The declarative process manager is a ProcessManager object with +The declarative process manager is a QProcessManager object with appropriate declarations so that it can be used from QML. Sample use: diff --git a/doc/src/standardpm.qdoc b/src/processmanager/doc/src/standardpm.qdoc index fef2b46..3857862 100644 --- a/doc/src/standardpm.qdoc +++ b/src/processmanager/doc/src/standardpm.qdoc @@ -34,34 +34,34 @@ \title Standard Process Manager -The standard ProcessManager object wraps the ProcessBackendManager -object, creates ProcessFrontend objects to wrap each ProcessBackend +The standard QProcessManager object wraps the QProcessBackendManager +object, creates QProcessFrontend objects to wrap each QProcessBackend object, and assigns unique string identifiers to each process. -This approach provides several advantages. First, the ProcessManager can +This approach provides several advantages. First, the QProcessManager can maintain a list of running processes indexed by identifier. Second, the -ProcessFrontend objects can be subclassed. This provides a convenient -way of adding convenience functions to the ProcessFrontend objects. Third, +QProcessFrontend objects can be subclassed. This provides a convenient +way of adding convenience functions to the QProcessFrontend objects. Third, instead of connecting to signals from each process, one can subclass -the ProcessManager itself and override the handler functions. +the QProcessManager itself and override the handler functions. The unique identifier assigned to each process created takes the form -of "NAME-NUMBER", where NAME comes from the ProcessInfo.name attribute +of "NAME-NUMBER", where NAME comes from the QProcessInfo.name attribute and NUMBER is a unique integer assigned at process creation. -\section2 Directly using the ProcessManager +\section2 Directly using the QProcessManager -You can directly use the ProcessManager in your code. +You can directly use the QProcessManager in your code. \code void MyClass::setup() { - ProcessManager *manager = new ProcessManager; - manager->addFactory(new UnixProcessBackendFactory); + QProcessManager *manager = new QProcessManager; + manager->addFactory(new QUnixProcessBackendFactory); m_manager = manager; } -void MyClass::start(ProcessInfo info) +void MyClass::start(QProcessInfo info) { - ProcessFrontend *frontend = m_manager->start(info); + QProcessFrontend *frontend = m_manager->start(info); connect(frontend, SIGNAL(started()), SLOT(started())); connect(frontend, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(finished(int, QProcess::ExitStatus))); @@ -69,27 +69,27 @@ void MyClass::start(ProcessInfo info) void MyClass::started() { - ProcessFrontend *frontend = qobject_cast<ProcessFrontend *>(sender()); + QProcessFrontend *frontend = qobject_cast<QProcessFrontend *>(sender()); if (frontend) qDebug() << "Process" << identifier << "started with pid=" << frontend->pid(); } void MyClass::finished(int exitCode, QProcess::ExitStatus exitStatus) { - ProcessFrontend *frontend = qobject_cast<ProcessFrontend *>(sender()); + QProcessFrontend *frontend = qobject_cast<QProcessFrontend *>(sender()); if (frontend) qDebug() << "Process" << identifier << "stopped with" << exitCode << exitStatus; } \endcode -\section2 Subclassing ProcessManager +\section2 Subclassing QProcessManager You can subclass the process manager to gain more control. This avoids connecting signals to every process you create. \code -class Example : public ProcessManager +class Example : public QProcessManager { Q_OBJECT public: @@ -101,39 +101,39 @@ protected slots: }; void Example::Example(QObject *parent) - : ProcessManager(parent) + : QProcessManager(parent) { addFactory(new UnixProcessBackendFactory); } void Example::processFrontendStarted() { - ProcessManager::processFrontendStarted(); - ProcessFrontend *frontend = qobject_cast<ProcessFrontend *>(sender()); + QProcessManager::processFrontendStarted(); + QProcessFrontend *frontend = qobject_cast<QProcessFrontend *>(sender()); qDebug() << "Process" << frontend->identifier() << "has started"; } void Example::processFrontendFinished(int exitCode, QProcess::ExitStatus exitStatus) { - ProcessManager::processFrontendFinished(exitCode, exitStatus); - ProcessFrontend *frontend = qobject_cast<ProcessFrontend *>(sender()); + QProcessManager::processFrontendFinished(exitCode, exitStatus); + QProcessFrontend *frontend = qobject_cast<QProcessFrontend *>(sender()); qDebug() << "Process" << frontend->identifier() << "has finished" << exitCode << exitStatus; } \endcode -\section2 Subclass ProcessFrontend objects +\section2 Subclass QProcessFrontend objects -To subclass ProcessFrontend objects, override the \l -{ProcessManager::} {createFrontend()} function and return an object -that derived from ProcessFrontend. For example: +To subclass QProcessFrontend objects, override the \l +{QProcessManager::} {createFrontend()} function and return an object +that derived from QProcessFrontend. For example: \code -class MyFrontend : public ProcessFrontend { +class MyFrontend : public QProcessFrontend { Q_OBJECT public: - MyFrontend(ProcessBackend *backend) : ProcessFrontend(backend) {} + MyFrontend(QProcessBackend *backend) : QProcessFrontend(backend) {} protected: void handleStateChanged(QProcess::ProcessState); signals: @@ -146,13 +146,13 @@ void MyFrontend::handleStateChanged(QProcess::ProcessState state) emit stopped(); } -class MyManager : public ProcessManager +class MyManager : public QProcessManager { Q_OBJECT public: - MyManager(QObject *parent=0) : ProcessManager(parent) {} + MyManager(QObject *parent=0) : QProcessManager(parent) {} protected : - ProcessFrontend *createFrontend(ProcessBackend *backend) { + QProcessFrontend *createFrontend(QProcessBackend *backend) { return new MyFrontend(backend); } }; @@ -161,7 +161,7 @@ protected : In the above example, the custom \c MyFrontend class raises a new \c stopped() signal when the child process stops running. The \c -MyManager class reimplements \l {ProcessManager::} {createFrontend()} +MyManager class reimplements \l {QProcessManager::} {createFrontend()} to return a \c MyFrontend objects for each created process. */ diff --git a/doc/style/style.css b/src/processmanager/doc/style/style.css index 24b0e0e..24b0e0e 100644 --- a/doc/style/style.css +++ b/src/processmanager/doc/style/style.css diff --git a/src/processmanager/launcherclient.cpp b/src/processmanager/launcherclient.cpp deleted file mode 100644 index 1886f69..0000000 --- a/src/processmanager/launcherclient.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QDebug> - -#include "launcherclient.h" -#include "remoteprotocol.h" -#include "processbackend.h" -#include "processbackendmanager.h" - -QT_BEGIN_NAMESPACE_PROCESSMANAGER - -/*! - \class LauncherClient - \brief The LauncherClient class handles a single Launcher client. - */ - -/*! - Create a new LauncherClient with ProcessBackendManager \a manager - */ - -LauncherClient::LauncherClient(ProcessBackendManager *manager) - : QObject(manager) - , m_manager(manager) -{ -} - -/*! - Process an incoming \a message - */ - -void LauncherClient::receive(const QJsonObject& message) -{ - // qDebug() << Q_FUNC_INFO << message; - QString cmd = message.value(RemoteProtocol::command()).toString(); - int id = message.value(RemoteProtocol::id()).toDouble(); - if ( cmd == RemoteProtocol::start() ) { - ProcessInfo info(message.value(RemoteProtocol::info()).toObject().toVariantMap()); - ProcessBackend *backend = m_manager->create(info, this); - if (backend) { - connect(backend, SIGNAL(started()), SLOT(started())); - connect(backend, SIGNAL(finished(int, QProcess::ExitStatus)), - SLOT(finished(int, QProcess::ExitStatus))); - connect(backend, SIGNAL(error(QProcess::ProcessError)), SLOT(error(QProcess::ProcessError))); - connect(backend, SIGNAL(stateChanged(QProcess::ProcessState)), - SLOT(stateChanged(QProcess::ProcessState))); - connect(backend, SIGNAL(standardOutput(const QByteArray&)), - SLOT(standardOutput(const QByteArray&))); - connect(backend, SIGNAL(standardError(const QByteArray&)), - SLOT(standardError(const QByteArray&))); - m_idToBackend.insert(id, backend); - m_backendToId.insert(backend, id); - backend->start(); - } - } - else if ( cmd == RemoteProtocol::stop() ) { - ProcessBackend *backend = m_idToBackend.value(id); - if (backend) { - int timeout = message.value(RemoteProtocol::timeout()).toDouble(); - backend->stop(timeout); - } - } - else if ( cmd == RemoteProtocol::set() ) { - ProcessBackend *backend = m_idToBackend.value(id); - if (backend) { - QString key = message.value(RemoteProtocol::key()).toString(); - int value = message.value(RemoteProtocol::value()).toDouble(); - if (key == RemoteProtocol::priority()) - backend->setDesiredPriority(value); - else if (key == RemoteProtocol::oomAdjustment()) - backend->setDesiredOomAdjustment(value); - } - } - else if ( cmd == RemoteProtocol::write() ) { - QByteArray data = QByteArray::fromBase64(message.value(RemoteProtocol::data()).toString().toLocal8Bit()); - ProcessBackend *backend = m_idToBackend.value(id); - if (backend) - backend->write(data); - } -} - -/*! - \internal - */ - -void LauncherClient::started() -{ - ProcessBackend *backend = qobject_cast<ProcessBackend *>(sender()); - QJsonObject msg; - msg.insert(RemoteProtocol::event(), RemoteProtocol::started()); - msg.insert(RemoteProtocol::id(), m_backendToId.value(backend)); - msg.insert(RemoteProtocol::pid(), (double) backend->pid()); - emit send(msg); -} - -/*! - \internal - */ - -void LauncherClient::finished(int exitCode, QProcess::ExitStatus exitStatus) -{ - ProcessBackend *backend = qobject_cast<ProcessBackend *>(sender()); - QJsonObject msg; - msg.insert(RemoteProtocol::event(), RemoteProtocol::finished()); - msg.insert(RemoteProtocol::id(), m_backendToId.value(backend)); - msg.insert(RemoteProtocol::exitCode(), exitCode); - msg.insert(RemoteProtocol::exitStatus(), exitStatus); - emit send(msg); -} - -/*! - \internal - */ - -void LauncherClient::error(QProcess::ProcessError err) -{ - ProcessBackend *backend = qobject_cast<ProcessBackend *>(sender()); - QJsonObject msg; - msg.insert(RemoteProtocol::event(), RemoteProtocol::error()); - msg.insert(RemoteProtocol::id(), m_backendToId.value(backend)); - msg.insert(RemoteProtocol::error(), err); - msg.insert(RemoteProtocol::errorString(), backend->errorString()); - emit send(msg); -} - -/*! - \internal - */ - -void LauncherClient::stateChanged(QProcess::ProcessState state) -{ - ProcessBackend *backend = qobject_cast<ProcessBackend *>(sender()); - QJsonObject msg; - msg.insert(RemoteProtocol::event(), RemoteProtocol::stateChanged()); - msg.insert(RemoteProtocol::id(), m_backendToId.value(backend)); - msg.insert(RemoteProtocol::stateChanged(), state); - emit send(msg); -} - -/*! - \internal - */ - -void LauncherClient::standardOutput(const QByteArray& data) -{ - ProcessBackend *backend = qobject_cast<ProcessBackend *>(sender()); - QJsonObject msg; - msg.insert(RemoteProtocol::event(), RemoteProtocol::output()); - msg.insert(RemoteProtocol::id(), m_backendToId.value(backend)); - msg.insert(RemoteProtocol::standardout(), QString::fromLocal8Bit(data.data(), data.size())); - emit send(msg); -} - -/*! - \internal - */ - -void LauncherClient::standardError(const QByteArray& data) -{ - ProcessBackend *backend = qobject_cast<ProcessBackend *>(sender()); - QJsonObject msg; - msg.insert(RemoteProtocol::event(), RemoteProtocol::output()); - msg.insert(RemoteProtocol::id(), m_backendToId.value(backend)); - msg.insert(RemoteProtocol::standarderror(), QString::fromLocal8Bit(data.data(), data.size())); - emit send(msg); -} - -/*! - \fn void LauncherClient::send(const QJsonObject& message) - - Send a \a message to the remote controller. -*/ - -#include "moc_launcherclient.cpp" - -QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/processmanager-lib.pri b/src/processmanager/processmanager-lib.pri index 8029a5b..b0a51a4 100644 --- a/src/processmanager/processmanager-lib.pri +++ b/src/processmanager/processmanager-lib.pri @@ -4,77 +4,77 @@ QT -= gui INCLUDEPATH += $$PWD PUBLIC_HEADERS += \ - $$PWD/process.h \ - $$PWD/processlist.h \ - $$PWD/processfrontend.h \ - $$PWD/processbackend.h \ - $$PWD/processbackendfactory.h \ - $$PWD/processbackendmanager.h \ - $$PWD/matchdelegate.h \ - $$PWD/rewritedelegate.h \ - $$PWD/gdbrewritedelegate.h \ - $$PWD/idledelegate.h \ - $$PWD/timeoutidledelegate.h \ - $$PWD/cpuidledelegate.h \ - $$PWD/ioidledelegate.h \ - $$PWD/infomatchdelegate.h \ - $$PWD/keymatchdelegate.h \ - $$PWD/processinfo.h \ - $$PWD/processmanager.h \ - $$PWD/standardprocessbackendfactory.h \ - $$PWD/prelaunchprocessbackendfactory.h \ - $$PWD/remoteprocessbackendfactory.h \ - $$PWD/pipeprocessbackendfactory.h \ - $$PWD/socketprocessbackendfactory.h \ - $$PWD/preforkprocessbackendfactory.h \ - $$PWD/unixprocessbackend.h \ - $$PWD/standardprocessbackend.h \ - $$PWD/prelaunchprocessbackend.h \ - $$PWD/remoteprocessbackend.h \ - $$PWD/processmanager-global.h \ - $$PWD/launcherclient.h \ - $$PWD/pipelauncher.h \ - $$PWD/socketlauncher.h \ - $$PWD/procutils.h \ - $$PWD/remoteprotocol.h \ - $$PWD/forklauncher.h \ - $$PWD/prefork.h + $$PWD/qpmprocess.h \ + $$PWD/qprocesslist.h \ + $$PWD/qprocessfrontend.h \ + $$PWD/qprocessbackend.h \ + $$PWD/qprocessbackendfactory.h \ + $$PWD/qprocessbackendmanager.h \ + $$PWD/qmatchdelegate.h \ + $$PWD/qrewritedelegate.h \ + $$PWD/qgdbrewritedelegate.h \ + $$PWD/qidledelegate.h \ + $$PWD/qtimeoutidledelegate.h \ + $$PWD/qcpuidledelegate.h \ + $$PWD/qioidledelegate.h \ + $$PWD/qinfomatchdelegate.h \ + $$PWD/qkeymatchdelegate.h \ + $$PWD/qprocessinfo.h \ + $$PWD/qprocessmanager.h \ + $$PWD/qstandardprocessbackendfactory.h \ + $$PWD/qprelaunchprocessbackendfactory.h \ + $$PWD/qremoteprocessbackendfactory.h \ + $$PWD/qpipeprocessbackendfactory.h \ + $$PWD/qsocketprocessbackendfactory.h \ + $$PWD/qpreforkprocessbackendfactory.h \ + $$PWD/qunixprocessbackend.h \ + $$PWD/qstandardprocessbackend.h \ + $$PWD/qprelaunchprocessbackend.h \ + $$PWD/qremoteprocessbackend.h \ + $$PWD/qprocessmanager-global.h \ + $$PWD/qlauncherclient.h \ + $$PWD/qpipelauncher.h \ + $$PWD/qsocketlauncher.h \ + $$PWD/qprocutils.h \ + $$PWD/qremoteprotocol.h \ + $$PWD/qforklauncher.h \ + $$PWD/qprefork.h HEADERS += \ $$PUBLIC_HEADERS \ - $$PWD/unixsandboxprocess.h + $$PWD/qunixsandboxprocess_p.h SOURCES += \ - $$PWD/process.cpp \ - $$PWD/processfrontend.cpp \ - $$PWD/processbackend.cpp \ - $$PWD/processbackendfactory.cpp \ - $$PWD/processbackendmanager.cpp \ - $$PWD/matchdelegate.cpp \ - $$PWD/rewritedelegate.cpp \ - $$PWD/gdbrewritedelegate.cpp \ - $$PWD/idledelegate.cpp \ - $$PWD/timeoutidledelegate.cpp \ - $$PWD/cpuidledelegate.cpp \ - $$PWD/ioidledelegate.cpp \ - $$PWD/infomatchdelegate.cpp \ - $$PWD/keymatchdelegate.cpp \ - $$PWD/processinfo.cpp \ - $$PWD/processmanager.cpp \ - $$PWD/unixprocessbackend.cpp \ - $$PWD/standardprocessbackendfactory.cpp \ - $$PWD/standardprocessbackend.cpp \ - $$PWD/unixsandboxprocess.cpp \ - $$PWD/prelaunchprocessbackendfactory.cpp \ - $$PWD/prelaunchprocessbackend.cpp \ - $$PWD/remoteprocessbackend.cpp \ - $$PWD/remoteprocessbackendfactory.cpp \ - $$PWD/pipeprocessbackendfactory.cpp \ - $$PWD/socketprocessbackendfactory.cpp \ - $$PWD/preforkprocessbackendfactory.cpp \ - $$PWD/launcherclient.cpp \ - $$PWD/pipelauncher.cpp \ - $$PWD/socketlauncher.cpp \ - $$PWD/procutils.cpp \ - $$PWD/forklauncher.cpp \ - $$PWD/prefork.cpp + $$PWD/qpmprocess.cpp \ + $$PWD/qprocessfrontend.cpp \ + $$PWD/qprocessbackend.cpp \ + $$PWD/qprocessbackendfactory.cpp \ + $$PWD/qprocessbackendmanager.cpp \ + $$PWD/qmatchdelegate.cpp \ + $$PWD/qrewritedelegate.cpp \ + $$PWD/qgdbrewritedelegate.cpp \ + $$PWD/qidledelegate.cpp \ + $$PWD/qtimeoutidledelegate.cpp \ + $$PWD/qcpuidledelegate.cpp \ + $$PWD/qioidledelegate.cpp \ + $$PWD/qinfomatchdelegate.cpp \ + $$PWD/qkeymatchdelegate.cpp \ + $$PWD/qprocessinfo.cpp \ + $$PWD/qprocessmanager.cpp \ + $$PWD/qunixprocessbackend.cpp \ + $$PWD/qstandardprocessbackendfactory.cpp \ + $$PWD/qstandardprocessbackend.cpp \ + $$PWD/qunixsandboxprocess.cpp \ + $$PWD/qprelaunchprocessbackendfactory.cpp \ + $$PWD/qprelaunchprocessbackend.cpp \ + $$PWD/qremoteprocessbackend.cpp \ + $$PWD/qremoteprocessbackendfactory.cpp \ + $$PWD/qpipeprocessbackendfactory.cpp \ + $$PWD/qsocketprocessbackendfactory.cpp \ + $$PWD/qpreforkprocessbackendfactory.cpp \ + $$PWD/qlauncherclient.cpp \ + $$PWD/qpipelauncher.cpp \ + $$PWD/qsocketlauncher.cpp \ + $$PWD/qprocutils.cpp \ + $$PWD/qforklauncher.cpp \ + $$PWD/qprefork.cpp diff --git a/src/processmanager/processmanager.pro b/src/processmanager/processmanager.pro index ddc714d..be63426 100644 --- a/src/processmanager/processmanager.pro +++ b/src/processmanager/processmanager.pro @@ -1,5 +1,7 @@ TARGET = QtAddOnProcessManager +QMAKE_DOCS = $$PWD/doc/processmanager.qdocconf + load(qt_module) DEFINES += QT_ADDON_PROCESSMANAGER_LIB diff --git a/src/processmanager/cpuidledelegate.cpp b/src/processmanager/qcpuidledelegate.cpp index 7ecef6c..9a98349 100644 --- a/src/processmanager/cpuidledelegate.cpp +++ b/src/processmanager/qcpuidledelegate.cpp @@ -49,7 +49,7 @@ #include <ctype.h> #endif -#include "cpuidledelegate.h" +#include "qcpuidledelegate.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER @@ -57,10 +57,11 @@ const int kIdleTimerInterval = 1000; const double kDefaultLoadThreshold = 0.4; /*! - \class CpuIdleDelegate - \brief The CpuIdleDelegate class generates a periodic cpu. + \class QCpuIdleDelegate + \brief The QCpuIdleDelegate class generates a periodic cpu. + \inmodule QtProcessManager - The CpuIdleDelegate class generates a periodic cpu for + The QCpuIdleDelegate class generates a periodic cpu for creation of idle resources. When idle CPU resources are requested it checks the system load level approximately once per second. When the load level is below the threshold set by \l{loadThreshold}, the @@ -68,12 +69,12 @@ const double kDefaultLoadThreshold = 0.4; */ /*! - \property CpuIdleDelegate::idleInterval + \property QCpuIdleDelegate::idleInterval \brief Time in milliseconds before a new idle CPU request will be fulfilled */ /*! - \property CpuIdleDelegate::loadThreshold + \property QCpuIdleDelegate::loadThreshold \brief Load level we need to be under to generate idle CPU requests. This value is a double that ranges from 0.0 to 1.0. A value greater @@ -84,11 +85,11 @@ const double kDefaultLoadThreshold = 0.4; /*! - Construct a CpuIdleDelegate with an optional \a parent. + Construct a QCpuIdleDelegate with an optional \a parent. */ -CpuIdleDelegate::CpuIdleDelegate(QObject *parent) - : IdleDelegate(parent) +QCpuIdleDelegate::QCpuIdleDelegate(QObject *parent) + : QIdleDelegate(parent) , m_load(1.0) , m_loadThreshold(kDefaultLoadThreshold) , m_total(0) @@ -102,7 +103,7 @@ CpuIdleDelegate::CpuIdleDelegate(QObject *parent) Turn on or off idle requests based on \a state. */ -void CpuIdleDelegate::handleStateChange(bool state) +void QCpuIdleDelegate::handleStateChange(bool state) { if (state) { updateStats(true); @@ -116,7 +117,7 @@ void CpuIdleDelegate::handleStateChange(bool state) \internal */ -double CpuIdleDelegate::updateStats(bool reset) +double QCpuIdleDelegate::updateStats(bool reset) { int idle = 0; int total = 0; @@ -175,7 +176,7 @@ double CpuIdleDelegate::updateStats(bool reset) \internal */ -void CpuIdleDelegate::timeout() +void QCpuIdleDelegate::timeout() { if (updateStats(false) <= m_loadThreshold) emit idleCpuAvailable(); @@ -186,7 +187,7 @@ void CpuIdleDelegate::timeout() Return the current launch interval in milliseconds */ -int CpuIdleDelegate::idleInterval() const +int QCpuIdleDelegate::idleInterval() const { return m_timer.interval(); } @@ -195,7 +196,7 @@ int CpuIdleDelegate::idleInterval() const Set the current idle interval to \a interval milliseconds */ -void CpuIdleDelegate::setIdleInterval(int interval) +void QCpuIdleDelegate::setIdleInterval(int interval) { if (m_timer.interval() != interval) { m_timer.stop(); @@ -210,7 +211,7 @@ void CpuIdleDelegate::setIdleInterval(int interval) Return the current load threshold as a number from 0.0 to 1.0 */ -double CpuIdleDelegate::loadThreshold() const +double QCpuIdleDelegate::loadThreshold() const { return m_loadThreshold; } @@ -219,7 +220,7 @@ double CpuIdleDelegate::loadThreshold() const Set the current load threshold to \a threshold milliseconds */ -void CpuIdleDelegate::setLoadThreshold(double threshold) +void QCpuIdleDelegate::setLoadThreshold(double threshold) { if (m_loadThreshold != threshold) { m_loadThreshold = threshold; @@ -228,23 +229,23 @@ void CpuIdleDelegate::setLoadThreshold(double threshold) } /*! - \fn void CpuIdleDelegate::idleIntervalChanged() + \fn void QCpuIdleDelegate::idleIntervalChanged() This signal is emitted when the idleInterval is changed. */ /*! - \fn void CpuIdleDelegate::loadThresholdChanged() + \fn void QCpuIdleDelegate::loadThresholdChanged() This signal is emitted when the loadThreshold is changed. */ /*! - \fn void CpuIdleDelegate::loadUpdate(double load) + \fn void QCpuIdleDelegate::loadUpdate(double load) This signal is emitted when the load is read. It mainly serves as a debugging signal. The \a load value will range between 0.0 and 1.0 */ -#include "moc_cpuidledelegate.cpp" +#include "moc_qcpuidledelegate.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/cpuidledelegate.h b/src/processmanager/qcpuidledelegate.h index 78abbda..cf91b44 100644 --- a/src/processmanager/cpuidledelegate.h +++ b/src/processmanager/qcpuidledelegate.h @@ -41,20 +41,20 @@ #define CPU_IDLE_DELEGATE_H #include <QTimer> -#include "idledelegate.h" +#include "qidledelegate.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class ProcessInfo; +class QProcessInfo; -class Q_ADDON_PROCESSMANAGER_EXPORT CpuIdleDelegate : public IdleDelegate +class Q_ADDON_PROCESSMANAGER_EXPORT QCpuIdleDelegate : public QIdleDelegate { Q_OBJECT Q_PROPERTY(int idleInterval READ idleInterval WRITE setIdleInterval NOTIFY idleIntervalChanged) Q_PROPERTY(double loadThreshold READ loadThreshold WRITE setLoadThreshold NOTIFY loadThresholdChanged) public: - explicit CpuIdleDelegate(QObject *parent = 0); + explicit QCpuIdleDelegate(QObject *parent = 0); int idleInterval() const; void setIdleInterval(int interval); @@ -77,7 +77,7 @@ private: double updateStats(bool); private: - Q_DISABLE_COPY(CpuIdleDelegate); + Q_DISABLE_COPY(QCpuIdleDelegate); QTimer m_timer; double m_load, m_loadThreshold; int m_total, m_idle; diff --git a/src/processmanager/forklauncher.cpp b/src/processmanager/qforklauncher.cpp index e3bd334..441d67a 100644 --- a/src/processmanager/forklauncher.cpp +++ b/src/processmanager/qforklauncher.cpp @@ -60,10 +60,10 @@ #include <sys/wait.h> #include <grp.h> -#include "forklauncher.h" -#include "remoteprotocol.h" -#include "processinfo.h" -#include "procutils.h" +#include "qforklauncher.h" +#include "qremoteprotocol.h" +#include "qprocessinfo.h" +#include "qprocutils.h" #if defined(Q_OS_LINUX) #include <sys/prctl.h> @@ -81,17 +81,17 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \headerfile <forklauncher.h> - \title Forklauncher + \headerfile <qforklauncher.h> + \title QForklauncher \ingroup funclists - \brief The <forklauncher.h> file provides the \l{forklauncher()} function + \brief The <qforklauncher.h> file provides the \l{qForkLauncher()} function to convert a runtime into a forking runtime factory. */ /*! - \fn void forklauncher(int *argc, char ***argv) - \relates <forklauncher.h> + \fn void qForkLauncher(int *argc, char ***argv) + \relates <qforklauncher.h> \brief The fork launcher class converts any standard runtime object into remote process backend that forks off new children. @@ -102,8 +102,8 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER initialization, and then fork off copies of it self each time the process is being started. - The forklauncher functions makes it easy to convert any program into - a self-forking parent process. Simply call \c{forklauncher()} just + The qForkLauncher function makes it easy to convert any program into + a self-forking parent process. Simply call \c{qForkLauncher()} just after the program has started and initialized any stateless global values. You must pass a pointer to \a argc and a pointer to \a argv. For example: @@ -112,43 +112,43 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER // Program "myForkProgram" int main(int argc, char **argv) { - forklauncher(&argc, &argv); + qForkLauncher(&argc, &argv); QCoreApplication app(argc, argv); MyAppStuff stuff; return app.exec(); } \endcode - The \c{forklauncher} function grabs control of the process and listens + The \c{qForkLauncher} function grabs control of the process and listens on STDIN for JSON-formatted messages that follow the remote protocol. - This matches logically with the \l{PipeProcessBackendFactory} class, which + This matches logically with the \l{QPipeProcessBackendFactory} class, which spawns off a process and expects to talk with that process over the STDIN/STDOUT pair connected to that process. So your server code looks something like: \code - ProcessBackendManager *manager = new ProcessBackendManager; - ProcessInfo info; + QProcessBackendManager *manager = new QProcessBackendManager; + QProcessInfo info; info.setValue("program", "myForkProgram"); - PipeProcessBackendFactory *factory = new PipeProcessBackendFactory; + QPipeProcessBackendFactory *factory = new QPipeProcessBackendFactory; factory->setProcessInfo(info); manager->addFactory(factory); \endcode - Any processes creation requests to the \l{PipeProcessBackendFactory} will - be sent to \c{myForkProgram}. The \c{forkLauncher()} function will + Any processes creation requests to the \l{QPipeProcessBackendFactory} will + be sent to \c{myForkProgram}. The \c{qForkLauncher()} function will receive the process creation request, call \c{fork()} to create a child - process, and then return from the \c{forkLauncher()} function call + process, and then return from the \c{qForkLauncher()} function call in the child process. Which means that the \c{myForkProgram} will run the rest of the program as written, and never realize that it is a forked copy of a master program which is still listening to the - \l{PipeProcessBackendFactory}. + \l{QPipeProcessBackendFactory}. - The process creation routine passes a complete \l{ProcessInfo} record, + The process creation routine passes a complete \l{QProcessInfo} record, including program name and command line arguments. This program name and these command line arguments are written into the child's \c{argc}, and \c{argv} variables. Just remember, you can only access the child's - command line arguments \e{after} you return from \c{forklauncher()} + command line arguments \e{after} you return from \c{qForkLauncher()} */ @@ -193,8 +193,8 @@ static void writeFromBuffer(int fd, QByteArray& buffer) static void copyToOutgoing(QByteArray& outgoing, const QString& channel, QByteArray& buf, int id) { QJsonObject message; - message.insert(RemoteProtocol::event(), RemoteProtocol::output()); - message.insert(RemoteProtocol::id(), id); + message.insert(QRemoteProtocol::event(), QRemoteProtocol::output()); + message.insert(QRemoteProtocol::id(), id); message.insert(channel, QString::fromLocal8Bit(buf.data(), buf.size())); outgoing.append(QJsonDocument(message).toBinaryData()); @@ -205,13 +205,13 @@ static void copyToOutgoing(QByteArray& outgoing, const QString& channel, QByteAr Update the current process to match the information in info */ -static void fixProcessState(const ProcessInfo& info, int *argc_ptr, char ***argv_ptr) +static void fixProcessState(const QProcessInfo& info, int *argc_ptr, char ***argv_ptr) { // Fix the UID & GID values ::setpgid(0,0); - if (info.contains(ProcessInfoConstants::Gid)) + if (info.contains(QProcessInfoConstants::Gid)) ::setgid(info.gid()); - if (info.contains(ProcessInfoConstants::Uid)) + if (info.contains(QProcessInfoConstants::Uid)) ::setuid(info.uid()); uint umask = info.umask(); if (umask) @@ -225,26 +225,26 @@ static void fixProcessState(const ProcessInfo& info, int *argc_ptr, char ***argv #endif ::setgroups(0,0); - if (info.contains(ProcessInfoConstants::Priority)) { + if (info.contains(QProcessInfoConstants::Priority)) { int priority = info.priority(); if (::setpriority(PRIO_PROCESS, ::getpid(), priority) == -1) qWarning("Unable to set priority of pid=%d to %d", ::getpid(), priority); } - if (info.contains(ProcessInfoConstants::OomAdjustment)) { + if (info.contains(QProcessInfoConstants::OomAdjustment)) { int adj = info.oomAdjustment(); - if (!ProcUtils::setOomAdjustment(::getpid(), adj)) + if (!QProcUtils::setOomAdjustment(::getpid(), adj)) qWarning("Unable to set oom adjustment of pid=%d to %d", ::getpid(), adj); } - if (info.contains(ProcessInfoConstants::WorkingDirectory)) { + if (info.contains(QProcessInfoConstants::WorkingDirectory)) { QByteArray wd = QFile::encodeName(info.workingDirectory()); if (!::chdir(wd.constData())) qWarning("Unable to chdir to %s", wd.constData()); } // Fix the environment - if (info.contains(ProcessInfoConstants::Environment)) { + if (info.contains(QProcessInfoConstants::Environment)) { const char *entry; QList<QByteArray> envlist; for (int count = 0 ; (entry = environ[count]) ; ++count) { @@ -272,10 +272,10 @@ static void fixProcessState(const ProcessInfo& info, int *argc_ptr, char ***argv } // Fix up the argument list - if (info.contains(ProcessInfoConstants::Arguments)) { + if (info.contains(QProcessInfoConstants::Arguments)) { const int argc = info.arguments().size() + 1; char **argv = new char *[argc + 1]; - if (info.contains(ProcessInfoConstants::Program)) + if (info.contains(QProcessInfoConstants::Program)) argv[0] = strdup(info.program().toLocal8Bit().constData()); else argv[0] = (*argv_ptr)[0]; @@ -285,7 +285,7 @@ static void fixProcessState(const ProcessInfo& info, int *argc_ptr, char ***argv *argc_ptr = argc; *argv_ptr = argv; } - else if (info.contains(ProcessInfoConstants::Program)) { + else if (info.contains(QProcessInfoConstants::Program)) { // No new arguments; just copy in the new program name (*argv_ptr)[0] = strdup(info.program().toLocal8Bit().constData()); } @@ -375,16 +375,16 @@ void ChildProcess::processFdSet(QByteArray& outgoing, fd_set& rfds, fd_set& wfds if (FD_ISSET(m_stdout, &rfds)) { // Data to read readToBuffer(m_stdout, m_outbuf); if (m_outbuf.size()) - copyToOutgoing(outgoing, RemoteProtocol::standardout(), m_outbuf, m_id); + copyToOutgoing(outgoing, QRemoteProtocol::standardout(), m_outbuf, m_id); } if (FD_ISSET(m_stderr, &rfds)) { // Data to read readToBuffer(m_stderr, m_errbuf); if (m_errbuf.size()) - copyToOutgoing(outgoing, RemoteProtocol::standarderror(), m_errbuf, m_id); + copyToOutgoing(outgoing, QRemoteProtocol::standarderror(), m_errbuf, m_id); } if (m_state == SentSigTerm && m_timer.hasExpired(m_timeout)) { m_state = SentSigKill; - ProcUtils::sendSignalToProcess(m_pid, SIGKILL); + QProcUtils::sendSignalToProcess(m_pid, SIGKILL); } } @@ -400,11 +400,11 @@ void ChildProcess::stop(int timeout) m_state = SentSigTerm; m_timeout = timeout; m_timer.start(); - ProcUtils::sendSignalToProcess(m_pid, SIGTERM); + QProcUtils::sendSignalToProcess(m_pid, SIGTERM); } else { m_state = SentSigKill; - ProcUtils::sendSignalToProcess(m_pid, SIGKILL); + QProcUtils::sendSignalToProcess(m_pid, SIGKILL); } } } @@ -417,7 +417,7 @@ void ChildProcess::setPriority(int priority) void ChildProcess::setOomAdjustment(int oomAdjustment) { - if (!ProcUtils::setOomAdjustment(m_pid, oomAdjustment)) + if (!QProcUtils::setOomAdjustment(m_pid, oomAdjustment)) qWarning("Unable to set oom adjustment of pid=%d to %d", m_pid, oomAdjustment); } @@ -474,38 +474,38 @@ bool ChildProcess::doFork() void ChildProcess::sendStateChanged(QByteArray& outgoing, QProcess::ProcessState state) { QJsonObject msg; - msg.insert(RemoteProtocol::event(), RemoteProtocol::stateChanged()); - msg.insert(RemoteProtocol::id(), m_id); - msg.insert(RemoteProtocol::stateChanged(), state); + msg.insert(QRemoteProtocol::event(), QRemoteProtocol::stateChanged()); + msg.insert(QRemoteProtocol::id(), m_id); + msg.insert(QRemoteProtocol::stateChanged(), state); outgoing.append(QJsonDocument(msg).toBinaryData()); } void ChildProcess::sendStarted(QByteArray& outgoing) { QJsonObject msg; - msg.insert(RemoteProtocol::event(), RemoteProtocol::started()); - msg.insert(RemoteProtocol::id(), m_id); - msg.insert(RemoteProtocol::pid(), m_pid); + msg.insert(QRemoteProtocol::event(), QRemoteProtocol::started()); + msg.insert(QRemoteProtocol::id(), m_id); + msg.insert(QRemoteProtocol::pid(), m_pid); outgoing.append(QJsonDocument(msg).toBinaryData()); } void ChildProcess::sendFinished(QByteArray& outgoing, int exitCode, QProcess::ExitStatus exitStatus) { QJsonObject msg; - msg.insert(RemoteProtocol::event(), RemoteProtocol::finished()); - msg.insert(RemoteProtocol::id(), m_id); - msg.insert(RemoteProtocol::exitCode(), exitCode); - msg.insert(RemoteProtocol::exitStatus(), exitStatus); + msg.insert(QRemoteProtocol::event(), QRemoteProtocol::finished()); + msg.insert(QRemoteProtocol::id(), m_id); + msg.insert(QRemoteProtocol::exitCode(), exitCode); + msg.insert(QRemoteProtocol::exitStatus(), exitStatus); outgoing.append(QJsonDocument(msg).toBinaryData()); } void ChildProcess::sendError(QByteArray& outgoing, QProcess::ProcessError err, const QString& errString) { QJsonObject msg; - msg.insert(RemoteProtocol::event(), RemoteProtocol::error()); - msg.insert(RemoteProtocol::id(), m_id); - msg.insert(RemoteProtocol::error(), err); - msg.insert(RemoteProtocol::errorString(), errString); + msg.insert(QRemoteProtocol::event(), QRemoteProtocol::error()); + msg.insert(QRemoteProtocol::id(), m_id); + msg.insert(QRemoteProtocol::error(), err); + msg.insert(QRemoteProtocol::errorString(), errString); outgoing.append(QJsonDocument(msg).toBinaryData()); } @@ -640,33 +640,33 @@ bool ParentProcess::processFdSet(fd_set& rfds, fd_set& wfds) // Return 'true' if this is a child process bool ParentProcess::handleMessage(QJsonObject& message) { - if (message.value(RemoteProtocol::remote()).toString() == RemoteProtocol::halt()) { + if (message.value(QRemoteProtocol::remote()).toString() == QRemoteProtocol::halt()) { // Force all children to stop foreach (ChildProcess *child, m_children) child->stop(0); exit(0); } else { - QString command = message.value(RemoteProtocol::command()).toString(); - int id = message.value(RemoteProtocol::id()).toDouble(); - if (command == RemoteProtocol::stop()) { + QString command = message.value(QRemoteProtocol::command()).toString(); + int id = message.value(QRemoteProtocol::id()).toDouble(); + if (command == QRemoteProtocol::stop()) { ChildProcess *child = m_children.value(id); if (child) { - int timeout = message.value(RemoteProtocol::timeout()).toDouble(); + int timeout = message.value(QRemoteProtocol::timeout()).toDouble(); child->stop(timeout); } - } else if (command == RemoteProtocol::set()) { + } else if (command == QRemoteProtocol::set()) { ChildProcess *child = m_children.value(id); if (child) { - QString key = message.value(RemoteProtocol::key()).toString(); - int value = message.value(RemoteProtocol::value()).toDouble(); - if (key == RemoteProtocol::priority()) + QString key = message.value(QRemoteProtocol::key()).toString(); + int value = message.value(QRemoteProtocol::value()).toDouble(); + if (key == QRemoteProtocol::priority()) child->setPriority(value); - else if (key == RemoteProtocol::oomAdjustment()) + else if (key == QRemoteProtocol::oomAdjustment()) child->setOomAdjustment(value); } - } else if (command == RemoteProtocol::start()) { - ProcessInfo info(message.value(RemoteProtocol::info()).toObject().toVariantMap()); + } else if (command == QRemoteProtocol::start()) { + QProcessInfo info(message.value(QRemoteProtocol::info()).toObject().toVariantMap()); ChildProcess *child = new ChildProcess(id); if (child->doFork()) { delete child; @@ -679,10 +679,10 @@ bool ParentProcess::handleMessage(QJsonObject& message) child->sendStateChanged(m_sendbuf, QProcess::Running); child->sendStarted(m_sendbuf); } - } else if (command == RemoteProtocol::write()) { + } else if (command == QRemoteProtocol::write()) { ChildProcess *child = m_children.value(id); if (child) - child->write(QByteArray::fromBase64(message.value(RemoteProtocol::data()).toString().toLatin1())); + child->write(QByteArray::fromBase64(message.value(QRemoteProtocol::data()).toString().toLatin1())); } } return false; @@ -702,7 +702,7 @@ bool ParentProcess::needTimeout() const /**************************************************************************/ -void forklauncher(int *argc, char ***argv ) +void qForkLauncher(int *argc, char ***argv ) { ParentProcess parent(argc, argv); diff --git a/src/processmanager/forklauncher.h b/src/processmanager/qforklauncher.h index 8cb74ea..5aec282 100644 --- a/src/processmanager/forklauncher.h +++ b/src/processmanager/qforklauncher.h @@ -40,12 +40,12 @@ #ifndef FORK_LAUNCHER_H #define FORK_LAUNCHER_H -#include "processmanager-global.h" +#include "qprocessmanager-global.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -Q_CORE_EXPORT void forklauncher(int *argc, char ***argv); -Q_CORE_EXPORT void displayFileDescriptors(int argc, char **argv); +Q_CORE_EXPORT void qForkLauncher(int *argc, char ***argv); +Q_CORE_EXPORT void qDisplayFileDescriptors(int argc, char **argv); QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/gdbrewritedelegate.cpp b/src/processmanager/qgdbrewritedelegate.cpp index f1a5eba..c4a1e1d 100644 --- a/src/processmanager/gdbrewritedelegate.cpp +++ b/src/processmanager/qgdbrewritedelegate.cpp @@ -38,33 +38,34 @@ ****************************************************************************/ #include <QStringList> -#include "gdbrewritedelegate.h" -#include "processinfo.h" +#include "qgdbrewritedelegate.h" +#include "qprocessinfo.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \class GdbRewriteDelegate - \brief The GdbRewriteDelegate class adds gdb to the process arguments. + \class QGdbRewriteDelegate + \brief The QGdbRewriteDelegate class adds gdb to the process arguments. + \inmodule QtProcessManager */ /*! - Construct a GdbRewriteDelegate with an optional \a parent. + Construct a QGdbRewriteDelegate with an optional \a parent. */ -GdbRewriteDelegate::GdbRewriteDelegate(QObject *parent) - : RewriteDelegate(parent) +QGdbRewriteDelegate::QGdbRewriteDelegate(QObject *parent) + : QRewriteDelegate(parent) { } /*! - \fn void GdbRewriteDelegate::rewrite(ProcessInfo& info) + \fn void QGdbRewriteDelegate::rewrite(QProcessInfo& info) - Rewrites the ProcessInfo \a info structure to launch gdb. + Rewrites the QProcessInfo \a info structure to launch gdb. For example, "prog arg1 arg2 ..." becomes "gdb -- prog arg1 arg2..." */ -void GdbRewriteDelegate::rewrite(ProcessInfo& info) +void QGdbRewriteDelegate::rewrite(QProcessInfo& info) { QStringList args = info.arguments(); args.prepend(info.program()); @@ -73,6 +74,6 @@ void GdbRewriteDelegate::rewrite(ProcessInfo& info) info.setArguments(args); } -#include "moc_gdbrewritedelegate.cpp" +#include "moc_qgdbrewritedelegate.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/gdbrewritedelegate.h b/src/processmanager/qgdbrewritedelegate.h index 3a0867c..4aa3a0f 100644 --- a/src/processmanager/gdbrewritedelegate.h +++ b/src/processmanager/qgdbrewritedelegate.h @@ -40,19 +40,19 @@ #ifndef GDB_REWRITE_DELEGATE_H #define GDB_REWRITE_DELEGATE_H -#include "rewritedelegate.h" +#include "qrewritedelegate.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class Q_ADDON_PROCESSMANAGER_EXPORT GdbRewriteDelegate : public RewriteDelegate +class Q_ADDON_PROCESSMANAGER_EXPORT QGdbRewriteDelegate : public QRewriteDelegate { Q_OBJECT public: - explicit GdbRewriteDelegate(QObject *parent = 0); - virtual void rewrite(ProcessInfo& info); + explicit QGdbRewriteDelegate(QObject *parent = 0); + virtual void rewrite(QProcessInfo& info); private: - Q_DISABLE_COPY(GdbRewriteDelegate); + Q_DISABLE_COPY(QGdbRewriteDelegate) }; QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/idledelegate.cpp b/src/processmanager/qidledelegate.cpp index c65f5c7..0843e4d 100644 --- a/src/processmanager/idledelegate.cpp +++ b/src/processmanager/qidledelegate.cpp @@ -37,34 +37,35 @@ ** ****************************************************************************/ -#include "idledelegate.h" +#include "qidledelegate.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \class IdleDelegate - \brief The IdleDelegate class is a virtual class for gathering idle CPU cycles + \class QIdleDelegate + \brief The QIdleDelegate class is a virtual class for gathering idle CPU cycles + \inmodule QtProcessManager You must subclass this class to do anything useful. - The IdleDelegate is turned on and off by the \l{requestIdleCpu()} function. - The IdleDelegate should emit the \l{idleCpuAvailable()} signal approximately + The QIdleDelegate is turned on and off by the \l{requestIdleCpu()} function. + The QIdleDelegate should emit the \l{idleCpuAvailable()} signal approximately once per second when it is turned on. Subclasses should respect the \l{enabled} property by not generating signals - if the IdleDelegate is not enabled. + if the QIdleDelegate is not enabled. */ /*! - \property IdleDelegate::enabled - \brief Boolean value of whether or not this IdleDelegate should generate signals. + \property QIdleDelegate::enabled + \brief Boolean value of whether or not this QIdleDelegate should generate signals. */ /*! - Construct a IdleDelegate with an optional \a parent. + Construct a QIdleDelegate with an optional \a parent. */ -IdleDelegate::IdleDelegate(QObject *parent) +QIdleDelegate::QIdleDelegate(QObject *parent) : QObject(parent) , m_enabled(true) , m_requested(false) @@ -75,7 +76,7 @@ IdleDelegate::IdleDelegate(QObject *parent) Set the \a enabled property. */ -void IdleDelegate::setEnabled(bool value) +void QIdleDelegate::setEnabled(bool value) { if (m_enabled != value) { m_enabled = value; @@ -86,11 +87,11 @@ void IdleDelegate::setEnabled(bool value) } /*! - \fn void IdleDelegate::requestIdleCpu(bool request) + \fn void QIdleDelegate::requestIdleCpu(bool request) Turn on or off idle requests based on \a request. */ -void IdleDelegate::requestIdleCpu(bool request) +void QIdleDelegate::requestIdleCpu(bool request) { if (m_requested != request) { m_requested = request; @@ -100,31 +101,31 @@ void IdleDelegate::requestIdleCpu(bool request) } /*! - \fn void IdleDelegate::handleStateChange(bool state) + \fn void QIdleDelegate::handleStateChange(bool state) Override this in subclasses to turn on and off your Idle delegate based on \a state (which is just the logical OR of \l{requested()} and \l{enabled()} */ /*! - \fn bool IdleDelegate::enabled() const + \fn bool QIdleDelegate::enabled() const Return true if this delegate is enabled */ /*! - \fn bool IdleDelegate::requested() const + \fn bool QIdleDelegate::requested() const Return true if this delegate has been requested */ /*! - \fn void IdleDelegate::idleCpuAvailable() + \fn void QIdleDelegate::idleCpuAvailable() Signal emitted periodically when idle CPU resources are available. */ /*! - \fn void IdleDelegate::enabledChanged() + \fn void QIdleDelegate::enabledChanged() Signal emitted when enabled value is changed */ -#include "moc_idledelegate.cpp" +#include "moc_qidledelegate.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/idledelegate.h b/src/processmanager/qidledelegate.h index cadd915..6b3c5cb 100644 --- a/src/processmanager/idledelegate.h +++ b/src/processmanager/qidledelegate.h @@ -41,17 +41,17 @@ #define IDLE_DELEGATE_H #include <QObject> -#include "processmanager-global.h" +#include "qprocessmanager-global.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class Q_ADDON_PROCESSMANAGER_EXPORT IdleDelegate : public QObject +class Q_ADDON_PROCESSMANAGER_EXPORT QIdleDelegate : public QObject { Q_OBJECT Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) public: - explicit IdleDelegate(QObject *parent = 0); + explicit QIdleDelegate(QObject *parent = 0); virtual void requestIdleCpu(bool request); bool enabled() const { return m_enabled; } @@ -67,7 +67,7 @@ protected: virtual void handleStateChange(bool state) = 0; private: - Q_DISABLE_COPY(IdleDelegate); + Q_DISABLE_COPY(QIdleDelegate); bool m_enabled; bool m_requested; }; diff --git a/src/processmanager/infomatchdelegate.cpp b/src/processmanager/qinfomatchdelegate.cpp index ed6e3fa..f740038 100644 --- a/src/processmanager/infomatchdelegate.cpp +++ b/src/processmanager/qinfomatchdelegate.cpp @@ -39,15 +39,16 @@ #include <QFileInfo> #include <QDebug> -#include "infomatchdelegate.h" +#include "qinfomatchdelegate.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \class InfoMatchDelegate - \brief The InfoMatchDelegate class matches based on a ProcessInfo structure. + \class QInfoMatchDelegate + \brief The QInfoMatchDelegate class matches based on a ProcessInfo structure. + \inmodule QtProcessManager - The InfoMatchDelegate class matches based on a ProcessInfo record. If an + The QInfoMatchDelegate class matches based on a ProcessInfo record. If an attribute is set in the ProcessInfo record, the value must match exactly. The only exception are the environment variables, which only need to match exactly for environment values set in the ProcessInfo @@ -55,16 +56,16 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER */ /*! - \property InfoMatchDelegate::info + \property QInfoMatchDelegate::info \brief The ProcessInfo object used by this delegate for matching. */ /*! - Construct a InfoMatchDelegate with an optional \a parent. + Construct a QInfoMatchDelegate with an optional \a parent. */ -InfoMatchDelegate::InfoMatchDelegate(QObject *parent) - : MatchDelegate(parent) +QInfoMatchDelegate::QInfoMatchDelegate(QObject *parent) + : QMatchDelegate(parent) { } @@ -72,7 +73,7 @@ InfoMatchDelegate::InfoMatchDelegate(QObject *parent) Return the current ProcessInfo data. */ -ProcessInfo InfoMatchDelegate::info() const +QProcessInfo QInfoMatchDelegate::info() const { return m_info; } @@ -81,14 +82,14 @@ ProcessInfo InfoMatchDelegate::info() const Set a new ProcessInfo \a info structure. */ -void InfoMatchDelegate::setInfo(const ProcessInfo& info) +void QInfoMatchDelegate::setInfo(const QProcessInfo& info) { m_info = info; emit infoChanged(); } /*! - \fn InfoMatchDelegate::matches(const ProcessInfo& info) + \fn QInfoMatchDelegate::matches(const QProcessInfo& info) We look at each configured field in the ProcessInfo \a info record. Return true if the ProcessInfo \a info record matches. @@ -98,12 +99,12 @@ void InfoMatchDelegate::setInfo(const ProcessInfo& info) All other record entries must match exactly. */ -bool InfoMatchDelegate::matches(const ProcessInfo& info) +bool QInfoMatchDelegate::matches(const QProcessInfo& info) { QMapIterator<QString, QVariant> iter(m_info.toMap()); while (iter.hasNext()) { iter.next(); - if (iter.key() == ProcessInfoConstants::Environment) { + if (iter.key() == QProcessInfoConstants::Environment) { QMapIterator<QString, QVariant> iter2(iter.value().toMap()); QVariantMap env = info.environment(); while (iter2.hasNext()) { @@ -121,10 +122,10 @@ bool InfoMatchDelegate::matches(const ProcessInfo& info) } /*! - \fn void InfoMatchDelegate::infoChanged() + \fn void QInfoMatchDelegate::infoChanged() Signal emitted when the ProcessInfo object on this delegate has been changed. */ -#include "moc_infomatchdelegate.cpp" +#include "moc_qinfomatchdelegate.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/infomatchdelegate.h b/src/processmanager/qinfomatchdelegate.h index e5232d6..13ac1cb 100644 --- a/src/processmanager/infomatchdelegate.h +++ b/src/processmanager/qinfomatchdelegate.h @@ -40,30 +40,30 @@ #ifndef PROCESS_INFOMATCHDELEGATE_H #define PROCESS_INFOMATCHDELEGATE_H -#include "matchdelegate.h" -#include "processinfo.h" +#include "qmatchdelegate.h" +#include "qprocessinfo.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class Q_ADDON_PROCESSMANAGER_EXPORT InfoMatchDelegate : public MatchDelegate +class Q_ADDON_PROCESSMANAGER_EXPORT QInfoMatchDelegate : public QMatchDelegate { Q_OBJECT - Q_PROPERTY(ProcessInfo info READ info WRITE setInfo NOTIFY infoChanged) + Q_PROPERTY(QProcessInfo info READ info WRITE setInfo NOTIFY infoChanged) public: - explicit InfoMatchDelegate(QObject *parent = 0); - virtual bool matches(const ProcessInfo& info); + explicit QInfoMatchDelegate(QObject *parent = 0); + virtual bool matches(const QProcessInfo& info); - ProcessInfo info() const; - void setInfo(const ProcessInfo& info); + QProcessInfo info() const; + void setInfo(const QProcessInfo& info); signals: void infoChanged(); private: - Q_DISABLE_COPY(InfoMatchDelegate); + Q_DISABLE_COPY(QInfoMatchDelegate) private: - ProcessInfo m_info; + QProcessInfo m_info; }; QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/ioidledelegate.cpp b/src/processmanager/qioidledelegate.cpp index 8774d47..4861ffa 100644 --- a/src/processmanager/ioidledelegate.cpp +++ b/src/processmanager/qioidledelegate.cpp @@ -47,7 +47,7 @@ #include <mach/processor_info.h> #endif -#include "ioidledelegate.h" +#include "qioidledelegate.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER @@ -55,10 +55,11 @@ const int kIdleTimerInterval = 1000; const double kDefaultLoadThreshold = 0.4; /*! - \class IoIdleDelegate - \brief The IoIdleDelegate class generates \l{idleCpuAvailable()} signals. + \class QIoIdleDelegate + \brief The QIoIdleDelegate class generates \l{idleCpuAvailable()} signals. + \inmodule QtProcessManager - The IoIdleDelegate determintes available CPU resources by watching + The QIoIdleDelegate determintes available CPU resources by watching the IO activity level on your system. This delegate is appropriate when your system is primarily IO bound and not CPU bound. When idle CPU resources are requested it checks the IO load level @@ -70,9 +71,9 @@ const double kDefaultLoadThreshold = 0.4; Under Linux, the \c{/proc/diskstats} file system object provides basic IO statistics use across all storage devices. The - IoIdleDelegate reads statistics for exactly one of these devices, + QIoIdleDelegate reads statistics for exactly one of these devices, from the \c{/sys/block/DEVICE/stat} file system entry. To use the - IoIdleDelegate under Linux, you must set the device property to be + QIoIdleDelegate under Linux, you must set the device property to be the name of the disk object. For example, on a standard Linux laptop, the hard disk usually shows @@ -82,7 +83,7 @@ const double kDefaultLoadThreshold = 0.4; could write: \code - IoIdleDelegate *delegate = new IoIdleDelegate; + QIoIdleDelegate *delegate = new QIoIdleDelegate; delegate->setDevice("sda1"); \endcode @@ -95,17 +96,17 @@ const double kDefaultLoadThreshold = 0.4; */ /*! - \property IoIdleDelegate::idleInterval + \property QIoIdleDelegate::idleInterval \brief Time in milliseconds before a new idle CPU request will be fulfilled */ /*! - \property IoIdleDelegate::device + \property QIoIdleDelegate::device \brief Unix device name for the disk that you want to measure */ /*! - \property IoIdleDelegate::loadThreshold + \property QIoIdleDelegate::loadThreshold \brief Load level we need to be under to generate idle CPU requests. This value is a double that ranges from 0.0 to 1.0. A value greater @@ -116,11 +117,11 @@ const double kDefaultLoadThreshold = 0.4; /*! - Construct a IoIdleDelegate with an optional \a parent. + Construct a QIoIdleDelegate with an optional \a parent. */ -IoIdleDelegate::IoIdleDelegate(QObject *parent) - : IdleDelegate(parent) +QIoIdleDelegate::QIoIdleDelegate(QObject *parent) + : QIdleDelegate(parent) , m_load(1.0) , m_loadThreshold(kDefaultLoadThreshold) , m_last_msecs(0) @@ -133,7 +134,7 @@ IoIdleDelegate::IoIdleDelegate(QObject *parent) Turn on or off idle requests based on \a state. */ -void IoIdleDelegate::handleStateChange(bool state) +void QIoIdleDelegate::handleStateChange(bool state) { if (state) { updateStats(true); @@ -150,7 +151,7 @@ void IoIdleDelegate::handleStateChange(bool state) \internal */ -double IoIdleDelegate::updateStats(bool reset) +double QIoIdleDelegate::updateStats(bool reset) { int msecs = 0; m_load = 1.0; // Always reset to max in case of error @@ -182,7 +183,7 @@ double IoIdleDelegate::updateStats(bool reset) \internal */ -void IoIdleDelegate::timeout() +void QIoIdleDelegate::timeout() { if (updateStats(false) <= m_loadThreshold) emit idleCpuAvailable(); @@ -193,7 +194,7 @@ void IoIdleDelegate::timeout() Return the current launch interval in milliseconds */ -int IoIdleDelegate::idleInterval() const +int QIoIdleDelegate::idleInterval() const { return m_timer.interval(); } @@ -202,7 +203,7 @@ int IoIdleDelegate::idleInterval() const Set the current idle interval to \a interval milliseconds */ -void IoIdleDelegate::setIdleInterval(int interval) +void QIoIdleDelegate::setIdleInterval(int interval) { if (m_timer.interval() != interval) { m_timer.stop(); @@ -217,7 +218,7 @@ void IoIdleDelegate::setIdleInterval(int interval) Return the current load threshold as a number from 0.0 to 1.0 */ -double IoIdleDelegate::loadThreshold() const +double QIoIdleDelegate::loadThreshold() const { return m_loadThreshold; } @@ -226,7 +227,7 @@ double IoIdleDelegate::loadThreshold() const Set the current load threshold to \a threshold milliseconds */ -void IoIdleDelegate::setLoadThreshold(double threshold) +void QIoIdleDelegate::setLoadThreshold(double threshold) { if (m_loadThreshold != threshold) { m_loadThreshold = threshold; @@ -238,7 +239,7 @@ void IoIdleDelegate::setLoadThreshold(double threshold) Return the current IO device */ -QString IoIdleDelegate::device() const +QString QIoIdleDelegate::device() const { return m_device; } @@ -247,7 +248,7 @@ QString IoIdleDelegate::device() const Set the current IO device */ -void IoIdleDelegate::setDevice(const QString& device) +void QIoIdleDelegate::setDevice(const QString& device) { if (m_device != device) { m_device = device; @@ -257,28 +258,28 @@ void IoIdleDelegate::setDevice(const QString& device) } /*! - \fn void IoIdleDelegate::idleIntervalChanged() + \fn void QIoIdleDelegate::idleIntervalChanged() This signal is emitted when the idleInterval is changed. */ /*! - \fn void IoIdleDelegate::loadThresholdChanged() + \fn void QIoIdleDelegate::loadThresholdChanged() This signal is emitted when the loadThreshold is changed. */ /*! - \fn void IoIdleDelegate::deviceChanged() + \fn void QIoIdleDelegate::deviceChanged() This signal is emitted when the device is changed. */ /*! - \fn void IoIdleDelegate::loadUpdate(double load) + \fn void QIoIdleDelegate::loadUpdate(double load) This signal is emitted when the load is read. It mainly serves as a debugging signal. The \a load value will range between 0.0 and 1.0 */ -#include "moc_ioidledelegate.cpp" +#include "moc_qioidledelegate.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/ioidledelegate.h b/src/processmanager/qioidledelegate.h index 9e2db92..9928f08 100644 --- a/src/processmanager/ioidledelegate.h +++ b/src/processmanager/qioidledelegate.h @@ -42,13 +42,13 @@ #include <QTimer> #include <QElapsedTimer> -#include "idledelegate.h" +#include "qidledelegate.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class ProcessInfo; +class QProcessInfo; -class Q_ADDON_PROCESSMANAGER_EXPORT IoIdleDelegate : public IdleDelegate +class Q_ADDON_PROCESSMANAGER_EXPORT QIoIdleDelegate : public QIdleDelegate { Q_OBJECT Q_PROPERTY(int idleInterval READ idleInterval WRITE setIdleInterval NOTIFY idleIntervalChanged) @@ -56,7 +56,7 @@ class Q_ADDON_PROCESSMANAGER_EXPORT IoIdleDelegate : public IdleDelegate Q_PROPERTY(QString device READ device WRITE setDevice NOTIFY deviceChanged) public: - explicit IoIdleDelegate(QObject *parent = 0); + explicit QIoIdleDelegate(QObject *parent = 0); int idleInterval() const; void setIdleInterval(int interval); @@ -83,7 +83,7 @@ private: double updateStats(bool); private: - Q_DISABLE_COPY(IoIdleDelegate); + Q_DISABLE_COPY(QIoIdleDelegate) QString m_device; QTimer m_timer; QElapsedTimer m_elapsed; diff --git a/src/processmanager/keymatchdelegate.cpp b/src/processmanager/qkeymatchdelegate.cpp index af24a4c..d6649e6 100644 --- a/src/processmanager/keymatchdelegate.cpp +++ b/src/processmanager/qkeymatchdelegate.cpp @@ -37,37 +37,38 @@ ** ****************************************************************************/ -#include "keymatchdelegate.h" -#include "processinfo.h" +#include "qkeymatchdelegate.h" +#include "qprocessinfo.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \class KeyMatchDelegate - \brief The KeyMatchDelegate class matches based on a key-value pair + \class QKeyMatchDelegate + \brief The QKeyMatchDelegate class matches based on a key-value pair + \inmodule QtProcessManager - The KeyMatchDelegate class matches based on key-value pair. It only - matches ProcessInfo records which contain "key". If a "value" attribute - is also set, then the KeyMatchDelegate will only match a ProcessInfo + The QKeyMatchDelegate class matches based on key-value pair. It only + matches QProcessInfo records which contain "key". If a "value" attribute + is also set, then the QKeyMatchDelegate will only match a QProcessInfo record if the value of the "key" record matches the value. */ /*! - \property KeyMatchDelegate::key - \brief The key value required in the ProcessInfo object for a match. + \property QKeyMatchDelegate::key + \brief The key value required in the QProcessInfo object for a match. */ /*! - \property KeyMatchDelegate::value - \brief If set, this value must match the record in the ProcessInfo object. + \property QKeyMatchDelegate::value + \brief If set, this value must match the record in the QProcessInfo object. */ /*! - Construct a KeyMatchDelegate with an optional \a parent. + Construct a QKeyMatchDelegate with an optional \a parent. */ -KeyMatchDelegate::KeyMatchDelegate(QObject *parent) - : MatchDelegate(parent) +QKeyMatchDelegate::QKeyMatchDelegate(QObject *parent) + : QMatchDelegate(parent) { } @@ -75,7 +76,7 @@ KeyMatchDelegate::KeyMatchDelegate(QObject *parent) Return the current key */ -QString KeyMatchDelegate::key() const +QString QKeyMatchDelegate::key() const { return m_key; } @@ -84,7 +85,7 @@ QString KeyMatchDelegate::key() const Set a new \a key. */ -void KeyMatchDelegate::setKey(const QString& key) +void QKeyMatchDelegate::setKey(const QString& key) { m_key = key; emit keyChanged(); @@ -94,7 +95,7 @@ void KeyMatchDelegate::setKey(const QString& key) Return the current value */ -QVariant KeyMatchDelegate::value() const +QVariant QKeyMatchDelegate::value() const { return m_value; } @@ -103,32 +104,32 @@ QVariant KeyMatchDelegate::value() const Set a new \a value. */ -void KeyMatchDelegate::setValue(const QVariant& value) +void QKeyMatchDelegate::setValue(const QVariant& value) { m_value = value; emit valueChanged(); } /*! - \fn KeyMatchDelegate::matches(const ProcessInfo& info) + \fn QKeyMatchDelegate::matches(const QProcessInfo& info) \brief Check \a info for key and value attributes */ -bool KeyMatchDelegate::matches(const ProcessInfo& info) +bool QKeyMatchDelegate::matches(const QProcessInfo& info) { return (info.contains(m_key) && (m_value.isNull() || info.value(m_key) == m_value)); } /*! - \fn void KeyMatchDelegate::keyChanged() + \fn void QKeyMatchDelegate::keyChanged() Signal emitted when the key on this delegate has been changed. */ /*! - \fn void KeyMatchDelegate::valueChanged() + \fn void QKeyMatchDelegate::valueChanged() Signal emitted when the value on this delegate has been changed. */ -#include "moc_keymatchdelegate.cpp" +#include "moc_qkeymatchdelegate.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/keymatchdelegate.h b/src/processmanager/qkeymatchdelegate.h index 6a41572..d3efbea 100644 --- a/src/processmanager/keymatchdelegate.h +++ b/src/processmanager/qkeymatchdelegate.h @@ -42,19 +42,19 @@ #include <QVariant> -#include "matchdelegate.h" +#include "qmatchdelegate.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class Q_ADDON_PROCESSMANAGER_EXPORT KeyMatchDelegate : public MatchDelegate +class Q_ADDON_PROCESSMANAGER_EXPORT QKeyMatchDelegate : public QMatchDelegate { Q_OBJECT Q_PROPERTY(QString key READ key WRITE setKey NOTIFY keyChanged) Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) public: - explicit KeyMatchDelegate(QObject *parent = 0); - virtual bool matches(const ProcessInfo& key); + explicit QKeyMatchDelegate(QObject *parent = 0); + virtual bool matches(const QProcessInfo& key); QString key() const; void setKey(const QString& key); @@ -67,7 +67,7 @@ signals: void valueChanged(); private: - Q_DISABLE_COPY(KeyMatchDelegate); + Q_DISABLE_COPY(QKeyMatchDelegate) private: QString m_key; diff --git a/src/processmanager/qlauncherclient.cpp b/src/processmanager/qlauncherclient.cpp new file mode 100644 index 0000000..8188eb2 --- /dev/null +++ b/src/processmanager/qlauncherclient.cpp @@ -0,0 +1,213 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QDebug> + +#include "qlauncherclient.h" +#include "qremoteprotocol.h" +#include "qprocessbackend.h" +#include "qprocessbackendmanager.h" + +QT_BEGIN_NAMESPACE_PROCESSMANAGER + +/*! + \class QLauncherClient + \brief The QLauncherClient class handles a single Launcher client. + \inmodule QtProcessManager + */ + +/*! + Create a new QLauncherClient with QProcessBackendManager \a manager + */ + +QLauncherClient::QLauncherClient(QProcessBackendManager *manager) + : QObject(manager) + , m_manager(manager) +{ +} + +/*! + Process an incoming \a message + */ + +void QLauncherClient::receive(const QJsonObject& message) +{ + // qDebug() << Q_FUNC_INFO << message; + QString cmd = message.value(QRemoteProtocol::command()).toString(); + int id = message.value(QRemoteProtocol::id()).toDouble(); + if ( cmd == QRemoteProtocol::start() ) { + QProcessInfo info(message.value(QRemoteProtocol::info()).toObject().toVariantMap()); + QProcessBackend *backend = m_manager->create(info, this); + if (backend) { + connect(backend, SIGNAL(started()), SLOT(started())); + connect(backend, SIGNAL(finished(int, QProcess::ExitStatus)), + SLOT(finished(int, QProcess::ExitStatus))); + connect(backend, SIGNAL(error(QProcess::ProcessError)), SLOT(error(QProcess::ProcessError))); + connect(backend, SIGNAL(stateChanged(QProcess::ProcessState)), + SLOT(stateChanged(QProcess::ProcessState))); + connect(backend, SIGNAL(standardOutput(const QByteArray&)), + SLOT(standardOutput(const QByteArray&))); + connect(backend, SIGNAL(standardError(const QByteArray&)), + SLOT(standardError(const QByteArray&))); + m_idToBackend.insert(id, backend); + m_backendToId.insert(backend, id); + backend->start(); + } + } + else if ( cmd == QRemoteProtocol::stop() ) { + QProcessBackend *backend = m_idToBackend.value(id); + if (backend) { + int timeout = message.value(QRemoteProtocol::timeout()).toDouble(); + backend->stop(timeout); + } + } + else if ( cmd == QRemoteProtocol::set() ) { + QProcessBackend *backend = m_idToBackend.value(id); + if (backend) { + QString key = message.value(QRemoteProtocol::key()).toString(); + int value = message.value(QRemoteProtocol::value()).toDouble(); + if (key == QRemoteProtocol::priority()) + backend->setDesiredPriority(value); + else if (key == QRemoteProtocol::oomAdjustment()) + backend->setDesiredOomAdjustment(value); + } + } + else if ( cmd == QRemoteProtocol::write() ) { + QByteArray data = QByteArray::fromBase64(message.value(QRemoteProtocol::data()).toString().toLocal8Bit()); + QProcessBackend *backend = m_idToBackend.value(id); + if (backend) + backend->write(data); + } +} + +/*! + \internal + */ + +void QLauncherClient::started() +{ + QProcessBackend *backend = qobject_cast<QProcessBackend *>(sender()); + QJsonObject msg; + msg.insert(QRemoteProtocol::event(), QRemoteProtocol::started()); + msg.insert(QRemoteProtocol::id(), m_backendToId.value(backend)); + msg.insert(QRemoteProtocol::pid(), (double) backend->pid()); + emit send(msg); +} + +/*! + \internal + */ + +void QLauncherClient::finished(int exitCode, QProcess::ExitStatus exitStatus) +{ + QProcessBackend *backend = qobject_cast<QProcessBackend *>(sender()); + QJsonObject msg; + msg.insert(QRemoteProtocol::event(), QRemoteProtocol::finished()); + msg.insert(QRemoteProtocol::id(), m_backendToId.value(backend)); + msg.insert(QRemoteProtocol::exitCode(), exitCode); + msg.insert(QRemoteProtocol::exitStatus(), exitStatus); + emit send(msg); +} + +/*! + \internal + */ + +void QLauncherClient::error(QProcess::ProcessError err) +{ + QProcessBackend *backend = qobject_cast<QProcessBackend *>(sender()); + QJsonObject msg; + msg.insert(QRemoteProtocol::event(), QRemoteProtocol::error()); + msg.insert(QRemoteProtocol::id(), m_backendToId.value(backend)); + msg.insert(QRemoteProtocol::error(), err); + msg.insert(QRemoteProtocol::errorString(), backend->errorString()); + emit send(msg); +} + +/*! + \internal + */ + +void QLauncherClient::stateChanged(QProcess::ProcessState state) +{ + QProcessBackend *backend = qobject_cast<QProcessBackend *>(sender()); + QJsonObject msg; + msg.insert(QRemoteProtocol::event(), QRemoteProtocol::stateChanged()); + msg.insert(QRemoteProtocol::id(), m_backendToId.value(backend)); + msg.insert(QRemoteProtocol::stateChanged(), state); + emit send(msg); +} + +/*! + \internal + */ + +void QLauncherClient::standardOutput(const QByteArray& data) +{ + QProcessBackend *backend = qobject_cast<QProcessBackend *>(sender()); + QJsonObject msg; + msg.insert(QRemoteProtocol::event(), QRemoteProtocol::output()); + msg.insert(QRemoteProtocol::id(), m_backendToId.value(backend)); + msg.insert(QRemoteProtocol::standardout(), QString::fromLocal8Bit(data.data(), data.size())); + emit send(msg); +} + +/*! + \internal + */ + +void QLauncherClient::standardError(const QByteArray& data) +{ + QProcessBackend *backend = qobject_cast<QProcessBackend *>(sender()); + QJsonObject msg; + msg.insert(QRemoteProtocol::event(), QRemoteProtocol::output()); + msg.insert(QRemoteProtocol::id(), m_backendToId.value(backend)); + msg.insert(QRemoteProtocol::standarderror(), QString::fromLocal8Bit(data.data(), data.size())); + emit send(msg); +} + +/*! + \fn void QLauncherClient::send(const QJsonObject& message) + + Send a \a message to the remote controller. +*/ + +#include "moc_qlauncherclient.cpp" + +QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/launcherclient.h b/src/processmanager/qlauncherclient.h index 13dd8e8..a53b567 100644 --- a/src/processmanager/launcherclient.h +++ b/src/processmanager/qlauncherclient.h @@ -45,17 +45,17 @@ #include <QProcess> #include <QMap> -#include "processmanager-global.h" +#include "qprocessmanager-global.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class ProcessBackend; -class ProcessBackendManager; +class QProcessBackend; +class QProcessBackendManager; -class LauncherClient : public QObject { +class QLauncherClient : public QObject { Q_OBJECT public: - LauncherClient(ProcessBackendManager *manager); + QLauncherClient(QProcessBackendManager *manager); void receive(const QJsonObject& message); signals: @@ -70,9 +70,9 @@ private slots: void standardError(const QByteArray&); private: - ProcessBackendManager *m_manager; - QMap<int, ProcessBackend *> m_idToBackend; - QMap<ProcessBackend *, int> m_backendToId; + QProcessBackendManager *m_manager; + QMap<int, QProcessBackend *> m_idToBackend; + QMap<QProcessBackend *, int> m_backendToId; }; QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/matchdelegate.cpp b/src/processmanager/qmatchdelegate.cpp index a90be18..a0baaa4 100644 --- a/src/processmanager/matchdelegate.cpp +++ b/src/processmanager/qmatchdelegate.cpp @@ -37,33 +37,34 @@ ** ****************************************************************************/ -#include "matchdelegate.h" +#include "qmatchdelegate.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \class MatchDelegate - \brief The MatchDelegate class is a virtual class for matching creation requests. + \class QMatchDelegate + \brief The QMatchDelegate class is a virtual class for matching creation requests. + \inmodule QtProcessManager You must subclass this class to do anything useful. */ /*! - Construct a MatchDelegate with an optional \a parent. + Construct a QMatchDelegate with an optional \a parent. */ -MatchDelegate::MatchDelegate(QObject *parent) +QMatchDelegate::QMatchDelegate(QObject *parent) : QObject(parent) { } /*! - \fn MatchDelegate::matches(const ProcessInfo& info) + \fn QMatchDelegate::matches(const QProcessInfo& info) Return true if the ProcessInfo \a info record matches. You must override this function. */ -#include "moc_matchdelegate.cpp" +#include "moc_qmatchdelegate.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/matchdelegate.h b/src/processmanager/qmatchdelegate.h index 6a15b25..b3da4df 100644 --- a/src/processmanager/matchdelegate.h +++ b/src/processmanager/qmatchdelegate.h @@ -42,21 +42,21 @@ #include <QObject> -#include "processmanager-global.h" +#include "qprocessmanager-global.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class ProcessInfo; +class QProcessInfo; -class Q_ADDON_PROCESSMANAGER_EXPORT MatchDelegate : public QObject +class Q_ADDON_PROCESSMANAGER_EXPORT QMatchDelegate : public QObject { Q_OBJECT public: - explicit MatchDelegate(QObject *parent = 0); - virtual bool matches(const ProcessInfo& info) = 0; + explicit QMatchDelegate(QObject *parent = 0); + virtual bool matches(const QProcessInfo& info) = 0; private: - Q_DISABLE_COPY(MatchDelegate); + Q_DISABLE_COPY(QMatchDelegate); }; QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/pipelauncher.cpp b/src/processmanager/qpipelauncher.cpp index 61fffc5..b6ca52e 100644 --- a/src/processmanager/pipelauncher.cpp +++ b/src/processmanager/qpipelauncher.cpp @@ -43,32 +43,33 @@ #include <QtEndian> #include <QJsonDocument> -#include "pipelauncher.h" -#include "launcherclient.h" -#include "remoteprotocol.h" +#include "qpipelauncher.h" +#include "qlauncherclient.h" +#include "qremoteprotocol.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \class PipeLauncher - \brief The PipeLauncher class accepts input from STDIN and writes data to STDOUT + \class QPipeLauncher + \brief The QPipeLauncher class accepts input from STDIN and writes data to STDOUT + \inmodule QtProcessManager - The PipeLauncher class is a ProcessBackendManager controlled over Unix + The QPipeLauncher class is a QProcessBackendManager controlled over Unix pipes. It accepts JSON-formatted commands over STDIN and returns JSON-formatted messages over STDOUT. */ /*! - Construct a PipeLauncher with optional \a parent. - The PipeLauncher reads JSON-formatted messages from stdin and + Construct a QPipeLauncher with optional \a parent. + The QPipeLauncher reads JSON-formatted messages from stdin and writes replies on stdout. */ -PipeLauncher::PipeLauncher(QObject *parent) - : ProcessBackendManager(parent) +QPipeLauncher::QPipeLauncher(QObject *parent) + : QProcessBackendManager(parent) { m_pipe = new QtAddOn::QtJsonStream::QJsonPipe(this); - m_client = new LauncherClient(this); + m_client = new QLauncherClient(this); connect(m_pipe, SIGNAL(messageReceived(const QJsonObject&)), SLOT(receive(const QJsonObject&))); @@ -89,14 +90,14 @@ PipeLauncher::PipeLauncher(QObject *parent) We only forward the request if we don't have an idle delegate. */ -void PipeLauncher::handleIdleCpuRequest() +void QPipeLauncher::handleIdleCpuRequest() { Q_ASSERT(m_client); if (!idleDelegate()) { QJsonObject object; - object.insert(RemoteProtocol::remote(), RemoteProtocol::idlecpurequested()); - object.insert(RemoteProtocol::request(), idleCpuRequest()); + object.insert(QRemoteProtocol::remote(), QRemoteProtocol::idlecpurequested()); + object.insert(QRemoteProtocol::request(), idleCpuRequest()); m_client->send(object); } } @@ -109,13 +110,13 @@ void PipeLauncher::handleIdleCpuRequest() if that should be on the list, it's up to the controlling side to add it. */ -void PipeLauncher::handleInternalProcessChange() +void QPipeLauncher::handleInternalProcessChange() { Q_ASSERT(m_client); QJsonObject object; - object.insert(RemoteProtocol::remote(), RemoteProtocol::internalprocesses()); - object.insert(RemoteProtocol::processes(), pidListToArray(internalProcesses())); + object.insert(QRemoteProtocol::remote(), QRemoteProtocol::internalprocesses()); + object.insert(QRemoteProtocol::processes(), pidListToArray(internalProcesses())); m_client->send(object); } @@ -125,13 +126,13 @@ void PipeLauncher::handleInternalProcessChange() We override this function to forward internal process errors */ -void PipeLauncher::handleInternalProcessError(QProcess::ProcessError error) +void QPipeLauncher::handleInternalProcessError(QProcess::ProcessError error) { Q_ASSERT(m_client); QJsonObject object; - object.insert(RemoteProtocol::remote(), RemoteProtocol::internalprocesserror()); - object.insert(RemoteProtocol::processError(), error); + object.insert(QRemoteProtocol::remote(), QRemoteProtocol::internalprocesserror()); + object.insert(QRemoteProtocol::processError(), error); m_client->send(object); } @@ -139,14 +140,14 @@ void PipeLauncher::handleInternalProcessError(QProcess::ProcessError error) \internal */ -void PipeLauncher::receive(const QJsonObject& message) +void QPipeLauncher::receive(const QJsonObject& message) { - QString remote = message.value(RemoteProtocol::remote()).toString(); - if (remote == RemoteProtocol::halt()) // ### TODO: Should halt children + QString remote = message.value(QRemoteProtocol::remote()).toString(); + if (remote == QRemoteProtocol::halt()) // ### TODO: Should halt children exit(0); - else if ( remote == RemoteProtocol::memory() ) - setMemoryRestricted(message.value(RemoteProtocol::restricted()).toBool()); - else if ( remote == RemoteProtocol::idlecpuavailable() ) { + else if ( remote == QRemoteProtocol::memory() ) + setMemoryRestricted(message.value(QRemoteProtocol::restricted()).toBool()); + else if ( remote == QRemoteProtocol::idlecpuavailable() ) { if (!idleDelegate()) idleCpuAvailable(); // Only accept idlecpuavailable if we have no idleDelegate } @@ -154,6 +155,6 @@ void PipeLauncher::receive(const QJsonObject& message) m_client->receive(message); } -#include "moc_pipelauncher.cpp" +#include "moc_qpipelauncher.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/pipelauncher.h b/src/processmanager/qpipelauncher.h index 4465cfc..5746441 100644 --- a/src/processmanager/pipelauncher.h +++ b/src/processmanager/qpipelauncher.h @@ -44,17 +44,17 @@ #include <QJsonObject> #include <qjsonpipe.h> -#include "processbackendmanager.h" +#include "qprocessbackendmanager.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class LauncherClient; +class QLauncherClient; -class Q_ADDON_PROCESSMANAGER_EXPORT PipeLauncher : public ProcessBackendManager { +class Q_ADDON_PROCESSMANAGER_EXPORT QPipeLauncher : public QProcessBackendManager { Q_OBJECT public: - PipeLauncher(QObject *parent=0); + QPipeLauncher(QObject *parent=0); protected: virtual void handleIdleCpuRequest(); @@ -68,7 +68,7 @@ private slots: private: QtAddOn::QtJsonStream::QJsonPipe *m_pipe; - LauncherClient *m_client; + QLauncherClient *m_client; }; QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/pipeprocessbackendfactory.cpp b/src/processmanager/qpipeprocessbackendfactory.cpp index 4b7e946..d6436fb 100644 --- a/src/processmanager/pipeprocessbackendfactory.cpp +++ b/src/processmanager/qpipeprocessbackendfactory.cpp @@ -37,10 +37,10 @@ ** ****************************************************************************/ -#include "pipeprocessbackendfactory.h" -#include "remoteprocessbackend.h" -#include "remoteprotocol.h" -#include "processinfo.h" +#include "qpipeprocessbackendfactory.h" +#include "qremoteprocessbackend.h" +#include "qremoteprotocol.h" +#include "qprocessinfo.h" #include <QDebug> #include <QJsonDocument> @@ -52,26 +52,27 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER const int kPipeTimerInterval = 1000; /*! - \class PipeProcessBackendFactory - \brief The PipeProcessBackendFactory class forks a new process to launch applications. + \class QPipeProcessBackendFactory + \brief The QPipeProcessBackendFactory class forks a new process to launch applications. + \inmodule QtProcessManager - The PipeProcessBackendFactory launches a persistent pipe process. + The QPipeProcessBackendFactory launches a persistent pipe process. The factory communicates with the pipe process by sending and receiving messages over stdin/stdout. */ /*! - \property PipeProcessBackendFactory::processInfo - \brief ProcessInfo record used to create the pipe process + \property QPipeProcessBackendFactory::processInfo + \brief QProcessInfo record used to create the pipe process */ /*! - Construct a PipeProcessBackendFactory with optional \a parent. - You must set a ProcessInfo object before this factory will be activated. + Construct a QPipeProcessBackendFactory with optional \a parent. + You must set a QProcessInfo object before this factory will be activated. */ -PipeProcessBackendFactory::PipeProcessBackendFactory(QObject *parent) - : RemoteProcessBackendFactory(parent) +QPipeProcessBackendFactory::QPipeProcessBackendFactory(QObject *parent) + : QRemoteProcessBackendFactory(parent) , m_process(NULL) , m_info(NULL) { @@ -81,7 +82,7 @@ PipeProcessBackendFactory::PipeProcessBackendFactory(QObject *parent) Destroy this and child objects. */ -PipeProcessBackendFactory::~PipeProcessBackendFactory() +QPipeProcessBackendFactory::~QPipeProcessBackendFactory() { stopRemoteProcess(); } @@ -95,11 +96,11 @@ PipeProcessBackendFactory::~PipeProcessBackendFactory() the remote process to kill itself. */ -void PipeProcessBackendFactory::stopRemoteProcess() +void QPipeProcessBackendFactory::stopRemoteProcess() { if (m_process && m_process->state() == QProcess::Running) { QJsonObject object; - object.insert(RemoteProtocol::remote(), RemoteProtocol::halt()); + object.insert(QRemoteProtocol::remote(), QRemoteProtocol::halt()); m_process->write(QJsonDocument(object).toBinaryData()); m_process->waitForBytesWritten(); // Block until they have been written m_process = NULL; @@ -107,23 +108,23 @@ void PipeProcessBackendFactory::stopRemoteProcess() } /*! - Return true if the PipeProcessBackendFactory can create a process + Return true if the QPipeProcessBackendFactory can create a process that matches \a info. The default implementation only checks that a valid info object has been previously set in the factory, and then passes the decision on to the default implementation, which should - probably have some kind of MatchDelegate installed. + probably have some kind of QMatchDelegate installed. */ -bool PipeProcessBackendFactory::canCreate(const ProcessInfo &info) const +bool QPipeProcessBackendFactory::canCreate(const QProcessInfo &info) const { if (!m_info || !m_process || m_process->state() != QProcess::Running) return false; - return RemoteProcessBackendFactory::canCreate(info); + return QRemoteProcessBackendFactory::canCreate(info); } /*! - Sets the ProcessInfo that is used to create the pipe process to \a processInfo. + Sets the QProcessInfo that is used to create the pipe process to \a processInfo. An internal copy is made of the \a processInfo object. This routine will start the pipe process. @@ -132,7 +133,7 @@ bool PipeProcessBackendFactory::canCreate(const ProcessInfo &info) const don't exist. */ -void PipeProcessBackendFactory::setProcessInfo(ProcessInfo *processInfo) +void QPipeProcessBackendFactory::setProcessInfo(QProcessInfo *processInfo) { if (m_info != processInfo) { if (m_info) { @@ -143,7 +144,7 @@ void PipeProcessBackendFactory::setProcessInfo(ProcessInfo *processInfo) stopRemoteProcess(); if (processInfo) { - m_info = new ProcessInfo(*processInfo); + m_info = new QProcessInfo(*processInfo); m_info->setParent(this); m_process = new QProcess; // Note that we do NOT own the pipe process @@ -175,9 +176,9 @@ void PipeProcessBackendFactory::setProcessInfo(ProcessInfo *processInfo) } /*! - Sets the ProcessInfo that is used to determine the prelaunched runtime to \a processInfo. + Sets the QProcessInfo that is used to determine the prelaunched runtime to \a processInfo. */ -void PipeProcessBackendFactory::setProcessInfo(ProcessInfo& processInfo) +void QPipeProcessBackendFactory::setProcessInfo(QProcessInfo& processInfo) { setProcessInfo(&processInfo); } @@ -186,7 +187,7 @@ void PipeProcessBackendFactory::setProcessInfo(ProcessInfo& processInfo) Return the pipe process information */ -ProcessInfo *PipeProcessBackendFactory::processInfo() const +QProcessInfo *QPipeProcessBackendFactory::processInfo() const { return m_info; } @@ -195,9 +196,9 @@ ProcessInfo *PipeProcessBackendFactory::processInfo() const Return the local process if it is running */ -PidList PipeProcessBackendFactory::localInternalProcesses() const +QPidList QPipeProcessBackendFactory::localInternalProcesses() const { - PidList result; + QPidList result; if (m_process && m_process->state() == QProcess::Running) result << m_process->pid(); return result; @@ -206,7 +207,7 @@ PidList PipeProcessBackendFactory::localInternalProcesses() const /*! Send \a message to a pipe process. */ -bool PipeProcessBackendFactory::send(const QJsonObject& message) +bool QPipeProcessBackendFactory::send(const QJsonObject& message) { // qDebug() << Q_FUNC_INFO << message; return (m_process->state() == QProcess::Running && @@ -214,7 +215,7 @@ bool PipeProcessBackendFactory::send(const QJsonObject& message) } -void PipeProcessBackendFactory::pipeReadyReadStandardOutput() +void QPipeProcessBackendFactory::pipeReadyReadStandardOutput() { m_buffer.append(m_process->readAllStandardOutput()); while (m_buffer.size() >= 12) { // QJsonDocuments are at least this large @@ -229,7 +230,7 @@ void PipeProcessBackendFactory::pipeReadyReadStandardOutput() } } -void PipeProcessBackendFactory::pipeReadyReadStandardError() +void QPipeProcessBackendFactory::pipeReadyReadStandardError() { const QByteArray byteArray = m_process->readAllStandardError(); QList<QByteArray> lines = byteArray.split('\n'); @@ -239,24 +240,24 @@ void PipeProcessBackendFactory::pipeReadyReadStandardError() } } -void PipeProcessBackendFactory::pipeStarted() +void QPipeProcessBackendFactory::pipeStarted() { handleConnected(); } -void PipeProcessBackendFactory::pipeError(QProcess::ProcessError error) +void QPipeProcessBackendFactory::pipeError(QProcess::ProcessError error) { qWarning("Pipe process error: %d", error); } -void PipeProcessBackendFactory::pipeFinished(int exitCode, QProcess::ExitStatus exitStatus) +void QPipeProcessBackendFactory::pipeFinished(int exitCode, QProcess::ExitStatus exitStatus) { qCritical("Pipe process died, exit code=%d status=%d", exitCode, exitStatus); delete m_process; m_process = NULL; } -void PipeProcessBackendFactory::pipeStateChanged(QProcess::ProcessState) +void QPipeProcessBackendFactory::pipeStateChanged(QProcess::ProcessState) { // This may result in a small amount of extra because not all transitions // result in a change in the number of internal processes. @@ -265,11 +266,11 @@ void PipeProcessBackendFactory::pipeStateChanged(QProcess::ProcessState) /*! - \fn void PipeProcessBackendFactory::processInfoChanged() - This signal is emitted when the internal ProcessInfo record is + \fn void QPipeProcessBackendFactory::processInfoChanged() + This signal is emitted when the internal QProcessInfo record is changed. */ -#include "moc_pipeprocessbackendfactory.cpp" +#include "moc_qpipeprocessbackendfactory.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/pipeprocessbackendfactory.h b/src/processmanager/qpipeprocessbackendfactory.h index ed76fd6..5cd4d10 100644 --- a/src/processmanager/pipeprocessbackendfactory.h +++ b/src/processmanager/qpipeprocessbackendfactory.h @@ -40,30 +40,30 @@ #ifndef PIPE_PROCESS_BACKEND_FACTORY_H #define PIPE_PROCESS_BACKEND_FACTORY_H -#include "remoteprocessbackendfactory.h" +#include "qremoteprocessbackendfactory.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class Q_ADDON_PROCESSMANAGER_EXPORT PipeProcessBackendFactory : public RemoteProcessBackendFactory +class Q_ADDON_PROCESSMANAGER_EXPORT QPipeProcessBackendFactory : public QRemoteProcessBackendFactory { Q_OBJECT - Q_PROPERTY(ProcessInfo* processInfo READ processInfo WRITE setProcessInfo NOTIFY processInfoChanged) + Q_PROPERTY(QProcessInfo* processInfo READ processInfo WRITE setProcessInfo NOTIFY processInfoChanged) public: - PipeProcessBackendFactory(QObject *parent = 0); - virtual ~PipeProcessBackendFactory(); + QPipeProcessBackendFactory(QObject *parent = 0); + virtual ~QPipeProcessBackendFactory(); - virtual bool canCreate(const ProcessInfo &info) const; + virtual bool canCreate(const QProcessInfo &info) const; - ProcessInfo *processInfo() const; - void setProcessInfo(ProcessInfo *processInfo); - void setProcessInfo(ProcessInfo& processInfo); + QProcessInfo *processInfo() const; + void setProcessInfo(QProcessInfo *processInfo); + void setProcessInfo(QProcessInfo& processInfo); signals: void processInfoChanged(); protected: - virtual PidList localInternalProcesses() const; + virtual QPidList localInternalProcesses() const; virtual bool send(const QJsonObject&); private slots: @@ -79,7 +79,7 @@ private: private: QProcess *m_process; - ProcessInfo *m_info; + QProcessInfo *m_info; QByteArray m_buffer; }; diff --git a/src/processmanager/process.cpp b/src/processmanager/qpmprocess.cpp index f838dc9..9fc52d9 100644 --- a/src/processmanager/process.cpp +++ b/src/processmanager/qpmprocess.cpp @@ -38,17 +38,18 @@ ****************************************************************************/ -#include "process.h" +#include "qpmprocess.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \class Process - \brief The Process class contains common enumaration definitions for the process manager. + \class QPmProcess + \brief The QPmProcess class contains common enumaration definitions for the QPmProcess manager. + \inmodule QtProcessManager */ /*! - \enum Process::ProcessError + \enum QPmProcess::ProcessError This enum is an exact match for QProcess::ProcessError. It has been duplicated here so that it can be exposed to QML. @@ -76,7 +77,7 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER */ /*! - \enum Process::ProcessState + \enum QPmProcess::ProcessState This enum is an exact match for QProcess::ProcessState. It has been duplicated here so that it can be exposed to QML. @@ -91,7 +92,7 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER */ /*! - \enum Process::ExitStatus + \enum QPmProcess::ExitStatus This enum is an exact match for QProcess::ExitStatus. It has been duplicated here so that it can be exposed to QML. @@ -102,6 +103,6 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER */ -#include "moc_process.cpp" +#include "moc_qpmprocess.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/process.h b/src/processmanager/qpmprocess.h index 3b1291b..509e9ef 100644 --- a/src/processmanager/process.h +++ b/src/processmanager/qpmprocess.h @@ -40,12 +40,12 @@ #ifndef _PROCESS_H #define _PROCESS_H -#include "processmanager-global.h" +#include "qprocessmanager-global.h" #include <QObject> QT_BEGIN_NAMESPACE_PROCESSMANAGER -class Q_ADDON_PROCESSMANAGER_EXPORT Process : public QObject +class Q_ADDON_PROCESSMANAGER_EXPORT QPmProcess : public QObject { Q_OBJECT diff --git a/src/processmanager/prefork.cpp b/src/processmanager/qprefork.cpp index eae8495..bbd4e39 100644 --- a/src/processmanager/prefork.cpp +++ b/src/processmanager/qprefork.cpp @@ -37,7 +37,7 @@ ** ****************************************************************************/ -#include "prefork.h" +#include "qprefork.h" #include <signal.h> #include <unistd.h> @@ -63,7 +63,7 @@ static struct sigaction old_child_handler; static void prefork_child_handler(int sig, siginfo_t* info, void *) { if (sig == SIGCHLD) - Prefork::instance()->checkChildDied(info->si_pid); + QPrefork::instance()->checkChildDied(info->si_pid); // Complicated way of calling the old child handler void (*oldAction)(int) = ((volatile struct sigaction *)&old_child_handler)->sa_handler; @@ -82,13 +82,14 @@ static void makePipe(int fd[]) /**************************************************************************/ /*! - \class Prefork + \class QPrefork - \brief The Prefork class forks into a series of pipe-connected + \brief The QPrefork class forks into a series of pipe-connected processes with dynamically loaded main functions + \inmodule QtProcessManager Many modern programs have complicated initialization routines that - preload tables of information into each process. The Prefork class + preload tables of information into each process. The QPrefork class allows you to initialize data just once, fork into multiple processes, and use the dynamic linker to load and execute the \c{main()} function from each desired child process. By not @@ -96,15 +97,15 @@ static void makePipe(int fd[]) process, we ensure that the original initialized data does not have to be reloaded for each child. - Using the Prefork class is as simple as: + Using the QPrefork class is as simple as: \code - #include "prefork.h" + #include "qprefork.h" int main(int argc, char **argv) { // ... Initialize common data items here - Prefork::instance()->execute(&argc, &argv); // This function never returns + QPrefork::instance()->execute(&argc, &argv); // This function never returns } \endcode @@ -128,22 +129,22 @@ static void makePipe(int fd[]) After preforking, the master process needs a method of finding which file descriptors are used to talk with which child process. It uses the \l{instance()} to retrieve the singleton - Prefork object and the Prefork::size() and Prefork::at() functions + QPrefork object and the QPrefork::size() and QPrefork::at() functions to retrieve information about the child processes. - The PreforkProcessBackendFactory class is a wrapper around the - Prefork object to make it easy to write a program that uses + The QPreforkProcessBackendFactory class is a wrapper around the + QPrefork object to make it easy to write a program that uses preforking to launch child processes. */ /*! - Return the singleton Prefork instance + Return the singleton QPrefork instance */ -Prefork *Prefork::instance() { - static Prefork *s_forkit; +QPrefork *QPrefork::instance() { + static QPrefork *s_forkit; if (!s_forkit) - s_forkit = new Prefork; + s_forkit = new QPrefork; return s_forkit; } @@ -151,7 +152,7 @@ Prefork *Prefork::instance() { \internal */ -Prefork::Prefork() +QPrefork::QPrefork() : m_argc(0) , m_argv(NULL) , m_argv_size(0) @@ -164,7 +165,7 @@ Prefork::Prefork() \internal */ -int Prefork::nextMarker(int index) +int QPrefork::nextMarker(int index) { while (index < m_argc && ::strcmp(m_argv[index], "--") != 0) ++index; @@ -180,7 +181,7 @@ typedef int (*main_func_t)(int argc, char *argv[]); This function never returns. */ -void Prefork::launch(int start, int end) +void QPrefork::launch(int start, int end) { // Move over the old arguments to the front of the m_argv array size_t bytes_to_skip = m_argv[start] - m_argv[0]; @@ -210,7 +211,7 @@ void Prefork::launch(int start, int end) a child. Return the index of the next starting point */ -int Prefork::makeChild(int start) +int QPrefork::makeChild(int start) { int end = nextMarker(start); if (start < end) { @@ -253,7 +254,7 @@ int Prefork::makeChild(int start) child process will have \c{argc} and \c{argv} correctly rewritten. */ -void Prefork::execute(int *argc_ptr, char ***argv_ptr) +void QPrefork::execute(int *argc_ptr, char ***argv_ptr) { m_argc = *argc_ptr; m_argv = *argv_ptr; @@ -268,7 +269,7 @@ void Prefork::execute(int *argc_ptr, char ***argv_ptr) qFatal("Expected to see at least two '--' markers"); // This is excessive paranoia - I worry about a QList access in a signal handler int count = marker_count - 1; - m_children = (PreforkChildData *) ::calloc(sizeof(PreforkChildData), count); + m_children = (QPreforkChildData *) ::calloc(sizeof(QPreforkChildData), count); if (!m_children) qFatal("Memory error"); @@ -298,7 +299,7 @@ void Prefork::execute(int *argc_ptr, char ***argv_ptr) children die, the entire set of processes should shut down. */ -void Prefork::checkChildDied(pid_t pid) +void QPrefork::checkChildDied(pid_t pid) { for (int i = 0 ; i < m_count ; i++) { if (m_children[i].pid == pid) { @@ -314,7 +315,7 @@ void Prefork::checkChildDied(pid_t pid) process for each \c{fork()} call in the main process. */ -int Prefork::size() const +int QPrefork::size() const { return m_count; } @@ -323,29 +324,30 @@ int Prefork::size() const Return information about the child at index \a i. */ -const PreforkChildData *Prefork::at(int i) const +const QPreforkChildData *QPrefork::at(int i) const { Q_ASSERT(i >= 0 && i < m_count); return &m_children[i]; } /*! - \class PreforkChildData - \brief The PreforkChildData class provides information about a single preforked child + \class QPreforkChildData + \brief The QPreforkChildData class provides information about a single preforked child + \inmodule QtProcessManager */ /*! - \variable PreforkChildData::in + \variable QPreforkChildData::in \brief The file descriptor of the child's stdin (write to this) */ /*! - \variable PreforkChildData::out + \variable QPreforkChildData::out \brief The file descriptor of the child's stdout (read from this) */ /*! - \variable PreforkChildData::pid + \variable QPreforkChildData::pid \brief The child's process id */ diff --git a/src/processmanager/prefork.h b/src/processmanager/qprefork.h index 925bb93..969a11e 100644 --- a/src/processmanager/prefork.h +++ b/src/processmanager/qprefork.h @@ -40,27 +40,27 @@ #ifndef PREFORK_H #define PREFORK_H -#include "processmanager-global.h" +#include "qprocessmanager-global.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -struct Q_ADDON_PROCESSMANAGER_EXPORT PreforkChildData { +struct Q_ADDON_PROCESSMANAGER_EXPORT QPreforkChildData { int in; // Child stdin (write to this) int out; // Child stdout (read from this) int pid; // Child process ID }; -class Q_ADDON_PROCESSMANAGER_EXPORT Prefork { +class Q_ADDON_PROCESSMANAGER_EXPORT QPrefork { public: - static Prefork *instance(); + static QPrefork *instance(); void execute(int *argc_ptr, char ***argv_ptr); void checkChildDied(pid_t pid); int size() const; - const PreforkChildData *at(int i) const; + const QPreforkChildData *at(int i) const; private: - Prefork(); + QPrefork(); int nextMarker(int index); void launch(int start, int end); @@ -71,7 +71,7 @@ private: char **m_argv; // Original pointer to argument size_t m_argv_size; // Length of vector allocated to original list int m_count; // Number of child processes forked - PreforkChildData *m_children; + QPreforkChildData *m_children; }; QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/preforkprocessbackendfactory.cpp b/src/processmanager/qpreforkprocessbackendfactory.cpp index 7ffc90b..c5b1158 100644 --- a/src/processmanager/preforkprocessbackendfactory.cpp +++ b/src/processmanager/qpreforkprocessbackendfactory.cpp @@ -37,10 +37,9 @@ ** ****************************************************************************/ -#include "preforkprocessbackendfactory.h" -#include "prefork.h" -#include "remoteprocessbackend.h" -#include "remoteprotocol.h" +#include "qpreforkprocessbackendfactory.h" +#include "qprefork.h" +#include "qremoteprotocol.h" #include <QDebug> #include <QJsonDocument> @@ -50,33 +49,34 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER const int kPreforkTimerInterval = 1000; /*! - \class PreforkProcessBackendFactory - \brief The PreforkProcessBackendFactory class connects to a preforked client - - The PreforkProcessBackendFactory class can only be used in a process - that has been started by the \l{Prefork} class. Each - PreforkProcessBackendFactory object must be associated with a single - child process started from the \l{Prefork} class. The association is + \class QPreforkProcessBackendFactory + \brief The QPreforkProcessBackendFactory class connects to a preforked client + \inmodule QtProcessManager + + The QPreforkProcessBackendFactory class can only be used in a process + that has been started by the \l{QPrefork} class. Each + QPreforkProcessBackendFactory object must be associated with a single + child process started from the \l{QPrefork} class. The association is done by setting the \l{index} property to match a valid index from - the \l{Prefork} singleton object. + the \l{QPrefork} singleton object. - The PreforkProcessBackendFactory communicates with the child process - using the same protocol as the \l{PipeProcessBackendFactory} (simple + The QPreforkProcessBackendFactory communicates with the child process + using the same protocol as the \l{QPipeProcessBackendFactory} (simple JSON-formatted messages). */ /*! - \property PreforkProcessBackendFactory::index + \property QPreforkProcessBackendFactory::index Index into the prefork instance of which process this should be connected to. */ /*! - Construct a PreforkProcessBackendFactory with optional \a parent. + Construct a QPreforkProcessBackendFactory with optional \a parent. */ -PreforkProcessBackendFactory::PreforkProcessBackendFactory(QObject *parent) - : RemoteProcessBackendFactory(parent) +QPreforkProcessBackendFactory::QPreforkProcessBackendFactory(QObject *parent) + : QRemoteProcessBackendFactory(parent) , m_index(-1) { m_pipe = new QtAddOn::QtJsonStream::QJsonPipe(this); @@ -89,13 +89,13 @@ PreforkProcessBackendFactory::PreforkProcessBackendFactory(QObject *parent) Destroy this and child objects. */ -PreforkProcessBackendFactory::~PreforkProcessBackendFactory() +QPreforkProcessBackendFactory::~QPreforkProcessBackendFactory() { if (m_index >= 0) { - const PreforkChildData *data = Prefork::instance()->at(m_index); + const QPreforkChildData *data = QPrefork::instance()->at(m_index); if (data) { QJsonObject message; - message.insert(RemoteProtocol::remote(), RemoteProtocol::halt()); + message.insert(QRemoteProtocol::remote(), QRemoteProtocol::halt()); m_pipe->send(message); m_pipe->waitForBytesWritten(); } @@ -106,7 +106,7 @@ PreforkProcessBackendFactory::~PreforkProcessBackendFactory() Return the process index */ -int PreforkProcessBackendFactory::index() const +int QPreforkProcessBackendFactory::index() const { return m_index; } @@ -115,14 +115,14 @@ int PreforkProcessBackendFactory::index() const Set the prefork index to \a index */ -void PreforkProcessBackendFactory::setIndex(int index) +void QPreforkProcessBackendFactory::setIndex(int index) { - Prefork *prefork = Prefork::instance(); + QPrefork *prefork = QPrefork::instance(); Q_ASSERT(prefork); if (index >= 0 && index < prefork->size()) { m_index = index; - const PreforkChildData *data = prefork->at(index); + const QPreforkChildData *data = prefork->at(index); m_pipe->setFds(data->out, data->in); emit indexChanged(); } @@ -134,14 +134,14 @@ void PreforkProcessBackendFactory::setIndex(int index) Return the local process */ -PidList PreforkProcessBackendFactory::localInternalProcesses() const +QPidList QPreforkProcessBackendFactory::localInternalProcesses() const { - Prefork *prefork = Prefork::instance(); + QPrefork *prefork = QPrefork::instance(); Q_ASSERT(prefork); QList<Q_PID> list; if (m_index >= 0 && m_index < prefork->size()) { - const PreforkChildData *data = prefork->at(m_index); + const QPreforkChildData *data = prefork->at(m_index); list << data->pid; } return list; @@ -151,16 +151,16 @@ PidList PreforkProcessBackendFactory::localInternalProcesses() const Send a \a message to the preforked process */ -bool PreforkProcessBackendFactory::send(const QJsonObject& message) +bool QPreforkProcessBackendFactory::send(const QJsonObject& message) { return m_pipe->send(message); } /*! - \fn PreforkProcessBackendFactory::indexChanged() + \fn QPreforkProcessBackendFactory::indexChanged() This signal is emitted when the index is changed. */ -#include "moc_preforkprocessbackendfactory.cpp" +#include "moc_qpreforkprocessbackendfactory.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/preforkprocessbackendfactory.h b/src/processmanager/qpreforkprocessbackendfactory.h index 3e1b371..ebe5479 100644 --- a/src/processmanager/preforkprocessbackendfactory.h +++ b/src/processmanager/qpreforkprocessbackendfactory.h @@ -41,18 +41,18 @@ #define PREFORK_PROCESS_BACKEND_FACTORY_H #include "qjsonpipe.h" -#include "remoteprocessbackendfactory.h" +#include "qremoteprocessbackendfactory.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class Q_ADDON_PROCESSMANAGER_EXPORT PreforkProcessBackendFactory : public RemoteProcessBackendFactory +class Q_ADDON_PROCESSMANAGER_EXPORT QPreforkProcessBackendFactory : public QRemoteProcessBackendFactory { Q_OBJECT Q_PROPERTY(int index READ index WRITE setIndex NOTIFY indexChanged) public: - PreforkProcessBackendFactory(QObject *parent = 0); - virtual ~PreforkProcessBackendFactory(); + QPreforkProcessBackendFactory(QObject *parent = 0); + virtual ~QPreforkProcessBackendFactory(); int index() const; void setIndex(int index); @@ -61,7 +61,7 @@ signals: void indexChanged(); protected: - virtual PidList localInternalProcesses() const; + virtual QPidList localInternalProcesses() const; virtual bool send(const QJsonObject&); private: diff --git a/src/processmanager/prelaunchprocessbackend.cpp b/src/processmanager/qprelaunchprocessbackend.cpp index f855af4..1219c7a 100644 --- a/src/processmanager/prelaunchprocessbackend.cpp +++ b/src/processmanager/qprelaunchprocessbackend.cpp @@ -37,7 +37,7 @@ ** ****************************************************************************/ -#include "prelaunchprocessbackend.h" +#include "qprelaunchprocessbackend.h" #include <qjsondocument.h> #include <QUuid> @@ -46,25 +46,26 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \class PrelaunchProcessBackend - \brief The PrelaunchProcessBackend class encapsulates a process that is started and later told what to run. + \class QPrelaunchProcessBackend + \brief The QPrelaunchProcessBackend class encapsulates a process that is started and later told what to run. + \inmodule QtProcessManager - The PrelaunchProcessBackend class contains an internal QProcess object that is - "prelaunched" by the PrelaunchProcessBackendFactory object. When the factory + The QPrelaunchProcessBackend class contains an internal QProcess object that is + "prelaunched" by the QPrelaunchProcessBackendFactory object. When the factory is asked to create a new process, the prelaunched backend is returned. When start() is - called, the prelaunched process is passed a ProcessInfo record encoded in QBinaryJson + called, the prelaunched process is passed a QProcessInfo record encoded in QBinaryJson document format (a serialized JSON object). This record should be used by the prelaunched process to transform itself into the correctly running application. */ /*! - Construct a PrelaunchProcessBackend with ProcessInfo \a info and optional \a parent. - The \a info ProcessInfo is used to start the internal QProcess. This is different - from the final ProcessInfo which will be directly passed to the running QProcess. + Construct a QPrelaunchProcessBackend with QProcessInfo \a info and optional \a parent. + The \a info QProcessInfo is used to start the internal QProcess. This is different + from the final QProcessInfo which will be directly passed to the running QProcess. */ -PrelaunchProcessBackend::PrelaunchProcessBackend(const ProcessInfo &info, QObject *parent) - : UnixProcessBackend(info, parent) +QPrelaunchProcessBackend::QPrelaunchProcessBackend(const QProcessInfo &info, QObject *parent) + : QUnixProcessBackend(info, parent) , m_started(false) { } @@ -73,7 +74,7 @@ PrelaunchProcessBackend::PrelaunchProcessBackend(const ProcessInfo &info, QObjec Destroy this and child objects */ -PrelaunchProcessBackend::~PrelaunchProcessBackend() +QPrelaunchProcessBackend::~QPrelaunchProcessBackend() { } @@ -81,18 +82,18 @@ PrelaunchProcessBackend::~PrelaunchProcessBackend() Starts the internal QProcess with the prelaunch information. */ -void PrelaunchProcessBackend::prestart() +void QPrelaunchProcessBackend::prestart() { if (createProcess()) startProcess(); } /*! - Switch the stored ProcessInfo to the final \a info object. + Switch the stored QProcessInfo to the final \a info object. This function also updates the identifier of the process. */ -void PrelaunchProcessBackend::setInfo(const ProcessInfo& info) +void QPrelaunchProcessBackend::setInfo(const QProcessInfo& info) { m_info = info; setDesiredPriority(m_info.priority()); @@ -105,19 +106,19 @@ void PrelaunchProcessBackend::setInfo(const ProcessInfo& info) Return true if the process has been created and is running. */ -bool PrelaunchProcessBackend::isReady() const +bool QPrelaunchProcessBackend::isReady() const { return m_process && m_process->state() == QProcess::Running; } /*! Pretend to start the prelaunched process. - The stored ProcessInfo record is written to the internal QProcess as a serialized + The stored QProcessInfo record is written to the internal QProcess as a serialized JSON object (the internal QProcess receives it from stdin). Then emit all queued signals that were captured from the QProcess. */ -void PrelaunchProcessBackend::start() +void QPrelaunchProcessBackend::start() { if (m_started) { qWarning() << "Can't restart prelaunched process"; @@ -153,10 +154,10 @@ void PrelaunchProcessBackend::start() officially "started", the state has to be NotRunning. */ -QProcess::ProcessState PrelaunchProcessBackend::state() const +QProcess::ProcessState QPrelaunchProcessBackend::state() const { if (m_started) - return UnixProcessBackend::state(); + return QUnixProcessBackend::state(); else return QProcess::NotRunning; } @@ -164,9 +165,9 @@ QProcess::ProcessState PrelaunchProcessBackend::state() const /*! \internal */ -void PrelaunchProcessBackend::handleProcessStarted() +void QPrelaunchProcessBackend::handleProcessStarted() { - UnixProcessBackend::handleProcessStarted(); + QUnixProcessBackend::handleProcessStarted(); if (!m_started) { QueuedSignal s; s.name = QueuedSignal::Started; @@ -178,9 +179,9 @@ void PrelaunchProcessBackend::handleProcessStarted() /*! \internal */ -void PrelaunchProcessBackend::handleProcessError(QProcess::ProcessError processError) +void QPrelaunchProcessBackend::handleProcessError(QProcess::ProcessError processError) { - UnixProcessBackend::handleProcessError(processError); + QUnixProcessBackend::handleProcessError(processError); if (!m_started) { QueuedSignal s; s.name = QueuedSignal::Error; @@ -193,9 +194,9 @@ void PrelaunchProcessBackend::handleProcessError(QProcess::ProcessError processE /*! \internal */ -void PrelaunchProcessBackend::handleProcessFinished(int exitCode, QProcess::ExitStatus status) +void QPrelaunchProcessBackend::handleProcessFinished(int exitCode, QProcess::ExitStatus status) { - UnixProcessBackend::handleProcessFinished(exitCode, status); + QUnixProcessBackend::handleProcessFinished(exitCode, status); if (!m_started) { QueuedSignal s; s.name = QueuedSignal::Finished; @@ -209,9 +210,9 @@ void PrelaunchProcessBackend::handleProcessFinished(int exitCode, QProcess::Exit /*! \internal */ -void PrelaunchProcessBackend::handleProcessStateChanged(QProcess::ProcessState state) +void QPrelaunchProcessBackend::handleProcessStateChanged(QProcess::ProcessState state) { - UnixProcessBackend::handleProcessStateChanged(state); + QUnixProcessBackend::handleProcessStateChanged(state); if (!m_started) { QueuedSignal s; s.name = QueuedSignal::StateChanged; @@ -231,6 +232,6 @@ void PrelaunchProcessBackend::handleProcessStateChanged(QProcess::ProcessState s \internal */ -#include "moc_prelaunchprocessbackend.cpp" +#include "moc_qprelaunchprocessbackend.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/prelaunchprocessbackend.h b/src/processmanager/qprelaunchprocessbackend.h index cefb1a4..3bba547 100644 --- a/src/processmanager/prelaunchprocessbackend.h +++ b/src/processmanager/qprelaunchprocessbackend.h @@ -40,8 +40,8 @@ #ifndef PRELAUNCHPROCESSBACKEND_H #define PRELAUNCHPROCESSBACKEND_H -#include "unixprocessbackend.h" -#include "processmanager-global.h" +#include "qunixprocessbackend.h" +#include "qprocessmanager-global.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER @@ -61,16 +61,16 @@ public: } n; }; -class Q_ADDON_PROCESSMANAGER_EXPORT PrelaunchProcessBackend : public UnixProcessBackend +class Q_ADDON_PROCESSMANAGER_EXPORT QPrelaunchProcessBackend : public QUnixProcessBackend { Q_OBJECT public: - PrelaunchProcessBackend(const ProcessInfo& info, QObject *parent); - virtual ~PrelaunchProcessBackend(); + QPrelaunchProcessBackend(const QProcessInfo& info, QObject *parent); + virtual ~QPrelaunchProcessBackend(); void prestart(); - void setInfo(const ProcessInfo& info); + void setInfo(const QProcessInfo& info); bool isReady() const; virtual void start(); diff --git a/src/processmanager/prelaunchprocessbackendfactory.cpp b/src/processmanager/qprelaunchprocessbackendfactory.cpp index 06356e3..201aa0d 100644 --- a/src/processmanager/prelaunchprocessbackendfactory.cpp +++ b/src/processmanager/qprelaunchprocessbackendfactory.cpp @@ -39,27 +39,28 @@ #include <QDebug> -#include "prelaunchprocessbackendfactory.h" -#include "prelaunchprocessbackend.h" -#include "processinfo.h" +#include "qprelaunchprocessbackendfactory.h" +#include "qprelaunchprocessbackend.h" +#include "qprocessinfo.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \class PrelaunchProcessBackendFactory - \brief The PrelaunchProcessBackendFactory class creates PrelaunchProcessBackend objects + \class QPrelaunchProcessBackendFactory + \brief The QPrelaunchProcessBackendFactory class creates QPrelaunchProcessBackend objects + \inmodule QtProcessManager - The PrelaunchProcessBackendFactory starts up a PrelaunchProcessBackend using + The QPrelaunchProcessBackendFactory starts up a QPrelaunchProcessBackend using information passed in the constructor. */ /*! - \property PrelaunchProcessBackendFactory::processInfo - \brief ProcessInfo record used to create the prelaunched process + \property QPrelaunchProcessBackendFactory::processInfo + \brief QProcessInfo record used to create the prelaunched process */ /*! - \property PrelaunchProcessBackendFactory::prelaunchEnabled + \property QPrelaunchProcessBackendFactory::prelaunchEnabled \brief Controls whether or not a prelaunched process is created. If this property is true, a prelaunched process will be created @@ -68,12 +69,12 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER */ /*! - Construct a PrelaunchProcessBackendFactory with optional \a parent. - To be able to use the PrelaunchProcessBackendFactory, you also need to set - a ProcessInfo object to it that specifies which process is prelaunched. + Construct a QPrelaunchProcessBackendFactory with optional \a parent. + To be able to use the QPrelaunchProcessBackendFactory, you also need to set + a QProcessInfo object to it that specifies which process is prelaunched. */ -PrelaunchProcessBackendFactory::PrelaunchProcessBackendFactory(QObject *parent) - : ProcessBackendFactory(parent) +QPrelaunchProcessBackendFactory::QPrelaunchProcessBackendFactory(QObject *parent) + : QProcessBackendFactory(parent) , m_prelaunch(NULL) , m_info(NULL) , m_prelaunchEnabled(true) @@ -84,34 +85,34 @@ PrelaunchProcessBackendFactory::PrelaunchProcessBackendFactory(QObject *parent) Destroy this and child objects. */ -PrelaunchProcessBackendFactory::~PrelaunchProcessBackendFactory() +QPrelaunchProcessBackendFactory::~QPrelaunchProcessBackendFactory() { } /*! - Return true if the PrelaunchProcessBackendFactory can create + Return true if the QPrelaunchProcessBackendFactory can create a process that matches \a info. The default implementation only checks that a valid info object has been previously set in the factory, and then passes the decision on to the default implementation, which should probably - have some kind of MatchDelegate installed. + have some kind of QMatchDelegate installed. */ -bool PrelaunchProcessBackendFactory::canCreate(const ProcessInfo &info) const +bool QPrelaunchProcessBackendFactory::canCreate(const QProcessInfo &info) const { if (!m_info) return false; - return ProcessBackendFactory::canCreate(info); + return QProcessBackendFactory::canCreate(info); } /*! - Construct a PrelaunchProcessBackend from a ProcessInfo \a info record with \a parent. + Construct a PrelaunchProcessBackend from a QProcessInfo \a info record with \a parent. */ -ProcessBackend * PrelaunchProcessBackendFactory::create(const ProcessInfo &info, QObject *parent) +QProcessBackend * QPrelaunchProcessBackendFactory::create(const QProcessInfo &info, QObject *parent) { Q_ASSERT(m_info); - PrelaunchProcessBackend *prelaunch = m_prelaunch; + QPrelaunchProcessBackend *prelaunch = m_prelaunch; if (hasPrelaunchedProcess()) { // qDebug() << "Using existing prelaunch"; @@ -122,7 +123,7 @@ ProcessBackend * PrelaunchProcessBackendFactory::create(const ProcessInfo &info, updateState(); } else { // qDebug() << "Creating prelaunch from scratch"; - prelaunch = new PrelaunchProcessBackend(*m_info, parent); + prelaunch = new QPrelaunchProcessBackend(*m_info, parent); prelaunch->prestart(); prelaunch->setInfo(info); } @@ -133,7 +134,7 @@ ProcessBackend * PrelaunchProcessBackendFactory::create(const ProcessInfo &info, Return the prelaunched process information */ -ProcessInfo *PrelaunchProcessBackendFactory::processInfo() const +QProcessInfo *QPrelaunchProcessBackendFactory::processInfo() const { return m_info; } @@ -141,12 +142,12 @@ ProcessInfo *PrelaunchProcessBackendFactory::processInfo() const /*! Returns whether prelaunching is enabled for this factory. */ -bool PrelaunchProcessBackendFactory::prelaunchEnabled() const +bool QPrelaunchProcessBackendFactory::prelaunchEnabled() const { return m_prelaunchEnabled; } -void PrelaunchProcessBackendFactory::setPrelaunchEnabled(bool value) +void QPrelaunchProcessBackendFactory::setPrelaunchEnabled(bool value) { if (m_prelaunchEnabled != value) { m_prelaunchEnabled = value; @@ -158,7 +159,7 @@ void PrelaunchProcessBackendFactory::setPrelaunchEnabled(bool value) /*! Returns whether there is a prelaunched process which is ready to be consumed. */ -bool PrelaunchProcessBackendFactory::hasPrelaunchedProcess() const +bool QPrelaunchProcessBackendFactory::hasPrelaunchedProcess() const { return (m_prelaunch && m_prelaunch->isReady()); } @@ -166,7 +167,7 @@ bool PrelaunchProcessBackendFactory::hasPrelaunchedProcess() const /*! Under memory restriction, terminate the prelaunch process. */ -void PrelaunchProcessBackendFactory::handleMemoryRestrictionChange() +void QPrelaunchProcessBackendFactory::handleMemoryRestrictionChange() { if (m_memoryRestricted) { if (m_prelaunch) { @@ -180,7 +181,7 @@ void PrelaunchProcessBackendFactory::handleMemoryRestrictionChange() /*! Returns the prelaunched process backend, or null if none is created. */ -PrelaunchProcessBackend *PrelaunchProcessBackendFactory::prelaunchProcessBackend() const +QPrelaunchProcessBackend *QPrelaunchProcessBackendFactory::prelaunchProcessBackend() const { return m_prelaunch; } @@ -189,12 +190,12 @@ PrelaunchProcessBackend *PrelaunchProcessBackendFactory::prelaunchProcessBackend Launch a new prelaunched process backend. */ -void PrelaunchProcessBackendFactory::idleCpuAvailable() +void QPrelaunchProcessBackendFactory::idleCpuAvailable() { // qDebug() << Q_FUNC_INFO; if (m_prelaunchEnabled && !m_prelaunch && !m_memoryRestricted && m_info) { // qDebug() << Q_FUNC_INFO << "...launching"; - m_prelaunch = new PrelaunchProcessBackend(*m_info, this); + m_prelaunch = new QPrelaunchProcessBackend(*m_info, this); connect(m_prelaunch, SIGNAL(finished(int,QProcess::ExitStatus)), SLOT(prelaunchFinished(int,QProcess::ExitStatus))); connect(m_prelaunch, SIGNAL(error(QProcess::ProcessError)), @@ -212,7 +213,7 @@ void PrelaunchProcessBackendFactory::idleCpuAvailable() unexpectedly. */ -void PrelaunchProcessBackendFactory::prelaunchFinished(int exitCode, QProcess::ExitStatus status) +void QPrelaunchProcessBackendFactory::prelaunchFinished(int exitCode, QProcess::ExitStatus status) { qWarning() << Q_FUNC_INFO << "died unexpectedly" << exitCode << status; if (m_prelaunch) { @@ -226,7 +227,7 @@ void PrelaunchProcessBackendFactory::prelaunchFinished(int exitCode, QProcess::E Handle surprise error conditions on the prelaunched process. */ -void PrelaunchProcessBackendFactory::prelaunchError(QProcess::ProcessError err) +void QPrelaunchProcessBackendFactory::prelaunchError(QProcess::ProcessError err) { qWarning() << Q_FUNC_INFO << "unexpected error" << err; if (m_prelaunch) { @@ -247,23 +248,23 @@ void PrelaunchProcessBackendFactory::prelaunchError(QProcess::ProcessError err) Update our presented state, consisting of whether or not we need idle CPU resources and how many internal processes we are running. */ -void PrelaunchProcessBackendFactory::updateState() +void QPrelaunchProcessBackendFactory::updateState() { Q_ASSERT(!m_prelaunch || !m_memoryRestricted); // If memory is restricted, we must not have a prelaunch process setIdleCpuRequest(!m_memoryRestricted && m_prelaunchEnabled && !m_prelaunch && m_info); - PidList list; + QPidList list; if (m_prelaunch && m_prelaunch->isReady()) list << m_prelaunch->pid(); setInternalProcesses(list); } /*! - Sets the ProcessInfo that is used to determine the prelaunched runtime to \a processInfo. + Sets the QProcessInfo that is used to determine the prelaunched runtime to \a processInfo. An internal copy is made of the \a processInfo object. */ -void PrelaunchProcessBackendFactory::setProcessInfo(ProcessInfo *processInfo) +void QPrelaunchProcessBackendFactory::setProcessInfo(QProcessInfo *processInfo) { if (m_info != processInfo) { if (m_info) { @@ -272,7 +273,7 @@ void PrelaunchProcessBackendFactory::setProcessInfo(ProcessInfo *processInfo) } if (processInfo) { - m_info = new ProcessInfo(*processInfo); + m_info = new QProcessInfo(*processInfo); m_info->setParent(this); if (m_prelaunch) { m_prelaunch->deleteLater(); @@ -285,28 +286,28 @@ void PrelaunchProcessBackendFactory::setProcessInfo(ProcessInfo *processInfo) } /*! - Sets the ProcessInfo that is used to determine the prelaunched runtime to \a processInfo. + Sets the QProcessInfo that is used to determine the prelaunched runtime to \a processInfo. */ -void PrelaunchProcessBackendFactory::setProcessInfo(ProcessInfo& processInfo) +void QPrelaunchProcessBackendFactory::setProcessInfo(QProcessInfo& processInfo) { setProcessInfo(&processInfo); } /*! - \fn void PrelaunchProcessBackendFactory::processInfoChanged() - This signal is emitted when the internal ProcessInfo record is + \fn void QPrelaunchProcessBackendFactory::processInfoChanged() + This signal is emitted when the internal QProcessInfo record is changed. */ /*! - \fn void PrelaunchProcessBackendFactory::prelaunchEnabledChanged() + \fn void QPrelaunchProcessBackendFactory::prelaunchEnabledChanged() This signal is emitted when the prelaunchEnabled property is changed. */ /*! - \fn void PrelaunchProcessBackendFactory::processPrelaunched() + \fn void QPrelaunchProcessBackendFactory::processPrelaunched() This signal is emitted when the prelaunched process is first created. */ -#include "moc_prelaunchprocessbackendfactory.cpp" +#include "moc_qprelaunchprocessbackendfactory.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/prelaunchprocessbackendfactory.h b/src/processmanager/qprelaunchprocessbackendfactory.h index c2b9543..5496a9a 100644 --- a/src/processmanager/prelaunchprocessbackendfactory.h +++ b/src/processmanager/qprelaunchprocessbackendfactory.h @@ -40,30 +40,30 @@ #ifndef PRELAUNCH_PROCESS_BACKEND_FACTORY_H #define PRELAUNCH_PROCESS_BACKEND_FACTORY_H -#include "processbackendfactory.h" -#include "processmanager-global.h" +#include "qprocessbackendfactory.h" +#include "qprocessmanager-global.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class ProcessInfo; -class PrelaunchProcessBackend; +class QProcessInfo; +class QPrelaunchProcessBackend; -class Q_ADDON_PROCESSMANAGER_EXPORT PrelaunchProcessBackendFactory : public ProcessBackendFactory +class Q_ADDON_PROCESSMANAGER_EXPORT QPrelaunchProcessBackendFactory : public QProcessBackendFactory { Q_OBJECT - Q_PROPERTY(ProcessInfo* processInfo READ processInfo WRITE setProcessInfo NOTIFY processInfoChanged) + Q_PROPERTY(QProcessInfo* processInfo READ processInfo WRITE setProcessInfo NOTIFY processInfoChanged) Q_PROPERTY(bool prelaunchEnabled READ prelaunchEnabled WRITE setPrelaunchEnabled NOTIFY prelaunchEnabledChanged) public: - PrelaunchProcessBackendFactory(QObject *parent = 0); - virtual ~PrelaunchProcessBackendFactory(); + QPrelaunchProcessBackendFactory(QObject *parent = 0); + virtual ~QPrelaunchProcessBackendFactory(); - virtual bool canCreate(const ProcessInfo &info) const; - virtual ProcessBackend *create(const ProcessInfo& info, QObject *parent); + virtual bool canCreate(const QProcessInfo &info) const; + virtual QProcessBackend *create(const QProcessInfo& info, QObject *parent); - ProcessInfo *processInfo() const; - void setProcessInfo(ProcessInfo *processInfo); - void setProcessInfo(ProcessInfo& processInfo); + QProcessInfo *processInfo() const; + void setProcessInfo(QProcessInfo *processInfo); + void setProcessInfo(QProcessInfo& processInfo); bool prelaunchEnabled() const; void setPrelaunchEnabled(bool value); @@ -77,7 +77,7 @@ signals: protected: virtual void handleMemoryRestrictionChange(); - PrelaunchProcessBackend *prelaunchProcessBackend() const; + QPrelaunchProcessBackend *prelaunchProcessBackend() const; protected slots: virtual void idleCpuAvailable(); @@ -88,8 +88,8 @@ private slots: void updateState(); private: - PrelaunchProcessBackend *m_prelaunch; - ProcessInfo *m_info; + QPrelaunchProcessBackend *m_prelaunch; + QProcessInfo *m_info; bool m_prelaunchEnabled; }; diff --git a/src/processmanager/processbackend.cpp b/src/processmanager/qprocessbackend.cpp index 5288e65..834e642 100644 --- a/src/processmanager/processbackend.cpp +++ b/src/processmanager/qprocessbackend.cpp @@ -38,7 +38,7 @@ ****************************************************************************/ -#include "processbackend.h" +#include "qprocessbackend.h" #include <QDateTime> #include <QUuid> @@ -52,20 +52,21 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \class ProcessBackend - \brief The ProcessBackend class is a generalized representation of a process. + \class QProcessBackend + \brief The QProcessBackend class is a generalized representation of a process. + \inmodule QtProcessManager - The ProcessBackend class encapsulates a process whose lifecycle is controlled by the process manager. - It is a generalized representation - in actuality, subclasses of the ProcessBackend class are used + The QProcessBackend class encapsulates a process whose lifecycle is controlled by the process manager. + It is a generalized representation - in actuality, subclasses of the QProcessBackend class are used to control processes. These subclasses are used to accelerate process launching, wrap processes with additional arguments and settings, or fake the existence of a process. - The ProcessBackend class itself cannot be instantiated. + The QProcessBackend class itself cannot be instantiated. - A ProcessBackend object always contains a ProcessInfo object, which is the static information + A QProcessBackend object always contains a QProcessInfo object, which is the static information used to start and execute the process. - Because ProcessBackends represent actual or fake processes, they can only - modify a few of the process properties. Currently the ProcessBackend can + Because QProcessBackends represent actual or fake processes, they can only + modify a few of the process properties. Currently the QProcessBackend can only modify the process priority (or niceness) and the oomAdjustment score (for Linux systems). All other process properties (such as UID, GID, program name) can be considered fixed. @@ -83,12 +84,12 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! \internal - Constructs a ProcessBackend instance with ProcessInfo \a info and optional \a parent + Constructs a QProcessBackend instance with QProcessInfo \a info and optional \a parent */ -ProcessBackend::ProcessBackend(const ProcessInfo& info, QObject *parent) +QProcessBackend::QProcessBackend(const QProcessInfo &info, QObject *parent) : QObject(parent) , m_info(info) - , m_echo(ProcessBackend::EchoStdoutStderr) + , m_echo(QProcessBackend::EchoStdoutStderr) { static int backend_count = 0; m_id = ++backend_count; @@ -99,7 +100,7 @@ ProcessBackend::ProcessBackend(const ProcessInfo& info, QObject *parent) Destroy this process object. */ -ProcessBackend::~ProcessBackend() +QProcessBackend::~QProcessBackend() { } @@ -107,7 +108,7 @@ ProcessBackend::~ProcessBackend() Return the process name */ -QString ProcessBackend::name() const +QString QProcessBackend::name() const { return m_name; } @@ -116,7 +117,7 @@ QString ProcessBackend::name() const Return the process identifier */ -QString ProcessBackend::identifier() const +QString QProcessBackend::identifier() const { return m_info.identifier(); } @@ -125,7 +126,7 @@ QString ProcessBackend::identifier() const Return the process program */ -QString ProcessBackend::program() const +QString QProcessBackend::program() const { return m_info.program(); } @@ -134,7 +135,7 @@ QString ProcessBackend::program() const Return the process arguments */ -QStringList ProcessBackend::arguments() const +QStringList QProcessBackend::arguments() const { return m_info.arguments(); } @@ -143,7 +144,7 @@ QStringList ProcessBackend::arguments() const Return the process environment */ -QVariantMap ProcessBackend::environment() const +QVariantMap QProcessBackend::environment() const { return m_info.environment(); } @@ -152,7 +153,7 @@ QVariantMap ProcessBackend::environment() const Return the process working directory */ -QString ProcessBackend::workingDirectory() const +QString QProcessBackend::workingDirectory() const { return m_info.workingDirectory(); } @@ -161,7 +162,7 @@ QString ProcessBackend::workingDirectory() const Returns a human-readable description of the last device error that occurred. */ -QString ProcessBackend::errorString() const +QString QProcessBackend::errorString() const { return QString(); } @@ -169,7 +170,7 @@ QString ProcessBackend::errorString() const /*! Returns the PID of this process. If the process has not started up yet properly, its PID will be 0. */ -Q_PID ProcessBackend::pid() const +Q_PID QProcessBackend::pid() const { return 0; } @@ -179,28 +180,28 @@ Q_PID ProcessBackend::pid() const the same as the actual priority */ -qint32 ProcessBackend::desiredPriority() const +qint32 QProcessBackend::desiredPriority() const { return m_info.priority(); } /*! Return the actual process priority. This should be - overriden by a subclass. + overridden by a subclass. */ -qint32 ProcessBackend::actualPriority() const +qint32 QProcessBackend::actualPriority() const { return 0; } /*! Set the process priority to \a priority. - The base class updates the ProcessInfo object + The base class updates the QProcessInfo object Subclasses should should override this function. */ -void ProcessBackend::setDesiredPriority(qint32 priority) +void QProcessBackend::setDesiredPriority(qint32 priority) { m_info.setPriority(priority); } @@ -209,7 +210,7 @@ void ProcessBackend::setDesiredPriority(qint32 priority) Return the desired process oomAdjustment */ -qint32 ProcessBackend::desiredOomAdjustment() const +qint32 QProcessBackend::desiredOomAdjustment() const { return m_info.oomAdjustment(); } @@ -219,33 +220,33 @@ qint32 ProcessBackend::desiredOomAdjustment() const Override this in a subclass that actual touches the oomAdjustment */ -qint32 ProcessBackend::actualOomAdjustment() const +qint32 QProcessBackend::actualOomAdjustment() const { return 0; } /*! Set the process desired \a oomAdjustment. - The base class updates the ProcessInfo object + The base class updates the QProcessInfo object Subclasses should override this function. Please note that there is no guarantee that the actual oomAdjustment will match the desired oomAdjustment. */ -void ProcessBackend::setDesiredOomAdjustment(qint32 oomAdjustment) +void QProcessBackend::setDesiredOomAdjustment(qint32 oomAdjustment) { m_info.setOomAdjustment(oomAdjustment); } /*! - \fn QProcess::ProcessState ProcessBackend::state() const + \fn QProcess::ProcessState QProcessBackend::state() const Returns the state of the process. */ /*! - \fn void ProcessBackend::start() + \fn void QProcessBackend::start() \brief Starts the process. After the process is started, the started() signal is emitted. @@ -259,7 +260,7 @@ void ProcessBackend::setDesiredOomAdjustment(qint32 oomAdjustment) */ /*! - \fn void ProcessBackend::stop(int timeout) + \fn void QProcessBackend::stop(int timeout) Attempts to stop a process by giving it a \a timeout time to die, measured in milliseconds. If the process does not die in the given time limit, it is killed. @@ -272,7 +273,7 @@ void ProcessBackend::setDesiredOomAdjustment(qint32 oomAdjustment) Returns the number of bytes that were actually written, or -1 if an error occurred. */ -qint64 ProcessBackend::write(const char *data, qint64 maxSize) +qint64 QProcessBackend::write(const char *data, qint64 maxSize) { Q_UNUSED(data); Q_UNUSED(maxSize); @@ -289,7 +290,7 @@ qint64 ProcessBackend::write(const char *data, qint64 maxSize) \endcode */ -qint64 ProcessBackend::write(const char *data) +qint64 QProcessBackend::write(const char *data) { return write(data, qstrlen(data)); } @@ -299,17 +300,17 @@ qint64 ProcessBackend::write(const char *data) Returns the number of bytes that were actually written, or -1 if an error occurred. */ -qint64 ProcessBackend::write(const QByteArray& byteArray) +qint64 QProcessBackend::write(const QByteArray& byteArray) { return write(byteArray.data(), byteArray.length()); } /*! - \enum ProcessBackend::EchoOutput + \enum QProcessBackend::EchoOutput This enum is used to control if data should be copied from an individual process stdout/stderr to the global stdout/stderr. By default, it is - set to \c ProcessBackend::EchoStdoutStderr, which means that all data + set to \c QProcessBackend::EchoStdoutStderr, which means that all data from the child process will be copied to stdout and stderr. \value EchoNone No data will be displayed @@ -322,7 +323,7 @@ qint64 ProcessBackend::write(const QByteArray& byteArray) Return the current echo setting. */ -ProcessBackend::EchoOutput ProcessBackend::echo() const +QProcessBackend::EchoOutput QProcessBackend::echo() const { return m_echo; } @@ -331,16 +332,16 @@ ProcessBackend::EchoOutput ProcessBackend::echo() const Set the \a echo setting */ -void ProcessBackend::setEcho( ProcessBackend::EchoOutput echo ) +void QProcessBackend::setEcho( QProcessBackend::EchoOutput echo ) { m_echo = echo; } /*! - Return a copy of the current ProcessInfo + Return a copy of the current QProcessInfo */ -ProcessInfo ProcessBackend::processInfo() const +QProcessInfo QProcessBackend::processInfo() const { return m_info; } @@ -376,7 +377,7 @@ static void _writeByteArrayToFd(const QByteArray& data, const QByteArray& prefix Reimplement this method to provide handling for standard output. */ -void ProcessBackend::handleStandardOutput(const QByteArray &byteArray) +void QProcessBackend::handleStandardOutput(const QByteArray &byteArray) { if (m_echo == EchoStdoutOnly || m_echo == EchoStdoutStderr) { QByteArray prefix = QString::fromLatin1("%1 [%2]: ").arg(m_name).arg(pid()).toLocal8Bit(); @@ -390,7 +391,7 @@ void ProcessBackend::handleStandardOutput(const QByteArray &byteArray) Reimplement this method to provide handling for standard error output. */ -void ProcessBackend::handleStandardError(const QByteArray &byteArray) +void QProcessBackend::handleStandardError(const QByteArray &byteArray) { if (m_echo == EchoStderrOnly || m_echo == EchoStdoutStderr) { QByteArray prefix = QString::fromLatin1("%1 [%2] ERR: ").arg(m_name).arg(pid()).toLocal8Bit(); @@ -405,7 +406,7 @@ void ProcessBackend::handleStandardError(const QByteArray &byteArray) then call this function after changing the name. */ -void ProcessBackend::createName() +void QProcessBackend::createName() { m_name = QString::fromLatin1("%1-%2").arg(m_info.identifier().isEmpty() ? QString::fromLatin1("process") @@ -413,18 +414,18 @@ void ProcessBackend::createName() } /*! - \fn void ProcessBackend::started() - This signal is emitted when the proces has started successfully. + \fn void QProcessBackend::started() + This signal is emitted when the process has started successfully. */ /*! - \fn void ProcessBackend::error(QProcess::ProcessError error) + \fn void QProcessBackend::error(QProcess::ProcessError error) This signal is emitted on a process error. The \a error argument is the error emitted by the internal QProcess. */ /*! - \fn void ProcessBackend::finished(int exitCode, QProcess::ExitStatus exitStatus) + \fn void QProcessBackend::finished(int exitCode, QProcess::ExitStatus exitStatus) This signal is emitted when the process has stopped and its execution is over. The \a exitStatus tells you how the process exited; the \a exitCode is the return value of the process. @@ -435,21 +436,21 @@ void ProcessBackend::createName() */ /*! - \fn void ProcessBackend::stateChanged(QProcess::ProcessState newState) + \fn void QProcessBackend::stateChanged(QProcess::ProcessState newState) This signal is emitted whenever the state of QProcess changes. The \a newState argument is the state the internal QProcess changed to. */ /*! - \fn void ProcessBackend::standardOutput(const QByteArray& data) + \fn void QProcessBackend::standardOutput(const QByteArray& data) This signal is emitted whenever standard output \a data is received from the child. */ /*! - \fn void ProcessBackend::standardError(const QByteArray& data) + \fn void QProcessBackend::standardError(const QByteArray& data) This signal is emitted whenever standard error \a data is received from the child */ -#include "moc_processbackend.cpp" +#include "moc_qprocessbackend.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/processbackend.h b/src/processmanager/qprocessbackend.h index cafa2b5..fc43ab1 100644 --- a/src/processmanager/processbackend.h +++ b/src/processmanager/qprocessbackend.h @@ -41,20 +41,20 @@ #define PROCESS_BACKEND_H #include <QObject> -#include "processinfo.h" -#include "processmanager-global.h" +#include "qprocessinfo.h" +#include "qprocessmanager-global.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class Q_ADDON_PROCESSMANAGER_EXPORT ProcessBackend : public QObject +class Q_ADDON_PROCESSMANAGER_EXPORT QProcessBackend : public QObject { Q_OBJECT protected: - ProcessBackend(const ProcessInfo& info, QObject *parent); + QProcessBackend(const QProcessInfo& info, QObject *parent); public: - virtual ~ProcessBackend(); + virtual ~QProcessBackend(); virtual QString name() const; virtual QString identifier() const; @@ -87,7 +87,7 @@ public: EchoOutput echo() const; void setEcho(EchoOutput); - ProcessInfo processInfo() const; + QProcessInfo processInfo() const; protected: virtual void handleStandardOutput(const QByteArray &output); @@ -106,12 +106,12 @@ signals: protected: QString m_name; int m_id; - ProcessInfo m_info; + QProcessInfo m_info; EchoOutput m_echo; }; QT_END_NAMESPACE_PROCESSMANAGER -QT_PROCESSMANAGER_DECLARE_METATYPE_PTR(ProcessBackend) +QT_PROCESSMANAGER_DECLARE_METATYPE_PTR(QProcessBackend) #endif // PROCESS_BACKEND_H diff --git a/src/processmanager/processbackendfactory.cpp b/src/processmanager/qprocessbackendfactory.cpp index c9d030b..21af547 100644 --- a/src/processmanager/processbackendfactory.cpp +++ b/src/processmanager/qprocessbackendfactory.cpp @@ -37,44 +37,45 @@ ** ****************************************************************************/ -#include "processbackendfactory.h" -#include "matchdelegate.h" -#include "rewritedelegate.h" +#include "qprocessbackendfactory.h" +#include "qmatchdelegate.h" +#include "qrewritedelegate.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \class ProcessBackendFactory - \brief The ProcessBackendFactory class is a virtual class for creating processes. + \class QProcessBackendFactory + \brief The QProcessBackendFactory class is a virtual class for creating processes. + \inmodule QtProcessManager Subclass this class to create particular types of processes. */ /*! - \property ProcessBackendFactory::internalProcesses + \property QProcessBackendFactory::internalProcesses \brief A list of the internal processes. */ /*! - \property ProcessBackendFactory::matchDelegate - \brief A MatchDelegate object assigned to this factory. + \property QProcessBackendFactory::matchDelegate + \brief A QMatchDelegate object assigned to this factory. */ /*! - \property ProcessBackendFactory::rewriteDelegate - \brief A RewriteDelegate object assigned to this factory. + \property QProcessBackendFactory::rewriteDelegate + \brief A QRewriteDelegate object assigned to this factory. */ /*! - \property ProcessBackendFactory::idleCpuRequest + \property QProcessBackendFactory::idleCpuRequest \brief A boolean value indicating that this factory would like idle CPU cycles */ /*! - Construct a ProcessBackendFactory with an optional \a parent. + Construct a QProcessBackendFactory with an optional \a parent. */ -ProcessBackendFactory::ProcessBackendFactory(QObject *parent) +QProcessBackendFactory::QProcessBackendFactory(QObject *parent) : QObject(parent) , m_matchDelegate(NULL) , m_rewriteDelegate(NULL) @@ -87,7 +88,7 @@ ProcessBackendFactory::ProcessBackendFactory(QObject *parent) Destroy a process factory */ -ProcessBackendFactory::~ProcessBackendFactory() +QProcessBackendFactory::~QProcessBackendFactory() { } @@ -96,7 +97,7 @@ ProcessBackendFactory::~ProcessBackendFactory() true requests the factory to free up as much memory as possible. */ -void ProcessBackendFactory::setMemoryRestricted(bool memoryRestricted) +void QProcessBackendFactory::setMemoryRestricted(bool memoryRestricted) { if (m_memoryRestricted != memoryRestricted) { m_memoryRestricted = memoryRestricted; @@ -108,7 +109,7 @@ void ProcessBackendFactory::setMemoryRestricted(bool memoryRestricted) Return a list of internal processes that are in use by this factory */ -PidList ProcessBackendFactory::internalProcesses() const +QPidList QProcessBackendFactory::internalProcesses() const { return m_internalProcesses; } @@ -118,7 +119,7 @@ PidList ProcessBackendFactory::internalProcesses() const list. The \a plist argument is a list of processes. */ -void ProcessBackendFactory::setInternalProcesses(const PidList& plist) +void QProcessBackendFactory::setInternalProcesses(const QPidList& plist) { if (!compareSortedLists(plist, m_internalProcesses)) { m_internalProcesses = plist; @@ -130,25 +131,25 @@ void ProcessBackendFactory::setInternalProcesses(const PidList& plist) Override this in subclasses to handle memory restriction changes */ -void ProcessBackendFactory::handleMemoryRestrictionChange() +void QProcessBackendFactory::handleMemoryRestrictionChange() { } /*! - Return the current MatchDelegate object + Return the current QMatchDelegate object */ -MatchDelegate *ProcessBackendFactory::matchDelegate() const +QMatchDelegate *QProcessBackendFactory::matchDelegate() const { return m_matchDelegate; } /*! - Set a new process MatchDelegate object \a matchDelegate. - The ProcessBackendFactory takes over parentage of the MatchDelegate. + Set a new process QMatchDelegate object \a matchDelegate. + The QProcessBackendFactory takes over parentage of the QMatchDelegate. */ -void ProcessBackendFactory::setMatchDelegate(MatchDelegate *matchDelegate) +void QProcessBackendFactory::setMatchDelegate(QMatchDelegate *matchDelegate) { if (matchDelegate != m_matchDelegate) { if (m_matchDelegate) @@ -161,20 +162,20 @@ void ProcessBackendFactory::setMatchDelegate(MatchDelegate *matchDelegate) } /*! - Return the current RewriteDelegate object + Return the current QRewriteDelegate object */ -RewriteDelegate *ProcessBackendFactory::rewriteDelegate() const +QRewriteDelegate *QProcessBackendFactory::rewriteDelegate() const { return m_rewriteDelegate; } /*! - Set a new process RewriteDelegate object \a rewriteDelegate. - The ProcessBackendFactory takes over parentage of the RewriteDelegate. + Set a new process QRewriteDelegate object \a rewriteDelegate. + The QProcessBackendFactory takes over parentage of the QRewriteDelegate. */ -void ProcessBackendFactory::setRewriteDelegate(RewriteDelegate *rewriteDelegate) +void QProcessBackendFactory::setRewriteDelegate(QRewriteDelegate *rewriteDelegate) { if (rewriteDelegate != m_rewriteDelegate) { if (m_rewriteDelegate) @@ -190,7 +191,7 @@ void ProcessBackendFactory::setRewriteDelegate(RewriteDelegate *rewriteDelegate) Return true if the factory is requesting idle CPU cycles */ -bool ProcessBackendFactory::idleCpuRequest() const +bool QProcessBackendFactory::idleCpuRequest() const { return m_idleCpuRequest; } @@ -199,7 +200,7 @@ bool ProcessBackendFactory::idleCpuRequest() const Set the current idle CPU request value to \a value */ -void ProcessBackendFactory::setIdleCpuRequest(bool value) +void QProcessBackendFactory::setIdleCpuRequest(bool value) { if (value != m_idleCpuRequest) { m_idleCpuRequest = value; @@ -212,22 +213,22 @@ void ProcessBackendFactory::setIdleCpuRequest(bool value) Subclasses should override this function. */ -void ProcessBackendFactory::idleCpuAvailable() +void QProcessBackendFactory::idleCpuAvailable() { } /*! - \fn bool ProcessBackendFactory::canCreate(const ProcessInfo& info) const + \fn bool QProcessBackendFactory::canCreate(const QProcessInfo& info) const - Return true if this ProcessBackendFactory matches the ProcessInfo \a info + Return true if this QProcessBackendFactory matches the QProcessInfo \a info process binding and can create an appropriate process. The default implementation - delegates the decision to the MatchDelegate object. If no MatchDelegate + delegates the decision to the QMatchDelegate object. If no QMatchDelegate has been installed, the default implementation returns true. This virtual function may be overridden. */ -bool ProcessBackendFactory::canCreate(const ProcessInfo& info) const +bool QProcessBackendFactory::canCreate(const QProcessInfo& info) const { if (m_matchDelegate) return m_matchDelegate->matches(info); @@ -235,55 +236,55 @@ bool ProcessBackendFactory::canCreate(const ProcessInfo& info) const } /*! - \fn void ProcessBackendFactory::rewrite(ProcessInfo& info) + \fn void QProcessBackendFactory::rewrite(QProcessInfo& info) - Rewrites the ProcessInfo \a info object by passing it to the RewriteDelegate - object. If no RewriteDelegate object is installed, this function does nothing. + Rewrites the QProcessInfo \a info object by passing it to the QRewriteDelegate + object. If no QRewriteDelegate object is installed, this function does nothing. This virtual function may be overridden. */ -void ProcessBackendFactory::rewrite(ProcessInfo& info) +void QProcessBackendFactory::rewrite(QProcessInfo& info) { if (m_rewriteDelegate) m_rewriteDelegate->rewrite(info); } /*! - \fn void ProcessBackendFactory::internalProcessesChanged() + \fn void QProcessBackendFactory::internalProcessesChanged() Signal emitted whenever the list of internal processes has changed. */ /*! - \fn void ProcessBackendFactory::matchDelegateChanged() + \fn void QProcessBackendFactory::matchDelegateChanged() - Signal emitted whenever the MatchDelegate is changed. + Signal emitted whenever the QMatchDelegate is changed. */ /*! - \fn void ProcessBackendFactory::rewriteDelegateChanged() + \fn void QProcessBackendFactory::rewriteDelegateChanged() - Signal emitted whenever the RewriteDelegate is changed. + Signal emitted whenever the QRewriteDelegate is changed. */ /*! - \fn void ProcessBackendFactory::idleCpuRequestChanged() + \fn void QProcessBackendFactory::idleCpuRequestChanged() Signal emitted whenever the idle CPU request is changed */ /*! - \fn ProcessBackend * ProcessBackendFactory::create(const ProcessInfo& info, QObject *parent) + \fn QProcessBackend * QProcessBackendFactory::create(const QProcessInfo& info, QObject *parent) - Create a ProcessBackend object based on the ProcessInfo \a info and \a parent. + Create a QProcessBackend object based on the QProcessInfo \a info and \a parent. */ /*! - \fn void ProcessBackendFactory::internalProcessError(QProcess::ProcessError error) + \fn void QProcessBackendFactory::internalProcessError(QProcess::ProcessError error) This signal is emitted when an internal process has an \a error. */ -#include "moc_processbackendfactory.cpp" +#include "moc_qprocessbackendfactory.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/processbackendfactory.h b/src/processmanager/qprocessbackendfactory.h index c313442..d00292f 100644 --- a/src/processmanager/processbackendfactory.h +++ b/src/processmanager/qprocessbackendfactory.h @@ -43,40 +43,40 @@ #include <QObject> #include <QProcessEnvironment> -#include "processmanager-global.h" -#include "processlist.h" +#include "qprocessmanager-global.h" +#include "qprocesslist.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class ProcessBackend; -class ProcessInfo; -class MatchDelegate; -class RewriteDelegate; +class QProcessBackend; +class QProcessInfo; +class QMatchDelegate; +class QRewriteDelegate; -class Q_ADDON_PROCESSMANAGER_EXPORT ProcessBackendFactory : public QObject +class Q_ADDON_PROCESSMANAGER_EXPORT QProcessBackendFactory : public QObject { Q_OBJECT - Q_PROPERTY(PidList internalProcesses READ internalProcesses NOTIFY internalProcessesChanged) - Q_PROPERTY(MatchDelegate* matchDelegate READ matchDelegate WRITE setMatchDelegate NOTIFY matchDelegateChanged) - Q_PROPERTY(RewriteDelegate* rewriteDelegate READ rewriteDelegate WRITE setRewriteDelegate NOTIFY rewriteDelegateChanged) + Q_PROPERTY(QPidList internalProcesses READ internalProcesses NOTIFY internalProcessesChanged) + Q_PROPERTY(QMatchDelegate* matchDelegate READ matchDelegate WRITE setMatchDelegate NOTIFY matchDelegateChanged) + Q_PROPERTY(QRewriteDelegate* rewriteDelegate READ rewriteDelegate WRITE setRewriteDelegate NOTIFY rewriteDelegateChanged) Q_PROPERTY(bool idleCpuRequest READ idleCpuRequest NOTIFY idleCpuRequestChanged) public: - ProcessBackendFactory(QObject *parent = 0); - virtual ~ProcessBackendFactory(); - virtual bool canCreate(const ProcessInfo& info) const; - virtual void rewrite(ProcessInfo& info); - virtual ProcessBackend *create(const ProcessInfo& info, QObject *parent) = 0; + QProcessBackendFactory(QObject *parent = 0); + virtual ~QProcessBackendFactory(); + virtual bool canCreate(const QProcessInfo& info) const; + virtual void rewrite(QProcessInfo& info); + virtual QProcessBackend *create(const QProcessInfo& info, QObject *parent) = 0; void setMemoryRestricted(bool); - PidList internalProcesses() const; + QPidList internalProcesses() const; - MatchDelegate * matchDelegate() const; - void setMatchDelegate(MatchDelegate *); + QMatchDelegate * matchDelegate() const; + void setMatchDelegate(QMatchDelegate *); - RewriteDelegate * rewriteDelegate() const; - void setRewriteDelegate(RewriteDelegate *); + QRewriteDelegate * rewriteDelegate() const; + void setRewriteDelegate(QRewriteDelegate *); bool idleCpuRequest() const; virtual void idleCpuAvailable(); @@ -90,13 +90,13 @@ signals: protected: void setIdleCpuRequest(bool); - virtual void setInternalProcesses(const PidList&); + virtual void setInternalProcesses(const QPidList&); virtual void handleMemoryRestrictionChange(); protected: - PidList m_internalProcesses; - MatchDelegate *m_matchDelegate; - RewriteDelegate *m_rewriteDelegate; + QPidList m_internalProcesses; + QMatchDelegate *m_matchDelegate; + QRewriteDelegate *m_rewriteDelegate; bool m_memoryRestricted; bool m_idleCpuRequest; }; diff --git a/src/processmanager/processbackendmanager.cpp b/src/processmanager/qprocessbackendmanager.cpp index 6321929..b94a01e 100644 --- a/src/processmanager/processbackendmanager.cpp +++ b/src/processmanager/qprocessbackendmanager.cpp @@ -39,58 +39,59 @@ #include <QDebug> -#include "processbackendmanager.h" -#include "processbackendfactory.h" -#include "processbackend.h" -#include "cpuidledelegate.h" +#include "qprocessbackendmanager.h" +#include "qprocessbackendfactory.h" +#include "qprocessbackend.h" +#include "qcpuidledelegate.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \class ProcessBackendManager - \brief The ProcessBackendManager class contains a list of ProcessBackendFactory - objects and is used to create ProcessBackend objects. + \class QProcessBackendManager + \brief The QProcessBackendManager class contains a list of QProcessBackendFactory + objects and is used to create QProcessBackend objects. + \inmodule QtProcessManager - The ProcessBackendManager class is a standalone class for creating ProcessBackend + The QProcessBackendManager class is a standalone class for creating QProcessBackend objects from factories. Typical use for the backend manager is like: \code - ProcessBackendManager *bm = new ProcessBackendManager; + QProcessBackendManager *bm = new QProcessBackendManager; ProcessInfo info; info.setProgram("/home/me/myprogram"); - bm->add(new PrelaunchProcessBackendFactory(info); - pm->add(new StandardProcessBackendFactory); + bm->add(new QPrelaunchProcessBackendFactory(info); + pm->add(new QStandardProcessBackendFactory); // ... - ProcessInfo i; + QProcessInfo i; i.setProgram("/home/me/myprogram"); i.setWorkingDirectory("/root"); - ProcessBackend *backend = bm->create(i); + QProcessBackend *backend = bm->create(i); \endcode The backend manager does not get involved in starting or tracking the lifetime of a process. In general, you should use the - ProcessManager class for processes, which contains a backend manager object. + QProcessManager class for processes, which contains a backend manager object. - You may assign an IdleDelegate to the process manager. Certain factory + You may assign a QIdleDelegate to the process manager. Certain factory objects required processing time to launch prelaunched runtime processes. - An IdleDelegate is a class that lets the process manager know when the + A QIdleDelegate is a class that lets the process manager know when the system load is low so that the prelaunch programs can be started. If - you do not assign an IdleDelegate, you may subclass the ProcessBackendManager + you do not assign a QIdleDelegate, you may subclass the QProcessBackendManager to override the default idle calculations. - If you do not assign an IdleDelegate, the CpuIdleDelegate will be + If you do not assign a QIdleDelegate, the QCpuIdleDelegate will be used by default. - If you prefer to not use delegates, you can subclass ProcessBackendManager + If you prefer to not use delegates, you can subclass QProcessBackendManager and override the \l{handleIdleCpuRequest()} function. If you do this, - you must shut off the default IdleDelegate. For example: + you must shut off the default QIdleDelegate. For example: \code - class MyManager : public ProcessBackendManager { + class MyManager : public QProcessBackendManager { public - MyManager(QObject *parent=0) : ProcessBackendManager(parent) { + MyManager(QObject *parent=0) : QProcessBackendManager(parent) { setIdleDelegate(0); connect(&timer, SIGNAL(timeout()), SLOT(checkCpuLoad())); timer.setInterval(1000); @@ -115,41 +116,41 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER */ /*! - \property ProcessBackendManager::idleDelegate - \brief The IdleDelegate object assigned to this factory. + \property QProcessBackendManager::idleDelegate + \brief The QIdleDelegate object assigned to this factory. */ /*! - Construct a ProcessBackendManager with an optional \a parent + Construct a QProcessBackendManager with an optional \a parent By default, a CpuIdleDelegate is assigned to the idleDelegate. */ -ProcessBackendManager::ProcessBackendManager(QObject *parent) +QProcessBackendManager::QProcessBackendManager(QObject *parent) : QObject(parent) , m_memoryRestricted(false) , m_idleCpuRequest(false) { - m_idleDelegate = new CpuIdleDelegate(this); + m_idleDelegate = new QCpuIdleDelegate(this); connect(m_idleDelegate, SIGNAL(idleCpuAvailable()), SLOT(idleCpuAvailable())); } /*! - Delete the ProcessBackendManager and terminate all factory processes. + Delete the QProcessBackendManager and terminate all factory processes. */ -ProcessBackendManager::~ProcessBackendManager() +QProcessBackendManager::~QProcessBackendManager() { } /*! - Create a new ProcessBackend based on ProcessInfo \a info and \a parent. + Create a new QProcessBackend based on QProcessInfo \a info and \a parent. */ -ProcessBackend *ProcessBackendManager::create(const ProcessInfo& info, QObject *parent) +QProcessBackend *QProcessBackendManager::create(const QProcessInfo& info, QObject *parent) { - foreach (ProcessBackendFactory *factory, m_factories) { + foreach (QProcessBackendFactory *factory, m_factories) { if (factory->canCreate(info)) { - ProcessInfo i = info; + QProcessInfo i = info; factory->rewrite(i); return factory->create(i, parent); } @@ -158,11 +159,11 @@ ProcessBackend *ProcessBackendManager::create(const ProcessInfo& info, QObject * } /*! - Add a ProcessBackendFactory \a factory to the end of the Factory list. + Add a QProcessBackendFactory \a factory to the end of the Factory list. The factory becomes a child of the backend manager. */ -void ProcessBackendManager::addFactory(ProcessBackendFactory *factory) +void QProcessBackendManager::addFactory(QProcessBackendFactory *factory) { m_factories.append(factory); factory->setParent(this); @@ -180,7 +181,7 @@ void ProcessBackendManager::addFactory(ProcessBackendFactory *factory) Return a list of all internal processes being used by factories */ -PidList ProcessBackendManager::internalProcesses() const +QPidList QProcessBackendManager::internalProcesses() const { return m_internalProcesses; } @@ -190,11 +191,11 @@ PidList ProcessBackendManager::internalProcesses() const all factories are requested to minimize memory use. */ -void ProcessBackendManager::setMemoryRestricted(bool memoryRestricted) +void QProcessBackendManager::setMemoryRestricted(bool memoryRestricted) { if (m_memoryRestricted != memoryRestricted) { m_memoryRestricted = memoryRestricted; - foreach (ProcessBackendFactory *factory, m_factories) { + foreach (QProcessBackendFactory *factory, m_factories) { factory->setMemoryRestricted(memoryRestricted); } } @@ -204,26 +205,26 @@ void ProcessBackendManager::setMemoryRestricted(bool memoryRestricted) Return current memory restriction setting */ -bool ProcessBackendManager::memoryRestricted() const +bool QProcessBackendManager::memoryRestricted() const { return m_memoryRestricted; } /*! - Return the current IdleDelegate object + Return the current QIdleDelegate object */ -IdleDelegate *ProcessBackendManager::idleDelegate() const +QIdleDelegate *QProcessBackendManager::idleDelegate() const { return m_idleDelegate; } /*! - Set a new process IdleDelegate object \a idleDelegate. - The ProcessBackendManager takes over parentage of the IdleDelegate. + Set a new process QIdleDelegate object \a idleDelegate. + The QProcessBackendManager takes over parentage of the QIdleDelegate. */ -void ProcessBackendManager::setIdleDelegate(IdleDelegate *idleDelegate) +void QProcessBackendManager::setIdleDelegate(QIdleDelegate *idleDelegate) { if (idleDelegate != m_idleDelegate) { if (m_idleDelegate) @@ -240,7 +241,7 @@ void ProcessBackendManager::setIdleDelegate(IdleDelegate *idleDelegate) } /*! - \fn bool ProcessBackendManager::idleCpuRequest() const + \fn bool QProcessBackendManager::idleCpuRequest() const Return \c{true} if we need idle CPU cycles. */ @@ -249,9 +250,9 @@ void ProcessBackendManager::setIdleDelegate(IdleDelegate *idleDelegate) the idle CPU to the first factory that has requested it. */ -void ProcessBackendManager::idleCpuAvailable() +void QProcessBackendManager::idleCpuAvailable() { - foreach (ProcessBackendFactory *factory, m_factories) { + foreach (QProcessBackendFactory *factory, m_factories) { if (factory->idleCpuRequest()) { factory->idleCpuAvailable(); return; @@ -264,10 +265,10 @@ void ProcessBackendManager::idleCpuAvailable() the factories. */ -void ProcessBackendManager::updateIdleCpuRequest() +void QProcessBackendManager::updateIdleCpuRequest() { bool request = false; - foreach (ProcessBackendFactory *factory, m_factories) + foreach (QProcessBackendFactory *factory, m_factories) request |= factory->idleCpuRequest(); if (request != m_idleCpuRequest) { @@ -282,10 +283,10 @@ void ProcessBackendManager::updateIdleCpuRequest() Update the list of internal processes */ -void ProcessBackendManager::updateInternalProcesses() +void QProcessBackendManager::updateInternalProcesses() { QList<Q_PID> plist; - foreach (ProcessBackendFactory *factory, m_factories) + foreach (QProcessBackendFactory *factory, m_factories) plist.append(factory->internalProcesses()); qSort(plist); if (!compareSortedLists(plist, m_internalProcesses)) { @@ -299,7 +300,7 @@ void ProcessBackendManager::updateInternalProcesses() Override this function to customize your handling of Idle CPU requests. */ -void ProcessBackendManager::handleIdleCpuRequest() +void QProcessBackendManager::handleIdleCpuRequest() { } @@ -308,7 +309,7 @@ void ProcessBackendManager::handleIdleCpuRequest() list of internal processes. */ -void ProcessBackendManager::handleInternalProcessChange() +void QProcessBackendManager::handleInternalProcessChange() { } @@ -317,26 +318,26 @@ void ProcessBackendManager::handleInternalProcessChange() process \a error values. */ -void ProcessBackendManager::handleInternalProcessError(QProcess::ProcessError error) +void QProcessBackendManager::handleInternalProcessError(QProcess::ProcessError error) { Q_UNUSED(error); } /*! - \fn void ProcessBackendManager::internalProcessesChanged() + \fn void QProcessBackendManager::internalProcessesChanged() Signal emitted whenever the list of internal processes has changed. */ /*! - \fn void ProcessBackendManager::idleDelegateChanged() + \fn void QProcessBackendManager::idleDelegateChanged() Signal emitted whenever the IdleDelegate is changed. */ /*! - \fn void ProcessBackendManager::internalProcessError(QProcess::ProcessError error) + \fn void QProcessBackendManager::internalProcessError(QProcess::ProcessError error) Signal emitted when an internal process has an \a error. */ -#include "moc_processbackendmanager.cpp" +#include "moc_qprocessbackendmanager.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/processbackendmanager.h b/src/processmanager/qprocessbackendmanager.h index 2c4fcbb..136f3a2 100644 --- a/src/processmanager/processbackendmanager.h +++ b/src/processmanager/qprocessbackendmanager.h @@ -44,35 +44,35 @@ #include <QHash> #include <QProcessEnvironment> -#include "processmanager-global.h" -#include "processlist.h" +#include "qprocessmanager-global.h" +#include "qprocesslist.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class ProcessFrontend; -class ProcessInfo; -class ProcessBackendFactory; -class ProcessBackend; -class IdleDelegate; +class QProcessFrontend; +class QProcessInfo; +class QProcessBackendFactory; +class QProcessBackend; +class QIdleDelegate; -class Q_ADDON_PROCESSMANAGER_EXPORT ProcessBackendManager : public QObject +class Q_ADDON_PROCESSMANAGER_EXPORT QProcessBackendManager : public QObject { Q_OBJECT - Q_PROPERTY(IdleDelegate* idleDelegate READ idleDelegate WRITE setIdleDelegate NOTIFY idleDelegateChanged); + Q_PROPERTY(QIdleDelegate* idleDelegate READ idleDelegate WRITE setIdleDelegate NOTIFY idleDelegateChanged) public: - explicit ProcessBackendManager(QObject *parent = 0); - virtual ~ProcessBackendManager(); + explicit QProcessBackendManager(QObject *parent = 0); + virtual ~QProcessBackendManager(); - ProcessBackend *create(const ProcessInfo& info, QObject *parent=0); - void addFactory(ProcessBackendFactory *factory); - PidList internalProcesses() const; + QProcessBackend *create(const QProcessInfo& info, QObject *parent=0); + void addFactory(QProcessBackendFactory *factory); + QPidList internalProcesses() const; void setMemoryRestricted(bool); bool memoryRestricted() const; - IdleDelegate * idleDelegate() const; - void setIdleDelegate(IdleDelegate *); + QIdleDelegate * idleDelegate() const; + void setIdleDelegate(QIdleDelegate *); bool idleCpuRequest() const { return m_idleCpuRequest; } signals: @@ -93,15 +93,15 @@ private slots: void updateInternalProcesses(); private: - QList<ProcessBackendFactory*> m_factories; - PidList m_internalProcesses; - IdleDelegate *m_idleDelegate; + QList<QProcessBackendFactory*> m_factories; + QPidList m_internalProcesses; + QIdleDelegate *m_idleDelegate; bool m_memoryRestricted; bool m_idleCpuRequest; }; QT_END_NAMESPACE_PROCESSMANAGER -QT_PROCESSMANAGER_DECLARE_METATYPE_PTR(ProcessBackendManager) +QT_PROCESSMANAGER_DECLARE_METATYPE_PTR(QProcessBackendManager) #endif // PROCESS_BACKEND_MANAGER_H diff --git a/src/processmanager/processfrontend.cpp b/src/processmanager/qprocessfrontend.cpp index 5876f39..7c1cbb6 100644 --- a/src/processmanager/processfrontend.cpp +++ b/src/processmanager/qprocessfrontend.cpp @@ -37,8 +37,8 @@ ** ****************************************************************************/ -#include "processfrontend.h" -#include "processbackend.h" +#include "qprocessfrontend.h" +#include "qprocessbackend.h" #include <QDateTime> @@ -47,83 +47,84 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \class ProcessFrontend - \brief The ProcessFrontend class is a generalized representation of a process. + \class QProcessFrontend + \brief The QProcessFrontend class is a generalized representation of a process. + \inmodule QtProcessManager - The ProcessFrontend class encapsulates a process whose lifecycle is controlled by the process manager. - It is a generalized representation - in actuality, subclasses of the ProcessFrontend class are used + The QProcessFrontend class encapsulates a process whose lifecycle is controlled by the process manager. + It is a generalized representation - in actuality, subclasses of the QProcessFrontend class are used to control processes. These subclasses are used to accelerate process launching, wrap processes with additional arguments and settings, or fake the existence of a process. - The ProcessFrontend class itself cannot be instantiated. + The QProcessFrontend class itself cannot be instantiated. A process object always contains a ProcessInfo object, which is the static information used to start and execute the process. */ /*! - \property ProcessFrontend::identifier + \property QProcessFrontend::identifier \brief the application identifier of the process. */ /*! - \property ProcessFrontend::name + \property QProcessFrontend::name \brief the application name of the process. */ /*! - \property ProcessFrontend::program + \property QProcessFrontend::program \brief the filename of the binary executable that is launched to start up the process. */ /*! - \property ProcessFrontend::arguments + \property QProcessFrontend::arguments \brief the arguments that will be passed to the program upon process startup */ /*! - \property ProcessFrontend::environment + \property QProcessFrontend::environment \brief a map of the environment variables that will be used by the process */ /*! - \property ProcessFrontend::workingDirectory + \property QProcessFrontend::workingDirectory \brief the directory that will be switched to before launching the process */ /*! - \property ProcessFrontend::pid + \property QProcessFrontend::pid \brief the process id (PID) of the process. Returns 0 if the process has not been started or if this is a "fake" process. */ /*! - \property ProcessFrontend::startTime + \property QProcessFrontend::startTime \brief the start time of the process, measured in milliseconds since the epoch (1st Jan 1970 00:00). Returns 0 if process has not been started. */ /*! - \property ProcessFrontend::priority + \property QProcessFrontend::priority \brief The Unix process priority (niceness). Returns the current process priority if the process is running. Otherwise, - it returns the ProcessFrontend priority setting. You can only set the priority once the + it returns the QProcessFrontend priority setting. You can only set the priority once the process is running. */ /*! - \property ProcessFrontend::oomAdjustment + \property QProcessFrontend::oomAdjustment \brief The Unix process /proc/<pid>/oom_score_adj (likelihood of being killed) Returns the current OOM adjustment score if the process is running. Otherwise, - it returns the ProcessFrontend OOM adjustment score setting. You can only set the OOM adjustment + it returns the QProcessFrontend OOM adjustment score setting. You can only set the OOM adjustment score when the process is running. */ /*! - \property ProcessFrontend::errorString + \property QProcessFrontend::errorString \brief The human-readable string describing the last error. Returns the string describing the last error received. This is equivalent to @@ -132,10 +133,10 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! \internal - Constructs a ProcessFrontend instance with ProcessBackend \a process and optional \a parent - The ProcessFrontend takes ownership of the ProcessBackend. + Constructs a QProcessFrontend instance with QProcessBackend \a process and optional \a parent + The QProcessFrontend takes ownership of the QProcessBackend. */ -ProcessFrontend::ProcessFrontend(ProcessBackend *backend, QObject *parent) +QProcessFrontend::QProcessFrontend(QProcessBackend *backend, QObject *parent) : QObject(parent) , m_startTimeSinceEpoch(0) , m_backend(backend) @@ -158,7 +159,7 @@ ProcessFrontend::ProcessFrontend(ProcessBackend *backend, QObject *parent) Destroy this process object. */ -ProcessFrontend::~ProcessFrontend() +QProcessFrontend::~QProcessFrontend() { } @@ -166,7 +167,7 @@ ProcessFrontend::~ProcessFrontend() Return the process identifier */ -QString ProcessFrontend::identifier() const +QString QProcessFrontend::identifier() const { Q_ASSERT(m_backend); return m_backend->identifier(); @@ -176,7 +177,7 @@ QString ProcessFrontend::identifier() const Return the process name */ -QString ProcessFrontend::name() const +QString QProcessFrontend::name() const { Q_ASSERT(m_backend); return m_backend->name(); @@ -186,7 +187,7 @@ QString ProcessFrontend::name() const Return the process program */ -QString ProcessFrontend::program() const +QString QProcessFrontend::program() const { Q_ASSERT(m_backend); return m_backend->program(); @@ -196,7 +197,7 @@ QString ProcessFrontend::program() const Return the process arguments */ -QStringList ProcessFrontend::arguments() const +QStringList QProcessFrontend::arguments() const { Q_ASSERT(m_backend); return m_backend->arguments(); @@ -206,7 +207,7 @@ QStringList ProcessFrontend::arguments() const Return the process environment */ -QVariantMap ProcessFrontend::environment() const +QVariantMap QProcessFrontend::environment() const { Q_ASSERT(m_backend); return m_backend->environment(); @@ -216,7 +217,7 @@ QVariantMap ProcessFrontend::environment() const Return the process working directory */ -QString ProcessFrontend::workingDirectory() const +QString QProcessFrontend::workingDirectory() const { Q_ASSERT(m_backend); return m_backend->workingDirectory(); @@ -225,7 +226,7 @@ QString ProcessFrontend::workingDirectory() const /*! Returns the PID of this process. If the process has not started up yet properly, its PID will be 0. */ -Q_PID ProcessFrontend::pid() const +Q_PID QProcessFrontend::pid() const { Q_ASSERT(m_backend); return m_backend->pid(); @@ -236,7 +237,7 @@ Q_PID ProcessFrontend::pid() const This may be different than the desired process priority. */ -qint32 ProcessFrontend::priority() const +qint32 QProcessFrontend::priority() const { Q_ASSERT(m_backend); return m_backend->actualPriority(); @@ -246,7 +247,7 @@ qint32 ProcessFrontend::priority() const Set the process priority */ -void ProcessFrontend::setPriority(qint32 priority) +void QProcessFrontend::setPriority(qint32 priority) { Q_ASSERT(m_backend); if (priority != m_backend->desiredPriority()) { @@ -259,7 +260,7 @@ void ProcessFrontend::setPriority(qint32 priority) Return the process actual oomAdjustment */ -qint32 ProcessFrontend::oomAdjustment() const +qint32 QProcessFrontend::oomAdjustment() const { Q_ASSERT(m_backend); return m_backend->actualOomAdjustment(); @@ -270,7 +271,7 @@ qint32 ProcessFrontend::oomAdjustment() const This may be different than the actual process oomAdjustment */ -void ProcessFrontend::setOomAdjustment(qint32 oomAdjustment) +void QProcessFrontend::setOomAdjustment(qint32 oomAdjustment) { Q_ASSERT(m_backend); if (oomAdjustment != m_backend->desiredOomAdjustment()) { @@ -283,7 +284,7 @@ void ProcessFrontend::setOomAdjustment(qint32 oomAdjustment) Returns the state of the process. The base class always returns NotRunning. */ -QProcess::ProcessState ProcessFrontend::state() const +QProcess::ProcessState QProcessFrontend::state() const { Q_ASSERT(m_backend); return m_backend->state(); @@ -301,7 +302,7 @@ QProcess::ProcessState ProcessFrontend::state() const \sa started() \sa error() */ -void ProcessFrontend::start() +void QProcessFrontend::start() { if (state() == QProcess::NotRunning) { Q_ASSERT(m_backend); @@ -318,7 +319,7 @@ void ProcessFrontend::start() \sa finished() */ -void ProcessFrontend::stop(int timeout) +void QProcessFrontend::stop(int timeout) { Q_ASSERT(m_backend); emit aboutToStop(); @@ -330,7 +331,7 @@ void ProcessFrontend::stop(int timeout) Returns the number of bytes that were actually written, or -1 if an error occurred. */ -qint64 ProcessFrontend::write(const char *data, qint64 maxSize) +qint64 QProcessFrontend::write(const char *data, qint64 maxSize) { return m_backend->write(data, maxSize); } @@ -341,11 +342,11 @@ qint64 ProcessFrontend::write(const char *data, qint64 maxSize) This is equivalent to \code - ProcessFrontend::write(data, qstrlen(data)); + QProcessFrontend::write(data, qstrlen(data)); \endcode */ -qint64 ProcessFrontend::write(const char *data) +qint64 QProcessFrontend::write(const char *data) { return m_backend->write(data, qstrlen(data)); } @@ -355,7 +356,7 @@ qint64 ProcessFrontend::write(const char *data) Returns the number of bytes that were actually written, or -1 if an error occurred. */ -qint64 ProcessFrontend::write(const QByteArray& byteArray) +qint64 QProcessFrontend::write(const QByteArray& byteArray) { return m_backend->write(byteArray.data(), byteArray.length()); } @@ -363,7 +364,7 @@ qint64 ProcessFrontend::write(const QByteArray& byteArray) /*! Returns the start time of the process, measured in milliseconds since the epoch (1st Jan 1970 00:00). */ -qint64 ProcessFrontend::startTime() const +qint64 QProcessFrontend::startTime() const { return m_startTimeSinceEpoch; } @@ -372,9 +373,9 @@ qint64 ProcessFrontend::startTime() const Returns the ProcessInfo object as a QVariantMap. If you use this method to retrieve the ProcessInfo content from the C++ side, you can - wrap it around ProcessInfo() object for convenience. + wrap it around QProcessInfo() object for convenience. */ -QVariantMap ProcessFrontend::processInfo() const +QVariantMap QProcessFrontend::processInfo() const { return m_backend->processInfo().toMap(); } @@ -383,7 +384,7 @@ QVariantMap ProcessFrontend::processInfo() const Handle a started() signal from the backend. The default implementation emits the started() signal. */ -void ProcessFrontend::handleStarted() +void QProcessFrontend::handleStarted() { emit started(); } @@ -392,7 +393,7 @@ void ProcessFrontend::handleStarted() Handle an error() signal from the backend with \a processError. The default implementation emits the error signal. */ -void ProcessFrontend::handleError(QProcess::ProcessError processError) +void QProcessFrontend::handleError(QProcess::ProcessError processError) { emit error(processError); } @@ -401,7 +402,7 @@ void ProcessFrontend::handleError(QProcess::ProcessError processError) Handle a finished() signal from the backend with \a exitCode and \a exitStatus. The default implementation emits the finished() signal */ -void ProcessFrontend::handleFinished(int exitCode, QProcess::ExitStatus exitStatus) +void QProcessFrontend::handleFinished(int exitCode, QProcess::ExitStatus exitStatus) { emit finished(exitCode, exitStatus); } @@ -410,7 +411,7 @@ void ProcessFrontend::handleFinished(int exitCode, QProcess::ExitStatus exitStat Handle a stateChange() signal from the backend with \a state. The default implementation emits the stateChanged() signal */ -void ProcessFrontend::handleStateChanged(QProcess::ProcessState state) +void QProcessFrontend::handleStateChanged(QProcess::ProcessState state) { emit stateChanged(state); } @@ -418,7 +419,7 @@ void ProcessFrontend::handleStateChanged(QProcess::ProcessState state) /*! Handle stdout \a data received from the process. */ -void ProcessFrontend::handleStandardOutput(const QByteArray& data) +void QProcessFrontend::handleStandardOutput(const QByteArray& data) { emit standardOutput(data); } @@ -426,7 +427,7 @@ void ProcessFrontend::handleStandardOutput(const QByteArray& data) /*! Handle stderr \a data received from the process. */ -void ProcessFrontend::handleStandardError(const QByteArray& data) +void QProcessFrontend::handleStandardError(const QByteArray& data) { emit standardError(data); } @@ -434,34 +435,34 @@ void ProcessFrontend::handleStandardError(const QByteArray& data) /*! Returns the backend object for this process. */ -ProcessBackend *ProcessFrontend::backend() const +QProcessBackend *QProcessFrontend::backend() const { return m_backend; } /*! - \fn void ProcessFrontend::aboutToStart() + \fn void QProcessFrontend::aboutToStart() This signal is emitted by start() just before the process starts running. */ /*! - \fn void ProcessFrontend::aboutToStop() + \fn void QProcessFrontend::aboutToStop() This signal is emitted by stop() just before the process is stopped. */ /*! - \fn void ProcessFrontend::started() - This signal is emitted when the proces has started successfully. + \fn void QProcessFrontend::started() + This signal is emitted when the process has started successfully. */ /*! - \fn void ProcessFrontend::error(QProcess::ProcessError error) + \fn void QProcessFrontend::error(QProcess::ProcessError error) This signal is emitted when the process has failed to start or has another \a error. */ /*! - \fn void ProcessFrontend::finished(int exitCode, QProcess::ExitStatus exitStatus) + \fn void QProcessFrontend::finished(int exitCode, QProcess::ExitStatus exitStatus) This signal is emitted when the process has stopped and its execution is over. The \a exitStatus tells you how the process exited; the \a exitCode is the return value of the process. @@ -472,28 +473,28 @@ ProcessBackend *ProcessFrontend::backend() const */ /*! - \fn void ProcessFrontend::stateChanged(QProcess::ProcessState newState) + \fn void QProcessFrontend::stateChanged(QProcess::ProcessState newState) This signal is emitted whenever the state of QProcess changes. The \a newState argument is the state the internal QProcess changed to. */ /*! - \fn void ProcessFrontend::standardOutput(const QByteArray& data) + \fn void QProcessFrontend::standardOutput(const QByteArray& data) This signal is emitted whenever \a data is received from the stdout of the process. */ /*! - \fn void ProcessFrontend::standardError(const QByteArray& data) + \fn void QProcessFrontend::standardError(const QByteArray& data) This signal is emitted whenever \a data is received from the stderr of the process. */ /*! - \fn void ProcessFrontend::priorityChanged() + \fn void QProcessFrontend::priorityChanged() This signal is emitted when the process priority has been changed for a running process. */ /*! - \fn void ProcessFrontend::oomAdjustmentChanged() + \fn void QProcessFrontend::oomAdjustmentChanged() This signal is emitted when the process oomAdjustment has been changed for a running process. Only applicable under Linux. */ @@ -502,11 +503,11 @@ ProcessBackend *ProcessFrontend::backend() const Returns a human-readable description of the last device error that occurred. */ -QString ProcessFrontend::errorString() const +QString QProcessFrontend::errorString() const { return m_backend->errorString(); } -#include "moc_processfrontend.cpp" +#include "moc_qprocessfrontend.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/processfrontend.h b/src/processmanager/qprocessfrontend.h index 6f7f231..24c1c02 100644 --- a/src/processmanager/processfrontend.h +++ b/src/processmanager/qprocessfrontend.h @@ -42,15 +42,15 @@ #define PROCESS_FRONTEND_H #include <QObject> -#include "processinfo.h" +#include "qprocessinfo.h" -#include "processmanager-global.h" +#include "qprocessmanager-global.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class ProcessBackend; +class QProcessBackend; -class Q_ADDON_PROCESSMANAGER_EXPORT ProcessFrontend : public QObject +class Q_ADDON_PROCESSMANAGER_EXPORT QProcessFrontend : public QObject { Q_OBJECT @@ -70,7 +70,7 @@ class Q_ADDON_PROCESSMANAGER_EXPORT ProcessFrontend : public QObject Q_PROPERTY(QString errorString READ errorString) public: - virtual ~ProcessFrontend(); + virtual ~QProcessFrontend(); QString identifier() const; QString name() const; @@ -122,8 +122,8 @@ protected slots: void handleStateChanged(QProcess::ProcessState); protected: - ProcessFrontend(ProcessBackend *backend, QObject *parent=0); - ProcessBackend *backend() const; + QProcessFrontend(QProcessBackend *backend, QObject *parent=0); + QProcessBackend *backend() const; private slots: void handleStandardOutput(const QByteArray&); @@ -133,14 +133,14 @@ protected: qint64 m_startTimeSinceEpoch; private: - ProcessBackend *m_backend; + QProcessBackend *m_backend; - friend class ProcessManager; + friend class QProcessManager; }; QT_END_NAMESPACE_PROCESSMANAGER -QT_PROCESSMANAGER_DECLARE_METATYPE_PTR(ProcessFrontend) -QT_PROCESSMANAGER_DECLARE_METATYPE_CONST_PTR(ProcessFrontend) +QT_PROCESSMANAGER_DECLARE_METATYPE_PTR(QProcessFrontend) +QT_PROCESSMANAGER_DECLARE_METATYPE_CONST_PTR(QProcessFrontend) #endif // PROCESS_FRONTEND_H diff --git a/src/processmanager/processinfo.cpp b/src/processmanager/qprocessinfo.cpp index ba37fa5..4073f5b 100644 --- a/src/processmanager/processinfo.cpp +++ b/src/processmanager/qprocessinfo.cpp @@ -37,23 +37,25 @@ ** ****************************************************************************/ -#include "processinfo.h" +#include "qprocessinfo.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \namespace ProcessInfoConstants - \target ProcessInfoConstants Namespace + \namespace QProcessInfoConstants + \target QProcessInfoConstants Namespace - \brief The ProcessInfoConstants namespace contains constant strings for ProcessInfo. + \brief The QProcessInfoConstants namespace contains constant strings for ProcessInfo. + \inmodule QtProcessManager */ /*! - \class ProcessInfo - \brief The ProcessInfo class is the set of information necessary to start a new process running. + \class QProcessInfo + \brief The QProcessInfo class is the set of information necessary to start a new process running. + \inmodule QtProcessManager - The ProcessInfo is internally implemented as a simple QVariantMap with a set of pre-defined - keys. This intentionally allows the ProcessInfo to be extended by the user without + The QProcessInfo is internally implemented as a simple QVariantMap with a set of pre-defined + keys. This intentionally allows the QProcessInfo to be extended by the user without changing the API. The predefined keys are: \list @@ -70,94 +72,98 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER */ /*! - \property ProcessInfo::identifier + \property QProcessInfo::identifier \brief the application identifier of the process. The identifier is used to construct a unique name. */ /*! - \property ProcessInfo::program + \property QProcessInfo::program \brief the filename of the binary executable that is launched to start up the process. */ /*! - \property ProcessInfo::arguments + \property QProcessInfo::arguments \brief the arguments that will be passed to the program upon process startup */ /*! - \property ProcessInfo::environment + \property QProcessInfo::environment \brief a map of the environment variables that will be used by the process */ /*! - \property ProcessInfo::workingDirectory + \property QProcessInfo::workingDirectory \brief the directory that will be switched to before launching the process */ /*! - \property ProcessInfo::uid + \property QProcessInfo::uid \brief the user id (uid) of the process. */ /*! - \property ProcessInfo::gid + \property QProcessInfo::gid \brief the group id (gid) of the process. */ /*! - \property ProcessInfo::umask + \property QProcessInfo::umask \brief the default umask of the process. */ /*! - \property ProcessInfo::priority + \property QProcessInfo::priority \brief the Unix priority "niceness" that the program will run at. */ /*! - \property ProcessInfo::oomAdjustment + \property QProcessInfo::oomAdjustment \brief the Unix OOM adjustment that programs run at (+1000 = kill me first) */ /*! - \property ProcessInfo::startOutputPattern + \property QProcessInfo::startOutputPattern \brief the start output pattern is QByteArray of a line to match. */ +/*! + \property QProcessInfo::dropCapabilities + \brief the capabilities that the process will drop after startup. +*/ /*! - Constructs a ProcessInfo instance with optional \a parent. + Constructs a QProcessInfo instance with optional \a parent. */ -ProcessInfo::ProcessInfo(QObject *parent) +QProcessInfo::QProcessInfo(QObject *parent) : QObject(parent) { } /*! - Copy constructor for ProcessInfo from \a other + Copy constructor for QProcessInfo from \a other */ -ProcessInfo::ProcessInfo(const ProcessInfo &other) +QProcessInfo::QProcessInfo(const QProcessInfo &other) : QObject(other.parent()) , m_info(other.m_info) { } /*! - Copy constructor for ProcessInfo from \a map + Copy constructor for QProcessInfo from \a map */ -ProcessInfo::ProcessInfo(const QVariantMap& map) +QProcessInfo::QProcessInfo(const QVariantMap& map) : m_info(map) { } /*! - Assignment constructor for ProcessInfo from \a other + Assignment constructor for QProcessInfo from \a other */ -ProcessInfo &ProcessInfo::operator =(const ProcessInfo &other) +QProcessInfo &QProcessInfo::operator =(const QProcessInfo &other) { m_info = other.m_info; return *this; @@ -168,79 +174,79 @@ ProcessInfo &ProcessInfo::operator =(const ProcessInfo &other) is used to construct a unique name for the process. */ -QString ProcessInfo::identifier() const +QString QProcessInfo::identifier() const { - return m_info.value(ProcessInfoConstants::Identifier).toString(); + return m_info.value(QProcessInfoConstants::Identifier).toString(); } /*! Set the application identifier of this process. */ -void ProcessInfo::setIdentifier(const QString &identifier) +void QProcessInfo::setIdentifier(const QString &identifier) { - setValue(ProcessInfoConstants::Identifier, identifier); + setValue(QProcessInfoConstants::Identifier, identifier); } /*! Returns the filename of the binary executable that is launched. */ -QString ProcessInfo::program() const +QString QProcessInfo::program() const { - return m_info.value(ProcessInfoConstants::Program).toString(); + return m_info.value(QProcessInfoConstants::Program).toString(); } /*! Set the filename of the binary executable to be launched. */ -void ProcessInfo::setProgram(const QString &program) +void QProcessInfo::setProgram(const QString &program) { - m_info.insert(ProcessInfoConstants::Program, program); + m_info.insert(QProcessInfoConstants::Program, program); } /*! Return the argument list. */ -QStringList ProcessInfo::arguments() const +QStringList QProcessInfo::arguments() const { - return m_info.value(ProcessInfoConstants::Arguments).toStringList(); + return m_info.value(QProcessInfoConstants::Arguments).toStringList(); } /*! Set the argument list to be passed to the program */ -void ProcessInfo::setArguments(const QStringList &argumentList) +void QProcessInfo::setArguments(const QStringList &argumentList) { - setValue(ProcessInfoConstants::Arguments, argumentList); + setValue(QProcessInfoConstants::Arguments, argumentList); } /*! Return the environment map */ -QVariantMap ProcessInfo::environment() const +QVariantMap QProcessInfo::environment() const { - return m_info.value(ProcessInfoConstants::Environment).toMap(); + return m_info.value(QProcessInfoConstants::Environment).toMap(); } /*! Set the environment map */ -void ProcessInfo::setEnvironment(const QVariantMap &environmentToSet) +void QProcessInfo::setEnvironment(const QVariantMap &environmentToSet) { - setValue(ProcessInfoConstants::Environment, environmentToSet); + setValue(QProcessInfoConstants::Environment, environmentToSet); } /*! Set the environment map using a QProcessEnvironment */ -void ProcessInfo::setEnvironment(const QProcessEnvironment &environment) +void QProcessInfo::setEnvironment(const QProcessEnvironment &environment) { QVariantMap env; QStringList keys = environment.keys(); @@ -249,25 +255,25 @@ void ProcessInfo::setEnvironment(const QProcessEnvironment &environment) env.insert(envKey, environment.value(envKey)); } - setValue(ProcessInfoConstants::Environment, env); + setValue(QProcessInfoConstants::Environment, env); } /*! Return the process working directory */ -QString ProcessInfo::workingDirectory() const +QString QProcessInfo::workingDirectory() const { - return m_info.value(ProcessInfoConstants::WorkingDirectory).toString(); + return m_info.value(QProcessInfoConstants::WorkingDirectory).toString(); } /*! Set the process working directory */ -void ProcessInfo::setWorkingDirectory(const QString &workingDir) +void QProcessInfo::setWorkingDirectory(const QString &workingDir) { - setValue(ProcessInfoConstants::WorkingDirectory, workingDir); + setValue(QProcessInfoConstants::WorkingDirectory, workingDir); } /*! @@ -276,18 +282,18 @@ void ProcessInfo::setWorkingDirectory(const QString &workingDir) Initializing this value to -1 will result in it being set to the process manager's uid. */ -qint64 ProcessInfo::uid() const +qint64 QProcessInfo::uid() const { - return m_info.value(ProcessInfoConstants::Uid).toLongLong(); + return m_info.value(QProcessInfoConstants::Uid).toLongLong(); } /*! Set the process UID */ -void ProcessInfo::setUid(qint64 newUid) +void QProcessInfo::setUid(qint64 newUid) { - setValue(ProcessInfoConstants::Uid, newUid); + setValue(QProcessInfoConstants::Uid, newUid); } /*! @@ -297,27 +303,27 @@ void ProcessInfo::setUid(qint64 newUid) set to the process manager's gid. */ -qint64 ProcessInfo::gid() const +qint64 QProcessInfo::gid() const { - return m_info.value(ProcessInfoConstants::Gid).toLongLong(); + return m_info.value(QProcessInfoConstants::Gid).toLongLong(); } /*! Set the process GID */ -void ProcessInfo::setGid(qint64 newGid) +void QProcessInfo::setGid(qint64 newGid) { - setValue(ProcessInfoConstants::Gid, newGid); + setValue(QProcessInfoConstants::Gid, newGid); } /*! Return the process default umask */ -qint64 ProcessInfo::umask() const +qint64 QProcessInfo::umask() const { - return m_info.value(ProcessInfoConstants::Umask).toLongLong(); + return m_info.value(QProcessInfoConstants::Umask).toLongLong(); } /*! @@ -327,18 +333,18 @@ qint64 ProcessInfo::umask() const process inheriting its parent's umask. */ -void ProcessInfo::setUmask(qint64 newUmask) +void QProcessInfo::setUmask(qint64 newUmask) { - setValue(ProcessInfoConstants::Umask, newUmask); + setValue(QProcessInfoConstants::Umask, newUmask); } /*! Return the capabilities that the process will drop */ -qint64 ProcessInfo::dropCapabilities() const +qint64 QProcessInfo::dropCapabilities() const { - return m_info.value(ProcessInfoConstants::DropCapabilities).toLongLong(); + return m_info.value(QProcessInfoConstants::DropCapabilities).toLongLong(); } /*! @@ -348,27 +354,27 @@ qint64 ProcessInfo::dropCapabilities() const process not dropping any capabilities. */ -void ProcessInfo::setDropCapabilities(qint64 dropCapabilities) +void QProcessInfo::setDropCapabilities(qint64 dropCapabilities) { - setValue(ProcessInfoConstants::DropCapabilities, dropCapabilities); + setValue(QProcessInfoConstants::DropCapabilities, dropCapabilities); } /*! Return the process priority */ -int ProcessInfo::priority() const +int QProcessInfo::priority() const { - return m_info.value(ProcessInfoConstants::Priority).toDouble(); + return m_info.value(QProcessInfoConstants::Priority).toDouble(); } /*! Return the OOM adjustment value */ -int ProcessInfo::oomAdjustment() const +int QProcessInfo::oomAdjustment() const { - return m_info.value(ProcessInfoConstants::OomAdjustment).toDouble(); + return m_info.value(QProcessInfoConstants::OomAdjustment).toDouble(); } /*! @@ -378,15 +384,15 @@ int ProcessInfo::oomAdjustment() const can vary based on the type of Unix system. A priority of -20 delivers most of the CPU to this process; a priority of +19 is the lowest and means that this process will be starved unless - nothing else is going on in the sytem. + nothing else is going on in the system. We do not do any checking on the value set for process priority. */ -void ProcessInfo::setPriority(int newPriority) +void QProcessInfo::setPriority(int newPriority) { if (newPriority != priority()) { - setValue(ProcessInfoConstants::Priority, newPriority); + setValue(QProcessInfoConstants::Priority, newPriority); emit priorityChanged(); } } @@ -403,10 +409,10 @@ void ProcessInfo::setPriority(int newPriority) We do not do any checking on the value set for process priority. */ -void ProcessInfo::setOomAdjustment(int newOomAdjustment) +void QProcessInfo::setOomAdjustment(int newOomAdjustment) { if (newOomAdjustment != oomAdjustment()) { - setValue(ProcessInfoConstants::OomAdjustment, newOomAdjustment); + setValue(QProcessInfoConstants::OomAdjustment, newOomAdjustment); emit oomAdjustmentChanged(); } } @@ -416,9 +422,9 @@ void ProcessInfo::setOomAdjustment(int newOomAdjustment) \sa setStartOutputPattern */ -QByteArray ProcessInfo::startOutputPattern() const +QByteArray QProcessInfo::startOutputPattern() const { - return m_info.value(ProcessInfoConstants::StartOutputPattern).toByteArray(); + return m_info.value(QProcessInfoConstants::StartOutputPattern).toByteArray(); } /*! @@ -428,15 +434,15 @@ QByteArray ProcessInfo::startOutputPattern() const it considers itself ready. Typically, a process is ready after it has started up and performed its initialization successfully. */ -void ProcessInfo::setStartOutputPattern(const QByteArray &outputPattern) +void QProcessInfo::setStartOutputPattern(const QByteArray &outputPattern) { - setValue(ProcessInfoConstants::StartOutputPattern, outputPattern); + setValue(QProcessInfoConstants::StartOutputPattern, outputPattern); } /*! - Returns the keys for which values have been set in this ProcessInfo object. + Returns the keys for which values have been set in this QProcessInfo object. */ -QStringList ProcessInfo::keys() const +QStringList QProcessInfo::keys() const { return m_info.keys(); } @@ -445,7 +451,7 @@ QStringList ProcessInfo::keys() const Return true if a value has been set for this \a key */ -bool ProcessInfo::contains(const QString &key) const +bool QProcessInfo::contains(const QString &key) const { return m_info.contains(key); } @@ -454,7 +460,7 @@ bool ProcessInfo::contains(const QString &key) const Return the value of this \a key */ -QVariant ProcessInfo::value(const QString &key) const +QVariant QProcessInfo::value(const QString &key) const { return m_info.value(key); } @@ -463,7 +469,7 @@ QVariant ProcessInfo::value(const QString &key) const Set \a key to \a value and emit appropriate change signals */ -void ProcessInfo::setValue(const QString &key, const QVariant &value) +void QProcessInfo::setValue(const QString &key, const QVariant &value) { if (key.isEmpty()) return; @@ -476,11 +482,11 @@ void ProcessInfo::setValue(const QString &key, const QVariant &value) } /*! - Sets the data provided by this ProcessInfo object to \a data. + Sets the data provided by this QProcessInfo object to \a data. Overwrites all existing values. */ -void ProcessInfo::setData(const QVariantMap &data) +void QProcessInfo::setData(const QVariantMap &data) { m_info = data; } @@ -492,7 +498,7 @@ void ProcessInfo::setData(const QVariantMap &data) original data. Leaves existing values with keys not contained by \a data untouched. */ -void ProcessInfo::insert(const QVariantMap &data) +void QProcessInfo::insert(const QVariantMap &data) { QStringList keys = data.keys(); foreach (const QString &key, keys) { @@ -501,9 +507,9 @@ void ProcessInfo::insert(const QVariantMap &data) } /*! - Return the ProcessInfo object as a QVariantMap + Return the QProcessInfo object as a QVariantMap */ -QVariantMap ProcessInfo::toMap() const +QVariantMap QProcessInfo::toMap() const { return m_info; } @@ -512,31 +518,31 @@ QVariantMap ProcessInfo::toMap() const \internal */ -void ProcessInfo::emitChangeSignal(const QString &key) +void QProcessInfo::emitChangeSignal(const QString &key) { - if (key == ProcessInfoConstants::Identifier) { + if (key == QProcessInfoConstants::Identifier) { emit identifierChanged(); - } else if (key == ProcessInfoConstants::Program) { + } else if (key == QProcessInfoConstants::Program) { emit programChanged(); - } else if (key == ProcessInfoConstants::Arguments) { + } else if (key == QProcessInfoConstants::Arguments) { emit argumentsChanged(); - } else if (key == ProcessInfoConstants::Environment) { + } else if (key == QProcessInfoConstants::Environment) { emit environmentChanged(); - } else if (key == ProcessInfoConstants::WorkingDirectory) { + } else if (key == QProcessInfoConstants::WorkingDirectory) { emit workingDirectoryChanged(); - } else if (key == ProcessInfoConstants::Uid) { + } else if (key == QProcessInfoConstants::Uid) { emit uidChanged(); - } else if (key == ProcessInfoConstants::Gid) { + } else if (key == QProcessInfoConstants::Gid) { emit gidChanged(); - } else if (key == ProcessInfoConstants::Umask) { + } else if (key == QProcessInfoConstants::Umask) { emit umaskChanged(); - } else if (key == ProcessInfoConstants::DropCapabilities) { + } else if (key == QProcessInfoConstants::DropCapabilities) { emit dropCapabilitiesChanged(); - } else if (key == ProcessInfoConstants::Priority) { + } else if (key == QProcessInfoConstants::Priority) { emit priorityChanged(); - } else if (key == ProcessInfoConstants::OomAdjustment) { + } else if (key == QProcessInfoConstants::OomAdjustment) { emit oomAdjustmentChanged(); - } else if (key == ProcessInfoConstants::StartOutputPattern) { + } else if (key == QProcessInfoConstants::StartOutputPattern) { emit startOutputPatternChanged(); } } @@ -545,7 +551,7 @@ void ProcessInfo::emitChangeSignal(const QString &key) Add \a newEnvironment to the current environment settings. */ -void ProcessInfo::insertEnvironment(const QVariantMap &newEnvironment) +void QProcessInfo::insertEnvironment(const QVariantMap &newEnvironment) { QVariantMap env = environment(); QMapIterator<QString, QVariant> it(newEnvironment); @@ -557,46 +563,46 @@ void ProcessInfo::insertEnvironment(const QVariantMap &newEnvironment) } /*! - \fn void ProcessInfo::identifierChanged() + \fn void QProcessInfo::identifierChanged() This signal is emitted when the process Identifier has been changed */ /*! - \fn void ProcessInfo::programChanged() + \fn void QProcessInfo::programChanged() This signal is emitted when the process Program has been changed */ /*! - \fn void ProcessInfo::argumentsChanged() + \fn void QProcessInfo::argumentsChanged() This signal is emitted when the process Arguments has been changed */ /*! - \fn void ProcessInfo::environmentChanged() + \fn void QProcessInfo::environmentChanged() This signal is emitted when the process Environment has been changed */ /*! - \fn void ProcessInfo::workingDirectoryChanged() + \fn void QProcessInfo::workingDirectoryChanged() This signal is emitted when the process WorkingDirectory has been changed */ /*! - \fn void ProcessInfo::uidChanged() + \fn void QProcessInfo::uidChanged() This signal is emitted when the process UID has been changed */ /*! - \fn void ProcessInfo::gidChanged() + \fn void QProcessInfo::gidChanged() This signal is emitted when the process GID has been changed */ /*! - \fn void ProcessInfo::priorityChanged() + \fn void QProcessInfo::priorityChanged() This signal is emitted when the process Priority has been changed */ /*! - \fn void ProcessInfo::oomAdjustmentChanged() + \fn void QProcessInfo::oomAdjustmentChanged() This signal is emitted when the process OOM adjustment has been changed */ /*! - \fn void ProcessInfo::startOutputPatternChanged() + \fn void QProcessInfo::startOutputPatternChanged() This signal is emitted when the startOutputPattern has been changed. */ -#include "moc_processinfo.cpp" +#include "moc_qprocessinfo.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/processinfo.h b/src/processmanager/qprocessinfo.h index 38721f7..12cca30 100644 --- a/src/processmanager/processinfo.h +++ b/src/processmanager/qprocessinfo.h @@ -45,11 +45,11 @@ #include <QStringList> #include <QProcessEnvironment> -#include "processmanager-global.h" +#include "qprocessmanager-global.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -namespace ProcessInfoConstants { +namespace QProcessInfoConstants { const QLatin1String Identifier = QLatin1String("identifier"); const QLatin1String Program = QLatin1String("program"); const QLatin1String Arguments = QLatin1String("arguments"); @@ -64,7 +64,7 @@ const QLatin1String OomAdjustment = QLatin1String("oomAdjustment"); const QLatin1String StartOutputPattern = QLatin1String("startOutputPattern"); } -class Q_ADDON_PROCESSMANAGER_EXPORT ProcessInfo : public QObject +class Q_ADDON_PROCESSMANAGER_EXPORT QProcessInfo : public QObject { Q_OBJECT Q_PROPERTY(QString identifier READ identifier WRITE setIdentifier NOTIFY identifierChanged) @@ -80,10 +80,10 @@ class Q_ADDON_PROCESSMANAGER_EXPORT ProcessInfo : public QObject Q_PROPERTY(int oomAdjustment READ oomAdjustment WRITE setOomAdjustment NOTIFY oomAdjustmentChanged) Q_PROPERTY(QByteArray startOutputPattern READ startOutputPattern WRITE setStartOutputPattern NOTIFY startOutputPatternChanged) public: - explicit ProcessInfo(QObject *parent = 0); - ProcessInfo(const ProcessInfo &other); - ProcessInfo(const QVariantMap& map); - ProcessInfo &operator =(const ProcessInfo &other); + explicit QProcessInfo(QObject *parent = 0); + QProcessInfo(const QProcessInfo &other); + QProcessInfo(const QVariantMap& map); + QProcessInfo &operator =(const QProcessInfo &other); QString identifier() const; void setIdentifier(const QString &identifier); @@ -156,6 +156,6 @@ private: QT_END_NAMESPACE_PROCESSMANAGER -QT_PROCESSMANAGER_DECLARE_METATYPE_PTR(ProcessInfo) +QT_PROCESSMANAGER_DECLARE_METATYPE_PTR(QProcessInfo) #endif // PROCESSINFO_H diff --git a/src/processmanager/processlist.h b/src/processmanager/qprocesslist.h index c96a618..d6d4a54 100644 --- a/src/processmanager/processlist.h +++ b/src/processmanager/qprocesslist.h @@ -44,13 +44,13 @@ #include <QProcess> #include <QJsonArray> -#include "processmanager-global.h" +#include "qprocessmanager-global.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -typedef QList<Q_PID> PidList; +typedef QList<Q_PID> QPidList; -inline bool compareSortedLists(const PidList& a, const PidList& b) +inline bool compareSortedLists(const QPidList& a, const QPidList& b) { if (a.size() != b.size()) return false; @@ -60,7 +60,7 @@ inline bool compareSortedLists(const PidList& a, const PidList& b) return true; } -inline QJsonArray pidListToArray(const PidList& plist) +inline QJsonArray pidListToArray(const QPidList& plist) { QJsonArray array; foreach (Q_PID pid, plist) @@ -68,9 +68,9 @@ inline QJsonArray pidListToArray(const PidList& plist) return array; } -inline PidList arrayToPidList(const QJsonArray& array) +inline QPidList arrayToPidList(const QJsonArray& array) { - PidList plist; + QPidList plist; for (int i = 0 ; i < array.size() ; i++) plist.append((int) array.at(i).toDouble()); return plist; diff --git a/src/processmanager/processmanager-global.h b/src/processmanager/qprocessmanager-global.h index 59be0bf..110acec 100644 --- a/src/processmanager/processmanager-global.h +++ b/src/processmanager/qprocessmanager-global.h @@ -50,19 +50,19 @@ #endif #if defined(QT_NAMESPACE) -# define QT_BEGIN_NAMESPACE_PROCESSMANAGER namespace QT_NAMESPACE { namespace QtAddOn { namespace ProcessManager { +# define QT_BEGIN_NAMESPACE_PROCESSMANAGER namespace QT_NAMESPACE { namespace QtAddOn { namespace QtProcessManager { # define QT_END_NAMESPACE_PROCESSMANAGER } } } -# define QT_USE_NAMESPACE_PROCESSMANAGER using namespace QT_NAMESPACE::QtAddOn::ProcessManager; -# define QT_PREPEND_NAMESPACE_PROCESSMANAGER(name) ::QT_NAMESPACE::QtAddOn::ProcessManager::name +# define QT_USE_NAMESPACE_PROCESSMANAGER using namespace QT_NAMESPACE::QtAddOn::QtProcessManager; +# define QT_PREPEND_NAMESPACE_PROCESSMANAGER(name) ::QT_NAMESPACE::QtAddOn::QtProcessManager::name #else -# define QT_BEGIN_NAMESPACE_PROCESSMANAGER namespace QtAddOn { namespace ProcessManager { +# define QT_BEGIN_NAMESPACE_PROCESSMANAGER namespace QtAddOn { namespace QtProcessManager { # define QT_END_NAMESPACE_PROCESSMANAGER } } -# define QT_USE_NAMESPACE_PROCESSMANAGER using namespace QtAddOn::ProcessManager; -# define QT_PREPEND_NAMESPACE_PROCESSMANAGER(name) ::QtAddOn::ProcessManager::name +# define QT_USE_NAMESPACE_PROCESSMANAGER using namespace QtAddOn::QtProcessManager; +# define QT_PREPEND_NAMESPACE_PROCESSMANAGER(name) ::QtAddOn::QtProcessManager::name #endif -#define QT_PROCESSMANAGER_DECLARE_METATYPE_PTR(name) Q_DECLARE_METATYPE(QtAddOn::ProcessManager::name *) -#define QT_PROCESSMANAGER_DECLARE_METATYPE_CONST_PTR(name) Q_DECLARE_METATYPE(const QtAddOn::ProcessManager::name *) +#define QT_PROCESSMANAGER_DECLARE_METATYPE_PTR(name) Q_DECLARE_METATYPE(QtAddOn::QtProcessManager::name *) +#define QT_PROCESSMANAGER_DECLARE_METATYPE_CONST_PTR(name) Q_DECLARE_METATYPE(const QtAddOn::QtProcessManager::name *) // a workaround for moc - if there is a header file that doesn't use processmanager // namespace, we still force moc to do "using namespace" but the namespace have to diff --git a/src/processmanager/processmanager.cpp b/src/processmanager/qprocessmanager.cpp index ac49d23..f6be13f 100644 --- a/src/processmanager/processmanager.cpp +++ b/src/processmanager/qprocessmanager.cpp @@ -37,64 +37,65 @@ ** ****************************************************************************/ -#include "processmanager.h" -#include "processfrontend.h" -#include "processbackendfactory.h" -#include "processbackendmanager.h" -#include "processbackend.h" +#include "qprocessmanager.h" +#include "qprocessfrontend.h" +#include "qprocessbackendfactory.h" +#include "qprocessbackendmanager.h" +#include "qprocessbackend.h" #include <QDebug> QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \class ProcessManager - \brief The ProcessManager class encapsulates ways of creating and tracking processes. + \class QProcessManager + \brief The QProcessManager class encapsulates ways of creating and tracking processes. + \inmodule QtProcessManager */ /*! - \property ProcessManager::memoryRestricted + \property QProcessManager::memoryRestricted \brief the current setting of memory restriction */ /*! - \property ProcessManager::idleDelegate + \property QProcessManager::idleDelegate \brief The IdleDelegate object assigned to this factory. */ /*! - Construct a ProcessManager with an optional \a parent + Construct a QProcessManager with an optional \a parent */ -ProcessManager::ProcessManager(QObject *parent) +QProcessManager::QProcessManager(QObject *parent) : QObject(parent) { - m_backend = new ProcessBackendManager(this); + m_backend = new QProcessBackendManager(this); connect(m_backend, SIGNAL(internalProcessesChanged()), SIGNAL(internalProcessesChanged())); connect(m_backend, SIGNAL(internalProcessError(QProcess::ProcessError)), SIGNAL(internalProcessError(QProcess::ProcessError))); } /*! - Delete the ProcessManager and terminate all processes - The ProcessManager is the parent of all factories and process frontends. + Delete the QProcessManager and terminate all processes + The QProcessManager is the parent of all factories and process frontends. */ -ProcessManager::~ProcessManager() +QProcessManager::~QProcessManager() { } /*! - Create a new ProcessFrontend based on ProcessInfo \a info - The parent of the ProcessFrontend is the ProcessManager. + Create a new QProcessFrontend based on QProcessInfo \a info + The parent of the QProcessFrontend is the QProcessManager. */ -ProcessFrontend *ProcessManager::create(const ProcessInfo& info) +QProcessFrontend *QProcessManager::create(const QProcessInfo& info) { - ProcessBackend *backend = m_backend->create(info); + QProcessBackend *backend = m_backend->create(info); if (!backend) return NULL; - ProcessFrontend *frontend = createFrontend(backend); + QProcessFrontend *frontend = createFrontend(backend); frontend->setParent(this); m_processlist.append(frontend); connect(frontend, SIGNAL(aboutToStart()), SLOT(processFrontendAboutToStart())); @@ -110,36 +111,36 @@ ProcessFrontend *ProcessManager::create(const ProcessInfo& info) } /*! - Create a new ProcessFrontend based on QVariantMap \a info - (which should look a lot like ProcessInfo). + Create a new QProcessFrontend based on QVariantMap \a info + (which should look a lot like QProcessInfo). */ -ProcessFrontend *ProcessManager::create(const QVariantMap& info) +QProcessFrontend *QProcessManager::create(const QVariantMap& info) { - return create(ProcessInfo(info)); + return create(QProcessInfo(info)); } /*! - Create a new ProcessFrontend for a \a backend. - Override this function if you need to subclass ProcessFrontend to + Create a new QProcessFrontend for a \a backend. + Override this function if you need to subclass QProcessFrontend to store additional process information or functions. */ -ProcessFrontend *ProcessManager::createFrontend(ProcessBackend *backend) +QProcessFrontend *QProcessManager::createFrontend(QProcessBackend *backend) { - return new ProcessFrontend(backend); + return new QProcessFrontend(backend); } /*! Returns a process that matches the name \a name. - Each process started with the ProcessManager has uniqut application name. + Each process started with the QProcessManager has uniqut application name. If the method returns 0, the name is either invalid or the process has been killed. */ -ProcessFrontend *ProcessManager::processForName(const QString &name) const +QProcessFrontend *QProcessManager::processForName(const QString &name) const { - foreach (ProcessFrontend *frontend, m_processlist) + foreach (QProcessFrontend *frontend, m_processlist) if (frontend->name() == name) return frontend; return NULL; @@ -151,12 +152,12 @@ ProcessFrontend *ProcessManager::processForName(const QString &name) const If more than one process matches the same ID, this method will return the first one find. */ -ProcessFrontend *ProcessManager::processForPID(qint64 pid) const +QProcessFrontend *QProcessManager::processForPID(qint64 pid) const { if (!pid) return NULL; - foreach (ProcessFrontend *frontend, m_processlist) + foreach (QProcessFrontend *frontend, m_processlist) if (frontend->pid() == pid) return frontend; return NULL; @@ -166,16 +167,16 @@ ProcessFrontend *ProcessManager::processForPID(qint64 pid) const Returns the number of processes. */ -int ProcessManager::size() const +int QProcessManager::size() const { return m_processlist.size(); } /*! - Add a ProcessBackendFactory \a factory to the end of the Factory list. + Add a QProcessBackendFactory \a factory to the end of the Factory list. */ -void ProcessManager::addBackendFactory(ProcessBackendFactory *factory) +void QProcessManager::addBackendFactory(QProcessBackendFactory *factory) { m_backend->addFactory(factory); } @@ -184,10 +185,10 @@ void ProcessManager::addBackendFactory(ProcessBackendFactory *factory) Return a list of current process names */ -QStringList ProcessManager::names() const +QStringList QProcessManager::names() const { QStringList result; - foreach (ProcessFrontend *frontend, m_processlist) + foreach (QProcessFrontend *frontend, m_processlist) result << frontend->name(); return result; } @@ -196,7 +197,7 @@ QStringList ProcessManager::names() const Return a list of all internal processes being used by factories */ -PidList ProcessManager::internalProcesses() const +QPidList QProcessManager::internalProcesses() const { return m_backend->internalProcesses(); } @@ -206,7 +207,7 @@ PidList ProcessManager::internalProcesses() const all factories are requested to minimize memory use. */ -void ProcessManager::setMemoryRestricted(bool memoryRestricted) +void QProcessManager::setMemoryRestricted(bool memoryRestricted) { m_backend->setMemoryRestricted(memoryRestricted); emit memoryRestrictedChanged(); @@ -216,7 +217,7 @@ void ProcessManager::setMemoryRestricted(bool memoryRestricted) Return current memory restriction setting */ -bool ProcessManager::memoryRestricted() const +bool QProcessManager::memoryRestricted() const { return m_backend->memoryRestricted(); } @@ -225,7 +226,7 @@ bool ProcessManager::memoryRestricted() const Set the backend idle delegate. */ -void ProcessManager::setIdleDelegate(IdleDelegate *idleDelegate) +void QProcessManager::setIdleDelegate(QIdleDelegate *idleDelegate) { m_backend->setIdleDelegate(idleDelegate); emit idleDelegateChanged(); @@ -235,7 +236,7 @@ void ProcessManager::setIdleDelegate(IdleDelegate *idleDelegate) Return current idle restriction setting */ -IdleDelegate * ProcessManager::idleDelegate() const +QIdleDelegate * QProcessManager::idleDelegate() const { return m_backend->idleDelegate(); } @@ -244,7 +245,7 @@ IdleDelegate * ProcessManager::idleDelegate() const Raise the processAboutToStart() signal. */ -void ProcessManager::processFrontendAboutToStart() +void QProcessManager::processFrontendAboutToStart() { } @@ -252,7 +253,7 @@ void ProcessManager::processFrontendAboutToStart() Raise the processAboutToStop() signal. */ -void ProcessManager::processFrontendAboutToStop() +void QProcessManager::processFrontendAboutToStop() { } @@ -260,7 +261,7 @@ void ProcessManager::processFrontendAboutToStop() Raise the processStarted() signal. */ -void ProcessManager::processFrontendStarted() +void QProcessManager::processFrontendStarted() { } @@ -269,7 +270,7 @@ void ProcessManager::processFrontendStarted() Pass through the \a error value. */ -void ProcessManager::processFrontendError(QProcess::ProcessError error) +void QProcessManager::processFrontendError(QProcess::ProcessError error) { Q_UNUSED(error); } @@ -279,7 +280,7 @@ void ProcessManager::processFrontendError(QProcess::ProcessError error) \a exitCode and \a exitStatus values. */ -void ProcessManager::processFrontendFinished(int exitCode, QProcess::ExitStatus exitStatus) +void QProcessManager::processFrontendFinished(int exitCode, QProcess::ExitStatus exitStatus) { Q_UNUSED(exitCode); Q_UNUSED(exitStatus); @@ -290,7 +291,7 @@ void ProcessManager::processFrontendFinished(int exitCode, QProcess::ExitStatus \a state value. */ -void ProcessManager::processFrontendStateChanged(QProcess::ProcessState state) +void QProcessManager::processFrontendStateChanged(QProcess::ProcessState state) { Q_UNUSED(state); } @@ -302,34 +303,34 @@ void ProcessManager::processFrontendStateChanged(QProcess::ProcessState state) the parent function. */ -void ProcessManager::processFrontendDestroyed() +void QProcessManager::processFrontendDestroyed() { - ProcessFrontend *frontend = static_cast<ProcessFrontend *>(sender()); + QProcessFrontend *frontend = static_cast<QProcessFrontend *>(sender()); if (frontend) m_processlist.removeAll(frontend); } /*! - \fn void ProcessManager::memoryRestrictedChanged() + \fn void QProcessManager::memoryRestrictedChanged() This signal is emitted when the memory restriction is changed */ /*! - \fn void ProcessManager::idleDelegateChanged() + \fn void QProcessManager::idleDelegateChanged() This signal is emitted when the idle delegate is changed */ /*! - \fn void ProcessManager::internalProcessesChanged() + \fn void QProcessManager::internalProcessesChanged() This signal is emitted when the list of internal processes changes. */ /*! - \fn void ProcessManager::internalProcessError(QProcess::ProcessError error) + \fn void QProcessManager::internalProcessError(QProcess::ProcessError error) This signal is emitted when an internal process has an \a error. */ -#include "moc_processmanager.cpp" +#include "moc_qprocessmanager.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/processmanager.h b/src/processmanager/qprocessmanager.h index b53260d..0712f90 100644 --- a/src/processmanager/processmanager.h +++ b/src/processmanager/qprocessmanager.h @@ -44,47 +44,47 @@ #include <QHash> #include <QProcessEnvironment> -#include "processmanager-global.h" -#include "process.h" -#include "processlist.h" +#include "qprocessmanager-global.h" +#include "qpmprocess.h" +#include "qprocesslist.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class ProcessFrontend; -class ProcessInfo; -class ProcessBackendFactory; -class ProcessBackendManager; -class ProcessBackend; -class IdleDelegate; +class QProcessFrontend; +class QProcessInfo; +class QProcessBackendFactory; +class QProcessBackendManager; +class QProcessBackend; +class QIdleDelegate; -class Q_ADDON_PROCESSMANAGER_EXPORT ProcessManager : public QObject +class Q_ADDON_PROCESSMANAGER_EXPORT QProcessManager : public QObject { Q_OBJECT Q_PROPERTY(bool memoryRestricted READ memoryRestricted WRITE setMemoryRestricted NOTIFY memoryRestrictedChanged) - Q_PROPERTY(IdleDelegate* idleDelegate READ idleDelegate WRITE setIdleDelegate NOTIFY idleDelegateChanged); + Q_PROPERTY(QIdleDelegate* idleDelegate READ idleDelegate WRITE setIdleDelegate NOTIFY idleDelegateChanged); public: - explicit ProcessManager(QObject *parent = 0); - virtual ~ProcessManager(); + explicit QProcessManager(QObject *parent = 0); + virtual ~QProcessManager(); - Q_INVOKABLE ProcessFrontend *create(const ProcessInfo& info); - Q_INVOKABLE ProcessFrontend *create(const QVariantMap& info); + Q_INVOKABLE QProcessFrontend *create(const QProcessInfo& info); + Q_INVOKABLE QProcessFrontend *create(const QVariantMap& info); Q_INVOKABLE QStringList names() const; - Q_INVOKABLE ProcessFrontend *processForName(const QString &name) const; - Q_INVOKABLE ProcessFrontend *processForPID(qint64 PID) const; + Q_INVOKABLE QProcessFrontend *processForName(const QString &name) const; + Q_INVOKABLE QProcessFrontend *processForPID(qint64 PID) const; Q_INVOKABLE int size() const; - Q_INVOKABLE void addBackendFactory(ProcessBackendFactory *factory); - Q_INVOKABLE PidList internalProcesses() const; + Q_INVOKABLE void addBackendFactory(QProcessBackendFactory *factory); + Q_INVOKABLE QPidList internalProcesses() const; void setMemoryRestricted(bool); bool memoryRestricted() const; - IdleDelegate * idleDelegate() const; - void setIdleDelegate(IdleDelegate *); + QIdleDelegate * idleDelegate() const; + void setIdleDelegate(QIdleDelegate *); signals: void memoryRestrictedChanged(); @@ -102,11 +102,11 @@ protected slots: virtual void processFrontendDestroyed(); protected: - virtual ProcessFrontend *createFrontend(ProcessBackend *backend); + virtual QProcessFrontend *createFrontend(QProcessBackend *backend); protected: - QList<ProcessFrontend*> m_processlist; - ProcessBackendManager *m_backend; + QList<QProcessFrontend*> m_processlist; + QProcessBackendManager *m_backend; }; QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/procutils.cpp b/src/processmanager/qprocutils.cpp index 9def49c..e4fe7f8 100644 --- a/src/processmanager/procutils.cpp +++ b/src/processmanager/qprocutils.cpp @@ -37,7 +37,7 @@ ** ****************************************************************************/ -#include "procutils.h" +#include "qprocutils.h" #include <cstdio> #include <dirent.h> @@ -78,7 +78,7 @@ struct ProcessPrivateData { Construct a ExecutingProcessInfo object from \a pid. */ -ExecutingProcessInfo::ExecutingProcessInfo(pid_t pid) +QExecutingProcessInfo::QExecutingProcessInfo(pid_t pid) : m_data(0) { #if defined(Q_OS_LINUX) @@ -242,22 +242,22 @@ ExecutingProcessInfo::ExecutingProcessInfo(pid_t pid) #endif } -bool ExecutingProcessInfo::exists() const { return (m_data != 0); } -pid_t ExecutingProcessInfo::pid() const { return (m_data ? m_data->pid : 0); } -pid_t ExecutingProcessInfo::ppid() const { return (m_data ? m_data->ppid : 0); } -pid_t ExecutingProcessInfo::pgrp() const { return (m_data ? m_data->pgrp : 0); } -pid_t ExecutingProcessInfo::sid() const { return (m_data ? m_data->sid : 0); } -uid_t ExecutingProcessInfo::uid() const { return (m_data ? m_data->uid : 0); } -uid_t ExecutingProcessInfo::euid() const { return (m_data ? m_data->euid : 0); } -uid_t ExecutingProcessInfo::suid() const { return (m_data ? m_data->suid : 0); } -gid_t ExecutingProcessInfo::gid() const { return (m_data ? m_data->gid : 0); } -gid_t ExecutingProcessInfo::egid() const { return (m_data ? m_data->egid : 0); } -gid_t ExecutingProcessInfo::sgid() const { return (m_data ? m_data->sgid : 0); } -int ExecutingProcessInfo::priority() const { return (m_data ? m_data->priority : 0); } -int ExecutingProcessInfo::nice() const { return (m_data ? m_data->nice : 0); } - - -ProcUtils::ProcUtils() +bool QExecutingProcessInfo::exists() const { return (m_data != 0); } +pid_t QExecutingProcessInfo::pid() const { return (m_data ? m_data->pid : 0); } +pid_t QExecutingProcessInfo::ppid() const { return (m_data ? m_data->ppid : 0); } +pid_t QExecutingProcessInfo::pgrp() const { return (m_data ? m_data->pgrp : 0); } +pid_t QExecutingProcessInfo::sid() const { return (m_data ? m_data->sid : 0); } +uid_t QExecutingProcessInfo::uid() const { return (m_data ? m_data->uid : 0); } +uid_t QExecutingProcessInfo::euid() const { return (m_data ? m_data->euid : 0); } +uid_t QExecutingProcessInfo::suid() const { return (m_data ? m_data->suid : 0); } +gid_t QExecutingProcessInfo::gid() const { return (m_data ? m_data->gid : 0); } +gid_t QExecutingProcessInfo::egid() const { return (m_data ? m_data->egid : 0); } +gid_t QExecutingProcessInfo::sgid() const { return (m_data ? m_data->sgid : 0); } +int QExecutingProcessInfo::priority() const { return (m_data ? m_data->priority : 0); } +int QExecutingProcessInfo::nice() const { return (m_data ? m_data->nice : 0); } + + +QProcUtils::QProcUtils() { } @@ -268,7 +268,7 @@ ProcUtils::ProcUtils() and sometimes other stuff. */ -QString ProcUtils::execNameForPid(qint64 pid) +QString QProcUtils::execNameForPid(qint64 pid) { #if defined(Q_OS_LINUX) enum { BUFFERSIZE = 1024 }; @@ -285,7 +285,7 @@ QString ProcUtils::execNameForPid(qint64 pid) return QString(); } -qint64 ProcUtils::ppidForPid(pid_t pid) +qint64 QProcUtils::ppidForPid(pid_t pid) { int ppid = 0; #if defined(Q_OS_LINUX) @@ -305,7 +305,7 @@ qint64 ProcUtils::ppidForPid(pid_t pid) return ppid; } -qint64 ProcUtils::pidForFilename(const QString &filename) +qint64 QProcUtils::pidForFilename(const QString &filename) { #if defined(Q_OS_LINUX) QFile file(filename); @@ -336,7 +336,7 @@ qint64 ProcUtils::pidForFilename(const QString &filename) return 0; } -qint64 ProcUtils::pidForLocalSocket(const QLocalSocket *socket) +qint64 QProcUtils::pidForLocalSocket(const QLocalSocket *socket) { #if defined(Q_OS_LINUX) if (socket) { @@ -352,7 +352,7 @@ qint64 ProcUtils::pidForLocalSocket(const QLocalSocket *socket) return 0; } -QByteArray ProcUtils::cmdlineForPid(qint64 pid) +QByteArray QProcUtils::cmdlineForPid(qint64 pid) { QByteArray cmdline; #if defined(Q_OS_LINUX) @@ -367,7 +367,7 @@ QByteArray ProcUtils::cmdlineForPid(qint64 pid) return cmdline; } -qint32 ProcUtils::oomAdjustment(pid_t pid, bool *ok) +qint32 QProcUtils::oomAdjustment(pid_t pid, bool *ok) { if (ok) *ok = false; @@ -385,7 +385,7 @@ qint32 ProcUtils::oomAdjustment(pid_t pid, bool *ok) return -1001; } -bool ProcUtils::setOomAdjustment(pid_t pid, qint32 oomAdjustment) +bool QProcUtils::setOomAdjustment(pid_t pid, qint32 oomAdjustment) { #if defined(Q_OS_LINUX) QFile file(QString::fromLatin1("/proc/%1/oom_score_adj").arg(pid)); @@ -405,7 +405,7 @@ bool ProcUtils::setOomAdjustment(pid_t pid, qint32 oomAdjustment) Send a signal to a process or process group. */ -void ProcUtils::sendSignalToProcess(pid_t pid, int sig) +void QProcUtils::sendSignalToProcess(pid_t pid, int sig) { pid_t pgrp = ::getpgid(pid); if (pgrp != -1 && pgrp != ::getpgrp() && ::killpg(pgrp, sig) == 0) @@ -419,7 +419,7 @@ void ProcUtils::sendSignalToProcess(pid_t pid, int sig) Set a process or process group priority */ -void ProcUtils::setPriority(pid_t pid, qint32 priority) +void QProcUtils::setPriority(pid_t pid, qint32 priority) { pid_t pgrp = ::getpgid(pid); if (pgrp != -1 && pgrp != ::getpgrp()) { @@ -438,7 +438,7 @@ void ProcUtils::setPriority(pid_t pid, qint32 priority) can read the number of threads. */ -int ProcUtils::getThreadCount(pid_t pid) +int QProcUtils::getThreadCount(pid_t pid) { #if defined(Q_OS_LINUX) QDir pdir(QString::fromLatin1("/proc/%1/task").arg(pid)); @@ -473,7 +473,7 @@ int ProcUtils::getThreadCount(pid_t pid) returns the "user visible" priority, a number from -20 to +19. */ -QList<qint32> ProcUtils::getThreadPriorities(pid_t pid) +QList<qint32> QProcUtils::getThreadPriorities(pid_t pid) { QList<qint32> plist; #if defined(Q_OS_LINUX) @@ -498,6 +498,6 @@ QList<qint32> ProcUtils::getThreadPriorities(pid_t pid) } -#include "moc_procutils.cpp" +#include "moc_qprocutils.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/procutils.h b/src/processmanager/qprocutils.h index 0c89226..a63b685 100644 --- a/src/processmanager/procutils.h +++ b/src/processmanager/qprocutils.h @@ -46,13 +46,13 @@ QT_FORWARD_DECLARE_CLASS(QLocalSocket) -#include "processmanager-global.h" +#include "qprocessmanager-global.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER struct ProcessPrivateData; -class Q_ADDON_PROCESSMANAGER_EXPORT ExecutingProcessInfo : public QObject +class Q_ADDON_PROCESSMANAGER_EXPORT QExecutingProcessInfo : public QObject { Q_OBJECT Q_PROPERTY(pid_t pid READ pid CONSTANT) @@ -71,7 +71,7 @@ class Q_ADDON_PROCESSMANAGER_EXPORT ExecutingProcessInfo : public QObject Q_PROPERTY(QString name READ name CONSTANT) public: - ExecutingProcessInfo(pid_t pid); + QExecutingProcessInfo(pid_t pid); bool exists() const; pid_t pid() const; @@ -96,10 +96,10 @@ private: QString m_name; }; -class Q_ADDON_PROCESSMANAGER_EXPORT ProcUtils +class Q_ADDON_PROCESSMANAGER_EXPORT QProcUtils { - ProcUtils(); - Q_DISABLE_COPY(ProcUtils) + QProcUtils(); + Q_DISABLE_COPY(QProcUtils) public: static QString execNameForPid(qint64 pid); static qint64 ppidForPid(pid_t pid); diff --git a/src/processmanager/remoteprocessbackend.cpp b/src/processmanager/qremoteprocessbackend.cpp index db8d344..2d5a0f3 100644 --- a/src/processmanager/remoteprocessbackend.cpp +++ b/src/processmanager/qremoteprocessbackend.cpp @@ -37,9 +37,9 @@ ** ****************************************************************************/ -#include "remoteprocessbackend.h" -#include "remoteprotocol.h" -#include "procutils.h" +#include "qremoteprocessbackend.h" +#include "qremoteprotocol.h" +#include "qprocutils.h" #include <sys/resource.h> #include <errno.h> #include <signal.h> @@ -48,26 +48,27 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \class RemoteProcessBackend + \class QRemoteProcessBackend - \brief The RemoteProcessBackend class handles a process started by another process. + \brief The QRemoteProcessBackend class handles a process started by another process. + \inmodule QtProcessManager - The RemoteProcessBackend is used to control a process that was started by - a separate "controller" process. The RemoteProcessBackendFactory object handles + The QRemoteProcessBackend is used to control a process that was started by + a separate "controller" process. The QRemoteProcessBackendFactory object handles the pipe or socket communication with the remote controller. Communication is carried over serialized JSON messages. */ /*! - Construct a RemoteProcessBackend with ProcessInfo \a info, \a factory, + Construct a QRemoteProcessBackend with QProcessInfo \a info, \a factory, \a id, and optional \a parent. */ -RemoteProcessBackend::RemoteProcessBackend(const ProcessInfo& info, - RemoteProcessBackendFactory *factory, +QRemoteProcessBackend::QRemoteProcessBackend(const QProcessInfo& info, + QRemoteProcessBackendFactory *factory, int id, QObject *parent) - : ProcessBackend(info, parent) + : QProcessBackend(info, parent) , m_factory(factory) , m_state(QProcess::NotRunning) , m_pid(-1) @@ -80,7 +81,7 @@ RemoteProcessBackend::RemoteProcessBackend(const ProcessInfo& info, Destroy this process object. */ -RemoteProcessBackend::~RemoteProcessBackend() +QRemoteProcessBackend::~QRemoteProcessBackend() { if (m_factory) m_factory->backendDestroyed(m_id); @@ -91,18 +92,18 @@ RemoteProcessBackend::~RemoteProcessBackend() Return the default value if it is not. */ -Q_PID RemoteProcessBackend::pid() const +Q_PID QRemoteProcessBackend::pid() const { if (m_pid != -1) return m_pid; - return ProcessBackend::pid(); + return QProcessBackend::pid(); } /*! Return the actual process priority (if running) */ -qint32 RemoteProcessBackend::actualPriority() const +qint32 QRemoteProcessBackend::actualPriority() const { if (m_pid != -1) { errno = 0; // getpriority can return -1, so we clear errno @@ -110,22 +111,22 @@ qint32 RemoteProcessBackend::actualPriority() const if (!errno) return result; } - return ProcessBackend::actualPriority(); + return QProcessBackend::actualPriority(); } /*! Set the process priority to \a priority */ -void RemoteProcessBackend::setDesiredPriority(qint32 priority) +void QRemoteProcessBackend::setDesiredPriority(qint32 priority) { - ProcessBackend::setDesiredPriority(priority); + QProcessBackend::setDesiredPriority(priority); if (m_factory && m_pid != -1) { QJsonObject object; - object.insert(RemoteProtocol::command(), RemoteProtocol::set()); - object.insert(RemoteProtocol::id(), m_id); - object.insert(RemoteProtocol::key(), RemoteProtocol::priority()); - object.insert(RemoteProtocol::value(), priority); + object.insert(QRemoteProtocol::command(), QRemoteProtocol::set()); + object.insert(QRemoteProtocol::id(), m_id); + object.insert(QRemoteProtocol::key(), QRemoteProtocol::priority()); + object.insert(QRemoteProtocol::value(), priority); m_factory->send(object); } } @@ -136,31 +137,31 @@ void RemoteProcessBackend::setDesiredPriority(qint32 priority) Return the process oomAdjustment */ -qint32 RemoteProcessBackend::actualOomAdjustment() const +qint32 QRemoteProcessBackend::actualOomAdjustment() const { if (m_pid != -1) { bool ok; - qint32 result = ProcUtils::oomAdjustment(m_pid, &ok); + qint32 result = QProcUtils::oomAdjustment(m_pid, &ok); if (ok) return result; qWarning() << "Unable to read oom adjustment for" << m_pid; } - return ProcessBackend::actualOomAdjustment(); + return QProcessBackend::actualOomAdjustment(); } /*! Set the process /proc/<pid>/oom_score_adj to \a oomAdjustment */ -void RemoteProcessBackend::setDesiredOomAdjustment(qint32 oomAdjustment) +void QRemoteProcessBackend::setDesiredOomAdjustment(qint32 oomAdjustment) { - ProcessBackend::setDesiredOomAdjustment(oomAdjustment); + QProcessBackend::setDesiredOomAdjustment(oomAdjustment); if (m_factory && m_pid != -1) { QJsonObject object; - object.insert(RemoteProtocol::command(), RemoteProtocol::set()); - object.insert(RemoteProtocol::id(), m_id); - object.insert(RemoteProtocol::key(), RemoteProtocol::oomAdjustment()); - object.insert(RemoteProtocol::value(), oomAdjustment); + object.insert(QRemoteProtocol::command(), QRemoteProtocol::set()); + object.insert(QRemoteProtocol::id(), m_id); + object.insert(QRemoteProtocol::key(), QRemoteProtocol::oomAdjustment()); + object.insert(QRemoteProtocol::value(), oomAdjustment); m_factory->send(object); } } @@ -171,7 +172,7 @@ void RemoteProcessBackend::setDesiredOomAdjustment(qint32 oomAdjustment) /*! Returns the state of the process. */ -QProcess::ProcessState RemoteProcessBackend::state() const +QProcess::ProcessState QRemoteProcessBackend::state() const { return m_state; } @@ -180,13 +181,13 @@ QProcess::ProcessState RemoteProcessBackend::state() const Start the process running */ -void RemoteProcessBackend::start() +void QRemoteProcessBackend::start() { if (m_factory) { QJsonObject object; - object.insert(RemoteProtocol::command(), RemoteProtocol::start()); - object.insert(RemoteProtocol::id(), m_id); - object.insert(RemoteProtocol::info(), QJsonValue::fromVariant(m_info.toMap())); + object.insert(QRemoteProtocol::command(), QRemoteProtocol::start()); + object.insert(QRemoteProtocol::id(), m_id); + object.insert(QRemoteProtocol::info(), QJsonValue::fromVariant(m_info.toMap())); m_factory->send(object); } } @@ -197,13 +198,13 @@ void RemoteProcessBackend::start() \sa finished() */ -void RemoteProcessBackend::stop(int timeout) +void QRemoteProcessBackend::stop(int timeout) { if (m_factory) { QJsonObject object; - object.insert(RemoteProtocol::command(), RemoteProtocol::stop()); - object.insert(RemoteProtocol::id(), m_id); - object.insert(RemoteProtocol::timeout(), timeout); + object.insert(QRemoteProtocol::command(), QRemoteProtocol::stop()); + object.insert(QRemoteProtocol::id(), m_id); + object.insert(QRemoteProtocol::timeout(), timeout); m_factory->send(object); } } @@ -212,13 +213,13 @@ void RemoteProcessBackend::stop(int timeout) Writes at most \a maxSize bytes of data from \a data to the device. Returns the number of bytes that were actually written, or -1 if an error occurred. */ -qint64 RemoteProcessBackend::write(const char *data, qint64 maxSize) +qint64 QRemoteProcessBackend::write(const char *data, qint64 maxSize) { if (m_factory) { QJsonObject object; - object.insert(RemoteProtocol::command(), RemoteProtocol::write()); - object.insert(RemoteProtocol::id(), m_id); - object.insert(RemoteProtocol::data(), QString::fromLatin1(QByteArray(data, maxSize).toBase64())); + object.insert(QRemoteProtocol::command(), QRemoteProtocol::write()); + object.insert(QRemoteProtocol::id(), m_id); + object.insert(QRemoteProtocol::data(), QString::fromLatin1(QByteArray(data, maxSize).toBase64())); if (m_factory->send(object)) return maxSize; } @@ -228,7 +229,7 @@ qint64 RemoteProcessBackend::write(const char *data, qint64 maxSize) /*! Returns the most recent error string */ -QString RemoteProcessBackend::errorString() const +QString QRemoteProcessBackend::errorString() const { return m_errorString; } @@ -239,31 +240,31 @@ QString RemoteProcessBackend::errorString() const The \a message is encoded in JSON format. */ -void RemoteProcessBackend::receive(const QJsonObject& message) +void QRemoteProcessBackend::receive(const QJsonObject& message) { - QString event = message.value(RemoteProtocol::event()).toString(); - if (event == RemoteProtocol::started()) { - m_pid = message.value(RemoteProtocol::pid()).toDouble(); + QString event = message.value(QRemoteProtocol::event()).toString(); + if (event == QRemoteProtocol::started()) { + m_pid = message.value(QRemoteProtocol::pid()).toDouble(); emit started(); } - else if (event == RemoteProtocol::error()) { - m_errorString = message.value(RemoteProtocol::errorString()).toString(); - emit error(static_cast<QProcess::ProcessError>(message.value(RemoteProtocol::error()).toDouble())); + else if (event == QRemoteProtocol::error()) { + m_errorString = message.value(QRemoteProtocol::errorString()).toString(); + emit error(static_cast<QProcess::ProcessError>(message.value(QRemoteProtocol::error()).toDouble())); } - else if (event == RemoteProtocol::finished()) { - emit finished(message.value(RemoteProtocol::exitCode()).toDouble(), - static_cast<QProcess::ExitStatus>(message.value(RemoteProtocol::exitStatus()).toDouble())); + else if (event == QRemoteProtocol::finished()) { + emit finished(message.value(QRemoteProtocol::exitCode()).toDouble(), + static_cast<QProcess::ExitStatus>(message.value(QRemoteProtocol::exitStatus()).toDouble())); } - else if (event == RemoteProtocol::stateChanged()) { - m_state = static_cast<QProcess::ProcessState>(message.value(RemoteProtocol::stateChanged()).toDouble()); + else if (event == QRemoteProtocol::stateChanged()) { + m_state = static_cast<QProcess::ProcessState>(message.value(QRemoteProtocol::stateChanged()).toDouble()); emit stateChanged(m_state); } - else if (event == RemoteProtocol::output()) { - if (message.contains(RemoteProtocol::standardout())) { - handleStandardOutput(message.value(RemoteProtocol::standardout()).toString().toLocal8Bit()); + else if (event == QRemoteProtocol::output()) { + if (message.contains(QRemoteProtocol::standardout())) { + handleStandardOutput(message.value(QRemoteProtocol::standardout()).toString().toLocal8Bit()); } - if (message.contains(RemoteProtocol::standarderror())) { - handleStandardError(message.value(RemoteProtocol::standarderror()).toString().toLocal8Bit()); + if (message.contains(QRemoteProtocol::standarderror())) { + handleStandardError(message.value(QRemoteProtocol::standarderror()).toString().toLocal8Bit()); } } else @@ -274,13 +275,13 @@ void RemoteProcessBackend::receive(const QJsonObject& message) \internal */ -void RemoteProcessBackend::killTimeout() +void QRemoteProcessBackend::killTimeout() { if (m_factory) { QJsonObject object; - object.insert(RemoteProtocol::command(), RemoteProtocol::signal()); - object.insert(RemoteProtocol::id(), m_id); - object.insert(RemoteProtocol::signal(), SIGKILL); + object.insert(QRemoteProtocol::command(), QRemoteProtocol::signal()); + object.insert(QRemoteProtocol::id(), m_id); + object.insert(QRemoteProtocol::signal(), SIGKILL); m_factory->send(object); } } @@ -289,7 +290,7 @@ void RemoteProcessBackend::killTimeout() \internal */ -void RemoteProcessBackend::factoryDestroyed() +void QRemoteProcessBackend::factoryDestroyed() { m_factory = NULL; if (m_state != QProcess::NotRunning) { @@ -298,6 +299,6 @@ void RemoteProcessBackend::factoryDestroyed() } } -#include "moc_remoteprocessbackend.cpp" +#include "moc_qremoteprocessbackend.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/remoteprocessbackend.h b/src/processmanager/qremoteprocessbackend.h index c57c492..6095c33 100644 --- a/src/processmanager/remoteprocessbackend.h +++ b/src/processmanager/qremoteprocessbackend.h @@ -42,20 +42,20 @@ #include <QJsonObject> -#include "processmanager-global.h" -#include "processbackend.h" -#include "remoteprocessbackendfactory.h" +#include "qprocessmanager-global.h" +#include "qprocessbackend.h" +#include "qremoteprocessbackendfactory.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class Q_ADDON_PROCESSMANAGER_EXPORT RemoteProcessBackend : public ProcessBackend +class Q_ADDON_PROCESSMANAGER_EXPORT QRemoteProcessBackend : public QProcessBackend { Q_OBJECT public: - RemoteProcessBackend(const ProcessInfo& info, RemoteProcessBackendFactory *factory, + QRemoteProcessBackend(const QProcessInfo& info, QRemoteProcessBackendFactory *factory, int id, QObject *parent); - virtual ~RemoteProcessBackend(); + virtual ~QRemoteProcessBackend(); virtual Q_PID pid() const; virtual qint32 actualPriority() const; @@ -73,13 +73,13 @@ public: virtual QString errorString() const; private: - friend class RemoteProcessBackendFactory; + friend class QRemoteProcessBackendFactory; void killTimeout(); void receive(const QJsonObject&); void factoryDestroyed(); private: - RemoteProcessBackendFactory *m_factory; + QRemoteProcessBackendFactory *m_factory; QProcess::ProcessState m_state; Q_PID m_pid; qint32 m_id; diff --git a/src/processmanager/remoteprocessbackendfactory.cpp b/src/processmanager/qremoteprocessbackendfactory.cpp index ba55297..81af2e1 100644 --- a/src/processmanager/remoteprocessbackendfactory.cpp +++ b/src/processmanager/qremoteprocessbackendfactory.cpp @@ -37,19 +37,20 @@ ** ****************************************************************************/ -#include "remoteprocessbackendfactory.h" -#include "remoteprocessbackend.h" -#include "remoteprotocol.h" +#include "qremoteprocessbackendfactory.h" +#include "qremoteprocessbackend.h" +#include "qremoteprotocol.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER const int kRemoteTimerInterval = 1000; /*! - \class RemoteProcessBackendFactory - \brief The RemoteProcessBackendFactory class creates RemoteProcessBackend objects + \class QRemoteProcessBackendFactory + \brief The QRemoteProcessBackendFactory class creates QRemoteProcessBackend objects + \inmodule QtProcessManager - The RemoteProcessBackendFactory communicates with a remote process to control + The QRemoteProcessBackendFactory communicates with a remote process to control other, child processes. The factory communicates with the remote process by sending and receiving JSON-formated messages. The remote process should respond to the following @@ -82,7 +83,7 @@ const int kRemoteTimerInterval = 1000; \endtable The following are events that are sent by the remote process - to the RemoteProcessBackendFactory: + to the QRemoteProcessBackendFactory: \table \header @@ -110,11 +111,11 @@ const int kRemoteTimerInterval = 1000; */ /*! - Construct a RemoteProcessBackendFactory with optional \a parent. + Construct a QRemoteProcessBackendFactory with optional \a parent. */ -RemoteProcessBackendFactory::RemoteProcessBackendFactory(QObject *parent) - : ProcessBackendFactory(parent) +QRemoteProcessBackendFactory::QRemoteProcessBackendFactory(QObject *parent) + : QProcessBackendFactory(parent) , m_idCount(100) { } @@ -123,20 +124,20 @@ RemoteProcessBackendFactory::RemoteProcessBackendFactory(QObject *parent) Destroy this and child objects. */ -RemoteProcessBackendFactory::~RemoteProcessBackendFactory() +QRemoteProcessBackendFactory::~QRemoteProcessBackendFactory() { - foreach (RemoteProcessBackend *backend, m_backendMap) + foreach (QRemoteProcessBackend *backend, m_backendMap) backend->factoryDestroyed(); } /*! - Construct a RemoteProcessBackend from a ProcessInfo \a info record with \a parent. + Construct a QRemoteProcessBackend from a ProcessInfo \a info record with \a parent. */ -ProcessBackend * RemoteProcessBackendFactory::create(const ProcessInfo& info, QObject *parent) +QProcessBackend * QRemoteProcessBackendFactory::create(const QProcessInfo& info, QObject *parent) { int id = m_idCount++; - RemoteProcessBackend *backend = new RemoteProcessBackend(info, this, id, parent); + QRemoteProcessBackend *backend = new QRemoteProcessBackend(info, this, id, parent); m_backendMap.insert(id, backend); return backend; } @@ -145,10 +146,10 @@ ProcessBackend * RemoteProcessBackendFactory::create(const ProcessInfo& info, QO Idle CPU is available. Send the message over the wire */ -void RemoteProcessBackendFactory::idleCpuAvailable() +void QRemoteProcessBackendFactory::idleCpuAvailable() { QJsonObject object; - object.insert(RemoteProtocol::remote(), RemoteProtocol::idlecpuavailable()); + object.insert(QRemoteProtocol::remote(), QRemoteProtocol::idlecpuavailable()); send(object); } @@ -156,11 +157,11 @@ void RemoteProcessBackendFactory::idleCpuAvailable() Tell the remote factory that memory is restricted and space should be freed up. */ -void RemoteProcessBackendFactory::handleMemoryRestrictionChange() +void QRemoteProcessBackendFactory::handleMemoryRestrictionChange() { QJsonObject object; - object.insert(RemoteProtocol::remote(), RemoteProtocol::memory()); - object.insert(RemoteProtocol::restricted(), m_memoryRestricted); + object.insert(QRemoteProtocol::remote(), QRemoteProtocol::memory()); + object.insert(QRemoteProtocol::restricted(), m_memoryRestricted); send(object); } @@ -171,9 +172,9 @@ void RemoteProcessBackendFactory::handleMemoryRestrictionChange() holding a process object */ -PidList RemoteProcessBackendFactory::localInternalProcesses() const +QPidList QRemoteProcessBackendFactory::localInternalProcesses() const { - return PidList(); + return QPidList(); } /*! @@ -181,7 +182,7 @@ PidList RemoteProcessBackendFactory::localInternalProcesses() const This function should be called by subclasses. */ -void RemoteProcessBackendFactory::handleConnected() +void QRemoteProcessBackendFactory::handleConnected() { handleMemoryRestrictionChange(); // Sends command="memory" message } @@ -191,21 +192,21 @@ void RemoteProcessBackendFactory::handleConnected() Call this function from your subclass to properly dispatch messages. */ -void RemoteProcessBackendFactory::receive(const QJsonObject& message) +void QRemoteProcessBackendFactory::receive(const QJsonObject& message) { // qDebug() << Q_FUNC_INFO << message; - QString remote = message.value(RemoteProtocol::remote()).toString(); - if (remote == RemoteProtocol::idlecpurequested()) - setIdleCpuRequest(message.value(RemoteProtocol::request()).toBool()); - else if (remote == RemoteProtocol::internalprocesses()) { - PidList plist = localInternalProcesses() + - arrayToPidList(message.value(RemoteProtocol::processes()).toArray()); + QString remote = message.value(QRemoteProtocol::remote()).toString(); + if (remote == QRemoteProtocol::idlecpurequested()) + setIdleCpuRequest(message.value(QRemoteProtocol::request()).toBool()); + else if (remote == QRemoteProtocol::internalprocesses()) { + QPidList plist = localInternalProcesses() + + arrayToPidList(message.value(QRemoteProtocol::processes()).toArray()); qSort(plist); setInternalProcesses(plist); } - else if (remote == RemoteProtocol::internalprocesserror()) { - int value = (int) message.value(RemoteProtocol::processError()).toDouble(); + else if (remote == QRemoteProtocol::internalprocesserror()) { + int value = (int) message.value(QRemoteProtocol::processError()).toDouble(); emit internalProcessError(static_cast<QProcess::ProcessError>(value)); } else { @@ -216,7 +217,7 @@ void RemoteProcessBackendFactory::receive(const QJsonObject& message) } /*! - \fn bool RemoteProcessBackendFactory::send(const QJsonObject& message) + \fn bool QRemoteProcessBackendFactory::send(const QJsonObject& message) Send a \a message to the remote process. This method must be implemented in a child process. Return true if the message can be sent. @@ -226,12 +227,12 @@ void RemoteProcessBackendFactory::receive(const QJsonObject& message) \internal */ -void RemoteProcessBackendFactory::backendDestroyed(int id) +void QRemoteProcessBackendFactory::backendDestroyed(int id) { if (m_backendMap.remove(id) != 1) qCritical("Missing remote process backend"); } -#include "moc_remoteprocessbackendfactory.cpp" +#include "moc_qremoteprocessbackendfactory.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/remoteprocessbackendfactory.h b/src/processmanager/qremoteprocessbackendfactory.h index 86417b6..f582879 100644 --- a/src/processmanager/remoteprocessbackendfactory.h +++ b/src/processmanager/qremoteprocessbackendfactory.h @@ -40,22 +40,22 @@ #ifndef REMOTE_PROCESS_BACKEND_FACTORY_H #define REMOTE_PROCESS_BACKEND_FACTORY_H -#include "processbackendfactory.h" +#include "qprocessbackendfactory.h" #include <QJsonObject> #include <QMap> QT_BEGIN_NAMESPACE_PROCESSMANAGER -class RemoteProcessBackend; +class QRemoteProcessBackend; -class Q_ADDON_PROCESSMANAGER_EXPORT RemoteProcessBackendFactory : public ProcessBackendFactory +class Q_ADDON_PROCESSMANAGER_EXPORT QRemoteProcessBackendFactory : public QProcessBackendFactory { Q_OBJECT public: - RemoteProcessBackendFactory(QObject *parent = 0); - virtual ~RemoteProcessBackendFactory(); + QRemoteProcessBackendFactory(QObject *parent = 0); + virtual ~QRemoteProcessBackendFactory(); - virtual ProcessBackend *create(const ProcessInfo& info, QObject *parent); + virtual QProcessBackend *create(const QProcessInfo& info, QObject *parent); virtual void idleCpuAvailable(); protected slots: @@ -64,16 +64,16 @@ protected slots: protected: virtual void handleMemoryRestrictionChange(); - virtual PidList localInternalProcesses() const; + virtual QPidList localInternalProcesses() const; virtual bool send(const QJsonObject&) = 0; private: void backendDestroyed(int); - friend class RemoteProcessBackend; + friend class QRemoteProcessBackend; protected: int m_idCount; - QMap<int, RemoteProcessBackend*> m_backendMap; + QMap<int, QRemoteProcessBackend*> m_backendMap; }; QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/remoteprotocol.h b/src/processmanager/qremoteprotocol.h index ed91e8d..ef063e6 100644 --- a/src/processmanager/remoteprotocol.h +++ b/src/processmanager/qremoteprotocol.h @@ -42,11 +42,11 @@ #include <QString> -#include "processmanager-global.h" +#include "qprocessmanager-global.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class RemoteProtocol { +class QRemoteProtocol { public: static inline const QString command() { return QStringLiteral("command"); } static inline const QString data() { return QStringLiteral("data"); } diff --git a/src/processmanager/rewritedelegate.cpp b/src/processmanager/qrewritedelegate.cpp index 287b232..6ef6600 100644 --- a/src/processmanager/rewritedelegate.cpp +++ b/src/processmanager/qrewritedelegate.cpp @@ -37,33 +37,34 @@ ** ****************************************************************************/ -#include "rewritedelegate.h" +#include "qrewritedelegate.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \class RewriteDelegate - \brief The RewriteDelegate class is a virtual class for rewriting ProcessInfo objects. + \class QRewriteDelegate + \brief The QRewriteDelegate class is a virtual class for rewriting ProcessInfo objects. + \inmodule QtProcessManager You must subclass this class to do anything useful. */ /*! - Construct a RewriteDelegate with an optional \a parent. + Construct a QRewriteDelegate with an optional \a parent. */ -RewriteDelegate::RewriteDelegate(QObject *parent) +QRewriteDelegate::QRewriteDelegate(QObject *parent) : QObject(parent) { } /*! - \fn void RewriteDelegate::rewrite(ProcessInfo& info) + \fn void QRewriteDelegate::rewrite(QProcessInfo& info) - Rewrite the ProcessInfo \a info object. + Rewrite the QProcessInfo \a info object. You must override this function in a subclass. */ -#include "moc_rewritedelegate.cpp" +#include "moc_qrewritedelegate.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/rewritedelegate.h b/src/processmanager/qrewritedelegate.h index f40c25f..d20d738 100644 --- a/src/processmanager/rewritedelegate.h +++ b/src/processmanager/qrewritedelegate.h @@ -41,21 +41,21 @@ #define REWRITE_DELEGATE_H #include <QObject> -#include "processmanager-global.h" +#include "qprocessmanager-global.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class ProcessInfo; +class QProcessInfo; -class Q_ADDON_PROCESSMANAGER_EXPORT RewriteDelegate : public QObject +class Q_ADDON_PROCESSMANAGER_EXPORT QRewriteDelegate : public QObject { Q_OBJECT public: - explicit RewriteDelegate(QObject *parent = 0); - virtual void rewrite(ProcessInfo& info) = 0; + explicit QRewriteDelegate(QObject *parent = 0); + virtual void rewrite(QProcessInfo& info) = 0; private: - Q_DISABLE_COPY(RewriteDelegate); + Q_DISABLE_COPY(QRewriteDelegate) }; QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/socketlauncher.cpp b/src/processmanager/qsocketlauncher.cpp index 249a102..18bcb29 100644 --- a/src/processmanager/socketlauncher.cpp +++ b/src/processmanager/qsocketlauncher.cpp @@ -40,28 +40,29 @@ #include <QDebug> #include <signal.h> -#include "socketlauncher.h" -#include "launcherclient.h" -#include "remoteprotocol.h" +#include "qsocketlauncher.h" +#include "qlauncherclient.h" +#include "qremoteprotocol.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \class SocketLauncher - \brief The SocketLauncher class accepts incoming socket connections and starts processes. + \class QSocketLauncher + \brief The QSocketLauncher class accepts incoming socket connections and starts processes. + \inmodule QtProcessManager - The SocketLauncher class accepts incoming socket connections and starts and stops + The QSocketLauncher class accepts incoming socket connections and starts and stops processes based on JSON-formatted messages. Each connection gets its own set of processes. When a connection is dropped, all processes associated with that connection are killed. */ /*! - Construct a SocketLauncher with optional \a parent. - The socket launcher opens a JsonServer object. + Construct a QSocketLauncher with optional \a parent. + The socket launcher opens a QJsonServer object. */ -SocketLauncher::SocketLauncher(QObject *parent) - : ProcessBackendManager(parent) +QSocketLauncher::QSocketLauncher(QObject *parent) + : QProcessBackendManager(parent) { m_server = new QtAddOn::QtJsonStream::QJsonServer(this); @@ -80,7 +81,7 @@ SocketLauncher::SocketLauncher(QObject *parent) The optional \a authority object is used to authenticate incoming connections. Return true if the port can be used. */ -bool SocketLauncher::listen(int port, QtAddOn::QtJsonStream::QJsonAuthority *authority) +bool QSocketLauncher::listen(int port, QtAddOn::QtJsonStream::QJsonAuthority *authority) { return m_server->listen(port, authority); } @@ -90,16 +91,16 @@ bool SocketLauncher::listen(int port, QtAddOn::QtJsonStream::QJsonAuthority *aut The optional \a authority object is used to authenticate incoming connections. Return true if the server can be started. */ -bool SocketLauncher::listen(const QString& socketname, QtAddOn::QtJsonStream::QJsonAuthority *authority) +bool QSocketLauncher::listen(const QString& socketname, QtAddOn::QtJsonStream::QJsonAuthority *authority) { return m_server->listen(socketname, authority); } /*! - Return the internal JsonServer object. + Return the internal QJsonServer object. */ -QtAddOn::QtJsonStream::QJsonServer * SocketLauncher::server() const +QtAddOn::QtJsonStream::QJsonServer * QSocketLauncher::server() const { return m_server; } @@ -107,9 +108,9 @@ QtAddOn::QtJsonStream::QJsonServer * SocketLauncher::server() const /*! \internal */ -void SocketLauncher::connectionAdded(const QString& identifier) +void QSocketLauncher::connectionAdded(const QString& identifier) { - LauncherClient *client = new LauncherClient(this); + QLauncherClient *client = new QLauncherClient(this); connect(client, SIGNAL(send(const QJsonObject&)), SLOT(send(const QJsonObject&))); m_idToClient.insert(identifier, client); m_clientToId.insert(client, identifier); @@ -117,23 +118,23 @@ void SocketLauncher::connectionAdded(const QString& identifier) // Send our current idle request and internal process list if (!idleDelegate()) { QJsonObject object; - object.insert(RemoteProtocol::remote(), RemoteProtocol::idlecpurequested()); - object.insert(RemoteProtocol::request(), idleCpuRequest()); + object.insert(QRemoteProtocol::remote(), QRemoteProtocol::idlecpurequested()); + object.insert(QRemoteProtocol::request(), idleCpuRequest()); sendToClient(object, client); } QJsonObject object; - object.insert(RemoteProtocol::remote(), RemoteProtocol::internalprocesses()); - object.insert(RemoteProtocol::processes(), pidListToArray(internalProcesses())); + object.insert(QRemoteProtocol::remote(), QRemoteProtocol::internalprocesses()); + object.insert(QRemoteProtocol::processes(), pidListToArray(internalProcesses())); sendToClient(object, client); } /*! \internal */ -void SocketLauncher::connectionRemoved(const QString& identifier) +void QSocketLauncher::connectionRemoved(const QString& identifier) { - LauncherClient *client = m_idToClient.take(identifier); + QLauncherClient *client = m_idToClient.take(identifier); if (client) { m_clientToId.take(client); delete client; @@ -151,12 +152,12 @@ void SocketLauncher::connectionRemoved(const QString& identifier) We only send the idlecpurequest message if we don't have an idle delegate */ -void SocketLauncher::handleIdleCpuRequest() +void QSocketLauncher::handleIdleCpuRequest() { if (!idleDelegate()) { QJsonObject object; - object.insert(RemoteProtocol::remote(), RemoteProtocol::idlecpurequested()); - object.insert(RemoteProtocol::request(), idleCpuRequest()); + object.insert(QRemoteProtocol::remote(), QRemoteProtocol::idlecpurequested()); + object.insert(QRemoteProtocol::request(), idleCpuRequest()); m_server->broadcast(object); } } @@ -168,11 +169,11 @@ void SocketLauncher::handleIdleCpuRequest() processes to all clients */ -void SocketLauncher::handleInternalProcessChange() +void QSocketLauncher::handleInternalProcessChange() { QJsonObject object; - object.insert(RemoteProtocol::remote(), RemoteProtocol::internalprocesses()); - object.insert(RemoteProtocol::processes(), pidListToArray(internalProcesses())); + object.insert(QRemoteProtocol::remote(), QRemoteProtocol::internalprocesses()); + object.insert(QRemoteProtocol::processes(), pidListToArray(internalProcesses())); m_server->broadcast(object); } @@ -181,11 +182,11 @@ void SocketLauncher::handleInternalProcessChange() We override this function to forward internal process errors */ -void SocketLauncher::handleInternalProcessError(QProcess::ProcessError error) +void QSocketLauncher::handleInternalProcessError(QProcess::ProcessError error) { QJsonObject object; - object.insert(RemoteProtocol::remote(), RemoteProtocol::internalprocesserror()); - object.insert(RemoteProtocol::processError(), error); + object.insert(QRemoteProtocol::remote(), QRemoteProtocol::internalprocesserror()); + object.insert(QRemoteProtocol::processError(), error); m_server->broadcast(object); } @@ -193,19 +194,19 @@ void SocketLauncher::handleInternalProcessError(QProcess::ProcessError error) \internal */ -void SocketLauncher::messageReceived(const QString& identifier, const QJsonObject& message) +void QSocketLauncher::messageReceived(const QString& identifier, const QJsonObject& message) { - QString remote = message.value(RemoteProtocol::remote()).toString(); - if (remote == RemoteProtocol::halt()) + QString remote = message.value(QRemoteProtocol::remote()).toString(); + if (remote == QRemoteProtocol::halt()) qDebug() << Q_FUNC_INFO << "Received halt request; ignoring"; - else if ( remote == RemoteProtocol::memory() ) - setMemoryRestricted(message.value(RemoteProtocol::restricted()).toBool()); - else if ( remote == RemoteProtocol::idlecpuavailable() ) { + else if ( remote == QRemoteProtocol::memory() ) + setMemoryRestricted(message.value(QRemoteProtocol::restricted()).toBool()); + else if ( remote == QRemoteProtocol::idlecpuavailable() ) { if (!idleDelegate()) idleCpuAvailable(); } else { - LauncherClient *client = m_idToClient.value(identifier); + QLauncherClient *client = m_idToClient.value(identifier); if (client) client->receive(message); } @@ -214,18 +215,18 @@ void SocketLauncher::messageReceived(const QString& identifier, const QJsonObjec /*! \internal - This function should only be called from a signal raised in LauncherClient + This function should only be called from a signal raised in QLauncherClient */ -void SocketLauncher::send(const QJsonObject& message) +void QSocketLauncher::send(const QJsonObject& message) { - sendToClient(message, qobject_cast<LauncherClient *>(sender())); + sendToClient(message, qobject_cast<QLauncherClient *>(sender())); } /*! \internal */ -void SocketLauncher::sendToClient(const QJsonObject& message, LauncherClient *client) +void QSocketLauncher::sendToClient(const QJsonObject& message, QLauncherClient *client) { Q_ASSERT(client); Q_ASSERT(m_server); @@ -233,6 +234,6 @@ void SocketLauncher::sendToClient(const QJsonObject& message, LauncherClient *cl } -#include "moc_socketlauncher.cpp" +#include "moc_qsocketlauncher.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/socketlauncher.h b/src/processmanager/qsocketlauncher.h index 33058bd..7620246 100644 --- a/src/processmanager/socketlauncher.h +++ b/src/processmanager/qsocketlauncher.h @@ -45,17 +45,17 @@ #include <QJsonObject> #include <qjsonserver.h> -#include "processbackendmanager.h" +#include "qprocessbackendmanager.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class LauncherClient; +class QLauncherClient; -class Q_ADDON_PROCESSMANAGER_EXPORT SocketLauncher : public ProcessBackendManager { +class Q_ADDON_PROCESSMANAGER_EXPORT QSocketLauncher : public QProcessBackendManager { Q_OBJECT public: - SocketLauncher(QObject *parent=0); + QSocketLauncher(QObject *parent=0); Q_INVOKABLE bool listen(int port, QtAddOn::QtJsonStream::QJsonAuthority *authority = 0); Q_INVOKABLE bool listen(const QString& socketname, QtAddOn::QtJsonStream::QJsonAuthority *authority=0); @@ -75,16 +75,16 @@ private slots: void send(const QJsonObject& message); private: - void sendToClient(const QJsonObject& message, LauncherClient *client); + void sendToClient(const QJsonObject& message, QLauncherClient *client); private: QtAddOn::QtJsonStream::QJsonServer *m_server; - QMap<QString, LauncherClient*> m_idToClient; - QMap<LauncherClient*, QString> m_clientToId; + QMap<QString, QLauncherClient*> m_idToClient; + QMap<QLauncherClient*, QString> m_clientToId; }; QT_END_NAMESPACE_PROCESSMANAGER -QT_PROCESSMANAGER_DECLARE_METATYPE_PTR(SocketLauncher) +QT_PROCESSMANAGER_DECLARE_METATYPE_PTR(QSocketLauncher) #endif // SOCKET_LAUNCHER_H diff --git a/src/processmanager/socketprocessbackendfactory.cpp b/src/processmanager/qsocketprocessbackendfactory.cpp index d30e7fc..8c933a1 100644 --- a/src/processmanager/socketprocessbackendfactory.cpp +++ b/src/processmanager/qsocketprocessbackendfactory.cpp @@ -42,29 +42,30 @@ #include <QJsonDocument> #include <QtEndian> -#include "socketprocessbackendfactory.h" +#include "qsocketprocessbackendfactory.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \class SocketProcessBackendFactory - \brief The SocketProcessBackendFactory class creates RemoteProcessBackend objects + \class QSocketProcessBackendFactory + \brief The QSocketProcessBackendFactory class creates QRemoteProcessBackend objects + \inmodule QtProcessManager - The SocketProcessBackendFactory connects over a Unix local socket to + The QSocketProcessBackendFactory connects over a Unix local socket to an already-running "launcher" server. */ /*! - \property SocketProcessBackendFactory::socketName + \property QSocketProcessBackendFactory::socketName The name of the Unix local socket that this factory should connect to. */ /*! - Construct a SocketProcessBackendFactory with optional \a parent. + Construct a QSocketProcessBackendFactory with optional \a parent. */ -SocketProcessBackendFactory::SocketProcessBackendFactory(QObject *parent) - : RemoteProcessBackendFactory(parent) +QSocketProcessBackendFactory::QSocketProcessBackendFactory(QObject *parent) + : QRemoteProcessBackendFactory(parent) { m_socket = new QLocalSocket(this); connect(m_socket, SIGNAL(connected()), SLOT(connected())); @@ -76,26 +77,26 @@ SocketProcessBackendFactory::SocketProcessBackendFactory(QObject *parent) Destroy this and child objects. */ -SocketProcessBackendFactory::~SocketProcessBackendFactory() +QSocketProcessBackendFactory::~QSocketProcessBackendFactory() { } /*! - The SocketProcessBackendFactory can only match if it has a valid + The QSocketProcessBackendFactory can only match if it has a valid connection to the socket. The \a info parameter is passed to the standard matching algorithm. */ -bool SocketProcessBackendFactory::canCreate(const ProcessInfo& info) const +bool QSocketProcessBackendFactory::canCreate(const QProcessInfo& info) const { - return m_socket->isValid() && RemoteProcessBackendFactory::canCreate(info); + return m_socket->isValid() && QRemoteProcessBackendFactory::canCreate(info); } /*! Returns the current socket name. An empty string indicates that no socket has been set. */ -QString SocketProcessBackendFactory::socketName() const +QString QSocketProcessBackendFactory::socketName() const { return m_socket->serverName(); } @@ -105,7 +106,7 @@ QString SocketProcessBackendFactory::socketName() const you will not be notified, but the socketName() function will return null. */ -void SocketProcessBackendFactory::setSocketName(const QString& socketname) +void QSocketProcessBackendFactory::setSocketName(const QString& socketname) { if (socketname != m_socket->serverName()) { m_socket->abort(); @@ -118,7 +119,7 @@ void SocketProcessBackendFactory::setSocketName(const QString& socketname) Read data from the socket */ -void SocketProcessBackendFactory::readyRead() +void QSocketProcessBackendFactory::readyRead() { m_buffer.append(m_socket->readAll()); while (m_buffer.size() >= 12) { // QJsonDocuments are at least this large @@ -135,7 +136,7 @@ void SocketProcessBackendFactory::readyRead() \internal */ -void SocketProcessBackendFactory::connected() +void QSocketProcessBackendFactory::connected() { handleConnected(); } @@ -144,7 +145,7 @@ void SocketProcessBackendFactory::connected() \internal */ -void SocketProcessBackendFactory::disconnected() +void QSocketProcessBackendFactory::disconnected() { qWarning("Launcher process socket disconnected"); } @@ -153,17 +154,17 @@ void SocketProcessBackendFactory::disconnected() \internal */ -bool SocketProcessBackendFactory::send(const QJsonObject& message) +bool QSocketProcessBackendFactory::send(const QJsonObject& message) { return (m_socket->isValid() && m_socket->write(QJsonDocument(message).toBinaryData()) != -1); } /*! - \fn void SocketProcessBackendFactory::socketNameChanged() + \fn void QSocketProcessBackendFactory::socketNameChanged() Signal emitted when the socket name has been changed */ -#include "moc_socketprocessbackendfactory.cpp" +#include "moc_qsocketprocessbackendfactory.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/socketprocessbackendfactory.h b/src/processmanager/qsocketprocessbackendfactory.h index b305716..2e9aa1b 100644 --- a/src/processmanager/socketprocessbackendfactory.h +++ b/src/processmanager/qsocketprocessbackendfactory.h @@ -40,21 +40,21 @@ #ifndef SOCKET_PROCESS_BACKEND_FACTORY_H #define SOCKET_PROCESS_BACKEND_FACTORY_H -#include "remoteprocessbackendfactory.h" +#include "qremoteprocessbackendfactory.h" class QLocalSocket; QT_BEGIN_NAMESPACE_PROCESSMANAGER -class Q_ADDON_PROCESSMANAGER_EXPORT SocketProcessBackendFactory : public RemoteProcessBackendFactory +class Q_ADDON_PROCESSMANAGER_EXPORT QSocketProcessBackendFactory : public QRemoteProcessBackendFactory { Q_OBJECT Q_PROPERTY(QString socketName READ socketName WRITE setSocketName NOTIFY socketNameChanged) public: - SocketProcessBackendFactory(QObject *parent = 0); - virtual ~SocketProcessBackendFactory(); - virtual bool canCreate(const ProcessInfo& info) const; + QSocketProcessBackendFactory(QObject *parent = 0); + virtual ~QSocketProcessBackendFactory(); + virtual bool canCreate(const QProcessInfo& info) const; QString socketName() const; void setSocketName(const QString&); diff --git a/src/processmanager/standardprocessbackend.cpp b/src/processmanager/qstandardprocessbackend.cpp index 94d7c90..02a4160 100644 --- a/src/processmanager/standardprocessbackend.cpp +++ b/src/processmanager/qstandardprocessbackend.cpp @@ -37,22 +37,23 @@ ** ****************************************************************************/ -#include "standardprocessbackend.h" +#include "qstandardprocessbackend.h" #include <QDebug> QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \class StandardProcessBackend - \brief The StandardProcessBackend class wraps a single QProcess object + \class QStandardProcessBackend + \brief The QStandardProcessBackend class wraps a single QProcess object + \inmodule QtProcessManager */ /*! - Construct a StandardProcessBackend with ProcessInfo \a info and optional \a parent + Construct a QStandardProcessBackend with QProcessInfo \a info and optional \a parent */ -StandardProcessBackend::StandardProcessBackend(const ProcessInfo& info, QObject *parent) - : UnixProcessBackend(info, parent) +QStandardProcessBackend::QStandardProcessBackend(const QProcessInfo &info, QObject *parent) + : QUnixProcessBackend(info, parent) { } @@ -63,7 +64,7 @@ StandardProcessBackend::StandardProcessBackend(const ProcessInfo& info, QObject an error(QProcess::FailedToStart) will be emitted. */ -void StandardProcessBackend::start() +void QStandardProcessBackend::start() { if (createProcess()) startProcess(); @@ -73,9 +74,9 @@ void StandardProcessBackend::start() Calls the parent class function and emits the started() signal. */ -void StandardProcessBackend::handleProcessStarted() +void QStandardProcessBackend::handleProcessStarted() { - UnixProcessBackend::handleProcessStarted(); + QUnixProcessBackend::handleProcessStarted(); emit started(); } @@ -83,9 +84,9 @@ void StandardProcessBackend::handleProcessStarted() Calls the parent class function and emits the error() signal with \a err. */ -void StandardProcessBackend::handleProcessError(QProcess::ProcessError err) +void QStandardProcessBackend::handleProcessError(QProcess::ProcessError err) { - UnixProcessBackend::handleProcessError(err); + QUnixProcessBackend::handleProcessError(err); emit error(err); } @@ -94,9 +95,9 @@ void StandardProcessBackend::handleProcessError(QProcess::ProcessError err) the \a exitCode and \a exitStatus. */ -void StandardProcessBackend::handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) +void QStandardProcessBackend::handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) { - UnixProcessBackend::handleProcessFinished(exitCode, exitStatus); + QUnixProcessBackend::handleProcessFinished(exitCode, exitStatus); emit finished(exitCode, exitStatus); } @@ -104,12 +105,12 @@ void StandardProcessBackend::handleProcessFinished(int exitCode, QProcess::ExitS Calls the parent class function and emits the stateChanged() signal with \a state. */ -void StandardProcessBackend::handleProcessStateChanged(QProcess::ProcessState state) +void QStandardProcessBackend::handleProcessStateChanged(QProcess::ProcessState state) { - UnixProcessBackend::handleProcessStateChanged(state); + QUnixProcessBackend::handleProcessStateChanged(state); emit stateChanged(state); } -#include "moc_standardprocessbackend.cpp" +#include "moc_qstandardprocessbackend.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/standardprocessbackend.h b/src/processmanager/qstandardprocessbackend.h index 3862bb6..cc1e08d 100644 --- a/src/processmanager/standardprocessbackend.h +++ b/src/processmanager/qstandardprocessbackend.h @@ -40,18 +40,18 @@ #ifndef STANDARD_PROCESS_BACKEND_H #define STANDARD_PROCESS_BACKEND_H -#include "unixprocessbackend.h" +#include "qunixprocessbackend.h" -#include "processmanager-global.h" +#include "qprocessmanager-global.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class Q_ADDON_PROCESSMANAGER_EXPORT StandardProcessBackend : public UnixProcessBackend +class Q_ADDON_PROCESSMANAGER_EXPORT QStandardProcessBackend : public QUnixProcessBackend { Q_OBJECT public: - StandardProcessBackend(const ProcessInfo& info, QObject *parent); + QStandardProcessBackend(const QProcessInfo& info, QObject *parent); virtual void start(); protected: diff --git a/src/processmanager/standardprocessbackendfactory.cpp b/src/processmanager/qstandardprocessbackendfactory.cpp index c62d94b..1314cdb 100644 --- a/src/processmanager/standardprocessbackendfactory.cpp +++ b/src/processmanager/qstandardprocessbackendfactory.cpp @@ -38,35 +38,36 @@ ****************************************************************************/ -#include "standardprocessbackendfactory.h" -#include "standardprocessbackend.h" +#include "qstandardprocessbackendfactory.h" +#include "qstandardprocessbackend.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \class StandardProcessBackendFactory - \brief The StandardProcessBackendFactory class creates StandardProcessBackend objects + \class QStandardProcessBackendFactory + \brief The QStandardProcessBackendFactory class creates StandardProcessBackend objects + \inmodule QtProcessManager */ /*! - Construct a StandardProcessBackendFactory with optional \a parent + Construct a QStandardProcessBackendFactory with optional \a parent */ -StandardProcessBackendFactory::StandardProcessBackendFactory(QObject *parent) - : ProcessBackendFactory(parent) +QStandardProcessBackendFactory::QStandardProcessBackendFactory(QObject *parent) + : QProcessBackendFactory(parent) { } /*! - Construct a StandardProcessBackend from a ProcessInfo \a info record + Construct a QStandardProcessBackend from a QProcessInfo \a info record with \a parent. */ -ProcessBackend * StandardProcessBackendFactory::create(const ProcessInfo& info, QObject *parent) +QProcessBackend * QStandardProcessBackendFactory::create(const QProcessInfo& info, QObject *parent) { - return new StandardProcessBackend(info, parent); + return new QStandardProcessBackend(info, parent); } -#include "moc_standardprocessbackendfactory.cpp" +#include "moc_qstandardprocessbackendfactory.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/standardprocessbackendfactory.h b/src/processmanager/qstandardprocessbackendfactory.h index c31cc56..d0b2cf9 100644 --- a/src/processmanager/standardprocessbackendfactory.h +++ b/src/processmanager/qstandardprocessbackendfactory.h @@ -40,19 +40,19 @@ #ifndef STANDARD_PROCESS_BACKEND_FACTORY_H #define STANDARD_PROCESS_BACKEND_FACTORY_H -#include "processbackendfactory.h" +#include "qprocessbackendfactory.h" -#include "processmanager-global.h" +#include "qprocessmanager-global.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class Q_ADDON_PROCESSMANAGER_EXPORT StandardProcessBackendFactory : public ProcessBackendFactory +class Q_ADDON_PROCESSMANAGER_EXPORT QStandardProcessBackendFactory : public QProcessBackendFactory { Q_OBJECT public: - StandardProcessBackendFactory(QObject *parent=0); - virtual ProcessBackend *create(const ProcessInfo& info, QObject *parent); + QStandardProcessBackendFactory(QObject *parent=0); + virtual QProcessBackend *create(const QProcessInfo& info, QObject *parent); }; QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/timeoutidledelegate.cpp b/src/processmanager/qtimeoutidledelegate.cpp index 68305fe..fa151d8 100644 --- a/src/processmanager/timeoutidledelegate.cpp +++ b/src/processmanager/qtimeoutidledelegate.cpp @@ -37,34 +37,35 @@ ** ****************************************************************************/ -#include "timeoutidledelegate.h" +#include "qtimeoutidledelegate.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER const int kIdleTimerInterval = 1000; /*! - \class TimeoutIdleDelegate - \brief The TimeoutIdleDelegate class generates a periodic timeout. + \class QTimeoutIdleDelegate + \brief The QTimeoutIdleDelegate class generates a periodic timeout. + \inmodule QtProcessManager - The TimeoutIdleDelegate class generates a periodic timeout for + The QTimeoutIdleDelegate class generates a periodic timeout for creation of idle resources. This is not an intelligent class - it doesn't matter what your CPU is doing, it will still generate the periodic timeout. */ /*! - \property TimeoutIdleDelegate::idleInterval + \property QTimeoutIdleDelegate::idleInterval \brief Time in milliseconds before a new idle CPU request will be fulfilled */ /*! - Construct a TimeoutIdleDelegate with an optional \a parent. + Construct a QTimeoutIdleDelegate with an optional \a parent. */ -TimeoutIdleDelegate::TimeoutIdleDelegate(QObject *parent) - : IdleDelegate(parent) +QTimeoutIdleDelegate::QTimeoutIdleDelegate(QObject *parent) + : QIdleDelegate(parent) { connect(&m_timer, SIGNAL(timeout()), SIGNAL(idleCpuAvailable())); m_timer.setInterval(kIdleTimerInterval); @@ -74,7 +75,7 @@ TimeoutIdleDelegate::TimeoutIdleDelegate(QObject *parent) Turn on or off idle requests based on \a state */ -void TimeoutIdleDelegate::handleStateChange(bool state) +void QTimeoutIdleDelegate::handleStateChange(bool state) { if (state) m_timer.start(); @@ -86,7 +87,7 @@ void TimeoutIdleDelegate::handleStateChange(bool state) Return the current launch interval in milliseconds */ -int TimeoutIdleDelegate::idleInterval() const +int QTimeoutIdleDelegate::idleInterval() const { return m_timer.interval(); } @@ -95,7 +96,7 @@ int TimeoutIdleDelegate::idleInterval() const Set the current idle interval to \a interval milliseconds */ -void TimeoutIdleDelegate::setIdleInterval(int interval) +void QTimeoutIdleDelegate::setIdleInterval(int interval) { if (m_timer.interval() != interval) { m_timer.stop(); @@ -107,11 +108,11 @@ void TimeoutIdleDelegate::setIdleInterval(int interval) } /*! - \fn void TimeoutIdleDelegate::idleIntervalChanged() + \fn void QTimeoutIdleDelegate::idleIntervalChanged() This signal is emitted when the idleInterval is changed. */ -#include "moc_timeoutidledelegate.cpp" +#include "moc_qtimeoutidledelegate.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/timeoutidledelegate.h b/src/processmanager/qtimeoutidledelegate.h index 73f5f0a..7c3288b 100644 --- a/src/processmanager/timeoutidledelegate.h +++ b/src/processmanager/qtimeoutidledelegate.h @@ -41,19 +41,19 @@ #define TIMEOUT_IDLE_DELEGATE_H #include <QTimer> -#include "idledelegate.h" +#include "qidledelegate.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class ProcessInfo; +class QProcessInfo; -class Q_ADDON_PROCESSMANAGER_EXPORT TimeoutIdleDelegate : public IdleDelegate +class Q_ADDON_PROCESSMANAGER_EXPORT QTimeoutIdleDelegate : public QIdleDelegate { Q_OBJECT Q_PROPERTY(int idleInterval READ idleInterval WRITE setIdleInterval NOTIFY idleIntervalChanged) public: - explicit TimeoutIdleDelegate(QObject *parent = 0); + explicit QTimeoutIdleDelegate(QObject *parent = 0); int idleInterval() const; void setIdleInterval(int interval); @@ -65,7 +65,7 @@ protected: virtual void handleStateChange(bool state); private: - Q_DISABLE_COPY(TimeoutIdleDelegate); + Q_DISABLE_COPY(QTimeoutIdleDelegate) QTimer m_timer; }; diff --git a/src/processmanager/unixprocessbackend.cpp b/src/processmanager/qunixprocessbackend.cpp index c211d63..ca0e724 100644 --- a/src/processmanager/unixprocessbackend.cpp +++ b/src/processmanager/qunixprocessbackend.cpp @@ -37,9 +37,9 @@ ** ****************************************************************************/ -#include "unixprocessbackend.h" -#include "unixsandboxprocess.h" -#include "procutils.h" +#include "qunixprocessbackend.h" +#include "qunixsandboxprocess_p.h" +#include "qprocutils.h" #include <sys/resource.h> #include <errno.h> #include <signal.h> @@ -48,16 +48,17 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \class UnixProcessBackend - \brief The UnixProcessBackend class wraps a QProcess object + \class QUnixProcessBackend + \brief The QUnixProcessBackend class wraps a QProcess object + \inmodule QtProcessManager */ /*! - Construct a UnixProcessBackend with ProcessInfo \a info and optional \a parent + Construct a QUnixProcessBackend with QProcessInfo \a info and optional \a parent */ -UnixProcessBackend::UnixProcessBackend(const ProcessInfo& info, QObject *parent) - : ProcessBackend(info, parent) +QUnixProcessBackend::QUnixProcessBackend(const QProcessInfo &info, QObject *parent) + : QProcessBackend(info, parent) , m_process(0) { } @@ -68,27 +69,27 @@ UnixProcessBackend::UnixProcessBackend(const ProcessInfo& info, QObject *parent) We have to do some special processing to terminate the process group. */ -UnixProcessBackend::~UnixProcessBackend() +QUnixProcessBackend::~QUnixProcessBackend() { if (m_process && m_process->state() != QProcess::NotRunning) - ProcUtils::sendSignalToProcess(m_process->pid(), SIGKILL); + QProcUtils::sendSignalToProcess(m_process->pid(), SIGKILL); } /*! Returns the PID of this process. If the process has not started up yet properly, its PID will be 0. */ -Q_PID UnixProcessBackend::pid() const +Q_PID QUnixProcessBackend::pid() const { if (m_process) return m_process->pid(); - return ProcessBackend::pid(); + return QProcessBackend::pid(); } /*! Return the actual process priority (if running) */ -qint32 UnixProcessBackend::actualPriority() const +qint32 QUnixProcessBackend::actualPriority() const { if (m_process) { errno = 0; // getpriority can return -1, so we clear errno @@ -96,7 +97,7 @@ qint32 UnixProcessBackend::actualPriority() const if (!errno) return result; } - return ProcessBackend::actualPriority(); + return QProcessBackend::actualPriority(); } /*! @@ -105,11 +106,11 @@ qint32 UnixProcessBackend::actualPriority() const of the entire group. */ -void UnixProcessBackend::setDesiredPriority(qint32 priority) +void QUnixProcessBackend::setDesiredPriority(qint32 priority) { - ProcessBackend::setDesiredPriority(priority); + QProcessBackend::setDesiredPriority(priority); if (m_process) - ProcUtils::setPriority(m_process->pid(), priority); + QProcUtils::setPriority(m_process->pid(), priority); } #if defined(Q_OS_LINUX) @@ -118,29 +119,29 @@ void UnixProcessBackend::setDesiredPriority(qint32 priority) Return the process oomAdjustment */ -qint32 UnixProcessBackend::actualOomAdjustment() const +qint32 QUnixProcessBackend::actualOomAdjustment() const { // ### TODO: What if m_process doesn't have a valid PID yet? if (m_process) { bool ok; - qint32 result = ProcUtils::oomAdjustment(m_process->pid(), &ok); + qint32 result = QProcUtils::oomAdjustment(m_process->pid(), &ok); if (ok) return result; qWarning() << "Unable to read oom adjustment for" << m_process->pid(); } - return ProcessBackend::actualOomAdjustment(); + return QProcessBackend::actualOomAdjustment(); } /*! Set the process /proc/<pid>/oom_score_adj to \a oomAdjustment */ -void UnixProcessBackend::setDesiredOomAdjustment(qint32 oomAdjustment) +void QUnixProcessBackend::setDesiredOomAdjustment(qint32 oomAdjustment) { - ProcessBackend::setDesiredOomAdjustment(oomAdjustment); + QProcessBackend::setDesiredOomAdjustment(oomAdjustment); if (m_process) { - if (!ProcUtils::setOomAdjustment(m_process->pid(), oomAdjustment)) + if (!QProcUtils::setOomAdjustment(m_process->pid(), oomAdjustment)) qWarning() << "Unable to set oom adjustment for" << m_process->pid(); } } @@ -151,7 +152,7 @@ void UnixProcessBackend::setDesiredOomAdjustment(qint32 oomAdjustment) Returns the state of the process. The base class always returns NotRunning. */ -QProcess::ProcessState UnixProcessBackend::state() const +QProcess::ProcessState QUnixProcessBackend::state() const { return m_process ? m_process->state() : QProcess::NotRunning; } @@ -160,16 +161,16 @@ QProcess::ProcessState UnixProcessBackend::state() const Internal function to create the QProcess. Returns true if a process was created. */ -bool UnixProcessBackend::createProcess() +bool QUnixProcessBackend::createProcess() { if (m_process) { qWarning() << "Can't restart process!"; return false; } - qint64 uid = (m_info.contains(ProcessInfoConstants::Uid) ? m_info.uid() : -1); - qint64 gid = (m_info.contains(ProcessInfoConstants::Gid) ? m_info.gid() : -1); - m_process = new UnixSandboxProcess(uid, gid, m_info.umask(), m_info.dropCapabilities(), this); + qint64 uid = (m_info.contains(QProcessInfoConstants::Uid) ? m_info.uid() : -1); + qint64 gid = (m_info.contains(QProcessInfoConstants::Gid) ? m_info.gid() : -1); + m_process = new QUnixSandboxProcess(uid, gid, m_info.umask(), m_info.dropCapabilities(), this); m_process->setReadChannel(QProcess::StandardOutput); connect(m_process, SIGNAL(readyReadStandardOutput()), @@ -192,7 +193,7 @@ bool UnixProcessBackend::createProcess() Internal function to start the QProcess running. */ -void UnixProcessBackend::startProcess() +void QUnixProcessBackend::startProcess() { QProcessEnvironment env; QMapIterator<QString, QVariant> it(m_info.environment()); @@ -214,17 +215,17 @@ void UnixProcessBackend::startProcess() \sa finished() */ -void UnixProcessBackend::stop(int timeout) +void QUnixProcessBackend::stop(int timeout) { Q_ASSERT(m_process); if (m_process->state() != QProcess::NotRunning) { if (timeout > 0) { - ProcUtils::sendSignalToProcess(m_process->pid(), SIGTERM); + QProcUtils::sendSignalToProcess(m_process->pid(), SIGTERM); m_killTimer.start(timeout); } else { - ProcUtils::sendSignalToProcess(m_process->pid(), SIGKILL); + QProcUtils::sendSignalToProcess(m_process->pid(), SIGKILL); } } } @@ -233,7 +234,7 @@ void UnixProcessBackend::stop(int timeout) Writes at most \a maxSize bytes of data from \a data to the device. Returns the number of bytes that were actually written, or -1 if an error occurred. */ -qint64 UnixProcessBackend::write(const char *data, qint64 maxSize) +qint64 QUnixProcessBackend::write(const char *data, qint64 maxSize) { if (m_process) return m_process->write(data, maxSize); @@ -244,13 +245,13 @@ qint64 UnixProcessBackend::write(const char *data, qint64 maxSize) Override this in subclasses. Make sure you call the parent class. Your subclass should emit \sa started() */ -void UnixProcessBackend::handleProcessStarted() +void QUnixProcessBackend::handleProcessStarted() { - if (m_info.contains(ProcessInfoConstants::Priority)) - ProcUtils::setPriority(m_process->pid(), m_info.priority()); + if (m_info.contains(QProcessInfoConstants::Priority)) + QProcUtils::setPriority(m_process->pid(), m_info.priority()); - if (m_info.contains(ProcessInfoConstants::OomAdjustment) && - !ProcUtils::setOomAdjustment(m_process->pid(), m_info.oomAdjustment())) + if (m_info.contains(QProcessInfoConstants::OomAdjustment) && + !QProcUtils::setOomAdjustment(m_process->pid(), m_info.oomAdjustment())) qWarning() << "Failed to set process oom score at startup from " << actualOomAdjustment() << "to" << m_info.oomAdjustment(); } @@ -258,7 +259,7 @@ void UnixProcessBackend::handleProcessStarted() Override this in subclasses. Make sure you call the parent class with \a error. Your subclass should emit \sa error() */ -void UnixProcessBackend::handleProcessError(QProcess::ProcessError error) +void QUnixProcessBackend::handleProcessError(QProcess::ProcessError error) { Q_UNUSED(error); } @@ -267,7 +268,7 @@ void UnixProcessBackend::handleProcessError(QProcess::ProcessError error) Override this in subclasses. Make sure you call the parent class with \a exitCode and \a exitStatus. Your subclass should emit \sa finished() */ -void UnixProcessBackend::handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) +void QUnixProcessBackend::handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) { Q_UNUSED(exitCode); Q_UNUSED(exitStatus); @@ -278,7 +279,7 @@ void UnixProcessBackend::handleProcessFinished(int exitCode, QProcess::ExitStatu Override this in subclasses. Make sure you call the parent class with \a state. Your subclass should emit \sa stateChanged() */ -void UnixProcessBackend::handleProcessStateChanged(QProcess::ProcessState state) +void QUnixProcessBackend::handleProcessStateChanged(QProcess::ProcessState state) { Q_UNUSED(state); m_killTimer.stop(); @@ -287,7 +288,7 @@ void UnixProcessBackend::handleProcessStateChanged(QProcess::ProcessState state) /*! \internal */ -void UnixProcessBackend::unixProcessStarted() +void QUnixProcessBackend::unixProcessStarted() { handleProcessStarted(); } @@ -295,7 +296,7 @@ void UnixProcessBackend::unixProcessStarted() /*! \internal */ -void UnixProcessBackend::unixProcessError(QProcess::ProcessError error) +void QUnixProcessBackend::unixProcessError(QProcess::ProcessError error) { handleProcessError(error); } @@ -303,7 +304,7 @@ void UnixProcessBackend::unixProcessError(QProcess::ProcessError error) /*! \internal */ -void UnixProcessBackend::unixProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) +void QUnixProcessBackend::unixProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) { handleProcessFinished(exitCode, exitStatus); } @@ -311,7 +312,7 @@ void UnixProcessBackend::unixProcessFinished(int exitCode, QProcess::ExitStatus /*! \internal */ -void UnixProcessBackend::unixProcessStateChanged(QProcess::ProcessState state) +void QUnixProcessBackend::unixProcessStateChanged(QProcess::ProcessState state) { handleProcessStateChanged(state); } @@ -319,7 +320,7 @@ void UnixProcessBackend::unixProcessStateChanged(QProcess::ProcessState state) /*! \internal */ -void UnixProcessBackend::killTimeout() +void QUnixProcessBackend::killTimeout() { if (m_process && m_process->state() == QProcess::Running) m_process->kill(); @@ -328,7 +329,7 @@ void UnixProcessBackend::killTimeout() /*! \internal */ -void UnixProcessBackend::readyReadStandardOutput() +void QUnixProcessBackend::readyReadStandardOutput() { handleStandardOutput(m_process->readAllStandardOutput()); } @@ -336,7 +337,7 @@ void UnixProcessBackend::readyReadStandardOutput() /*! \internal */ -void UnixProcessBackend::readyReadStandardError() +void QUnixProcessBackend::readyReadStandardError() { handleStandardError(m_process->readAllStandardError()); } @@ -344,11 +345,11 @@ void UnixProcessBackend::readyReadStandardError() /*! \internal */ -QString UnixProcessBackend::errorString() const +QString QUnixProcessBackend::errorString() const { return m_process->errorString(); } -#include "moc_unixprocessbackend.cpp" +#include "moc_qunixprocessbackend.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/unixprocessbackend.h b/src/processmanager/qunixprocessbackend.h index 9177e0f..fe05c05 100644 --- a/src/processmanager/unixprocessbackend.h +++ b/src/processmanager/qunixprocessbackend.h @@ -40,20 +40,20 @@ #ifndef UNIX_PROCESS_BACKEND_H #define UNIX_PROCESS_BACKEND_H -#include "processbackend.h" +#include "qprocessbackend.h" #include <QTimer> -#include "processmanager-global.h" +#include "qprocessmanager-global.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class Q_ADDON_PROCESSMANAGER_EXPORT UnixProcessBackend : public ProcessBackend +class Q_ADDON_PROCESSMANAGER_EXPORT QUnixProcessBackend : public QProcessBackend { Q_OBJECT public: - UnixProcessBackend(const ProcessInfo& info, QObject *parent=0); - virtual ~UnixProcessBackend(); + QUnixProcessBackend(const QProcessInfo& info, QObject *parent=0); + virtual ~QUnixProcessBackend(); virtual Q_PID pid() const; diff --git a/src/processmanager/unixsandboxprocess.cpp b/src/processmanager/qunixsandboxprocess.cpp index a1a70e2..d4b328c 100644 --- a/src/processmanager/unixsandboxprocess.cpp +++ b/src/processmanager/qunixsandboxprocess.cpp @@ -38,7 +38,7 @@ ****************************************************************************/ -#include "unixsandboxprocess.h" +#include "qunixsandboxprocess_p.h" #include <sys/stat.h> #include <errno.h> @@ -59,15 +59,17 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER /*! - \class UnixSandboxProcess - \brief The UnixSandboxProcess class sets the UID and GID on a Unix process + \class QUnixSandboxProcess + \brief The QUnixSandboxProcess class sets the UID and GID on a Unix process + \inmodule QtProcessManager */ /*! - Construct a UnixProcessBackend with \a uid, \a gid, \a umask, and optional \a parent. + Construct a UnixProcessBackend with \a uid, \a gid, \a umask, \a dropCapabilities, + and optional \a parent. */ -UnixSandboxProcess::UnixSandboxProcess(qint64 uid, qint64 gid, qint64 umask, qint64 dropCapabilities, QObject *parent) +QUnixSandboxProcess::QUnixSandboxProcess(qint64 uid, qint64 gid, qint64 umask, qint64 dropCapabilities, QObject *parent) : QProcess(parent) , m_uid(uid) , m_gid(gid) @@ -129,14 +131,14 @@ UnixSandboxProcess::UnixSandboxProcess(qint64 uid, qint64 gid, qint64 umask, qin */ -void UnixSandboxProcess::setupChildProcess() +void QUnixSandboxProcess::setupChildProcess() { #if defined(Q_OS_LINUX) if (::prctl(PR_SET_PDEATHSIG, SIGTERM)) - qFatal("UnixSandboxProcess prctl unable to set death signal: %s", strerror(errno)); + qFatal("QUnixSandboxProcess prctl unable to set death signal: %s", strerror(errno)); #endif if (::setpgid(0,0)) - qFatal("UnixSandboxProcess setpgid(): %s", strerror(errno)); + qFatal("QUnixSandboxProcess setpgid(): %s", strerror(errno)); if (m_umask >= 0) { mode_t umask = m_umask; @@ -147,35 +149,35 @@ void UnixSandboxProcess::setupChildProcess() errno = 0; struct passwd *pw = ::getpwuid(m_uid); if (!pw && errno) - qFatal("UnixSandboxProcess getpwuid(%ld): %s", (long) m_uid, strerror(errno)); + qFatal("QUnixSandboxProcess getpwuid(%ld): %s", (long) m_uid, strerror(errno)); gid_t gid = m_gid; if (m_gid < 0) { // UID set, GID unset if (!pw) - qFatal("UnixSandboxProcess did not find uid %ld in database", (long) m_uid); + qFatal("QUnixSandboxProcess did not find uid %ld in database", (long) m_uid); if (::initgroups(pw->pw_name, pw->pw_gid)) - qFatal("UnixSandboxProcess initgroups(%s, %ld): %s", pw->pw_name, (long) pw->pw_gid, strerror(errno)); + qFatal("QUnixSandboxProcess initgroups(%s, %ld): %s", pw->pw_name, (long) pw->pw_gid, strerror(errno)); gid = pw->pw_gid; } else { // UID set, GID set if (pw && pw->pw_gid == m_gid) { if (::initgroups(pw->pw_name, pw->pw_gid)) - qFatal("UnixSandboxProcess initgroups(%s, %ld): %s", pw->pw_name, (long) pw->pw_gid, strerror(errno)); + qFatal("QUnixSandboxProcess initgroups(%s, %ld): %s", pw->pw_name, (long) pw->pw_gid, strerror(errno)); } else { if (::setgroups(0, NULL)) - qFatal("UnixSandboxProcess setgroups(0,NULL): %s", strerror(errno)); + qFatal("QUnixSandboxProcess setgroups(0,NULL): %s", strerror(errno)); } } if (::setgid(gid)) - qFatal("UnixSandboxProcess setgid(%ld): %s", (long) gid, strerror(errno)); + qFatal("QUnixSandboxProcess setgid(%ld): %s", (long) gid, strerror(errno)); if (::setuid(m_uid)) - qFatal("UnixSandboxProcess setuid(%ld): %s", (long) m_uid, strerror(errno)); + qFatal("QUnixSandboxProcess setuid(%ld): %s", (long) m_uid, strerror(errno)); } else if (m_gid >=0) { // UID unset, GID set if (::setgroups(0, NULL)) - qFatal("UnixSandboxProcess setgroups(0,NULL): %s", strerror(errno)); + qFatal("QUnixSandboxProcess setgroups(0,NULL): %s", strerror(errno)); if (::setgid(m_gid)) - qFatal("UnixSandboxProcess setgid(%ld): %s", (long) m_gid, strerror(errno)); + qFatal("QUnixSandboxProcess setgid(%ld): %s", (long) m_gid, strerror(errno)); } @@ -194,12 +196,12 @@ void UnixSandboxProcess::setupChildProcess() ::cap_set_flag(caps, CAP_INHERITABLE, n, cap_list, CAP_CLEAR); ::cap_set_flag(caps, CAP_PERMITTED, n, cap_list, CAP_CLEAR); if (::cap_set_proc(caps) == -1) - qFatal("UnixSandboxProcess cap_set_proc (%ld): %s", (long) m_dropCapabilities, strerror(errno)); + qFatal("QUnixSandboxProcess cap_set_proc (%ld): %s", (long) m_dropCapabilities, strerror(errno)); ::cap_free(caps); } #endif } -#include "moc_unixsandboxprocess.cpp" +#include "moc_qunixsandboxprocess_p.cpp" QT_END_NAMESPACE_PROCESSMANAGER diff --git a/src/processmanager/unixsandboxprocess.h b/src/processmanager/qunixsandboxprocess_p.h index e007250..23e6535 100644 --- a/src/processmanager/unixsandboxprocess.h +++ b/src/processmanager/qunixsandboxprocess_p.h @@ -42,16 +42,16 @@ #include <QProcess> -#include "processmanager-global.h" +#include "qprocessmanager-global.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER -class UnixSandboxProcess : public QProcess +class QUnixSandboxProcess : public QProcess { Q_OBJECT public: - UnixSandboxProcess(qint64 uid, qint64 gid, qint64 umask, qint64 dropCapabilites, QObject *parent=0); + QUnixSandboxProcess(qint64 uid, qint64 gid, qint64 umask, qint64 dropCapabilites, QObject *parent=0); protected: void setupChildProcess(); diff --git a/tests/auto/declarative/testSocketLauncher/main.cpp b/tests/auto/declarative/testSocketLauncher/main.cpp index bcce54a..8d8cc6c 100644 --- a/tests/auto/declarative/testSocketLauncher/main.cpp +++ b/tests/auto/declarative/testSocketLauncher/main.cpp @@ -46,11 +46,11 @@ #include <qjsonuidauthority.h> #include <qjsonuidrangeauthority.h> -#include "declarativesocketlauncher.h" -#include "declarativeprocessmanager.h" -#include "standardprocessbackendfactory.h" -#include "keymatchdelegate.h" -#include "gdbrewritedelegate.h" +#include "qdeclarativesocketlauncher.h" +#include "qdeclarativeprocessmanager.h" +#include "qstandardprocessbackendfactory.h" +#include "qkeymatchdelegate.h" +#include "qgdbrewritedelegate.h" QT_USE_NAMESPACE_PROCESSMANAGER @@ -68,7 +68,7 @@ static void usage() static void registerQmlTypes() { const char *uri = "Test"; - DeclarativeProcessManager::registerTypes(uri); + QDeclarativeProcessManager::registerTypes(uri); qmlRegisterUncreatableType<QtAddOn::QtJsonStream::QJsonAuthority>(uri, 1, 0, "JsonAuthority", "Abstract class"); qmlRegisterType<QtAddOn::QtJsonStream::QJsonUIDRangeAuthority>(uri, 1, 0, "JsonUIDRangeAuthority"); qmlRegisterType<QtAddOn::QtJsonStream::QJsonUIDAuthority>(uri, 1, 0, "JsonUIDAuthority"); diff --git a/tests/auto/declarative/tst_declarative.cpp b/tests/auto/declarative/tst_declarative.cpp index 40f85da..eb0f479 100644 --- a/tests/auto/declarative/tst_declarative.cpp +++ b/tests/auto/declarative/tst_declarative.cpp @@ -49,16 +49,16 @@ #include <qjsonuidrangeauthority.h> -#include "declarativeprocessmanager.h" -#include "declarativematchdelegate.h" -#include "declarativerewritedelegate.h" -#include "standardprocessbackendfactory.h" -#include "prelaunchprocessbackendfactory.h" -#include "socketprocessbackendfactory.h" -#include "processfrontend.h" -#include "processbackend.h" -#include "process.h" -#include "timeoutidledelegate.h" +#include "qdeclarativeprocessmanager.h" +#include "qdeclarativematchdelegate.h" +#include "qdeclarativerewritedelegate.h" +#include "qstandardprocessbackendfactory.h" +#include "qprelaunchprocessbackendfactory.h" +#include "qsocketprocessbackendfactory.h" +#include "qprocessfrontend.h" +#include "qprocessbackend.h" +#include "qpmprocess.h" +#include "qtimeoutidledelegate.h" QT_USE_NAMESPACE_PROCESSMANAGER @@ -88,7 +88,7 @@ private slots: void tst_DeclarativeProcessManager::initTestCase() { const char *uri = "Test"; - DeclarativeProcessManager::registerTypes(uri); + QDeclarativeProcessManager::registerTypes(uri); qRegisterMetaType<QProcess::ProcessState>(); qRegisterMetaType<QProcess::ExitStatus>(); @@ -140,7 +140,7 @@ static void waitForTimeout(int timeout=5000) class Spy { public: - Spy(ProcessFrontend *process) + Spy(QProcessFrontend *process) : stateSpy(process, SIGNAL(stateChanged(QProcess::ProcessState))) , startSpy(process, SIGNAL(started())) , errorSpy(process, SIGNAL(error(QProcess::ProcessError))) @@ -235,13 +235,13 @@ static void _frontendTest(const QString& filename) if (component.isError()) qWarning() << component.errors(); - DeclarativeProcessManager *manager = qobject_cast<DeclarativeProcessManager*>(component.create()); + QDeclarativeProcessManager *manager = qobject_cast<QDeclarativeProcessManager*>(component.create()); QVERIFY(manager != NULL); for (int i = 0 ; i < 3 ; i++ ) { QVariant name; QVERIFY(QMetaObject::invokeMethod(manager, "makeProcess", Q_RETURN_ARG(QVariant, name))); - ProcessFrontend *frontend = manager->processForName(name.toString()); + QProcessFrontend *frontend = manager->processForName(name.toString()); QVERIFY(frontend); Spy spy(frontend); @@ -312,10 +312,10 @@ void tst_DeclarativeProcessManager::match() QQmlComponent component(&engine); component.setData(kMatchTest, QUrl()); QCOMPARE(component.status(), QQmlComponent::Ready); - DeclarativeMatchDelegate *delegate = qobject_cast<DeclarativeMatchDelegate *>(component.create()); + QDeclarativeMatchDelegate *delegate = qobject_cast<QDeclarativeMatchDelegate *>(component.create()); QVERIFY(delegate); - ProcessInfo info; + QProcessInfo info; info.setProgram("goodprogram"); QCOMPARE(delegate->matches(info), true); @@ -356,10 +356,10 @@ void tst_DeclarativeProcessManager::rewrite() QQmlComponent component(&engine); component.setData(kRewriteTest, QUrl()); QCOMPARE(component.status(), QQmlComponent::Ready); - DeclarativeRewriteDelegate *delegate = qobject_cast<DeclarativeRewriteDelegate *>(component.create()); + QDeclarativeRewriteDelegate *delegate = qobject_cast<QDeclarativeRewriteDelegate *>(component.create()); QVERIFY(delegate); - ProcessInfo info; + QProcessInfo info; info.setProgram("goodprogram"); info.setArguments(QStringList() << "cat"); QVariantMap env; @@ -396,7 +396,7 @@ void tst_DeclarativeProcessManager::timeoutIdleDelegate() QQmlComponent component(&engine); component.setData(kTimeoutIdleDelegateTest, QUrl()); QCOMPARE(component.status(), QQmlComponent::Ready); - TimeoutIdleDelegate *delegate = qobject_cast<TimeoutIdleDelegate *>(component.create()); + QTimeoutIdleDelegate *delegate = qobject_cast<QTimeoutIdleDelegate *>(component.create()); QVERIFY(delegate); QSignalSpy spyIdleInterval(delegate, SIGNAL(idleIntervalChanged())); diff --git a/tests/auto/matcher/tst_matcher.cpp b/tests/auto/matcher/tst_matcher.cpp index 59ac536..70df73f 100644 --- a/tests/auto/matcher/tst_matcher.cpp +++ b/tests/auto/matcher/tst_matcher.cpp @@ -39,19 +39,19 @@ #include <QtTest> -#include "infomatchdelegate.h" -#include "keymatchdelegate.h" +#include "qinfomatchdelegate.h" +#include "qkeymatchdelegate.h" QT_USE_NAMESPACE_PROCESSMANAGER /******************************************************************************/ -static void _testKeyMatch(ProcessInfo& info, +static void _testKeyMatch(QProcessInfo& info, bool answer, const char *key=0, const QVariant& value=QVariant()) { - KeyMatchDelegate matcher; + QKeyMatchDelegate matcher; if (key) matcher.setKey(key); if (!value.isNull()) @@ -59,7 +59,7 @@ static void _testKeyMatch(ProcessInfo& info, QCOMPARE(matcher.matches(info), answer); } -static void _makeEnvironmentInfo(ProcessInfo& info, +static void _makeEnvironmentInfo(QProcessInfo& info, const char *key1 = 0, const char *value1 = 0, const char *key2 = 0, @@ -73,14 +73,14 @@ static void _makeEnvironmentInfo(ProcessInfo& info, info.setEnvironment(test_env); } -static void _testEnvironment(InfoMatchDelegate& matcher, +static void _testEnvironment(QInfoMatchDelegate& matcher, bool answer, const char *key1 = 0, const char *value1 = 0, const char *key2 = 0, const char *value2 = 0) { - ProcessInfo test_info; + QProcessInfo test_info; _makeEnvironmentInfo(test_info, key1, value1, key2, value2); QCOMPARE(matcher.matches(test_info), answer); } @@ -99,7 +99,7 @@ private Q_SLOTS: void TestMatcher::matchKey() { - ProcessInfo info; + QProcessInfo info; info.setProgram("/usr/bin/abc"); info.setValue("prelaunch", "true"); @@ -112,13 +112,13 @@ void TestMatcher::matchKey() void TestMatcher::matchProgram() { - ProcessInfo match_info; + QProcessInfo match_info; match_info.setProgram("/usr/bin/abc"); - InfoMatchDelegate matcher; + QInfoMatchDelegate matcher; matcher.setInfo(match_info); - ProcessInfo info; + QProcessInfo info; info.setProgram("/usr/bin/abc"); QVERIFY(matcher.matches(info)); // Exactly the same value @@ -128,8 +128,8 @@ void TestMatcher::matchProgram() void TestMatcher::matchEnvironment() { - InfoMatchDelegate matcher; - ProcessInfo match_info; + QInfoMatchDelegate matcher; + QProcessInfo match_info; _makeEnvironmentInfo(match_info, "test", "value"); matcher.setInfo(match_info); diff --git a/tests/auto/processmanager/testForkLauncher/testForkLauncher.cpp b/tests/auto/processmanager/testForkLauncher/testForkLauncher.cpp index 64f507a..94457d0 100644 --- a/tests/auto/processmanager/testForkLauncher/testForkLauncher.cpp +++ b/tests/auto/processmanager/testForkLauncher/testForkLauncher.cpp @@ -45,7 +45,7 @@ #include <QJsonDocument> #include <QJsonObject> -#include "forklauncher.h" +#include "qforklauncher.h" #if defined(Q_OS_LINUX) #include <sys/types.h> @@ -134,7 +134,7 @@ private: extern "C" Q_DECL_EXPORT int main(int argc, char **argv) { - forklauncher(&argc, &argv); + qForkLauncher(&argc, &argv); QCoreApplication app(argc, argv); for (int i = 1 ; i < argc ; i++) { diff --git a/tests/auto/processmanager/testPipeLauncher/testPipeLauncher.cpp b/tests/auto/processmanager/testPipeLauncher/testPipeLauncher.cpp index 7dc3051..ca0972c 100644 --- a/tests/auto/processmanager/testPipeLauncher/testPipeLauncher.cpp +++ b/tests/auto/processmanager/testPipeLauncher/testPipeLauncher.cpp @@ -39,10 +39,10 @@ #include <QCoreApplication> #include <QDebug> -#include "pipelauncher.h" -#include "standardprocessbackendfactory.h" -#include "prelaunchprocessbackendfactory.h" -#include "processinfo.h" +#include "qpipelauncher.h" +#include "qstandardprocessbackendfactory.h" +#include "qprelaunchprocessbackendfactory.h" +#include "qprocessinfo.h" QT_USE_NAMESPACE_PROCESSMANAGER @@ -89,15 +89,15 @@ int main(int argc, char **argv) if (args.size()) usage(); - PipeLauncher launcher; + QPipeLauncher launcher; if (!prelaunch_program.isEmpty()) { - ProcessInfo info; + QProcessInfo info; info.setValue("program", prelaunch_program); - PrelaunchProcessBackendFactory *factory = new PrelaunchProcessBackendFactory; + QPrelaunchProcessBackendFactory *factory = new QPrelaunchProcessBackendFactory; factory->setProcessInfo(info); launcher.addFactory(factory); } else - launcher.addFactory(new StandardProcessBackendFactory); + launcher.addFactory(new QStandardProcessBackendFactory); return app.exec(); } diff --git a/tests/auto/processmanager/testPrefork/testPrefork.cpp b/tests/auto/processmanager/testPrefork/testPrefork.cpp index da4a00b..22450d0 100644 --- a/tests/auto/processmanager/testPrefork/testPrefork.cpp +++ b/tests/auto/processmanager/testPrefork/testPrefork.cpp @@ -39,13 +39,13 @@ /* This should be called "Frigg" */ -#include "prefork.h" +#include "qprefork.h" #include <QDebug> QT_USE_NAMESPACE_PROCESSMANAGER int main(int argc, char **argv) { - Prefork *prefork = Prefork::instance(); + QPrefork *prefork = QPrefork::instance(); prefork->execute(&argc, &argv); // This function never returns } diff --git a/tests/auto/processmanager/testPreforkLauncher/testPreforkLauncher.cpp b/tests/auto/processmanager/testPreforkLauncher/testPreforkLauncher.cpp index 6209811..fdb6937 100644 --- a/tests/auto/processmanager/testPreforkLauncher/testPreforkLauncher.cpp +++ b/tests/auto/processmanager/testPreforkLauncher/testPreforkLauncher.cpp @@ -43,8 +43,8 @@ #include <qjsonserver.h> #include <qjsonschemavalidator.h> -#include "socketlauncher.h" -#include "preforkprocessbackendfactory.h" +#include "qsocketlauncher.h" +#include "qpreforkprocessbackendfactory.h" QT_USE_NAMESPACE_PROCESSMANAGER @@ -57,8 +57,8 @@ extern "C" Q_DECL_EXPORT int main(int argc, char **argv) QStringList args = QCoreApplication::arguments(); QString progname = args.takeFirst(); - SocketLauncher launcher; - PreforkProcessBackendFactory *factory = new PreforkProcessBackendFactory; + QSocketLauncher launcher; + QPreforkProcessBackendFactory *factory = new QPreforkProcessBackendFactory; factory->setIndex(0); launcher.addFactory(factory); diff --git a/tests/auto/processmanager/testPrelaunch/testPrelaunch.cpp b/tests/auto/processmanager/testPrelaunch/testPrelaunch.cpp index ca3f4e1..a5482fa 100644 --- a/tests/auto/processmanager/testPrelaunch/testPrelaunch.cpp +++ b/tests/auto/processmanager/testPrelaunch/testPrelaunch.cpp @@ -44,7 +44,7 @@ #include <QtEndian> #include <QJsonDocument> #include <QJsonObject> -#include "processinfo.h" +#include "qprocessinfo.h" #include <signal.h> #include <stdio.h> #include <pthread.h> @@ -74,10 +74,10 @@ public: void handleMessage(const QJsonObject& object) { if (!count) { - ProcessInfo info(object.toVariantMap()); + QProcessInfo info(object.toVariantMap()); // qDebug() << "Received process info" << info.toMap(); - qint64 uid = (info.contains(ProcessInfoConstants::Uid) ? info.uid() : -1); - qint64 gid = (info.contains(ProcessInfoConstants::Gid) ? info.gid() : -1); + qint64 uid = (info.contains(QProcessInfoConstants::Uid) ? info.uid() : -1); + qint64 gid = (info.contains(QProcessInfoConstants::Gid) ? info.gid() : -1); if (gid >= 0) ::setgid(gid); if (uid >= 0) diff --git a/tests/auto/processmanager/testSocketLauncher/testSocketLauncher.cpp b/tests/auto/processmanager/testSocketLauncher/testSocketLauncher.cpp index 69628f0..3c553e4 100644 --- a/tests/auto/processmanager/testSocketLauncher/testSocketLauncher.cpp +++ b/tests/auto/processmanager/testSocketLauncher/testSocketLauncher.cpp @@ -45,10 +45,10 @@ #include <qjsonserver.h> #include <qjsonschemavalidator.h> -#include "socketlauncher.h" -#include "standardprocessbackendfactory.h" -#include "prelaunchprocessbackendfactory.h" -#include "processinfo.h" +#include "qsocketlauncher.h" +#include "qstandardprocessbackendfactory.h" +#include "qprelaunchprocessbackendfactory.h" +#include "qprocessinfo.h" QT_USE_NAMESPACE_PROCESSMANAGER @@ -157,16 +157,16 @@ int main(int argc, char **argv) if (args.size() != 1) usage(); - SocketLauncher launcher; + QSocketLauncher launcher; if (!prelaunch_program.isEmpty()) { - ProcessInfo info; + QProcessInfo info; info.setValue("program", prelaunch_program); - PrelaunchProcessBackendFactory *factory = new PrelaunchProcessBackendFactory; + QPrelaunchProcessBackendFactory *factory = new QPrelaunchProcessBackendFactory; factory->setProcessInfo(info); launcher.addFactory(factory); } else - launcher.addFactory(new StandardProcessBackendFactory); + launcher.addFactory(new QStandardProcessBackendFactory); if (!indir.isEmpty()) loadSchemasFromDirectory(launcher.server()->inboundValidator(), indir); diff --git a/tests/auto/processmanager/tst_processmanager.cpp b/tests/auto/processmanager/tst_processmanager.cpp index db10998..b0d9cb7 100644 --- a/tests/auto/processmanager/tst_processmanager.cpp +++ b/tests/auto/processmanager/tst_processmanager.cpp @@ -42,19 +42,19 @@ #include <QFileInfo> #include <QLocalSocket> -#include "process.h" -#include "processbackendmanager.h" -#include "processmanager.h" -#include "processinfo.h" -#include "prelaunchprocessbackendfactory.h" -#include "standardprocessbackendfactory.h" -#include "processbackend.h" -#include "processfrontend.h" +#include "qprocess.h" +#include "qprocessbackendmanager.h" +#include "qprocessmanager.h" +#include "qprocessinfo.h" +#include "qprelaunchprocessbackendfactory.h" +#include "qstandardprocessbackendfactory.h" +#include "qprocessbackend.h" +#include "qprocessfrontend.h" #include "qjsondocument.h" -#include "pipeprocessbackendfactory.h" -#include "socketprocessbackendfactory.h" -#include "timeoutidledelegate.h" -#include "procutils.h" +#include "qpipeprocessbackendfactory.h" +#include "qsocketprocessbackendfactory.h" +#include "qtimeoutidledelegate.h" +#include "qprocutils.h" #include <signal.h> #include <sys/time.h> @@ -63,9 +63,9 @@ QT_USE_NAMESPACE_PROCESSMANAGER -Q_DECLARE_METATYPE(QProcess::ExitStatus); -Q_DECLARE_METATYPE(QProcess::ProcessState); -Q_DECLARE_METATYPE(QProcess::ProcessError); +Q_DECLARE_METATYPE(QProcess::ExitStatus) +Q_DECLARE_METATYPE(QProcess::ProcessState) +Q_DECLARE_METATYPE(QProcess::ProcessError) const int kProcessCount = 10; @@ -94,9 +94,9 @@ const char *errorToString[] = { class ErrorSpy : public QObject { Q_OBJECT public: - ErrorSpy(ProcessBackend *target) {connect(target, SIGNAL(error(QProcess::ProcessError)), + ErrorSpy(QProcessBackend *target) {connect(target, SIGNAL(error(QProcess::ProcessError)), SLOT(handleError(QProcess::ProcessError))); } - ErrorSpy(ProcessFrontend *target) {connect(target, SIGNAL(error(QProcess::ProcessError)), + ErrorSpy(QProcessFrontend *target) {connect(target, SIGNAL(error(QProcess::ProcessError)), SLOT(handleError(QProcess::ProcessError))); } int count() const { return m_errors.size(); } @@ -106,11 +106,11 @@ public: private slots: void handleError(QProcess::ProcessError err) { m_errors << err; - ProcessBackend *backend = qobject_cast<ProcessBackend *>(sender()); + QProcessBackend *backend = qobject_cast<QProcessBackend *>(sender()); if (backend) m_errorStrings << backend->errorString(); else - m_errorStrings << qobject_cast<ProcessFrontend *>(sender())->errorString(); + m_errorStrings << qobject_cast<QProcessFrontend *>(sender())->errorString(); } private: QList<QProcess::ProcessError> m_errors; @@ -174,7 +174,7 @@ static void waitForThreadCount(Q_PID pid, int count, int timeout=5000) QTime stopWatch; stopWatch.start(); forever { - if (ProcUtils::getThreadCount(pid) == count) + if (QProcUtils::getThreadCount(pid) == count) break; if (stopWatch.elapsed() >= timeout) QFAIL("Timed out waiting for thread count"); @@ -182,7 +182,7 @@ static void waitForThreadCount(Q_PID pid, int count, int timeout=5000) } } -static void waitForInternalProcess(ProcessBackendManager *manager, int num=1, int timeout=5000) +static void waitForInternalProcess(QProcessBackendManager *manager, int num=1, int timeout=5000) { QObject::connect(manager, SIGNAL(internalProcessesChanged()), &QTestEventLoop::instance(), SLOT(exitLoop())); @@ -199,7 +199,7 @@ static void waitForInternalProcess(ProcessBackendManager *manager, int num=1, in &QTestEventLoop::instance(), SLOT(exitLoop())); } -static void waitForInternalProcess(ProcessManager *manager, int num=1, int timeout=5000) +static void waitForInternalProcess(QProcessManager *manager, int num=1, int timeout=5000) { QTime stopWatch; stopWatch.start(); @@ -229,7 +229,7 @@ static void waitForSocket(const QString& socketname, int timeout=5000) } } -static void waitForPriority(ProcessBackend *process, int priority, int timeout=5000) +static void waitForPriority(QProcessBackend *process, int priority, int timeout=5000) { QTime stopWatch; stopWatch.start(); @@ -259,7 +259,7 @@ static void waitForSignal(QSignalSpy& spy, int count=1, int timeout=5000) class Spy { public: - Spy(ProcessBackend *process) + Spy(QProcessBackend *process) : stateSpy(process, SIGNAL(stateChanged(QProcess::ProcessState))) , startSpy(process, SIGNAL(started())) , errorSpy(process) @@ -267,7 +267,7 @@ public: , stdoutSpy(process, SIGNAL(standardOutput(const QByteArray&))) , stderrSpy(process, SIGNAL(standardError(const QByteArray&))) {} - Spy(ProcessFrontend *process) + Spy(QProcessFrontend *process) : stateSpy(process, SIGNAL(stateChanged(QProcess::ProcessState))) , startSpy(process, SIGNAL(started())) , errorSpy(process) @@ -366,21 +366,21 @@ public: /******************************************************************************/ -static void writeLine(ProcessBackend *process, const char *command) +static void writeLine(QProcessBackend *process, const char *command) { QByteArray data(command); data += '\n'; process->write(data); } -static void writeJson(ProcessBackend *process, const char *command) +static void writeJson(QProcessBackend *process, const char *command) { QVariantMap map; map.insert("command", command); process->write(QJsonDocument::fromVariant(map).toBinaryData()); } -static void verifyRunning(ProcessBackend *process) +static void verifyRunning(QProcessBackend *process) { QVERIFY(process->state() == QProcess::Running); pid_t pid = process->pid(); @@ -398,18 +398,18 @@ static void verifyRunning(ProcessBackend *process) QCOMPARE(gid, gidString.toLongLong()); } -static void cleanupProcess(ProcessBackend *process) +static void cleanupProcess(QProcessBackend *process) { QVERIFY(process->state() == QProcess::NotRunning); QVERIFY(process->parent() == NULL); delete process; } -typedef void (*CommandFunc)(ProcessBackend *, const char *); +typedef void (*CommandFunc)(QProcessBackend *, const char *); -static void startAndStopClient(ProcessBackendManager *manager, ProcessInfo info, CommandFunc func) +static void startAndStopClient(QProcessBackendManager *manager, QProcessInfo info, CommandFunc func) { - ProcessBackend *process = manager->create(info); + QProcessBackend *process = manager->create(info); QVERIFY(process); QVERIFY(process->state() == QProcess::NotRunning); @@ -427,13 +427,13 @@ static void startAndStopClient(ProcessBackendManager *manager, ProcessInfo info, cleanupProcess(process); } -static void startAndStopMultiple(ProcessBackendManager *manager, ProcessInfo info, CommandFunc func) +static void startAndStopMultiple(QProcessBackendManager *manager, QProcessInfo info, CommandFunc func) { - ProcessBackend *plist[kProcessCount]; + QProcessBackend *plist[kProcessCount]; Spy *slist[kProcessCount]; for (int i = 0 ; i < kProcessCount ; i++) { - ProcessBackend *process = manager->create(info); + QProcessBackend *process = manager->create(info); QVERIFY(process); QVERIFY(process->state() == QProcess::NotRunning); Spy *spy = new Spy(process); @@ -466,11 +466,11 @@ static void startAndStopMultiple(ProcessBackendManager *manager, ProcessInfo inf } } -static void startAndKillClient(ProcessBackendManager *manager, ProcessInfo info, CommandFunc func) +static void startAndKillClient(QProcessBackendManager *manager, QProcessInfo info, CommandFunc func) { Q_UNUSED(func); - ProcessBackend *process = manager->create(info); + QProcessBackend *process = manager->create(info); QVERIFY(process); QVERIFY(process->state() == QProcess::NotRunning); @@ -490,9 +490,9 @@ static void startAndKillClient(ProcessBackendManager *manager, ProcessInfo info, cleanupProcess(process); } -static void startAndCrashClient(ProcessBackendManager *manager, ProcessInfo info, CommandFunc func) +static void startAndCrashClient(QProcessBackendManager *manager, QProcessInfo info, CommandFunc func) { - ProcessBackend *process = manager->create(info); + QProcessBackend *process = manager->create(info); QVERIFY(process); QVERIFY(process->state() == QProcess::NotRunning); @@ -511,11 +511,11 @@ static void startAndCrashClient(ProcessBackendManager *manager, ProcessInfo info cleanupProcess(process); } -static void failToStartClient(ProcessBackendManager *manager, ProcessInfo info, CommandFunc func) +static void failToStartClient(QProcessBackendManager *manager, QProcessInfo info, CommandFunc func) { Q_UNUSED(func); info.setValue("program", "thisProgramDoesntExist"); - ProcessBackend *process = manager->create(info); + QProcessBackend *process = manager->create(info); QVERIFY(process); QVERIFY(process->state() == QProcess::NotRunning); @@ -527,9 +527,9 @@ static void failToStartClient(ProcessBackendManager *manager, ProcessInfo info, cleanupProcess(process); } -static void echoClient(ProcessBackendManager *manager, ProcessInfo info, CommandFunc func) +static void echoClient(QProcessBackendManager *manager, QProcessInfo info, CommandFunc func) { - ProcessBackend *process = manager->create(info); + QProcessBackend *process = manager->create(info); QVERIFY(process); QVERIFY(process->state() == QProcess::NotRunning); @@ -552,10 +552,10 @@ static void echoClient(ProcessBackendManager *manager, ProcessInfo info, Command cleanupProcess(process); } -static void priorityChangeBeforeClient(ProcessBackendManager *manager, ProcessInfo info, CommandFunc func) +static void priorityChangeBeforeClient(QProcessBackendManager *manager, QProcessInfo info, CommandFunc func) { info.setValue("priority", 19); - ProcessBackend *process = manager->create(info); + QProcessBackend *process = manager->create(info); QVERIFY(process); Spy spy(process); @@ -574,9 +574,9 @@ static void priorityChangeBeforeClient(ProcessBackendManager *manager, ProcessIn cleanupProcess(process); } -static void priorityChangeAfterClient(ProcessBackendManager *manager, ProcessInfo info, CommandFunc func) +static void priorityChangeAfterClient(QProcessBackendManager *manager, QProcessInfo info, CommandFunc func) { - ProcessBackend *process = manager->create(info); + QProcessBackend *process = manager->create(info); QVERIFY(process); QVERIFY(process->state() == QProcess::NotRunning); @@ -598,7 +598,7 @@ static void priorityChangeAfterClient(ProcessBackendManager *manager, ProcessInf cleanupProcess(process); } -static void waitForOom(ProcessBackend *process, int oom, int timeout=5000) +static void waitForOom(QProcessBackend *process, int oom, int timeout=5000) { QTime stopWatch; stopWatch.start(); @@ -622,13 +622,13 @@ static bool canRunOomAdjustment() return false; } -static void oomChangeBeforeClient(ProcessBackendManager *manager, ProcessInfo info, CommandFunc func) +static void oomChangeBeforeClient(QProcessBackendManager *manager, QProcessInfo info, CommandFunc func) { if (!canRunOomAdjustment()) return; info.setOomAdjustment(500); - ProcessBackend *process = manager->create(info); + QProcessBackend *process = manager->create(info); QVERIFY(process); Spy spy(process); @@ -647,12 +647,12 @@ static void oomChangeBeforeClient(ProcessBackendManager *manager, ProcessInfo in cleanupProcess(process); } -static void oomChangeAfterClient(ProcessBackendManager *manager, ProcessInfo info, CommandFunc func) +static void oomChangeAfterClient(QProcessBackendManager *manager, QProcessInfo info, CommandFunc func) { if (!canRunOomAdjustment()) return; - ProcessBackend *process = manager->create(info); + QProcessBackend *process = manager->create(info); QVERIFY(process); QVERIFY(process->state() == QProcess::NotRunning); @@ -675,10 +675,10 @@ static void oomChangeAfterClient(ProcessBackendManager *manager, ProcessInfo inf } -typedef void (*clientFunc)(ProcessBackendManager *, ProcessInfo, CommandFunc); -typedef void (*infoFunc)(ProcessInfo&); +typedef void (*clientFunc)(QProcessBackendManager *, QProcessInfo, CommandFunc); +typedef void (*infoFunc)(QProcessInfo&); -static void fixUidGid(ProcessInfo& info) +static void fixUidGid(QProcessInfo& info) { QString uidString = qgetenv("TEST_UID"); QString gidString = qgetenv("TEST_GID"); @@ -688,7 +688,7 @@ static void fixUidGid(ProcessInfo& info) info.setGid(gidString.toLongLong()); } -static void makeTough(ProcessInfo& info) +static void makeTough(QProcessInfo& info) { QStringList args = info.arguments(); args << QStringLiteral("-noterm"); @@ -697,10 +697,10 @@ static void makeTough(ProcessInfo& info) static void standardTest( clientFunc func, infoFunc infoFixup=0 ) { - ProcessBackendManager *manager = new ProcessBackendManager; - manager->addFactory(new StandardProcessBackendFactory); + QProcessBackendManager *manager = new QProcessBackendManager; + manager->addFactory(new QStandardProcessBackendFactory); - ProcessInfo info; + QProcessInfo info; info.setValue("program", "testClient/testClient"); if (infoFixup) infoFixup(info); @@ -712,15 +712,15 @@ static void standardTest( clientFunc func, infoFunc infoFixup=0 ) static void prelaunchTest( clientFunc func, infoFunc infoFixup=0 ) { - ProcessBackendManager *manager = new ProcessBackendManager; - manager->setIdleDelegate(new TimeoutIdleDelegate); + QProcessBackendManager *manager = new QProcessBackendManager; + manager->setIdleDelegate(new QTimeoutIdleDelegate); - ProcessInfo info; + QProcessInfo info; info.setValue("program", "testPrelaunch/testPrelaunch"); if (infoFixup) infoFixup(info); - PrelaunchProcessBackendFactory *factory = new PrelaunchProcessBackendFactory; + QPrelaunchProcessBackendFactory *factory = new QPrelaunchProcessBackendFactory; factory->setProcessInfo(info); manager->addFactory(factory); @@ -735,16 +735,16 @@ static void prelaunchTest( clientFunc func, infoFunc infoFixup=0 ) static void prelaunchRestrictedTest( clientFunc func, infoFunc infoFixup=0 ) { - ProcessBackendManager *manager = new ProcessBackendManager; + QProcessBackendManager *manager = new QProcessBackendManager; manager->setMemoryRestricted(true); - manager->setIdleDelegate(new TimeoutIdleDelegate); + manager->setIdleDelegate(new QTimeoutIdleDelegate); - ProcessInfo info; + QProcessInfo info; info.setValue("program", "testPrelaunch/testPrelaunch"); if (infoFixup) infoFixup(info); - PrelaunchProcessBackendFactory *factory = new PrelaunchProcessBackendFactory; + QPrelaunchProcessBackendFactory *factory = new QPrelaunchProcessBackendFactory; factory->setProcessInfo(info); manager->addFactory(factory); @@ -757,10 +757,10 @@ static void prelaunchRestrictedTest( clientFunc func, infoFunc infoFixup=0 ) static void pipeLauncherTest( clientFunc func, infoFunc infoFixup=0 ) { - ProcessBackendManager *manager = new ProcessBackendManager; - ProcessInfo info; + QProcessBackendManager *manager = new QProcessBackendManager; + QProcessInfo info; info.setValue("program", "testPipeLauncher/testPipeLauncher"); - PipeProcessBackendFactory *factory = new PipeProcessBackendFactory; + QPipeProcessBackendFactory *factory = new QPipeProcessBackendFactory; factory->setProcessInfo(info); manager->addFactory(factory); @@ -768,7 +768,7 @@ static void pipeLauncherTest( clientFunc func, infoFunc infoFixup=0 ) waitForInternalProcess(manager); QVERIFY(manager->internalProcesses().count() == 1); - ProcessInfo info2; + QProcessInfo info2; info2.setValue("program", "testClient/testClient"); info2.setValue("pipe", "true"); if (infoFixup) @@ -788,12 +788,12 @@ static void socketLauncherTest( clientFunc func, QStringList args=QStringList(), QVERIFY(remote->waitForStarted()); waitForSocket(socketName); - ProcessBackendManager *manager = new ProcessBackendManager; - SocketProcessBackendFactory *factory = new SocketProcessBackendFactory; + QProcessBackendManager *manager = new QProcessBackendManager; + QSocketProcessBackendFactory *factory = new QSocketProcessBackendFactory; factory->setSocketName(socketName); manager->addFactory(factory); - ProcessInfo info; + QProcessInfo info; info.setValue("program", "testClient/testClient"); if (infoFixup) infoFixup(info); @@ -816,10 +816,10 @@ static void socketSchemaTest( clientFunc func, infoFunc infoFixup=0 ) static void forkLauncherTest( clientFunc func, infoFunc infoFixup=0 ) { #if defined(Q_OS_LINUX) - ProcessBackendManager *manager = new ProcessBackendManager; - ProcessInfo info; + QProcessBackendManager *manager = new QProcessBackendManager; + QProcessInfo info; info.setValue("program", "testForkLauncher/testForkLauncher"); - PipeProcessBackendFactory *factory = new PipeProcessBackendFactory; + QPipeProcessBackendFactory *factory = new QPipeProcessBackendFactory; factory->setProcessInfo(info); manager->addFactory(factory); @@ -827,7 +827,7 @@ static void forkLauncherTest( clientFunc func, infoFunc infoFixup=0 ) waitForInternalProcess(manager); QVERIFY(manager->internalProcesses().count() == 1); - ProcessInfo info2; + QProcessInfo info2; fixUidGid(info2); if (infoFixup) infoFixup(info2); @@ -852,12 +852,12 @@ static void preforkLauncherTest( clientFunc func, infoFunc infoFixup=0 ) QVERIFY(remote->waitForStarted()); waitForSocket(socketName); - ProcessBackendManager *manager = new ProcessBackendManager; - SocketProcessBackendFactory *factory = new SocketProcessBackendFactory; + QProcessBackendManager *manager = new QProcessBackendManager; + QSocketProcessBackendFactory *factory = new QSocketProcessBackendFactory; factory->setSocketName(socketName); manager->addFactory(factory); - ProcessInfo info; + QProcessInfo info; info.setValue("program", "testClient/testClient"); if (infoFixup) infoFixup(info); @@ -1005,14 +1005,14 @@ void tst_ProcessManager::initTestCase() void tst_ProcessManager::prelaunchChildAbort() { - ProcessBackendManager *manager = new ProcessBackendManager; - TimeoutIdleDelegate *delegate = new TimeoutIdleDelegate; + QProcessBackendManager *manager = new QProcessBackendManager; + QTimeoutIdleDelegate *delegate = new QTimeoutIdleDelegate; delegate->setIdleInterval(250); manager->setIdleDelegate(delegate); - ProcessInfo info; + QProcessInfo info; info.setValue("program", "testPrelaunch/testPrelaunch"); - PrelaunchProcessBackendFactory *factory = new PrelaunchProcessBackendFactory; + QPrelaunchProcessBackendFactory *factory = new QPrelaunchProcessBackendFactory; factory->setProcessInfo(info); manager->addFactory(factory); @@ -1035,16 +1035,16 @@ void tst_ProcessManager::prelaunchThreadPriority() { // Running this under Mac OSX has issues with permissions to read thread information #if defined(Q_OS_LINUX) - ProcessBackendManager *manager = new ProcessBackendManager; - TimeoutIdleDelegate *delegate = new TimeoutIdleDelegate; + QProcessBackendManager *manager = new QProcessBackendManager; + QTimeoutIdleDelegate *delegate = new QTimeoutIdleDelegate; delegate->setIdleInterval(250); manager->setIdleDelegate(delegate); - ProcessInfo info; + QProcessInfo info; info.setValue("program", "testPrelaunch/testPrelaunch"); info.setValue("arguments", QStringList() << "-threads"); info.setValue("priority", 19); - PrelaunchProcessBackendFactory *factory = new PrelaunchProcessBackendFactory; + QPrelaunchProcessBackendFactory *factory = new QPrelaunchProcessBackendFactory; factory->setProcessInfo(info); manager->addFactory(factory); @@ -1053,11 +1053,11 @@ void tst_ProcessManager::prelaunchThreadPriority() waitForInternalProcess(manager); Q_PID pid = manager->internalProcesses().at(0); waitForThreadCount(pid, 5); - foreach (qint32 priority, ProcUtils::getThreadPriorities(pid)) + foreach (qint32 priority, QProcUtils::getThreadPriorities(pid)) QCOMPARE(priority, 19); info.setValue("priority", 5); - ProcessBackend *process = manager->create(info); + QProcessBackend *process = manager->create(info); QVERIFY(process); Spy spy(process); @@ -1065,7 +1065,7 @@ void tst_ProcessManager::prelaunchThreadPriority() spy.waitStart(); verifyRunning(process); QCOMPARE(process->actualPriority(), 5); - foreach (qint32 priority, ProcUtils::getThreadPriorities(process->pid())) + foreach (qint32 priority, QProcUtils::getThreadPriorities(process->pid())) QCOMPARE(priority, 5); writeJson(process, "stop"); @@ -1078,15 +1078,15 @@ void tst_ProcessManager::prelaunchThreadPriority() void tst_ProcessManager::prelaunchWaitIdleTest() { - ProcessBackendManager *manager = new ProcessBackendManager; - TimeoutIdleDelegate *delegate = new TimeoutIdleDelegate; + QProcessBackendManager *manager = new QProcessBackendManager; + QTimeoutIdleDelegate *delegate = new QTimeoutIdleDelegate; delegate->setIdleInterval(250); delegate->setEnabled(false); manager->setIdleDelegate(delegate); - ProcessInfo info; + QProcessInfo info; info.setValue("program", "testPrelaunch/testPrelaunch"); - PrelaunchProcessBackendFactory *factory = new PrelaunchProcessBackendFactory; + QPrelaunchProcessBackendFactory *factory = new QPrelaunchProcessBackendFactory; factory->setProcessInfo(info); manager->addFactory(factory); @@ -1118,18 +1118,18 @@ void tst_ProcessManager::prelaunchWaitIdleTest() void tst_ProcessManager::prelaunchForPipeLauncherIdle() { - ProcessBackendManager *manager = new ProcessBackendManager; - TimeoutIdleDelegate *delegate = new TimeoutIdleDelegate; + QProcessBackendManager *manager = new QProcessBackendManager; + QTimeoutIdleDelegate *delegate = new QTimeoutIdleDelegate; delegate->setIdleInterval(250); delegate->setEnabled(false); manager->setIdleDelegate(delegate); - ProcessInfo info; + QProcessInfo info; info.setValue("program", "testPipeLauncher/testPipeLauncher"); info.setValue("arguments", QStringList() << QStringLiteral("-prelaunch") << QStringLiteral("testPrelaunch/testPrelaunch")); - PipeProcessBackendFactory *factory = new PipeProcessBackendFactory; + QPipeProcessBackendFactory *factory = new QPipeProcessBackendFactory; factory->setProcessInfo(info); manager->addFactory(factory); @@ -1173,18 +1173,18 @@ void tst_ProcessManager::prelaunchForPipeLauncherIdle() void tst_ProcessManager::prelaunchForPipeLauncherMemory() { - ProcessBackendManager *manager = new ProcessBackendManager; - TimeoutIdleDelegate *delegate = new TimeoutIdleDelegate; + QProcessBackendManager *manager = new QProcessBackendManager; + QTimeoutIdleDelegate *delegate = new QTimeoutIdleDelegate; delegate->setIdleInterval(250); manager->setIdleDelegate(delegate); manager->setMemoryRestricted(true); - ProcessInfo info; + QProcessInfo info; info.setValue("program", "testPipeLauncher/testPipeLauncher"); info.setValue("arguments", QStringList() << QStringLiteral("-prelaunch") << QStringLiteral("testPrelaunch/testPrelaunch")); - PipeProcessBackendFactory *factory = new PipeProcessBackendFactory; + QPipeProcessBackendFactory *factory = new QPipeProcessBackendFactory; factory->setProcessInfo(info); manager->addFactory(factory); @@ -1224,20 +1224,20 @@ void tst_ProcessManager::prelaunchForPipeLauncherMemory() void tst_ProcessManager::prelaunchForPipeLauncherMultiple() { - ProcessBackendManager *manager = new ProcessBackendManager; - TimeoutIdleDelegate *delegate = new TimeoutIdleDelegate; + QProcessBackendManager *manager = new QProcessBackendManager; + QTimeoutIdleDelegate *delegate = new QTimeoutIdleDelegate; delegate->setIdleInterval(250); manager->setMemoryRestricted(true); manager->setIdleDelegate(delegate); - ProcessInfo info; + QProcessInfo info; info.setValue("program", "testPipeLauncher/testPipeLauncher"); info.setValue("arguments", QStringList() << QStringLiteral("-prelaunch") << QStringLiteral("testPrelaunch/testPrelaunch")); for (int i = 0 ; i < kProcessCount ; i++ ) { - PipeProcessBackendFactory *factory = new PipeProcessBackendFactory; + QPipeProcessBackendFactory *factory = new QPipeProcessBackendFactory; factory->setProcessInfo(info); manager->addFactory(factory); } @@ -1281,13 +1281,13 @@ void tst_ProcessManager::prelaunchForSocketLauncherIdle() QVERIFY(remote->waitForStarted()); waitForSocket(socketName); - ProcessBackendManager *manager = new ProcessBackendManager; - TimeoutIdleDelegate *delegate = new TimeoutIdleDelegate; + QProcessBackendManager *manager = new QProcessBackendManager; + QTimeoutIdleDelegate *delegate = new QTimeoutIdleDelegate; delegate->setIdleInterval(250); delegate->setEnabled(false); manager->setIdleDelegate(delegate); - SocketProcessBackendFactory *factory = new SocketProcessBackendFactory; + QSocketProcessBackendFactory *factory = new QSocketProcessBackendFactory; factory->setSocketName(socketName); manager->addFactory(factory); @@ -1337,13 +1337,13 @@ void tst_ProcessManager::prelaunchForSocketLauncherMemory() QVERIFY(remote->waitForStarted()); waitForSocket(socketName); - ProcessBackendManager *manager = new ProcessBackendManager; - TimeoutIdleDelegate *delegate = new TimeoutIdleDelegate; + QProcessBackendManager *manager = new QProcessBackendManager; + QTimeoutIdleDelegate *delegate = new QTimeoutIdleDelegate; delegate->setIdleInterval(250); manager->setIdleDelegate(delegate); manager->setMemoryRestricted(true); - SocketProcessBackendFactory *factory = new SocketProcessBackendFactory; + QSocketProcessBackendFactory *factory = new QSocketProcessBackendFactory; factory->setSocketName(socketName); manager->addFactory(factory); @@ -1390,14 +1390,14 @@ void tst_ProcessManager::prelaunchForSocketLauncherMultiple() QVERIFY(remote->waitForStarted()); waitForSocket(socketName); - ProcessBackendManager *manager = new ProcessBackendManager; - TimeoutIdleDelegate *delegate = new TimeoutIdleDelegate; + QProcessBackendManager *manager = new QProcessBackendManager; + QTimeoutIdleDelegate *delegate = new QTimeoutIdleDelegate; delegate->setIdleInterval(250); manager->setIdleDelegate(delegate); manager->setMemoryRestricted(true); for (int i = 0 ; i < kProcessCount ; i++ ) { - SocketProcessBackendFactory *factory = new SocketProcessBackendFactory; + QSocketProcessBackendFactory *factory = new QSocketProcessBackendFactory; factory->setSocketName(socketName); manager->addFactory(factory); } @@ -1420,12 +1420,12 @@ void tst_ProcessManager::prelaunchForSocketLauncherMultiple() void tst_ProcessManager::frontend() { - ProcessManager *manager = new ProcessManager; - manager->addBackendFactory(new StandardProcessBackendFactory); + QProcessManager *manager = new QProcessManager; + manager->addBackendFactory(new QStandardProcessBackendFactory); - ProcessInfo info; + QProcessInfo info; info.setValue("program", "testClient/testClient"); - ProcessFrontend *process = manager->create(info); + QProcessFrontend *process = manager->create(info); QVERIFY(process); Spy spy(process); @@ -1448,13 +1448,13 @@ void tst_ProcessManager::frontend() void tst_ProcessManager::frontendWaitIdleTest() { - ProcessManager *manager = new ProcessManager; - TimeoutIdleDelegate *delegate = new TimeoutIdleDelegate; + QProcessManager *manager = new QProcessManager; + QTimeoutIdleDelegate *delegate = new QTimeoutIdleDelegate; manager->setIdleDelegate(delegate); - ProcessInfo info; + QProcessInfo info; info.setValue("program", "testPrelaunch/testPrelaunch"); - PrelaunchProcessBackendFactory *factory = new PrelaunchProcessBackendFactory; + QPrelaunchProcessBackendFactory *factory = new QPrelaunchProcessBackendFactory; factory->setProcessInfo(info); manager->addBackendFactory(factory); @@ -1473,11 +1473,11 @@ void tst_ProcessManager::frontendWaitIdleTest() delete manager; } -class TestProcess : public ProcessFrontend { +class TestProcess : public QProcessFrontend { Q_OBJECT Q_PROPERTY(QString magic READ magic WRITE setMagic NOTIFY magicChanged) public: - TestProcess(ProcessBackend *backend, QObject *parent=0) : ProcessFrontend(backend, parent) {} + TestProcess(QProcessBackend *backend, QObject *parent=0) : QProcessFrontend(backend, parent) {} QString magic() const { return m_magic; } void setMagic(const QString&s) { if (m_magic != s) { m_magic=s; emit magicChanged(); }} @@ -1487,12 +1487,12 @@ private: QString m_magic; }; -class TestManager : public ProcessManager { +class TestManager : public QProcessManager { Q_OBJECT Q_PROPERTY(QString magic READ magic WRITE setMagic NOTIFY magicChanged) public: - TestManager(QObject *parent=0) : ProcessManager(parent) {} - virtual Q_INVOKABLE TestProcess *createFrontend(ProcessBackend *backend) {return new TestProcess(backend);} + TestManager(QObject *parent=0) : QProcessManager(parent) {} + virtual Q_INVOKABLE TestProcess *createFrontend(QProcessBackend *backend) {return new TestProcess(backend);} QString magic() const { return m_magic; } void setMagic(const QString&s) { if (m_magic != s) { m_magic=s; emit magicChanged(); }} signals: @@ -1504,11 +1504,11 @@ private: void tst_ProcessManager::subclassFrontend() { TestManager *manager = new TestManager; - manager->addBackendFactory(new StandardProcessBackendFactory); + manager->addBackendFactory(new QStandardProcessBackendFactory); - ProcessInfo info; + QProcessInfo info; info.setValue("program", "testClient/testClient"); - ProcessFrontend *process = manager->create(info); + QProcessFrontend *process = manager->create(info); QVERIFY(process); QVERIFY(process->setProperty("magic", 42)); diff --git a/tests/auto/rewrite/tst_rewrite.cpp b/tests/auto/rewrite/tst_rewrite.cpp index 00bbd67..2e03bc6 100644 --- a/tests/auto/rewrite/tst_rewrite.cpp +++ b/tests/auto/rewrite/tst_rewrite.cpp @@ -39,8 +39,8 @@ #include <QtTest> -#include "gdbrewritedelegate.h" -#include "processinfo.h" +#include "qgdbrewritedelegate.h" +#include "qprocessinfo.h" QT_USE_NAMESPACE_PROCESSMANAGER @@ -63,11 +63,11 @@ TestRewrite::TestRewrite(QObject *parent) void TestRewrite::rewriteGdb() { - ProcessInfo info; + QProcessInfo info; info.setProgram("/usr/bin/abc"); info.setArguments(QStringList() << "a" << "b"); - GdbRewriteDelegate delegate; + QGdbRewriteDelegate delegate; delegate.rewrite(info); QCOMPARE(info.program(), QLatin1String("gdb")); |
