2013-11-06 21:36:19 +04:00
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
/* Copyright © 2013 Deutsche Telekom, Inc. */
|
|
|
|
|
2014-11-03 14:38:33 +03:00
|
|
|
enum NfcErrorMessage {
|
|
|
|
"",
|
|
|
|
"IOError",
|
|
|
|
"Timeout",
|
|
|
|
"Busy",
|
|
|
|
"ErrorConnect",
|
|
|
|
"ErrorDisconnect",
|
|
|
|
"ErrorRead",
|
|
|
|
"ErrorWrite",
|
|
|
|
"InvalidParameter",
|
|
|
|
"InsufficientResource",
|
|
|
|
"ErrorSocketCreation",
|
|
|
|
"FailEnableDiscovery",
|
|
|
|
"FailDisableDiscovery",
|
|
|
|
"NotInitialize",
|
|
|
|
"InitializeFail",
|
|
|
|
"DeinitializeFail",
|
|
|
|
"NotSupport",
|
|
|
|
"FailEnableLowPowerMode",
|
|
|
|
"FailDisableLowPowerMode"
|
|
|
|
};
|
|
|
|
|
2014-08-30 05:41:20 +04:00
|
|
|
[NoInterfaceObject]
|
2014-04-29 07:50:25 +04:00
|
|
|
interface MozNFCManager {
|
2014-10-20 13:55:29 +04:00
|
|
|
/**
|
|
|
|
* API to check if the given application's manifest
|
|
|
|
* URL is registered with the Chrome Process or not.
|
|
|
|
*
|
|
|
|
* Returns success if given manifestUrl is registered for 'onpeerready',
|
|
|
|
* otherwise error
|
|
|
|
*/
|
2015-07-14 05:25:26 +03:00
|
|
|
[CheckAnyPermissions="nfc-manager", AvailableIn=CertifiedApps]
|
2014-11-21 12:54:04 +03:00
|
|
|
Promise<boolean> checkP2PRegistration(DOMString manifestUrl);
|
2014-01-18 06:38:26 +04:00
|
|
|
|
2014-10-20 13:55:29 +04:00
|
|
|
/**
|
|
|
|
* Notify that user has accepted to share nfc message on P2P UI
|
|
|
|
*/
|
2015-07-14 05:25:26 +03:00
|
|
|
[CheckAnyPermissions="nfc-manager", AvailableIn=CertifiedApps]
|
2014-10-20 13:55:29 +04:00
|
|
|
void notifyUserAcceptedP2P(DOMString manifestUrl);
|
2014-01-18 06:38:26 +04:00
|
|
|
|
2014-10-20 13:55:29 +04:00
|
|
|
/**
|
|
|
|
* Notify the status of sendFile operation
|
|
|
|
*/
|
2015-07-14 05:25:26 +03:00
|
|
|
[CheckAnyPermissions="nfc-manager", AvailableIn=CertifiedApps]
|
2014-10-20 13:55:29 +04:00
|
|
|
void notifySendFileStatus(octet status, DOMString requestId);
|
2014-04-15 07:52:27 +04:00
|
|
|
|
2014-10-20 13:55:29 +04:00
|
|
|
/**
|
|
|
|
* Power on the NFC hardware and start polling for NFC tags or devices.
|
|
|
|
*/
|
2015-07-14 05:25:26 +03:00
|
|
|
[CheckAnyPermissions="nfc-manager", AvailableIn=CertifiedApps]
|
2014-11-21 12:54:04 +03:00
|
|
|
Promise<void> startPoll();
|
2014-04-15 07:52:27 +04:00
|
|
|
|
2014-10-20 13:55:29 +04:00
|
|
|
/**
|
|
|
|
* Stop polling for NFC tags or devices. i.e. enter low power mode.
|
|
|
|
*/
|
2015-07-14 05:25:26 +03:00
|
|
|
[CheckAnyPermissions="nfc-manager", AvailableIn=CertifiedApps]
|
2014-11-21 12:54:04 +03:00
|
|
|
Promise<void> stopPoll();
|
2014-04-15 07:52:27 +04:00
|
|
|
|
2014-10-20 13:55:29 +04:00
|
|
|
/**
|
|
|
|
* Power off the NFC hardware.
|
|
|
|
*/
|
2015-07-14 05:25:26 +03:00
|
|
|
[CheckAnyPermissions="nfc-manager", AvailableIn=CertifiedApps]
|
2014-11-21 12:54:04 +03:00
|
|
|
Promise<void> powerOff();
|
2014-01-16 05:47:43 +04:00
|
|
|
};
|
|
|
|
|
2014-12-26 15:57:11 +03:00
|
|
|
[JSImplementation="@mozilla.org/nfc/manager;1",
|
2014-01-16 05:47:43 +04:00
|
|
|
NavigatorProperty="mozNfc",
|
2014-08-19 14:43:57 +04:00
|
|
|
Func="Navigator::HasNFCSupport",
|
2015-07-14 05:25:26 +03:00
|
|
|
CheckAnyPermissions="nfc nfc-share",
|
2015-01-05 21:50:32 +03:00
|
|
|
AvailableIn="PrivilegedApps",
|
|
|
|
UnsafeInPrerendering]
|
2014-04-29 07:50:25 +04:00
|
|
|
interface MozNFC : EventTarget {
|
2014-12-12 10:13:40 +03:00
|
|
|
/**
|
|
|
|
* Indicate if NFC is enabled.
|
|
|
|
*/
|
|
|
|
readonly attribute boolean enabled;
|
|
|
|
|
2014-10-20 13:55:29 +04:00
|
|
|
/**
|
|
|
|
* This event will be fired when another NFCPeer is detected, and user confirms
|
|
|
|
* to share data to the NFCPeer object by calling mozNFC.notifyUserAcceptedP2P.
|
|
|
|
* The event will be type of NFCPeerEvent.
|
|
|
|
*/
|
2015-07-14 05:25:26 +03:00
|
|
|
[CheckAnyPermissions="nfc-share", AvailableIn=CertifiedApps]
|
2014-10-20 13:55:29 +04:00
|
|
|
attribute EventHandler onpeerready;
|
2014-10-30 09:08:00 +03:00
|
|
|
|
|
|
|
/**
|
2014-12-11 12:42:35 +03:00
|
|
|
* This event will be fired when a NFCPeer is detected. The application has to
|
|
|
|
* be running on the foreground (decided by System app) to receive this event.
|
|
|
|
*
|
|
|
|
* The default action of this event is to dispatch the event in System app
|
|
|
|
* again, and System app will run the default UX behavior (like vibration).
|
|
|
|
* So if the application would like to cancel the event, the application
|
|
|
|
* should call event.preventDefault() or return false in this event handler.
|
2014-10-30 09:08:00 +03:00
|
|
|
*/
|
|
|
|
attribute EventHandler onpeerfound;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This event will be fired when NFCPeer, earlier detected in onpeerready
|
2015-01-28 06:25:35 +03:00
|
|
|
* or onpeerfound, moves out of range, or if the application has been switched
|
|
|
|
* to the background (decided by System app).
|
2014-10-30 09:08:00 +03:00
|
|
|
*/
|
2014-10-20 13:55:29 +04:00
|
|
|
attribute EventHandler onpeerlost;
|
2014-10-20 13:53:39 +04:00
|
|
|
|
|
|
|
/**
|
2014-12-11 12:42:35 +03:00
|
|
|
* This event will be fired when a NFCTag is detected. The application has to
|
|
|
|
* be running on the foreground (decided by System app) to receive this event.
|
|
|
|
*
|
|
|
|
* The default action of this event is to dispatch the event in System app
|
|
|
|
* again, and System app will run the default UX behavior (like vibration) and
|
|
|
|
* launch MozActivity to handle the content of the tag. (For example, System
|
|
|
|
* app will launch Browser if the tag contains URL). So if the application
|
|
|
|
* would like to cancel the event, i.e. in the above example, the application
|
|
|
|
* would process the URL by itself without launching Browser, the application
|
|
|
|
* should call event.preventDefault() or return false in this event handler.
|
2014-10-20 13:53:39 +04:00
|
|
|
*/
|
|
|
|
attribute EventHandler ontagfound;
|
|
|
|
|
|
|
|
/**
|
2015-01-28 06:25:35 +03:00
|
|
|
* This event will be fired if the tag detected in ontagfound has been
|
|
|
|
* removed, or if the application has been switched to the background (decided
|
|
|
|
* by System app).
|
2014-10-20 13:53:39 +04:00
|
|
|
*/
|
|
|
|
attribute EventHandler ontaglost;
|
2014-01-16 05:47:43 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
// Mozilla Only
|
2014-04-29 07:50:25 +04:00
|
|
|
partial interface MozNFC {
|
2014-10-20 13:55:29 +04:00
|
|
|
[ChromeOnly]
|
|
|
|
void eventListenerWasAdded(DOMString aType);
|
|
|
|
[ChromeOnly]
|
|
|
|
void eventListenerWasRemoved(DOMString aType);
|
2013-11-06 21:36:19 +04:00
|
|
|
};
|
2014-01-16 05:47:43 +04:00
|
|
|
|
2014-04-29 07:50:25 +04:00
|
|
|
MozNFC implements MozNFCManager;
|