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 | |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | class LocalClientIo : public QtROClientIoDevice |
26 | { |
27 | Q_OBJECT |
28 | |
29 | public: |
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 | |
37 | public Q_SLOTS: |
38 | void onError(QLocalSocket::LocalSocketError error); |
39 | void onStateChanged(QLocalSocket::LocalSocketState state); |
40 | |
41 | protected: |
42 | void doClose() override; |
43 | void doDisconnectFromServer() override; |
44 | QLocalSocket* m_socket; |
45 | }; |
46 | |
47 | #ifdef Q_OS_LINUX |
48 | |
49 | class AbstractLocalClientIo final : public LocalClientIo |
50 | { |
51 | Q_OBJECT |
52 | |
53 | public: |
54 | explicit AbstractLocalClientIo(QObject *parent = nullptr); |
55 | }; |
56 | |
57 | #endif // Q_OS_LINUX |
58 | |
59 | class LocalServerIo final : public QtROServerIoDevice |
60 | { |
61 | Q_OBJECT |
62 | public: |
63 | explicit LocalServerIo(QLocalSocket *conn, QObject *parent = nullptr); |
64 | |
65 | QIODevice *connection() const override; |
66 | protected: |
67 | void doClose() override; |
68 | |
69 | private: |
70 | QLocalSocket *m_connection; |
71 | }; |
72 | |
73 | class LocalServerImpl : public QConnectionAbstractServer |
74 | { |
75 | Q_OBJECT |
76 | Q_DISABLE_COPY(LocalServerImpl) |
77 | |
78 | public: |
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 | |
89 | protected: |
90 | QLocalServer m_server; |
91 | }; |
92 | |
93 | #ifdef Q_OS_LINUX |
94 | |
95 | class AbstractLocalServerImpl final : public LocalServerImpl |
96 | { |
97 | Q_OBJECT |
98 | |
99 | public: |
100 | explicit AbstractLocalServerImpl(QObject *parent); |
101 | QUrl address() const override; |
102 | }; |
103 | |
104 | #endif // Q_OS_LINUX |
105 | |
106 | QT_END_NAMESPACE |
107 | |
108 | #endif |
109 |