QNearFieldShareManager Class
The QNearFieldShareManager class manages all interactions related to sharing files and data over NFC. More...
Header: | #include <QNearFieldShareManager> |
qmake: | QT += nfc |
Since: | Qt 5.3 |
Inherits: | QObject |
Public Types
enum | ShareError { NoError, UnknownError, InvalidShareContentError, ShareCanceledError, ..., SharePermissionDeniedError } |
enum | ShareMode { NoShare, NdefShare, FileShare } |
flags | ShareModes |
Public Functions
QNearFieldShareManager(QObject *parent = Q_NULLPTR) | |
~QNearFieldShareManager() | |
void | setShareModes(ShareModes mode) |
QNearFieldShareManager::ShareError | shareError() const |
QNearFieldShareManager::ShareModes | shareModes() const |
- 31 public functions inherited from QObject
Signals
void | error(QNearFieldShareManager::ShareError error) |
void | shareModesChanged(QNearFieldShareManager::ShareModes modes) |
void | targetDetected(QNearFieldShareTarget *shareTarget) |
- 2 signals inherited from QObject
Static Public Members
QNearFieldShareManager::ShareModes | supportedShareModes() |
- 10 static public members inherited from QObject
Additional Inherited Members
- 1 property inherited from QObject
- 1 public slot inherited from QObject
- 1 public variable inherited from QObject
- 9 protected functions inherited from QObject
- 2 protected variables inherited from QObject
Detailed Description
The QNearFieldShareManager class manages all interactions related to sharing files and data over NFC.
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.
Member Type Documentation
enum QNearFieldShareManager::ShareError
This enum specifies the share error type.
Constant | Value | Description |
---|---|---|
QNearFieldShareManager::NoError | 0 | No error. |
QNearFieldShareManager::UnknownError | 1 | Unknown or internal error occurred. |
QNearFieldShareManager::InvalidShareContentError | 2 | Invalid content was provided for sharing. |
QNearFieldShareManager::ShareCanceledError | 3 | Data or file sharing is canceled on the local or remote device. |
QNearFieldShareManager::ShareInterruptedError | 4 | Data or file sharing is interrupted due to an I/O error. |
QNearFieldShareManager::ShareRejectedError | 5 | Data or file sharing is rejected by the remote device. |
QNearFieldShareManager::UnsupportedShareModeError | 6 | Data or file sharing is not supported by the share target. |
QNearFieldShareManager::ShareAlreadyInProgressError | 7 | Data or file sharing is already in progress. |
QNearFieldShareManager::SharePermissionDeniedError | 8 | File sharing is denied due to insufficient permission. |
enum QNearFieldShareManager::ShareMode
flags QNearFieldShareManager::ShareModes
This enum specifies the content type to be shared.
Constant | Value | Description |
---|---|---|
QNearFieldShareManager::NoShare | 0x00 | No content is currently set to be shared. |
QNearFieldShareManager::NdefShare | 0x01 | Share NDEF message with target. |
QNearFieldShareManager::FileShare | 0x02 | Share file with target. |
The ShareModes type is a typedef for QFlags<ShareMode>. It stores an OR combination of ShareMode values.
Member Function Documentation
QNearFieldShareManager::QNearFieldShareManager(QObject *parent = Q_NULLPTR)
Constructs a new near field share manager with parent.
QNearFieldShareManager::~QNearFieldShareManager()
Destroys the near field share manager.
[signal]
void QNearFieldShareManager::error(QNearFieldShareManager::ShareError error)
This signal is emitted whenever an error occurs related to a share request.
void QNearFieldShareManager::setShareModes(ShareModes mode)
Initializes the NFC share 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.
See also shareModes().
QNearFieldShareManager::ShareError QNearFieldShareManager::shareError() const
Returns the error code of the error that occurred.
QNearFieldShareManager::ShareModes QNearFieldShareManager::shareModes() const
Returns which shared modes are set.
See also setShareModes().
[signal]
void QNearFieldShareManager::shareModesChanged(QNearFieldShareManager::ShareModes modes)
This signal is emitted whenever the share modes are changed.
[static]
QNearFieldShareManager::ShareModes QNearFieldShareManager::supportedShareModes()
Returns the shared modes supported by NFC.
[signal]
void QNearFieldShareManager::targetDetected(QNearFieldShareTarget *shareTarget)
This signal is emitted whenever a shareTarget is detected. The shareTarget instance is owned by QNearFieldShareManager and must not be deleted by the application.