QNearFieldShareManager Class

QNearFieldShareManager class manages all interactions related to sharing files and data over NFC. 更多...

头: #include <QNearFieldShareManager>
qmake: QT += nfc
Since: Qt 5.3
继承: QObject

公共类型

enum ShareError { NoError, UnknownError, InvalidShareContentError, ShareCanceledError, ..., SharePermissionDeniedError }
enum ShareMode { NoShare, NdefShare, FileShare }
flags ShareModes

公共函数

QNearFieldShareManager (QObject * parent = Q_NULLPTR)
~QNearFieldShareManager ()
void setShareModes (ShareModes mode )
QNearFieldShareManager::ShareError shareError () const
QNearFieldShareManager::ShareModes shareModes () const

信号

void error (QNearFieldShareManager::ShareError error )
void shareModesChanged (QNearFieldShareManager::ShareModes modes )
void targetDetected (QNearFieldShareTarget * shareTarget )

静态公共成员

QNearFieldShareManager::ShareModes supportedShareModes ()

额外继承成员

详细描述

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.

若出现错误, 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.

常量 描述
QNearFieldShareManager::NoError 0 没有错误。
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.

常量 描述
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.

成员函数文档编制

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.

另请参阅 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.

另请参阅 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 )

此信号被发射每当 shareTarget is detected. The shareTarget instance is owned by QNearFieldShareManager and must not be deleted by the application.