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