Warning: That file was not part of the compilation database. It may have many parsing errors.

1/****************************************************************************
2**
3** Copyright (C) 2018 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#ifndef QBLUETOOTHSOCKET_WINRT_P_H
41#define QBLUETOOTHSOCKET_WINRT_P_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists purely as an
48// implementation detail. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include "qbluetoothsocket.h"
55#include "qbluetoothsocketbase_p.h"
56#include <QtGlobal>
57
58QT_FORWARD_DECLARE_CLASS(SocketWorker)
59
60namespace ABI {
61 namespace Windows {
62 namespace Networking {
63 struct IHostName;
64 }
65 }
66}
67
68namespace Microsoft {
69 namespace WRL {
70 template <typename T> class ComPtr;
71 }
72}
73QT_BEGIN_NAMESPACE
74
75class QBluetoothSocketPrivateWinRT final: public QBluetoothSocketBasePrivate
76{
77 Q_OBJECT
78 friend class QBluetoothServerPrivate;
79
80public:
81 QBluetoothSocketPrivateWinRT();
82 ~QBluetoothSocketPrivateWinRT() override;
83
84 void connectToServiceHelper(const QBluetoothAddress &address,
85 quint16 port,
86 QIODevice::OpenMode openMode) override;
87
88 void connectToService(const QBluetoothServiceInfo &service,
89 QIODevice::OpenMode openMode) override;
90 void connectToService(const QBluetoothAddress &address, const QBluetoothUuid &uuid,
91 QIODevice::OpenMode openMode) override;
92 void connectToService(const QBluetoothAddress &address, quint16 port,
93 QIODevice::OpenMode openMode) override;
94
95 bool ensureNativeSocket(QBluetoothServiceInfo::Protocol type) override;
96
97 QString localName() const override;
98 QBluetoothAddress localAddress() const override;
99 quint16 localPort() const override;
100
101 QString peerName() const override;
102 QBluetoothAddress peerAddress() const override;
103 quint16 peerPort() const override;
104
105 void abort() override;
106 void close() override;
107
108 qint64 writeData(const char *data, qint64 maxSize) override;
109 qint64 readData(char *data, qint64 maxSize) override;
110
111 bool setSocketDescriptor(Microsoft::WRL::ComPtr<ABI::Windows::Networking::Sockets::IStreamSocket> socket,
112 QBluetoothServiceInfo::Protocol socketType,
113 QBluetoothSocket::SocketState socketState = QBluetoothSocket::ConnectedState,
114 QBluetoothSocket::OpenMode openMode = QBluetoothSocket::ReadWrite) override;
115
116 bool setSocketDescriptor(int socketDescriptor, QBluetoothServiceInfo::Protocol socketType,
117 QBluetoothSocket::SocketState socketState = QBluetoothSocket::ConnectedState,
118 QBluetoothSocket::OpenMode openMode = QBluetoothSocket::ReadWrite) override;
119
120 qint64 bytesAvailable() const override;
121 bool canReadLine() const override;
122 qint64 bytesToWrite() const override;
123
124 SocketWorker *m_worker;
125
126 Microsoft::WRL::ComPtr<ABI::Windows::Networking::Sockets::IStreamSocket> m_socketObject;
127 Microsoft::WRL::ComPtr<ABI::Windows::Foundation::IAsyncAction> m_connectOp;
128
129 QMutex m_readMutex;
130
131 // Protected by m_readMutex. Written in addToPendingData (native callback)
132 QVector<QByteArray> m_pendingData;
133
134 Q_INVOKABLE void addToPendingData(const QVector<QByteArray> &data);
135
136private slots:
137 void handleNewData(const QVector<QByteArray> &data);
138 void handleError(QBluetoothSocket::SocketError error);
139
140private:
141 void connectToService(Microsoft::WRL::ComPtr<ABI::Windows::Networking::IHostName> hostName,
142 const QString &serviceName, QIODevice::OpenMode openMode);
143 HRESULT handleConnectOpFinished(ABI::Windows::Foundation::IAsyncAction *action,
144 ABI::Windows::Foundation::AsyncStatus status);
145
146 QIODevice::OpenMode requestedOpenMode = QIODevice::NotOpen;
147};
148
149QT_END_NAMESPACE
150
151#endif
152

Warning: That file was not part of the compilation database. It may have many parsing errors.