summaryrefslogtreecommitdiffstats
path: root/src/nfc/qnearfieldsharemanager.cpp
blob: 515a9d6239f321063776dd219b9264c3a9f5e23b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/***************************************************************************
 **
 ** Copyright (C) 2016 BlackBerry Limited. All rights reserved.
 ** Contact: https://www.qt.io/licensing/
 **
 ** This file is part of the QtNfc module of the Qt Toolkit.
 **
 ** $QT_BEGIN_LICENSE:LGPL$
 ** Commercial License Usage
 ** Licensees holding valid commercial Qt licenses may use this file in
 ** accordance with the commercial license agreement provided with the
 ** Software or, alternatively, in accordance with the terms contained in
 ** a written agreement between you and The Qt Company. For licensing terms
 ** and conditions see https://www.qt.io/terms-conditions. For further
 ** information use the contact form at https://www.qt.io/contact-us.
 **
 ** GNU Lesser General Public License Usage
 ** Alternatively, this file may be used under the terms of the GNU Lesser
 ** General Public License version 3 as published by the Free Software
 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
 ** packaging of this file. Please review the following information to
 ** ensure the GNU Lesser General Public License version 3 requirements
 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
 **
 ** GNU General Public License Usage
 ** Alternatively, this file may be used under the terms of the GNU
 ** General Public License version 2.0 or (at your option) the GNU General
 ** Public license version 3 or any later version approved by the KDE Free
 ** Qt Foundation. The licenses are as published by the Free Software
 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
 ** included in the packaging of this file. Please review the following
 ** information to ensure the GNU General Public License requirements will
 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
 ** https://www.gnu.org/licenses/gpl-3.0.html.
 **
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/

#include "qnearfieldsharemanager.h"
#include "qnearfieldsharemanager_p.h"

#include "qnearfieldsharemanagerimpl_p.h"

#include "qnearfieldsharetarget.h"

QT_BEGIN_NAMESPACE

/*!
    \class QNearFieldShareManager
    \brief The QNearFieldShareManager class manages all interactions related to sharing files and data over NFC.

    \ingroup connectivity-nfc
    \inmodule QtNfc
    \since 5.3

    Applications can share NDEF data or file content using NFC technology by tapping two NFC-enabled devices
    together. The QNearFieldShareManager provides a high level entry point to access this functionality.

    The class allows both NDEF data and/or files to be shared between two devices by calling the setShareModes()
    method. This method specifies either an NDEF Data and/or a File transfer. The targetDetected() signal is emitted
    each time a share target is detected. A QNearFieldShareTarget pointer is passed with the signal, which can
    be used to share either an NDEF message or one or more files.

    The process of sharing files via NFC involves other underlying communication transports such as Bluetooth or Wi-Fi Direct.
    It is implementation specific how and what type of transports are used to perform file transfer. The overall time taken to
    transfer content depends on the maximum speed of the transport used. Note that the process of sharing NDEF message/data
    does not require the use of other transports outside NFC.

    If an error occurs, shareError() returns the error type.

    Platforms that do not support both NDEF data and file content sharing modes can return the supported subset in the
    supportedShareModes() method. Applications that call setShareModes() with an unsupported mode will receive an error
    signal with a UnsupportedShareModeError.

    Since sharing data over NFC is effectively a data pipe between two processes (one on the sender and one of
    the receiver), the application developer should only create a single instance of QNearFieldShareManager per
    application. This avoids the possibility that different parts of the same application attempt to all consume
    data transferred over NFC.
*/

/*!
    \enum QNearFieldShareManager::ShareError

    This enum specifies the share error type.

    \value NoError                         No error.
    \value UnknownError                    Unknown or internal error occurred.
    \value InvalidShareContentError        Invalid content was provided for sharing.
    \value ShareCanceledError              Data or file sharing is canceled on the local or remote device.
    \value ShareInterruptedError           Data or file sharing is interrupted due to an I/O error.
    \value ShareRejectedError              Data or file sharing is rejected by the remote device.
    \value UnsupportedShareModeError       Data or file sharing is not supported by the share target.
    \value ShareAlreadyInProgressError     Data or file sharing is already in progress.
    \value SharePermissionDeniedError      File sharing is denied due to insufficient permission.
*/

/*!
    \enum QNearFieldShareManager::ShareMode

    This enum specifies the content type to be shared.

    \value NoShare                         No content is currently set to be shared.
    \value NdefShare                       Share NDEF message with target.
    \value FileShare                       Share file with target.
*/

/*!
    \fn void QNearFieldShareManager::targetDetected(QNearFieldShareTarget* shareTarget)

    This signal is emitted whenever a \a shareTarget is detected. The \a shareTarget
    instance is owned by QNearFieldShareManager and must not be deleted by the application.
*/

/*!
    \fn void QNearFieldShareManager::shareModesChanged(ShareModes modes)

    This signal is emitted whenever the share \a modes are changed.
*/

/*!
    \fn void QNearFieldShareManager::error(ShareError error)

    This signal is emitted whenever an \a error occurs related to a share request.
*/

/*!
    Constructs a new near field share manager with \a parent.
*/
QNearFieldShareManager::QNearFieldShareManager(QObject *parent)
:   QObject(parent), d_ptr(new QNearFieldShareManagerPrivateImpl(this))
{
}

/*!
    Destroys the near field share manager.
*/
QNearFieldShareManager::~QNearFieldShareManager()
{
}

/*!
    Initializes the NFC share \a mode to detect a QNearFieldShareTarget for data and/or file sharing.
    Calls to this method will overwrite previous share modes.

    A shareModesChanged() signal will be emitted when share modes are different from previous modes.
    A targetDetected() signal will be emitted if a share target is detected.
*/
void QNearFieldShareManager::setShareModes(ShareModes mode)
{
    Q_D(QNearFieldShareManager);
    return d->setShareModes(mode);
}

/*!
    Returns the shared modes supported by NFC.
*/
QNearFieldShareManager::ShareModes QNearFieldShareManager::supportedShareModes()
{
    return QNearFieldShareManagerPrivateImpl::supportedShareModes();
}

/*!
    Returns which shared modes are set.
*/
QNearFieldShareManager::ShareModes QNearFieldShareManager::shareModes() const
{
    Q_D(const QNearFieldShareManager);
    return d->shareModes();
}

/*!
     Returns the error code of the error that occurred.
 */
QNearFieldShareManager::ShareError QNearFieldShareManager::shareError() const
{
    Q_D(const QNearFieldShareManager);
    return d->shareError();
}

QT_END_NAMESPACE