michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: #include "nsIDOMDOMRequest.idl" michael@0: michael@0: interface nsIVariant; michael@0: michael@0: [scriptable, function, uuid(26673d1a-4af4-470a-ba96-f1f54b1f2052)] michael@0: interface nsINfcPeerCallback : nsISupports michael@0: { michael@0: /** michael@0: * Callback function used to notify NFC peer events. michael@0: * michael@0: * @param event michael@0: * An event indicating 'PeerReady' or 'PeerLost' michael@0: * One of NFC_EVENT_PEER_XXXX michael@0: * michael@0: * @param sessionToken michael@0: * SessionToken received from Chrome process michael@0: */ michael@0: void peerNotification(in unsigned long event, michael@0: in DOMString sessionToken); michael@0: }; michael@0: michael@0: [scriptable, uuid(10b2eb1b-3fe0-4c98-9c67-9e4c2274cd78)] michael@0: interface nsINfcContentHelper : nsISupports michael@0: { michael@0: const long NFC_EVENT_PEER_READY = 0x01; michael@0: const long NFC_EVENT_PEER_LOST = 0x02; michael@0: michael@0: void setSessionToken(in DOMString sessionToken); michael@0: michael@0: nsIDOMDOMRequest getDetailsNDEF(in nsIDOMWindow window, in DOMString sessionToken); michael@0: nsIDOMDOMRequest readNDEF(in nsIDOMWindow window, in DOMString sessionToken); michael@0: nsIDOMDOMRequest writeNDEF(in nsIDOMWindow window, in nsIVariant records, in DOMString sessionToken); michael@0: nsIDOMDOMRequest makeReadOnlyNDEF(in nsIDOMWindow window, in DOMString sessionToken); michael@0: michael@0: nsIDOMDOMRequest connect(in nsIDOMWindow window, in unsigned long techType, in DOMString sessionToken); michael@0: nsIDOMDOMRequest close(in nsIDOMWindow window, in DOMString sessionToken); michael@0: michael@0: /** michael@0: * Initiate Send file operation michael@0: * michael@0: * @param window michael@0: * Current window michael@0: * michael@0: * @param blob michael@0: * Raw data of the file to be sent. This object represents a file-like michael@0: * (nsIDOMFile) object of immutable, raw data. The blob data needs michael@0: * to be 'object wrapped' before calling this interface. michael@0: * michael@0: * @param sessionToken michael@0: * Current token michael@0: * michael@0: * Returns DOMRequest, if initiation of send file operation is successful michael@0: * then 'onsuccess' is called else 'onerror' michael@0: */ michael@0: nsIDOMDOMRequest sendFile(in nsIDOMWindow window, michael@0: in jsval blob, michael@0: in DOMString sessionToken); michael@0: michael@0: /** michael@0: * Register the given application id with Chrome process michael@0: * michael@0: * @param window michael@0: * Current window michael@0: * michael@0: * @param appId michael@0: * Application ID to be registered michael@0: * michael@0: * @param event michael@0: * Event to be registered. Either NFC_EVENT_PEER_READY or NFC_EVENT_PEER_LOST michael@0: * michael@0: * @param callback michael@0: * Callback that is used to notify upper layers whenever PeerEvents happen. michael@0: */ michael@0: void registerTargetForPeerEvent(in nsIDOMWindow window, michael@0: in unsigned long appId, michael@0: in octet event, michael@0: in nsINfcPeerCallback callback); michael@0: /** michael@0: * Unregister the given application id with Chrome process michael@0: * michael@0: * @param window michael@0: * Current window michael@0: * michael@0: * @param appId michael@0: * Application ID to be registered michael@0: * michael@0: * @param event michael@0: * Event to be unregistered. Either NFC_EVENT_PEER_READY or NFC_EVENT_PEER_LOST michael@0: */ michael@0: void unregisterTargetForPeerEvent(in nsIDOMWindow window, michael@0: in unsigned long appId, michael@0: in octet event); michael@0: /** michael@0: * Checks if the given application's id is a registered peer target (with the Chrome process) michael@0: * michael@0: * @param window michael@0: * Current window michael@0: * michael@0: * @param appId michael@0: * Application ID to be updated with Chrome process michael@0: * michael@0: * Returns DOMRequest, if appId is registered then 'onsuccess' is called else 'onerror' michael@0: */ michael@0: nsIDOMDOMRequest checkP2PRegistration(in nsIDOMWindow window, in unsigned long appId); michael@0: michael@0: /** michael@0: * Notify the Chrome process that user has accepted to share nfc message on P2P UI michael@0: * michael@0: * @param window michael@0: * Current window michael@0: * michael@0: * @param appId michael@0: * Application ID that is capable of handling NFC_EVENT_PEER_READY event michael@0: */ michael@0: void notifyUserAcceptedP2P(in nsIDOMWindow window, in unsigned long appId); michael@0: michael@0: /** michael@0: * Notify the status of sendFile operation to Chrome process michael@0: * michael@0: * @param window michael@0: * Current window michael@0: * michael@0: * @param status michael@0: * Status of sendFile operation michael@0: * (GECKO_NFC_ERROR_SUCCESS, GECKO_NFC_ERROR_GENERIC_FAILURE) michael@0: * michael@0: * @param requestId michael@0: * Request ID of SendFile DOM Request michael@0: */ michael@0: void notifySendFileStatus(in nsIDOMWindow window, michael@0: in octet status, michael@0: in DOMString requestId); michael@0: michael@0: /** michael@0: * Power on the NFC hardware and start polling for NFC tags or devices. michael@0: */ michael@0: nsIDOMDOMRequest startPoll(in nsIDOMWindow window); michael@0: michael@0: /** michael@0: * Stop polling for NFC tags or devices. i.e. enter low power mode. michael@0: */ michael@0: nsIDOMDOMRequest stopPoll(in nsIDOMWindow window); michael@0: michael@0: /** michael@0: * Power off the NFC hardware. michael@0: */ michael@0: nsIDOMDOMRequest powerOff(in nsIDOMWindow window); michael@0: };