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