Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qlocalsocket_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QLOCALSOCKET_P_H
6#define QLOCALSOCKET_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists for the convenience
13// of the QLocalSocket class. This header file may change from
14// version to version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtNetwork/private/qtnetworkglobal_p.h>
20
21#include "qlocalsocket.h"
22#include "private/qiodevice_p.h"
23
24#include <qtimer.h>
25
27
28#if defined(QT_LOCALSOCKET_TCP)
29# include "qtcpsocket.h"
30#elif defined(Q_OS_WIN)
31# include "private/qwindowspipereader_p.h"
32# include "private/qwindowspipewriter_p.h"
33# include <qwineventnotifier.h>
34#else
35# include "private/qabstractsocketengine_p.h"
36# include <qtcpsocket.h>
37# include <qsocketnotifier.h>
38# include <errno.h>
39#endif
40
41struct sockaddr_un;
42
43QT_BEGIN_NAMESPACE
44
45#if !defined(Q_OS_WIN) || defined(QT_LOCALSOCKET_TCP)
46
47class QLocalUnixSocket : public QTcpSocket
48{
49
50public:
51 QLocalUnixSocket() : QTcpSocket()
52 {
53 }
54
55 inline void setSocketState(QAbstractSocket::SocketState state)
56 {
57 QTcpSocket::setSocketState(state);
58 }
59
60 inline void setErrorString(const QString &string)
61 {
62 QTcpSocket::setErrorString(string);
63 }
64
65 inline void setSocketError(QAbstractSocket::SocketError error)
66 {
67 QTcpSocket::setSocketError(error);
68 }
69
70 inline qint64 readData(char *data, qint64 maxSize) override
71 {
72 return QTcpSocket::readData(data, maxSize);
73 }
74
75 inline qint64 writeData(const char *data, qint64 maxSize) override
76 {
77 return QTcpSocket::writeData(data, maxSize);
78 }
79};
80#endif //#if !defined(Q_OS_WIN) || defined(QT_LOCALSOCKET_TCP)
81
83{
84public:
85 Q_DECLARE_PUBLIC(QLocalSocket)
86
88 void init();
89
90#if defined(QT_LOCALSOCKET_TCP)
92 bool ownsTcpSocket;
98#elif defined(Q_OS_WIN)
101 void _q_canRead();
103 void _q_pipeClosed();
105 void _q_writeFailed();
110#else
111 QLocalUnixSocket unixSocket;
112 QString generateErrorString(QLocalSocket::LocalSocketError, const QString &function) const;
113 void setErrorAndEmit(QLocalSocket::LocalSocketError, const QString &function);
114 void _q_stateChanged(QAbstractSocket::SocketState newState);
115 void _q_errorOccurred(QAbstractSocket::SocketError newError);
116 void _q_connectToSocket();
119 void describeSocket(qintptr socketDescriptor);
120 static bool parseSockaddr(const sockaddr_un &addr, uint len,
121 QString &fullServerName, QString &serverName, bool &abstractNamespace);
127#endif
128 QLocalSocket::LocalSocketState state;
131#if defined(Q_OS_WIN) && !defined(QT_LOCALSOCKET_TCP)
132 bool emittedReadyRead;
134#endif
135
136 Q_OBJECT_BINDABLE_PROPERTY(QLocalSocketPrivate, QLocalSocket::SocketOptions, socketOptions)
137};
138
139QT_END_NAMESPACE
140
141#endif // QLOCALSOCKET_P_H
void _q_stateChanged(QAbstractSocket::SocketState newState)
void describeSocket(qintptr socketDescriptor)
QLocalUnixSocket unixSocket
void _q_errorOccurred(QAbstractSocket::SocketError newError)
void setErrorAndEmit(QLocalSocket::LocalSocketError, const QString &function)
QIODevice::OpenMode connectingOpenMode
QSocketNotifier * delayConnect
QString generateErrorString(QLocalSocket::LocalSocketError, const QString &function) const
QT_REQUIRE_CONFIG(animation)
QT_REQUIRE_CONFIG(localserver)