summaryrefslogtreecommitdiffstats
path: root/src/remoteobjects/qconnection_local_backend_p.h
blob: cf1a5ba6b2df31b93eb246685346794f72bcc99c (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright (C) 2017-2015 Ford Motor Company
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QCONNECTIONCLIENTFACTORY_P_H
#define QCONNECTIONCLIENTFACTORY_P_H

//
//  W A R N I N G
//  -------------
//
// This file is not part of the Qt API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//

#include "qconnectionfactories_p.h"

#include <QtNetwork/qlocalserver.h>
#include <QtNetwork/qlocalsocket.h>

QT_BEGIN_NAMESPACE

class LocalClientIo : public QtROClientIoDevice
{
    Q_OBJECT

public:
    explicit LocalClientIo(QObject *parent = nullptr);
    ~LocalClientIo() override;

    QIODevice *connection() const override;
    void connectToServer() override;
    bool isOpen() const override;

public Q_SLOTS:
    void onError(QLocalSocket::LocalSocketError error);
    void onStateChanged(QLocalSocket::LocalSocketState state);

protected:
    void doClose() override;
    void doDisconnectFromServer() override;
    QLocalSocket* m_socket;
};

#ifdef Q_OS_LINUX

class AbstractLocalClientIo final : public LocalClientIo
{
    Q_OBJECT

public:
    explicit AbstractLocalClientIo(QObject *parent = nullptr);
};

#endif // Q_OS_LINUX

class LocalServerIo final : public QtROServerIoDevice
{
    Q_OBJECT
public:
    explicit LocalServerIo(QLocalSocket *conn, QObject *parent = nullptr);

    QIODevice *connection() const override;
protected:
    void doClose() override;

private:
    QLocalSocket *m_connection;
};

class LocalServerImpl : public QConnectionAbstractServer
{
    Q_OBJECT
    Q_DISABLE_COPY(LocalServerImpl)

public:
    explicit LocalServerImpl(QObject *parent);
    ~LocalServerImpl() override;

    bool hasPendingConnections() const override;
    QtROServerIoDevice *configureNewConnection() override;
    QUrl address() const override;
    bool listen(const QUrl &address) override;
    QAbstractSocket::SocketError serverError() const override;
    void close() override;
    void setSocketOptions(QLocalServer::SocketOptions options);

protected:
    QLocalServer m_server;
};

#ifdef Q_OS_LINUX

class AbstractLocalServerImpl final : public LocalServerImpl
{
    Q_OBJECT

public:
    explicit AbstractLocalServerImpl(QObject *parent);
    QUrl address() const override;
};

#endif // Q_OS_LINUX

QT_END_NAMESPACE

#endif