1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtBluetooth module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #include "qbluetoothsocket.h" |
41 | #include "qbluetoothsocket_dummy_p.h" |
42 | #ifndef QT_IOS_BLUETOOTH |
43 | #include "dummy/dummy_helper_p.h" |
44 | #endif |
45 | |
46 | QT_BEGIN_NAMESPACE |
47 | |
48 | QBluetoothSocketPrivateDummy::QBluetoothSocketPrivateDummy() |
49 | { |
50 | secFlags = QBluetooth::NoSecurity; |
51 | #ifndef QT_IOS_BLUETOOTH |
52 | printDummyWarning(); |
53 | #endif |
54 | } |
55 | |
56 | QBluetoothSocketPrivateDummy::~QBluetoothSocketPrivateDummy() |
57 | { |
58 | } |
59 | |
60 | bool QBluetoothSocketPrivateDummy::ensureNativeSocket(QBluetoothServiceInfo::Protocol type) |
61 | { |
62 | socketType = type; |
63 | return false; |
64 | } |
65 | |
66 | void QBluetoothSocketPrivateDummy::connectToServiceHelper(const QBluetoothAddress &address, quint16 port, QIODevice::OpenMode openMode) |
67 | { |
68 | Q_UNUSED(openMode); |
69 | Q_UNUSED(address); |
70 | Q_UNUSED(port); |
71 | } |
72 | |
73 | void QBluetoothSocketPrivateDummy::connectToService( |
74 | const QBluetoothServiceInfo &service, QIODevice::OpenMode openMode) |
75 | { |
76 | Q_UNUSED(service); |
77 | Q_UNUSED(openMode); |
78 | |
79 | Q_Q(QBluetoothSocket); |
80 | |
81 | qWarning() << "Using non-functional QBluetoothSocketPrivateDummy" ; |
82 | errorString = QBluetoothSocket::tr(s: "Socket type not supported" ); |
83 | q->setSocketError(QBluetoothSocket::UnsupportedProtocolError); |
84 | } |
85 | |
86 | void QBluetoothSocketPrivateDummy::connectToService( |
87 | const QBluetoothAddress &address, const QBluetoothUuid &uuid, QIODevice::OpenMode openMode) |
88 | { |
89 | Q_UNUSED(address); |
90 | Q_UNUSED(uuid); |
91 | Q_UNUSED(openMode); |
92 | |
93 | Q_Q(QBluetoothSocket); |
94 | |
95 | qWarning() << "Using non-functional QBluetoothSocketPrivateDummy" ; |
96 | errorString = QBluetoothSocket::tr(s: "Socket type not supported" ); |
97 | q->setSocketError(QBluetoothSocket::UnsupportedProtocolError); |
98 | } |
99 | |
100 | void QBluetoothSocketPrivateDummy::connectToService( |
101 | const QBluetoothAddress &address, quint16 port, QIODevice::OpenMode openMode) |
102 | { |
103 | Q_UNUSED(address); |
104 | Q_UNUSED(port); |
105 | Q_UNUSED(openMode); |
106 | |
107 | Q_Q(QBluetoothSocket); |
108 | |
109 | qWarning() << "Using non-functional QBluetoothSocketPrivateDummy" ; |
110 | errorString = QBluetoothSocket::tr(s: "Socket type not supported" ); |
111 | q->setSocketError(QBluetoothSocket::UnsupportedProtocolError); |
112 | } |
113 | |
114 | void QBluetoothSocketPrivateDummy::abort() |
115 | { |
116 | } |
117 | |
118 | QString QBluetoothSocketPrivateDummy::localName() const |
119 | { |
120 | return QString(); |
121 | } |
122 | |
123 | QBluetoothAddress QBluetoothSocketPrivateDummy::localAddress() const |
124 | { |
125 | return QBluetoothAddress(); |
126 | } |
127 | |
128 | quint16 QBluetoothSocketPrivateDummy::localPort() const |
129 | { |
130 | return 0; |
131 | } |
132 | |
133 | QString QBluetoothSocketPrivateDummy::peerName() const |
134 | { |
135 | return QString(); |
136 | } |
137 | |
138 | QBluetoothAddress QBluetoothSocketPrivateDummy::peerAddress() const |
139 | { |
140 | return QBluetoothAddress(); |
141 | } |
142 | |
143 | quint16 QBluetoothSocketPrivateDummy::peerPort() const |
144 | { |
145 | return 0; |
146 | } |
147 | |
148 | qint64 QBluetoothSocketPrivateDummy::writeData(const char *data, qint64 maxSize) |
149 | { |
150 | Q_UNUSED(data); |
151 | Q_UNUSED(maxSize); |
152 | |
153 | Q_Q(QBluetoothSocket); |
154 | |
155 | if (state != QBluetoothSocket::ConnectedState) { |
156 | errorString = QBluetoothSocket::tr(s: "Cannot write while not connected" ); |
157 | q->setSocketError(QBluetoothSocket::OperationError); |
158 | return -1; |
159 | } |
160 | return -1; |
161 | } |
162 | |
163 | qint64 QBluetoothSocketPrivateDummy::readData(char *data, qint64 maxSize) |
164 | { |
165 | Q_UNUSED(data); |
166 | Q_UNUSED(maxSize); |
167 | |
168 | Q_Q(QBluetoothSocket); |
169 | |
170 | if (state != QBluetoothSocket::ConnectedState) { |
171 | errorString = QBluetoothSocket::tr(s: "Cannot read while not connected" ); |
172 | q->setSocketError(QBluetoothSocket::OperationError); |
173 | return -1; |
174 | } |
175 | |
176 | return -1; |
177 | } |
178 | |
179 | void QBluetoothSocketPrivateDummy::close() |
180 | { |
181 | } |
182 | |
183 | bool QBluetoothSocketPrivateDummy::setSocketDescriptor(int socketDescriptor, QBluetoothServiceInfo::Protocol socketType, |
184 | QBluetoothSocket::SocketState socketState, QBluetoothSocket::OpenMode openMode) |
185 | { |
186 | Q_UNUSED(socketDescriptor); |
187 | Q_UNUSED(socketType) |
188 | Q_UNUSED(socketState); |
189 | Q_UNUSED(openMode); |
190 | return false; |
191 | } |
192 | |
193 | qint64 QBluetoothSocketPrivateDummy::bytesAvailable() const |
194 | { |
195 | return 0; |
196 | } |
197 | |
198 | bool QBluetoothSocketPrivateDummy::canReadLine() const |
199 | { |
200 | return false; |
201 | } |
202 | |
203 | qint64 QBluetoothSocketPrivateDummy::bytesToWrite() const |
204 | { |
205 | return 0; |
206 | } |
207 | |
208 | QT_END_NAMESPACE |
209 | |