qbluetoothsocket.sip 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. // qbluetoothsocket.sip generated by MetaSIP
  2. //
  3. // This file is part of the QtBluetooth 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. %If (Qt_6_2_0 -)
  22. class QBluetoothSocket : public QIODevice
  23. {
  24. %TypeHeaderCode
  25. #include <qbluetoothsocket.h>
  26. %End
  27. public:
  28. enum class SocketState
  29. {
  30. UnconnectedState,
  31. ServiceLookupState,
  32. ConnectingState,
  33. ConnectedState,
  34. BoundState,
  35. ClosingState,
  36. ListeningState,
  37. };
  38. enum class SocketError
  39. {
  40. NoSocketError,
  41. UnknownSocketError,
  42. RemoteHostClosedError,
  43. HostNotFoundError,
  44. ServiceNotFoundError,
  45. NetworkError,
  46. UnsupportedProtocolError,
  47. OperationError,
  48. %If (Qt_6_4_0 -)
  49. MissingPermissionsError,
  50. %End
  51. };
  52. QBluetoothSocket(QBluetoothServiceInfo::Protocol socketType, QObject *parent /TransferThis/ = 0);
  53. explicit QBluetoothSocket(QObject *parent /TransferThis/ = 0);
  54. virtual ~QBluetoothSocket();
  55. void abort();
  56. virtual void close() /ReleaseGIL/;
  57. virtual bool isSequential() const;
  58. virtual qint64 bytesAvailable() const;
  59. virtual qint64 bytesToWrite() const;
  60. virtual bool canReadLine() const;
  61. void connectToService(const QBluetoothAddress &address, QBluetoothUuid::ServiceClassUuid uuid, QIODeviceBase::OpenMode mode = QIODeviceBase::ReadWrite) /ReleaseGIL/;
  62. void connectToService(const QBluetoothAddress &address, quint16 port, QIODeviceBase::OpenMode mode = QIODeviceBase::ReadWrite) /ReleaseGIL/;
  63. void connectToService(const QBluetoothAddress &address, const QBluetoothUuid &uuid, QIODeviceBase::OpenMode mode = QIODeviceBase::ReadWrite) /ReleaseGIL/;
  64. void connectToService(const QBluetoothServiceInfo &service, QIODeviceBase::OpenMode mode = QIODeviceBase::ReadWrite) /ReleaseGIL/;
  65. void disconnectFromService() /ReleaseGIL/;
  66. QString localName() const;
  67. QBluetoothAddress localAddress() const;
  68. quint16 localPort() const;
  69. QString peerName() const;
  70. QBluetoothAddress peerAddress() const;
  71. quint16 peerPort() const;
  72. bool setSocketDescriptor(int socketDescriptor, QBluetoothServiceInfo::Protocol socketType, QBluetoothSocket::SocketState state = QBluetoothSocket::SocketState::ConnectedState, QIODeviceBase::OpenMode mode = QIODeviceBase::ReadWrite);
  73. int socketDescriptor() const;
  74. QBluetoothServiceInfo::Protocol socketType() const;
  75. QBluetoothSocket::SocketState state() const;
  76. QBluetoothSocket::SocketError error() const;
  77. QString errorString() const;
  78. signals:
  79. void connected();
  80. void disconnected();
  81. void errorOccurred(QBluetoothSocket::SocketError error);
  82. void stateChanged(QBluetoothSocket::SocketState state);
  83. protected:
  84. virtual SIP_PYOBJECT readData(qint64 maxlen) /TypeHint="bytes",ReleaseGIL/ [qint64 (char *data, qint64 maxSize)];
  85. %MethodCode
  86. // Return the data read or None if there was an error.
  87. if (a0 < 0)
  88. {
  89. PyErr_SetString(PyExc_ValueError, "maximum length of data to be read cannot be negative");
  90. sipIsErr = 1;
  91. }
  92. else
  93. {
  94. char *s = new char[a0];
  95. qint64 len;
  96. Py_BEGIN_ALLOW_THREADS
  97. #if defined(SIP_PROTECTED_IS_PUBLIC)
  98. len = sipSelfWasArg ? sipCpp->QBluetoothSocket::readData(s, a0) : sipCpp->readData(s, a0);
  99. #else
  100. len = sipCpp->sipProtectVirt_readData(sipSelfWasArg, s, a0);
  101. #endif
  102. Py_END_ALLOW_THREADS
  103. if (len < 0)
  104. {
  105. Py_INCREF(Py_None);
  106. sipRes = Py_None;
  107. }
  108. else
  109. {
  110. sipRes = PyBytes_FromStringAndSize(s, len);
  111. if (!sipRes)
  112. sipIsErr = 1;
  113. }
  114. delete[] s;
  115. }
  116. %End
  117. virtual qint64 writeData(const char *data /Array/, qint64 maxSize /ArraySize/) /ReleaseGIL/;
  118. void setSocketState(QBluetoothSocket::SocketState state);
  119. void setSocketError(QBluetoothSocket::SocketError error);
  120. void doDeviceDiscovery(const QBluetoothServiceInfo &service, QIODeviceBase::OpenMode openMode);
  121. public:
  122. void setPreferredSecurityFlags(QBluetooth::SecurityFlags flags);
  123. QBluetooth::SecurityFlags preferredSecurityFlags() const;
  124. };
  125. %End