1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/system/gonk/nsINfcContentHelper.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,153 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#include "nsISupports.idl" 1.9 +#include "nsIDOMDOMRequest.idl" 1.10 + 1.11 +interface nsIVariant; 1.12 + 1.13 +[scriptable, function, uuid(26673d1a-4af4-470a-ba96-f1f54b1f2052)] 1.14 +interface nsINfcPeerCallback : nsISupports 1.15 +{ 1.16 + /** 1.17 + * Callback function used to notify NFC peer events. 1.18 + * 1.19 + * @param event 1.20 + * An event indicating 'PeerReady' or 'PeerLost' 1.21 + * One of NFC_EVENT_PEER_XXXX 1.22 + * 1.23 + * @param sessionToken 1.24 + * SessionToken received from Chrome process 1.25 + */ 1.26 + void peerNotification(in unsigned long event, 1.27 + in DOMString sessionToken); 1.28 +}; 1.29 + 1.30 +[scriptable, uuid(10b2eb1b-3fe0-4c98-9c67-9e4c2274cd78)] 1.31 +interface nsINfcContentHelper : nsISupports 1.32 +{ 1.33 + const long NFC_EVENT_PEER_READY = 0x01; 1.34 + const long NFC_EVENT_PEER_LOST = 0x02; 1.35 + 1.36 + void setSessionToken(in DOMString sessionToken); 1.37 + 1.38 + nsIDOMDOMRequest getDetailsNDEF(in nsIDOMWindow window, in DOMString sessionToken); 1.39 + nsIDOMDOMRequest readNDEF(in nsIDOMWindow window, in DOMString sessionToken); 1.40 + nsIDOMDOMRequest writeNDEF(in nsIDOMWindow window, in nsIVariant records, in DOMString sessionToken); 1.41 + nsIDOMDOMRequest makeReadOnlyNDEF(in nsIDOMWindow window, in DOMString sessionToken); 1.42 + 1.43 + nsIDOMDOMRequest connect(in nsIDOMWindow window, in unsigned long techType, in DOMString sessionToken); 1.44 + nsIDOMDOMRequest close(in nsIDOMWindow window, in DOMString sessionToken); 1.45 + 1.46 + /** 1.47 + * Initiate Send file operation 1.48 + * 1.49 + * @param window 1.50 + * Current window 1.51 + * 1.52 + * @param blob 1.53 + * Raw data of the file to be sent. This object represents a file-like 1.54 + * (nsIDOMFile) object of immutable, raw data. The blob data needs 1.55 + * to be 'object wrapped' before calling this interface. 1.56 + * 1.57 + * @param sessionToken 1.58 + * Current token 1.59 + * 1.60 + * Returns DOMRequest, if initiation of send file operation is successful 1.61 + * then 'onsuccess' is called else 'onerror' 1.62 + */ 1.63 + nsIDOMDOMRequest sendFile(in nsIDOMWindow window, 1.64 + in jsval blob, 1.65 + in DOMString sessionToken); 1.66 + 1.67 + /** 1.68 + * Register the given application id with Chrome process 1.69 + * 1.70 + * @param window 1.71 + * Current window 1.72 + * 1.73 + * @param appId 1.74 + * Application ID to be registered 1.75 + * 1.76 + * @param event 1.77 + * Event to be registered. Either NFC_EVENT_PEER_READY or NFC_EVENT_PEER_LOST 1.78 + * 1.79 + * @param callback 1.80 + * Callback that is used to notify upper layers whenever PeerEvents happen. 1.81 + */ 1.82 + void registerTargetForPeerEvent(in nsIDOMWindow window, 1.83 + in unsigned long appId, 1.84 + in octet event, 1.85 + in nsINfcPeerCallback callback); 1.86 + /** 1.87 + * Unregister the given application id with Chrome process 1.88 + * 1.89 + * @param window 1.90 + * Current window 1.91 + * 1.92 + * @param appId 1.93 + * Application ID to be registered 1.94 + * 1.95 + * @param event 1.96 + * Event to be unregistered. Either NFC_EVENT_PEER_READY or NFC_EVENT_PEER_LOST 1.97 + */ 1.98 + void unregisterTargetForPeerEvent(in nsIDOMWindow window, 1.99 + in unsigned long appId, 1.100 + in octet event); 1.101 + /** 1.102 + * Checks if the given application's id is a registered peer target (with the Chrome process) 1.103 + * 1.104 + * @param window 1.105 + * Current window 1.106 + * 1.107 + * @param appId 1.108 + * Application ID to be updated with Chrome process 1.109 + * 1.110 + * Returns DOMRequest, if appId is registered then 'onsuccess' is called else 'onerror' 1.111 + */ 1.112 + nsIDOMDOMRequest checkP2PRegistration(in nsIDOMWindow window, in unsigned long appId); 1.113 + 1.114 + /** 1.115 + * Notify the Chrome process that user has accepted to share nfc message on P2P UI 1.116 + * 1.117 + * @param window 1.118 + * Current window 1.119 + * 1.120 + * @param appId 1.121 + * Application ID that is capable of handling NFC_EVENT_PEER_READY event 1.122 + */ 1.123 + void notifyUserAcceptedP2P(in nsIDOMWindow window, in unsigned long appId); 1.124 + 1.125 + /** 1.126 + * Notify the status of sendFile operation to Chrome process 1.127 + * 1.128 + * @param window 1.129 + * Current window 1.130 + * 1.131 + * @param status 1.132 + * Status of sendFile operation 1.133 + * (GECKO_NFC_ERROR_SUCCESS, GECKO_NFC_ERROR_GENERIC_FAILURE) 1.134 + * 1.135 + * @param requestId 1.136 + * Request ID of SendFile DOM Request 1.137 + */ 1.138 + void notifySendFileStatus(in nsIDOMWindow window, 1.139 + in octet status, 1.140 + in DOMString requestId); 1.141 + 1.142 + /** 1.143 + * Power on the NFC hardware and start polling for NFC tags or devices. 1.144 + */ 1.145 + nsIDOMDOMRequest startPoll(in nsIDOMWindow window); 1.146 + 1.147 + /** 1.148 + * Stop polling for NFC tags or devices. i.e. enter low power mode. 1.149 + */ 1.150 + nsIDOMDOMRequest stopPoll(in nsIDOMWindow window); 1.151 + 1.152 + /** 1.153 + * Power off the NFC hardware. 1.154 + */ 1.155 + nsIDOMDOMRequest powerOff(in nsIDOMWindow window); 1.156 +};