2015-10-01 12:45:06 +02:00
|
|
|
/****************************************************************************
|
2015-06-01 18:51:55 +02:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2015-06-01 18:51:55 +02:00
|
|
|
**
|
|
|
|
|
** 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
|
2016-01-15 14:58:39 +01:00
|
|
|
** 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.
|
2015-06-01 18:51:55 +02:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** 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.
|
2015-06-01 18:51:55 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2016-06-29 16:49:56 +02:00
|
|
|
#include "clangcodemodelserverproxy.h"
|
2015-06-18 18:08:48 +02:00
|
|
|
#include "lineprefixer.h"
|
2015-06-16 12:38:04 +02:00
|
|
|
|
2015-06-01 18:51:55 +02:00
|
|
|
#include <QLocalSocket>
|
2015-11-30 20:32:47 +01:00
|
|
|
#include <QProcessEnvironment>
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QProcess;
|
2016-08-04 15:26:53 +02:00
|
|
|
class QTemporaryDir;
|
2015-06-01 18:51:55 +02:00
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
|
|
class Utf8String;
|
|
|
|
|
class Utf8StringVector;
|
|
|
|
|
|
2015-06-16 11:56:00 +02:00
|
|
|
namespace ClangBackEnd {
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
class FileContainer;
|
|
|
|
|
|
|
|
|
|
class CMBIPC_EXPORT ConnectionClient : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2016-07-04 14:55:58 +02:00
|
|
|
ConnectionClient();
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2016-07-11 13:44:02 +02:00
|
|
|
void startProcessAndConnectToServerAsynchronously();
|
2015-06-01 18:51:55 +02:00
|
|
|
bool disconnectFromServer();
|
|
|
|
|
bool isConnected() const;
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
void sendEndMessage();
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
void resetProcessAliveTimer();
|
|
|
|
|
void setProcessAliveTimerInterval(int processTimerInterval);
|
|
|
|
|
|
|
|
|
|
const QString &processPath() const;
|
|
|
|
|
void setProcessPath(const QString &processPath);
|
|
|
|
|
|
2016-07-11 13:44:02 +02:00
|
|
|
void restartProcessAsynchronously();
|
2015-06-01 18:51:55 +02:00
|
|
|
void restartProcessIfTimerIsNotResettedAndSocketIsEmpty();
|
|
|
|
|
void finishProcess();
|
|
|
|
|
bool isProcessIsRunning() const;
|
|
|
|
|
|
|
|
|
|
bool waitForEcho();
|
2016-07-11 13:44:02 +02:00
|
|
|
bool waitForConnected();
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
QProcess *processForTestOnly() const;
|
|
|
|
|
|
|
|
|
|
signals:
|
2016-07-11 13:44:02 +02:00
|
|
|
void connectedToLocalSocket();
|
|
|
|
|
void processFinished();
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2016-07-04 14:55:58 +02:00
|
|
|
protected:
|
|
|
|
|
QIODevice *ioDevice();
|
2016-08-04 15:26:53 +02:00
|
|
|
const QTemporaryDir &temporaryDirectory() const;
|
|
|
|
|
LinePrefixer &stdErrPrefixer();
|
|
|
|
|
LinePrefixer &stdOutPrefixer();
|
2016-07-04 14:55:58 +02:00
|
|
|
|
|
|
|
|
virtual void sendEndCommand() = 0;
|
|
|
|
|
virtual void resetCounter() = 0;
|
2016-08-04 15:26:53 +02:00
|
|
|
virtual QString connectionName() const = 0;
|
|
|
|
|
virtual QString outputName() const = 0;
|
2016-07-04 14:55:58 +02:00
|
|
|
|
2015-06-01 18:51:55 +02:00
|
|
|
private:
|
2016-07-11 13:44:02 +02:00
|
|
|
std::unique_ptr<QProcess> startProcess();
|
|
|
|
|
void finishProcess(std::unique_ptr<QProcess> &&process);
|
|
|
|
|
void connectToLocalSocket();
|
|
|
|
|
void endProcess(QProcess *process);
|
|
|
|
|
void terminateProcess(QProcess *process);
|
|
|
|
|
void killProcess(QProcess *process);
|
|
|
|
|
void resetProcessIsStarting();
|
2015-06-01 18:51:55 +02:00
|
|
|
void printLocalSocketError(QLocalSocket::LocalSocketError socketError);
|
|
|
|
|
void printStandardOutput();
|
|
|
|
|
void printStandardError();
|
|
|
|
|
|
2016-07-11 13:44:02 +02:00
|
|
|
void connectLocalSocketConnected();
|
|
|
|
|
void connectProcessFinished(QProcess *process) const;
|
|
|
|
|
void connectProcessStarted(QProcess *process) const;
|
|
|
|
|
void disconnectProcessFinished(QProcess *process) const;
|
|
|
|
|
void connectStandardOutputAndError(QProcess *process) const;
|
|
|
|
|
void connectLocalSocketError() const;
|
|
|
|
|
void connectAliveTimer();
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
void ensureMessageIsWritten();
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2015-11-30 20:32:47 +01:00
|
|
|
QProcessEnvironment processEnvironment() const;
|
|
|
|
|
|
2015-06-01 18:51:55 +02:00
|
|
|
private:
|
2016-08-04 15:26:53 +02:00
|
|
|
LinePrefixer stdErrPrefixer_;
|
|
|
|
|
LinePrefixer stdOutPrefixer_;
|
|
|
|
|
|
2015-06-01 18:51:55 +02:00
|
|
|
mutable std::unique_ptr<QProcess> process_;
|
|
|
|
|
QLocalSocket localSocket;
|
|
|
|
|
QTimer processAliveTimer;
|
|
|
|
|
QString processPath_;
|
2016-07-11 13:44:02 +02:00
|
|
|
bool isAliveTimerResetted = false;
|
|
|
|
|
bool processIsStarting = false;
|
2015-06-18 18:08:48 +02:00
|
|
|
|
2015-06-01 18:51:55 +02:00
|
|
|
};
|
|
|
|
|
|
2015-06-16 11:56:00 +02:00
|
|
|
} // namespace ClangBackEnd
|