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 "qbluetoothtransfermanager.h" |
41 | #include "qbluetoothtransferrequest.h" |
42 | #include "qbluetoothtransferreply.h" |
43 | #if QT_CONFIG(bluez) |
44 | #include "qbluetoothtransferreply_bluez_p.h" |
45 | #elif QT_OSX_BLUETOOTH |
46 | #include "qbluetoothtransferreply_osx_p.h" |
47 | #else |
48 | #if !defined(QT_ANDROID_BLUETOOTH) && !defined(QT_IOS_BLUETOOTH) |
49 | #include "dummy/dummy_helper_p.h" |
50 | #endif |
51 | #endif |
52 | |
53 | QT_BEGIN_NAMESPACE |
54 | |
55 | /*! |
56 | \class QBluetoothTransferManager |
57 | \inmodule QtBluetooth |
58 | \brief The QBluetoothTransferManager class transfers data to another device |
59 | using Object Push Profile (OPP). |
60 | |
61 | \since 5.2 |
62 | |
63 | QBluetoothTransferManager uses OBEX to send put commands to remote devices. A typical |
64 | OBEX transfer is initialized as follows: |
65 | |
66 | \snippet doc_src_qtbluetooth.cpp sendfile |
67 | |
68 | Note that this API is not currently supported on Android. |
69 | */ |
70 | |
71 | /*! |
72 | \fn QBluetoothTransferReply *QBluetoothTransferManager::put(const QBluetoothTransferRequest &request, QIODevice *data) |
73 | |
74 | Sends the contents of \a data to the remote device identified by \a request, and returns a new |
75 | QBluetoothTransferReply that can be used to track the request's progress. \a data must remain valid |
76 | until the \l finished() signal is emitted. |
77 | |
78 | The returned \l QBluetoothTransferReply object must be immediately checked for its |
79 | \l {QBluetoothTransferReply::error()}{error()} state. This is required in case |
80 | this function detects an error during the initialization of the |
81 | \l QBluetoothTransferReply. In such cases \l {QBluetoothTransferReply::isFinished()} returns |
82 | \c true as well. |
83 | |
84 | If the platform does not support the Object Push profile, this function will return \c 0. |
85 | */ |
86 | |
87 | |
88 | |
89 | /*! |
90 | \fn void QBluetoothTransferManager::finished(QBluetoothTransferReply *reply) |
91 | |
92 | This signal is emitted when the transfer for \a reply finishes. |
93 | */ |
94 | |
95 | /*! |
96 | Constructs a new QBluetoothTransferManager with \a parent. |
97 | */ |
98 | QBluetoothTransferManager::QBluetoothTransferManager(QObject *parent) |
99 | : QObject(parent) |
100 | { |
101 | qRegisterMetaType<QBluetoothTransferReply*>(); |
102 | qRegisterMetaType<QBluetoothTransferReply::TransferError>(); |
103 | } |
104 | |
105 | /*! |
106 | Destroys the QBluetoothTransferManager. |
107 | */ |
108 | QBluetoothTransferManager::~QBluetoothTransferManager() |
109 | { |
110 | } |
111 | |
112 | QBluetoothTransferReply *QBluetoothTransferManager::put(const QBluetoothTransferRequest &request, |
113 | QIODevice *data) |
114 | { |
115 | #if QT_CONFIG(bluez) |
116 | QBluetoothTransferReplyBluez *rep = new QBluetoothTransferReplyBluez(data, request, this); |
117 | connect(rep, SIGNAL(finished(QBluetoothTransferReply*)), this, SIGNAL(finished(QBluetoothTransferReply*))); |
118 | return rep; |
119 | #elif QT_OSX_BLUETOOTH |
120 | QBluetoothTransferReply *reply = new QBluetoothTransferReplyOSX(data, request, this); |
121 | connect(reply, SIGNAL(finished(QBluetoothTransferReply*)), this, SIGNAL(finished(QBluetoothTransferReply*))); |
122 | return reply; |
123 | #else |
124 | // Android, iOS, and Win/WinRT have no implementation |
125 | #if !defined(QT_ANDROID_BLUETOOTH) && !defined(QT_IOS_BLUETOOTH) && !defined(QT_WINRT_BLUETOOTH) && !defined(QT_WIN_BLUETOOTH) |
126 | printDummyWarning(); |
127 | #endif |
128 | Q_UNUSED(request); |
129 | Q_UNUSED(data); |
130 | return 0; |
131 | #endif |
132 | } |
133 | |
134 | QT_END_NAMESPACE |
135 | |
136 | #include "moc_qbluetoothtransfermanager.cpp" |
137 | |