2022-01-21 15:01:01 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2022 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
|
|
|
|
**
|
|
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-02-18 00:56:14 +01:00
|
|
|
#include "processenums.h"
|
|
|
|
|
|
|
|
|
|
#include <QProcess>
|
2022-01-21 15:01:01 +01:00
|
|
|
|
|
|
|
|
namespace Utils {
|
|
|
|
|
|
|
|
|
|
class CommandLine;
|
|
|
|
|
class Environment;
|
|
|
|
|
class FilePath;
|
|
|
|
|
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class TerminalProcess : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2022-03-31 15:33:30 +02:00
|
|
|
|
2022-01-21 15:01:01 +01:00
|
|
|
public:
|
2022-02-21 15:52:03 +01:00
|
|
|
explicit TerminalProcess(QObject *parent);
|
2022-01-21 15:01:01 +01:00
|
|
|
~TerminalProcess() override;
|
|
|
|
|
|
2022-02-21 15:52:03 +01:00
|
|
|
void setProcessImpl(ProcessImpl processImpl);
|
|
|
|
|
void setTerminalMode(TerminalMode mode);
|
2022-01-21 15:01:01 +01:00
|
|
|
void setCommand(const CommandLine &command);
|
|
|
|
|
void setWorkingDirectory(const FilePath &dir);
|
|
|
|
|
void setEnvironment(const Environment &env);
|
|
|
|
|
|
|
|
|
|
QProcess::ProcessError error() const;
|
|
|
|
|
QString errorString() const;
|
|
|
|
|
|
|
|
|
|
void start();
|
|
|
|
|
void stopProcess();
|
|
|
|
|
|
|
|
|
|
// OK, however, impl looks a bit different (!= NotRunning vs == Running).
|
|
|
|
|
// Most probably changing it into (== Running) should be OK.
|
2022-01-21 16:15:17 +01:00
|
|
|
bool isRunning() const;
|
|
|
|
|
|
|
|
|
|
QProcess::ProcessState state() const;
|
2022-01-21 15:01:01 +01:00
|
|
|
qint64 processId() const;
|
2022-01-21 16:15:17 +01:00
|
|
|
int exitCode() const;
|
|
|
|
|
QProcess::ExitStatus exitStatus() const;
|
2022-01-21 15:01:01 +01:00
|
|
|
|
2022-01-21 16:15:17 +01:00
|
|
|
void setAbortOnMetaChars(bool abort); // used only in sshDeviceProcess
|
2022-01-21 15:01:01 +01:00
|
|
|
void kickoffProcess(); // only debugger terminal, only non-windows
|
2022-03-04 08:30:19 +01:00
|
|
|
void interrupt(); // only debugger terminal, only non-windows
|
2022-01-21 15:01:01 +01:00
|
|
|
qint64 applicationMainThreadID() const; // only debugger terminal, only windows (-1 otherwise)
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void started();
|
2022-02-17 17:28:08 +01:00
|
|
|
void finished();
|
2022-01-21 15:01:01 +01:00
|
|
|
void errorOccurred(QProcess::ProcessError error);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void stubConnectionAvailable();
|
|
|
|
|
void readStubOutput();
|
|
|
|
|
void stubExited();
|
|
|
|
|
void cleanupAfterStartFailure(const QString &errorMessage);
|
|
|
|
|
void finish(int exitCode, QProcess::ExitStatus exitStatus);
|
|
|
|
|
void killProcess();
|
|
|
|
|
void killStub();
|
|
|
|
|
void emitError(QProcess::ProcessError err, const QString &errorString);
|
|
|
|
|
QString stubServerListen();
|
|
|
|
|
void stubServerShutdown();
|
|
|
|
|
void cleanupStub();
|
|
|
|
|
void cleanupInferior();
|
|
|
|
|
|
|
|
|
|
class TerminalProcessPrivate *d;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // Internal
|
|
|
|
|
} // Utils
|