1// Copyright (C) 2017-2015 Ford Motor Company
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QCONNECTIONCLIENTFACTORY_P_H
5#define QCONNECTIONCLIENTFACTORY_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qconnectionfactories_p.h"
19
20#include <QtNetwork/qlocalserver.h>
21#include <QtNetwork/qlocalsocket.h>
22
23QT_BEGIN_NAMESPACE
24
25class LocalClientIo : public QtROClientIoDevice
26{
27 Q_OBJECT
28
29public:
30 explicit LocalClientIo(QObject *parent = nullptr);
31 ~LocalClientIo() override;
32
33 QIODevice *connection() const override;
34 void connectToServer() override;
35 bool isOpen() const override;
36
37public Q_SLOTS:
38 void onError(QLocalSocket::LocalSocketError error);
39 void onStateChanged(QLocalSocket::LocalSocketState state);
40
41protected:
42 void doClose() override;
43 void doDisconnectFromServer() override;
44 QLocalSocket* m_socket;
45};
46
47#ifdef Q_OS_LINUX
48
49class AbstractLocalClientIo final : public LocalClientIo
50{
51 Q_OBJECT
52
53public:
54 explicit AbstractLocalClientIo(QObject *parent = nullptr);
55};
56
57#endif // Q_OS_LINUX
58
59class LocalServerIo final : public QtROServerIoDevice
60{
61 Q_OBJECT
62public:
63 explicit LocalServerIo(QLocalSocket *conn, QObject *parent = nullptr);
64
65 QIODevice *connection() const override;
66protected:
67 void doClose() override;
68
69private:
70 QLocalSocket *m_connection;
71};
72
73class LocalServerImpl : public QConnectionAbstractServer
74{
75 Q_OBJECT
76 Q_DISABLE_COPY(LocalServerImpl)
77
78public:
79 explicit LocalServerImpl(QObject *parent);
80 ~LocalServerImpl() override;
81
82 bool hasPendingConnections() const override;
83 QtROServerIoDevice *configureNewConnection() override;
84 QUrl address() const override;
85 bool listen(const QUrl &address) override;
86 QAbstractSocket::SocketError serverError() const override;
87 void close() override;
88
89protected:
90 QLocalServer m_server;
91};
92
93#ifdef Q_OS_LINUX
94
95class AbstractLocalServerImpl final : public LocalServerImpl
96{
97 Q_OBJECT
98
99public:
100 explicit AbstractLocalServerImpl(QObject *parent);
101 QUrl address() const override;
102};
103
104#endif // Q_OS_LINUX
105
106QT_END_NAMESPACE
107
108#endif
109

source code of qtremoteobjects/src/remoteobjects/qconnection_local_backend_p.h