qlocalsocket.sip 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. // qlocalsocket.sip generated by MetaSIP
  2. //
  3. // This file is part of the QtNetwork Python extension module.
  4. //
  5. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  6. //
  7. // This file is part of PyQt6.
  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. class QLocalSocket : public QIODevice
  22. {
  23. %TypeHeaderCode
  24. #include <qlocalsocket.h>
  25. %End
  26. public:
  27. enum LocalSocketError
  28. {
  29. ConnectionRefusedError,
  30. PeerClosedError,
  31. ServerNotFoundError,
  32. SocketAccessError,
  33. SocketResourceError,
  34. SocketTimeoutError,
  35. DatagramTooLargeError,
  36. ConnectionError,
  37. UnsupportedSocketOperationError,
  38. OperationError,
  39. UnknownSocketError,
  40. };
  41. enum LocalSocketState
  42. {
  43. UnconnectedState,
  44. ConnectingState,
  45. ConnectedState,
  46. ClosingState,
  47. };
  48. QLocalSocket(QObject *parent /TransferThis/ = 0);
  49. virtual ~QLocalSocket();
  50. void connectToServer(const QString &name, QIODeviceBase::OpenMode mode = QIODeviceBase::ReadWrite) /ReleaseGIL/;
  51. void connectToServer(QIODeviceBase::OpenMode mode = QIODeviceBase::ReadWrite) /ReleaseGIL/;
  52. void disconnectFromServer() /ReleaseGIL/;
  53. virtual bool open(QIODeviceBase::OpenMode mode = QIODeviceBase::ReadWrite);
  54. QString serverName() const;
  55. void setServerName(const QString &name);
  56. QString fullServerName() const;
  57. void abort();
  58. virtual bool isSequential() const;
  59. virtual qint64 bytesAvailable() const;
  60. virtual qint64 bytesToWrite() const;
  61. virtual bool canReadLine() const;
  62. virtual void close();
  63. QLocalSocket::LocalSocketError error() const;
  64. bool flush();
  65. bool isValid() const;
  66. qint64 readBufferSize() const;
  67. void setReadBufferSize(qint64 size);
  68. bool setSocketDescriptor(qintptr socketDescriptor, QLocalSocket::LocalSocketState state = QLocalSocket::ConnectedState, QIODeviceBase::OpenMode mode = QIODeviceBase::ReadWrite);
  69. qintptr socketDescriptor() const;
  70. QLocalSocket::LocalSocketState state() const;
  71. virtual bool waitForBytesWritten(int msecs = 30000) /ReleaseGIL/;
  72. bool waitForConnected(int msecs = 30000) /ReleaseGIL/;
  73. bool waitForDisconnected(int msecs = 30000) /ReleaseGIL/;
  74. virtual bool waitForReadyRead(int msecs = 30000) /ReleaseGIL/;
  75. signals:
  76. void connected();
  77. void disconnected();
  78. void errorOccurred(QLocalSocket::LocalSocketError socketError);
  79. void stateChanged(QLocalSocket::LocalSocketState socketState);
  80. protected:
  81. virtual SIP_PYOBJECT readData(qint64 maxlen) /TypeHint="bytes",ReleaseGIL/ [qint64 (char *, qint64)];
  82. %MethodCode
  83. // Return the data read or None if there was an error.
  84. if (a0 < 0)
  85. {
  86. PyErr_SetString(PyExc_ValueError, "maximum length of data to be read cannot be negative");
  87. sipIsErr = 1;
  88. }
  89. else
  90. {
  91. char *s = new char[a0];
  92. qint64 len;
  93. Py_BEGIN_ALLOW_THREADS
  94. #if defined(SIP_PROTECTED_IS_PUBLIC)
  95. len = sipSelfWasArg ? sipCpp->QLocalSocket::readData(s, a0) : sipCpp->readData(s, a0);
  96. #else
  97. len = sipCpp->sipProtectVirt_readData(sipSelfWasArg, s, a0);
  98. #endif
  99. Py_END_ALLOW_THREADS
  100. if (len < 0)
  101. {
  102. Py_INCREF(Py_None);
  103. sipRes = Py_None;
  104. }
  105. else
  106. {
  107. sipRes = PyBytes_FromStringAndSize(s, len);
  108. if (!sipRes)
  109. sipIsErr = 1;
  110. }
  111. delete[] s;
  112. }
  113. %End
  114. virtual qint64 writeData(SIP_PYBUFFER) /ReleaseGIL/ [qint64 (const char *, qint64)];
  115. %MethodCode
  116. sipBufferInfoDef bi;
  117. if (sipGetBufferInfo(a0, &bi) > 0)
  118. {
  119. Py_BEGIN_ALLOW_THREADS
  120. #if defined(SIP_PROTECTED_IS_PUBLIC)
  121. sipRes = sipSelfWasArg ?
  122. sipCpp->QLocalSocket::writeData(reinterpret_cast<char *>(bi.bi_buf), bi.bi_len) :
  123. sipCpp->writeData(reinterpret_cast<char *>(bi.bi_buf), bi.bi_len);
  124. #else
  125. sipRes = sipCpp->sipProtectVirt_writeData(sipSelfWasArg, reinterpret_cast<char *>(bi.bi_buf),
  126. bi.bi_len);
  127. #endif
  128. Py_END_ALLOW_THREADS
  129. sipReleaseBufferInfo(&bi);
  130. }
  131. else
  132. {
  133. sipIsErr = 1;
  134. }
  135. %End
  136. virtual qint64 skipData(qint64 maxSize) /ReleaseGIL/;
  137. public:
  138. %If (Qt_6_2_0 -)
  139. enum SocketOption /BaseType=Flag/
  140. {
  141. NoOptions,
  142. AbstractNamespaceOption,
  143. };
  144. %End
  145. %If (Qt_6_2_0 -)
  146. typedef QFlags<QLocalSocket::SocketOption> SocketOptions;
  147. %End
  148. %If (Qt_6_2_0 -)
  149. void setSocketOptions(QLocalSocket::SocketOptions option);
  150. %End
  151. %If (Qt_6_2_0 -)
  152. QLocalSocket::SocketOptions socketOptions() const;
  153. %End
  154. protected:
  155. %If (Qt_6_3_0 -)
  156. virtual SIP_PYOBJECT readLineData(qint64 maxlen) /ReleaseGIL,TypeHint="bytes"/ [qint64 (char *data, qint64 maxSize)];
  157. %MethodCode
  158. // Return the data read or None if there was an error.
  159. if (a0 < 0)
  160. {
  161. PyErr_SetString(PyExc_ValueError, "maximum length of data to be read cannot be negative");
  162. sipIsErr = 1;
  163. }
  164. else
  165. {
  166. char *s = new char[a0];
  167. qint64 len;
  168. Py_BEGIN_ALLOW_THREADS
  169. #if defined(SIP_PROTECTED_IS_PUBLIC)
  170. len = sipSelfWasArg ? sipCpp->QLocalSocket::readLineData(s, a0) : sipCpp->readLineData(s, a0);
  171. #else
  172. len = sipCpp->sipProtectVirt_readLineData(sipSelfWasArg, s, a0);
  173. #endif
  174. Py_END_ALLOW_THREADS
  175. if (len < 0)
  176. {
  177. Py_INCREF(Py_None);
  178. sipRes = Py_None;
  179. }
  180. else
  181. {
  182. sipRes = PyBytes_FromStringAndSize(s, len);
  183. if (!sipRes)
  184. sipIsErr = 1;
  185. }
  186. delete[] s;
  187. }
  188. %End
  189. %End
  190. };