gecko/dom/nfc/nsINfcContentHelper.idl
dlee cf352f8410 Bug 1109456 - Support NFC tag transceive WebAPI. r=smaug, yoshi
---
 dom/nfc/NfcContentHelper.js        |   33 ++++++++++++++++++++++
 dom/nfc/gonk/Nfc.js                |    7 ++++-
 dom/nfc/gonk/NfcGonkMessage.h      |    2 ++
 dom/nfc/gonk/NfcMessageHandler.cpp |   54 ++++++++++++++++++++++++++++++++++++
 dom/nfc/gonk/NfcMessageHandler.h   |    4 ++-
 dom/nfc/gonk/NfcOptions.h          |   13 +++++++++
 dom/nfc/gonk/NfcService.cpp        |    6 ++++
 dom/nfc/nsINfcContentHelper.idl    |   27 ++++++++++++++++--
 dom/nfc/nsNfc.js                   |   19 +++++++++++++
 dom/webidl/MozNFCTag.webidl        |    6 ++++
 dom/webidl/NfcOptions.webidl       |    6 ++++
 11 files changed, 173 insertions(+), 4 deletions(-)
2015-01-09 10:42:48 +08:00

301 lines
7.6 KiB
Plaintext

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
interface nsIVariant;
interface nsIDOMWindow;
[scriptable, uuid(a694c7e8-10dd-416e-a3d9-433edf40647e)]
interface nsITagInfo : nsISupports
{
/**
* Array of technolgies supported. See NFCTechType in MozNFCTag.webidl
*/
readonly attribute nsIVariant techList;
readonly attribute nsIVariant tagId; // Uint8Array
};
[scriptable, uuid(74d70ebb-557f-4ac8-8296-7885961cd1dc)]
interface nsITagNDEFInfo : nsISupports
{
// one of NFCTagType defined in MozNFCTag.webidl.
readonly attribute DOMString tagType;
readonly attribute long maxNDEFSize;
readonly attribute boolean isReadOnly;
readonly attribute boolean isFormatable;
};
[scriptable, uuid(be09c440-8385-4210-bb7b-7d3333ec3d43)]
interface nsINfcEventListener : nsISupports
{
/**
* Callback function used to notify tagfound.
*
* @param sessionToken
* SessionToken received from parent process
* @param tagInfo
* nsITagInfo received from parent process.
* @param ndefInfo
* nsITagNDEFInfo received from parent process, could be null if the
* tag is not formated as NDEF.
* @param ndefRecords
* NDEF records pre-read during tag-discovered.
*/
void notifyTagFound(in DOMString sessionToken,
in nsITagInfo tagInfo,
in nsITagNDEFInfo ndefInfo,
in nsIVariant ndefRecords);
/**
* Callback function used to notify taglost.
*
* @param sessionToken
* SessionToken received from parent process
*/
void notifyTagLost(in DOMString sessionToken);
/**
* Callback function used to notify peerfound/peerready.
* @param sessionToken
* SessionToken received from parent process
* @param isPeerReady
* Set to true to dispatch peerready instead of peerfound
*/
void notifyPeerFound(in DOMString sessionToken, [optional] in boolean isPeerReady);
/**
* Callback function used to notify peerlost.
*
* @param sessionToken
* SessionToken received from parent process
*/
void notifyPeerLost(in DOMString sessionToken);
/**
* Callback function used to notify RF state change.
*
* @param rfState
* RF state received from parent process
*/
void notifyRFStateChange(in DOMString rfState);
};
[scriptable, uuid(6c913015-9658-46a9-88d9-6ecfda2bd020)]
interface nsINfcRequestCallback : nsISupports
{
DOMString getCallbackId();
void notifySuccess();
void notifySuccessWithBoolean(in boolean result);
void notifySuccessWithNDEFRecords(in nsIVariant records);
void notifySuccessWithByteArray(in nsIVariant array);
void notifyError(in DOMString errorMsg);
};
[scriptable, uuid(0f8aae32-9920-491e-a197-8995941d54df)]
interface nsINfcContentHelper : nsISupports
{
void init(in nsIDOMWindow window);
/**
* Read current NDEF data on the tag.
*
* @param sessionToken
* Current token
*
* @param callback
* Called when request is finished
*/
void readNDEF(in DOMString sessionToken,
in nsINfcRequestCallback callback);
/**
* Write NDEF data to a peer device or a tag.
*
* @param records
* NDEF records to be written
*
* @param sessionToken
* Current token
*
* @param callback
* Called when request is finished
*/
void writeNDEF(in nsIVariant records,
in DOMString sessionToken,
in nsINfcRequestCallback callback);
/**
* Make a tag read-only
*
* @param sessionToken
* Current token
*
* @param callback
* Called when request is finished
*/
void makeReadOnly(in DOMString sessionToken,
in nsINfcRequestCallback callback);
/**
* Format a tag as NDEF
*
* @param sessionToken
* Current token
*
* @param callback
* Called when request is finished
*/
void format(in DOMString sessionToken,
in nsINfcRequestCallback callback);
/**
* Send raw command to the tag and receive the response.
*
* @param sessionToken
* Current token
*
* @param technology
* Tag technology
*
* @param command
* Command to send
*
* @param callback
* Called when request is finished
*
*/
void transceive(in DOMString sessionToken,
in DOMString technology,
in nsIVariant command,
in nsINfcRequestCallback callback);
/**
* Enable I/O operations to the tag
*
* @param techType
* Interface to a technology in a Tag
*
* @param sessionToken
* Current token
*
* @param callback
* Called when request is finished
*/
void connect(in unsigned long techType,
in DOMString sessionToken,
in nsINfcRequestCallback callback);
/**
* Disable I/O operations to the tag
*
* @param sessionToken
* Current token
*
* @param callback
* Called when request is finished
*/
void close(in DOMString sessionToken,
in nsINfcRequestCallback callback);
/**
* Get current RF state.
*/
DOMString queryRFState();
/**
* Initiate send file operation.
*
* @param blob
* Raw data of the file to be sent. This object represents a file-like
* (nsIDOMFile) object of immutable, raw data. The blob data needs
* to be 'object wrapped' before calling this interface.
*
* @param sessionToken
* Current token
*
* @param callback
* Called when request is finished
*/
void sendFile(in jsval blob,
in DOMString sessionToken,
in nsINfcRequestCallback callback);
/**
* Add the event listener.
*
* @param listener
* An instance of the nsINfcEventListener.
*/
void addEventListener(in nsINfcEventListener listener);
/**
* Register the given application id with parent process
*
* @param appId
* Application ID to be registered
*/
void registerTargetForPeerReady(in unsigned long appId);
/**
* Unregister the given application id with parent process
*
* @param appId
* Application ID to be registered
*/
void unregisterTargetForPeerReady(in unsigned long appId);
/**
* Checks if the given application's id is a registered peer target (with the parent process)
*
* @param appId
* Application ID to be updated with parent process
*
* @param callback
* Called when request is finished
*/
void checkP2PRegistration(in unsigned long appId,
in nsINfcRequestCallback callback);
/**
* Notify the parent process that user has accepted to share nfc message on P2P UI
*
* @param appId
* Application ID that is capable of handling NFC_EVENT_PEER_READY event
*/
void notifyUserAcceptedP2P(in unsigned long appId);
/**
* Notify the status of sendFile operation to parent process
*
* @param status
* Status of sendFile operation
*
* @param requestId
* Request ID of SendFile DOM Request
*/
void notifySendFileStatus(in octet status,
in DOMString requestId);
/**
* Change RF state.
*
* @param rfState. Possible values are 'idle', 'listen' and 'discovery'.
*
* @param callback
* Called when request is finished
*/
void changeRFState(in DOMString rfState,
in nsINfcRequestCallback callback);
};