aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/debugger/outputcollector.h
blob: ac0b5fe33737d36d99a3e3b3d2d2b56450072fd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#pragma once

#include <QObject>

QT_BEGIN_NAMESPACE
class QLocalServer;
class QLocalSocket;
class QSocketNotifier;
QT_END_NAMESPACE

namespace Debugger::Internal {

class OutputCollector : public QObject
{
    Q_OBJECT

public:
    OutputCollector() = default;
    ~OutputCollector() override;
    bool listen();
    void shutdown();
    QString serverName() const;
    QString errorString() const;

signals:
    void byteDelivery(const QByteArray &data);

private:
    void bytesAvailable();
#ifdef Q_OS_WIN
    void newConnectionAvailable();
    QLocalServer *m_server = nullptr;
    QLocalSocket *m_socket = nullptr;
#else
    QString m_serverPath;
    int m_serverFd;
    QSocketNotifier *m_serverNotifier = nullptr;
    QString m_errorString;
#endif
};

} // Debugger::Internal