Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #include "nsISupports.idl" |
michael@0 | 6 | #include "nsIDOMDOMRequest.idl" |
michael@0 | 7 | |
michael@0 | 8 | interface nsIVariant; |
michael@0 | 9 | |
michael@0 | 10 | [scriptable, function, uuid(26673d1a-4af4-470a-ba96-f1f54b1f2052)] |
michael@0 | 11 | interface nsINfcPeerCallback : nsISupports |
michael@0 | 12 | { |
michael@0 | 13 | /** |
michael@0 | 14 | * Callback function used to notify NFC peer events. |
michael@0 | 15 | * |
michael@0 | 16 | * @param event |
michael@0 | 17 | * An event indicating 'PeerReady' or 'PeerLost' |
michael@0 | 18 | * One of NFC_EVENT_PEER_XXXX |
michael@0 | 19 | * |
michael@0 | 20 | * @param sessionToken |
michael@0 | 21 | * SessionToken received from Chrome process |
michael@0 | 22 | */ |
michael@0 | 23 | void peerNotification(in unsigned long event, |
michael@0 | 24 | in DOMString sessionToken); |
michael@0 | 25 | }; |
michael@0 | 26 | |
michael@0 | 27 | [scriptable, uuid(10b2eb1b-3fe0-4c98-9c67-9e4c2274cd78)] |
michael@0 | 28 | interface nsINfcContentHelper : nsISupports |
michael@0 | 29 | { |
michael@0 | 30 | const long NFC_EVENT_PEER_READY = 0x01; |
michael@0 | 31 | const long NFC_EVENT_PEER_LOST = 0x02; |
michael@0 | 32 | |
michael@0 | 33 | void setSessionToken(in DOMString sessionToken); |
michael@0 | 34 | |
michael@0 | 35 | nsIDOMDOMRequest getDetailsNDEF(in nsIDOMWindow window, in DOMString sessionToken); |
michael@0 | 36 | nsIDOMDOMRequest readNDEF(in nsIDOMWindow window, in DOMString sessionToken); |
michael@0 | 37 | nsIDOMDOMRequest writeNDEF(in nsIDOMWindow window, in nsIVariant records, in DOMString sessionToken); |
michael@0 | 38 | nsIDOMDOMRequest makeReadOnlyNDEF(in nsIDOMWindow window, in DOMString sessionToken); |
michael@0 | 39 | |
michael@0 | 40 | nsIDOMDOMRequest connect(in nsIDOMWindow window, in unsigned long techType, in DOMString sessionToken); |
michael@0 | 41 | nsIDOMDOMRequest close(in nsIDOMWindow window, in DOMString sessionToken); |
michael@0 | 42 | |
michael@0 | 43 | /** |
michael@0 | 44 | * Initiate Send file operation |
michael@0 | 45 | * |
michael@0 | 46 | * @param window |
michael@0 | 47 | * Current window |
michael@0 | 48 | * |
michael@0 | 49 | * @param blob |
michael@0 | 50 | * Raw data of the file to be sent. This object represents a file-like |
michael@0 | 51 | * (nsIDOMFile) object of immutable, raw data. The blob data needs |
michael@0 | 52 | * to be 'object wrapped' before calling this interface. |
michael@0 | 53 | * |
michael@0 | 54 | * @param sessionToken |
michael@0 | 55 | * Current token |
michael@0 | 56 | * |
michael@0 | 57 | * Returns DOMRequest, if initiation of send file operation is successful |
michael@0 | 58 | * then 'onsuccess' is called else 'onerror' |
michael@0 | 59 | */ |
michael@0 | 60 | nsIDOMDOMRequest sendFile(in nsIDOMWindow window, |
michael@0 | 61 | in jsval blob, |
michael@0 | 62 | in DOMString sessionToken); |
michael@0 | 63 | |
michael@0 | 64 | /** |
michael@0 | 65 | * Register the given application id with Chrome process |
michael@0 | 66 | * |
michael@0 | 67 | * @param window |
michael@0 | 68 | * Current window |
michael@0 | 69 | * |
michael@0 | 70 | * @param appId |
michael@0 | 71 | * Application ID to be registered |
michael@0 | 72 | * |
michael@0 | 73 | * @param event |
michael@0 | 74 | * Event to be registered. Either NFC_EVENT_PEER_READY or NFC_EVENT_PEER_LOST |
michael@0 | 75 | * |
michael@0 | 76 | * @param callback |
michael@0 | 77 | * Callback that is used to notify upper layers whenever PeerEvents happen. |
michael@0 | 78 | */ |
michael@0 | 79 | void registerTargetForPeerEvent(in nsIDOMWindow window, |
michael@0 | 80 | in unsigned long appId, |
michael@0 | 81 | in octet event, |
michael@0 | 82 | in nsINfcPeerCallback callback); |
michael@0 | 83 | /** |
michael@0 | 84 | * Unregister the given application id with Chrome process |
michael@0 | 85 | * |
michael@0 | 86 | * @param window |
michael@0 | 87 | * Current window |
michael@0 | 88 | * |
michael@0 | 89 | * @param appId |
michael@0 | 90 | * Application ID to be registered |
michael@0 | 91 | * |
michael@0 | 92 | * @param event |
michael@0 | 93 | * Event to be unregistered. Either NFC_EVENT_PEER_READY or NFC_EVENT_PEER_LOST |
michael@0 | 94 | */ |
michael@0 | 95 | void unregisterTargetForPeerEvent(in nsIDOMWindow window, |
michael@0 | 96 | in unsigned long appId, |
michael@0 | 97 | in octet event); |
michael@0 | 98 | /** |
michael@0 | 99 | * Checks if the given application's id is a registered peer target (with the Chrome process) |
michael@0 | 100 | * |
michael@0 | 101 | * @param window |
michael@0 | 102 | * Current window |
michael@0 | 103 | * |
michael@0 | 104 | * @param appId |
michael@0 | 105 | * Application ID to be updated with Chrome process |
michael@0 | 106 | * |
michael@0 | 107 | * Returns DOMRequest, if appId is registered then 'onsuccess' is called else 'onerror' |
michael@0 | 108 | */ |
michael@0 | 109 | nsIDOMDOMRequest checkP2PRegistration(in nsIDOMWindow window, in unsigned long appId); |
michael@0 | 110 | |
michael@0 | 111 | /** |
michael@0 | 112 | * Notify the Chrome process that user has accepted to share nfc message on P2P UI |
michael@0 | 113 | * |
michael@0 | 114 | * @param window |
michael@0 | 115 | * Current window |
michael@0 | 116 | * |
michael@0 | 117 | * @param appId |
michael@0 | 118 | * Application ID that is capable of handling NFC_EVENT_PEER_READY event |
michael@0 | 119 | */ |
michael@0 | 120 | void notifyUserAcceptedP2P(in nsIDOMWindow window, in unsigned long appId); |
michael@0 | 121 | |
michael@0 | 122 | /** |
michael@0 | 123 | * Notify the status of sendFile operation to Chrome process |
michael@0 | 124 | * |
michael@0 | 125 | * @param window |
michael@0 | 126 | * Current window |
michael@0 | 127 | * |
michael@0 | 128 | * @param status |
michael@0 | 129 | * Status of sendFile operation |
michael@0 | 130 | * (GECKO_NFC_ERROR_SUCCESS, GECKO_NFC_ERROR_GENERIC_FAILURE) |
michael@0 | 131 | * |
michael@0 | 132 | * @param requestId |
michael@0 | 133 | * Request ID of SendFile DOM Request |
michael@0 | 134 | */ |
michael@0 | 135 | void notifySendFileStatus(in nsIDOMWindow window, |
michael@0 | 136 | in octet status, |
michael@0 | 137 | in DOMString requestId); |
michael@0 | 138 | |
michael@0 | 139 | /** |
michael@0 | 140 | * Power on the NFC hardware and start polling for NFC tags or devices. |
michael@0 | 141 | */ |
michael@0 | 142 | nsIDOMDOMRequest startPoll(in nsIDOMWindow window); |
michael@0 | 143 | |
michael@0 | 144 | /** |
michael@0 | 145 | * Stop polling for NFC tags or devices. i.e. enter low power mode. |
michael@0 | 146 | */ |
michael@0 | 147 | nsIDOMDOMRequest stopPoll(in nsIDOMWindow window); |
michael@0 | 148 | |
michael@0 | 149 | /** |
michael@0 | 150 | * Power off the NFC hardware. |
michael@0 | 151 | */ |
michael@0 | 152 | nsIDOMDOMRequest powerOff(in nsIDOMWindow window); |
michael@0 | 153 | }; |