1// qabstractsocket.sip generated by MetaSIP 2// 3// This file is part of the QtNetwork Python extension module. 4// 5// Copyright (c) 2021 Riverbank Computing Limited <info@riverbankcomputing.com> 6// 7// This file is part of PyQt5. 8// 9// This file may be used under the terms of the GNU General Public License 10// version 3.0 as published by the Free Software Foundation and appearing in 11// the file LICENSE included in the packaging of this file. Please review the 12// following information to ensure the GNU General Public License version 3.0 13// requirements will be met: http://www.gnu.org/copyleft/gpl.html. 14// 15// If you do not wish to use this file under the terms of the GPL version 3.0 16// then you may purchase a commercial license. For more information contact 17// info@riverbankcomputing.com. 18// 19// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 22 23class QAbstractSocket : QIODevice 24{ 25%TypeHeaderCode 26#include <qabstractsocket.h> 27%End 28 29%ConvertToSubClassCode 30 static struct class_graph { 31 const char *name; 32 sipTypeDef **type; 33 int yes, no; 34 } graph[] = { 35 {sipName_QNetworkReply, &sipType_QNetworkReply, -1, 1}, 36 {sipName_QHttpMultiPart, &sipType_QHttpMultiPart, -1, 2}, 37 {sipName_QAbstractNetworkCache, &sipType_QAbstractNetworkCache, 12, 3}, 38 {sipName_QNetworkConfigurationManager, &sipType_QNetworkConfigurationManager, -1, 4}, 39 {sipName_QNetworkCookieJar, &sipType_QNetworkCookieJar, -1, 5}, 40 {sipName_QAbstractSocket, &sipType_QAbstractSocket, 13, 6}, 41 {sipName_QLocalSocket, &sipType_QLocalSocket, -1, 7}, 42 {sipName_QDnsLookup, &sipType_QDnsLookup, -1, 8}, 43 {sipName_QNetworkSession, &sipType_QNetworkSession, -1, 9}, 44 {sipName_QTcpServer, &sipType_QTcpServer, -1, 10}, 45 {sipName_QNetworkAccessManager, &sipType_QNetworkAccessManager, -1, 11}, 46 {sipName_QLocalServer, &sipType_QLocalServer, -1, -1}, 47 {sipName_QNetworkDiskCache, &sipType_QNetworkDiskCache, -1, -1}, 48 {sipName_QUdpSocket, &sipType_QUdpSocket, -1, 14}, 49 {sipName_QTcpSocket, &sipType_QTcpSocket, 15, -1}, 50 #if defined(SIP_FEATURE_PyQt_SSL) 51 {sipName_QSslSocket, &sipType_QSslSocket, -1, -1}, 52 #else 53 {0, 0, -1, -1}, 54 #endif 55 }; 56 57 int i = 0; 58 59 sipType = NULL; 60 61 do 62 { 63 struct class_graph *cg = &graph[i]; 64 65 if (cg->name != NULL && sipCpp->inherits(cg->name)) 66 { 67 sipType = *cg->type; 68 i = cg->yes; 69 } 70 else 71 i = cg->no; 72 } 73 while (i >= 0); 74%End 75 76public: 77 enum SocketType 78 { 79 TcpSocket, 80 UdpSocket, 81%If (Qt_5_8_0 -) 82 SctpSocket, 83%End 84 UnknownSocketType, 85 }; 86 87 enum NetworkLayerProtocol 88 { 89 IPv4Protocol, 90 IPv6Protocol, 91 AnyIPProtocol, 92 UnknownNetworkLayerProtocol, 93 }; 94 95 enum SocketError 96 { 97 ConnectionRefusedError, 98 RemoteHostClosedError, 99 HostNotFoundError, 100 SocketAccessError, 101 SocketResourceError, 102 SocketTimeoutError, 103 DatagramTooLargeError, 104 NetworkError, 105 AddressInUseError, 106 SocketAddressNotAvailableError, 107 UnsupportedSocketOperationError, 108 UnfinishedSocketOperationError, 109 ProxyAuthenticationRequiredError, 110 SslHandshakeFailedError, 111 ProxyConnectionRefusedError, 112 ProxyConnectionClosedError, 113 ProxyConnectionTimeoutError, 114 ProxyNotFoundError, 115 ProxyProtocolError, 116 OperationError, 117 SslInternalError, 118 SslInvalidUserDataError, 119 TemporaryError, 120 UnknownSocketError, 121 }; 122 123 enum SocketState 124 { 125 UnconnectedState, 126 HostLookupState, 127 ConnectingState, 128 ConnectedState, 129 BoundState, 130 ListeningState, 131 ClosingState, 132 }; 133 134 QAbstractSocket(QAbstractSocket::SocketType socketType, QObject *parent /TransferThis/); 135 virtual ~QAbstractSocket(); 136 virtual void connectToHost(const QString &hostName, quint16 port, QIODevice::OpenMode mode = QIODevice::ReadWrite, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::AnyIPProtocol) /ReleaseGIL/; 137 virtual void connectToHost(const QHostAddress &address, quint16 port, QIODevice::OpenMode mode = QIODevice::ReadWrite) /ReleaseGIL/; 138 virtual void disconnectFromHost() /ReleaseGIL/; 139 bool isValid() const; 140 virtual qint64 bytesAvailable() const; 141 virtual qint64 bytesToWrite() const; 142 virtual bool canReadLine() const; 143 quint16 localPort() const; 144 QHostAddress localAddress() const; 145 quint16 peerPort() const; 146 QHostAddress peerAddress() const; 147 QString peerName() const; 148 qint64 readBufferSize() const; 149 virtual void setReadBufferSize(qint64 size); 150 void abort(); 151 virtual bool setSocketDescriptor(qintptr socketDescriptor, QAbstractSocket::SocketState state = QAbstractSocket::ConnectedState, QIODevice::OpenMode mode = QIODevice::ReadWrite); 152 virtual qintptr socketDescriptor() const; 153 QAbstractSocket::SocketType socketType() const; 154 QAbstractSocket::SocketState state() const; 155 QAbstractSocket::SocketError error() const; 156 virtual void close(); 157 virtual bool isSequential() const; 158 virtual bool atEnd() const; 159 bool flush() /ReleaseGIL/; 160 virtual bool waitForConnected(int msecs = 30000) /ReleaseGIL/; 161 virtual bool waitForReadyRead(int msecs = 30000) /ReleaseGIL/; 162 virtual bool waitForBytesWritten(int msecs = 30000) /ReleaseGIL/; 163 virtual bool waitForDisconnected(int msecs = 30000) /ReleaseGIL/; 164 void setProxy(const QNetworkProxy &networkProxy); 165 QNetworkProxy proxy() const; 166 167signals: 168 void hostFound(); 169 void connected(); 170 void disconnected(); 171 void stateChanged(QAbstractSocket::SocketState); 172 void error(QAbstractSocket::SocketError); 173%If (Qt_5_15_0 -) 174 void errorOccurred(QAbstractSocket::SocketError); 175%End 176 void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator); 177 178protected: 179 virtual SIP_PYOBJECT readData(qint64 maxlen) /TypeHint="Py_v3:bytes;str",ReleaseGIL/ [qint64 (char *data, qint64 maxlen)]; 180%MethodCode 181 // Return the data read or None if there was an error. 182 if (a0 < 0) 183 { 184 PyErr_SetString(PyExc_ValueError, "maximum length of data to be read cannot be negative"); 185 sipIsErr = 1; 186 } 187 else 188 { 189 char *s = new char[a0]; 190 qint64 len; 191 192 Py_BEGIN_ALLOW_THREADS 193 #if defined(SIP_PROTECTED_IS_PUBLIC) 194 len = sipSelfWasArg ? sipCpp->QAbstractSocket::readData(s, a0) : sipCpp->readData(s, a0); 195 #else 196 len = sipCpp->sipProtectVirt_readData(sipSelfWasArg, s, a0); 197 #endif 198 Py_END_ALLOW_THREADS 199 200 if (len < 0) 201 { 202 Py_INCREF(Py_None); 203 sipRes = Py_None; 204 } 205 else 206 { 207 sipRes = SIPBytes_FromStringAndSize(s, len); 208 209 if (!sipRes) 210 sipIsErr = 1; 211 } 212 213 delete[] s; 214 } 215%End 216 217 virtual SIP_PYOBJECT readLineData(qint64 maxlen) /TypeHint="Py_v3:bytes;str",ReleaseGIL/ [qint64 (char *data, qint64 maxlen)]; 218%MethodCode 219 // Return the data read or None if there was an error. 220 if (a0 < 0) 221 { 222 PyErr_SetString(PyExc_ValueError, "maximum length of data to be read cannot be negative"); 223 sipIsErr = 1; 224 } 225 else 226 { 227 char *s = new char[a0]; 228 qint64 len; 229 230 Py_BEGIN_ALLOW_THREADS 231 #if defined(SIP_PROTECTED_IS_PUBLIC) 232 len = sipSelfWasArg ? sipCpp->QAbstractSocket::readLineData(s, a0) : sipCpp->readLineData(s, a0); 233 #else 234 len = sipCpp->sipProtectVirt_readLineData(sipSelfWasArg, s, a0); 235 #endif 236 Py_END_ALLOW_THREADS 237 238 if (len < 0) 239 { 240 Py_INCREF(Py_None); 241 sipRes = Py_None; 242 } 243 else 244 { 245 sipRes = SIPBytes_FromStringAndSize(s, len); 246 247 if (!sipRes) 248 sipIsErr = 1; 249 } 250 251 delete[] s; 252 } 253%End 254 255 virtual qint64 writeData(const char *data /Array/, qint64 len /ArraySize/) /ReleaseGIL/; 256 void setSocketState(QAbstractSocket::SocketState state); 257 void setSocketError(QAbstractSocket::SocketError socketError); 258 void setLocalPort(quint16 port); 259 void setLocalAddress(const QHostAddress &address); 260 void setPeerPort(quint16 port); 261 void setPeerAddress(const QHostAddress &address); 262 void setPeerName(const QString &name); 263 264public: 265 enum SocketOption 266 { 267 LowDelayOption, 268 KeepAliveOption, 269 MulticastTtlOption, 270 MulticastLoopbackOption, 271 TypeOfServiceOption, 272%If (Qt_5_3_0 -) 273 SendBufferSizeSocketOption, 274%End 275%If (Qt_5_3_0 -) 276 ReceiveBufferSizeSocketOption, 277%End 278%If (Qt_5_11_0 -) 279 PathMtuSocketOption, 280%End 281 }; 282 283 virtual void setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value); 284 virtual QVariant socketOption(QAbstractSocket::SocketOption option); 285 286 enum BindFlag 287 { 288 DefaultForPlatform, 289 ShareAddress, 290 DontShareAddress, 291 ReuseAddressHint, 292 }; 293 294 typedef QFlags<QAbstractSocket::BindFlag> BindMode; 295 296 enum PauseMode 297 { 298 PauseNever, 299 PauseOnSslErrors, 300 }; 301 302 typedef QFlags<QAbstractSocket::PauseMode> PauseModes; 303 virtual void resume() /ReleaseGIL/; 304 QAbstractSocket::PauseModes pauseMode() const; 305 void setPauseMode(QAbstractSocket::PauseModes pauseMode); 306 bool bind(const QHostAddress &address, quint16 port = 0, QAbstractSocket::BindMode mode = QAbstractSocket::DefaultForPlatform); 307 bool bind(quint16 port = 0, QAbstractSocket::BindMode mode = QAbstractSocket::DefaultForPlatform); 308%If (Qt_5_13_0 -) 309 QString protocolTag() const; 310%End 311%If (Qt_5_13_0 -) 312 void setProtocolTag(const QString &tag); 313%End 314}; 315 316QFlags<QAbstractSocket::BindFlag> operator|(QAbstractSocket::BindFlag f1, QFlags<QAbstractSocket::BindFlag> f2); 317QFlags<QAbstractSocket::PauseMode> operator|(QAbstractSocket::PauseMode f1, QFlags<QAbstractSocket::PauseMode> f2); 318