Bug 1110059 - IDL for NFC system message. r=dimi

From 774da50e697c2d194146d1f0ff748aa6f31fe8dc Mon Sep 17 00:00:00 2001
---
 dom/nfc/gonk/Nfc.js                  | 36 ++++++++++++++++++++++++++++++++++--
 dom/nfc/gonk/nsINfcSystemMessage.idl | 25 +++++++++++++++++++++++++
 dom/nfc/moz.build                    |  1 +
 3 files changed, 60 insertions(+), 2 deletions(-)
 create mode 100644 dom/nfc/gonk/nsINfcSystemMessage.idl
This commit is contained in:
Yoshi Huang 2014-12-11 18:53:27 +08:00
parent ec3496b87c
commit d4a7bc83e9
3 changed files with 60 additions and 2 deletions

View File

@ -476,7 +476,10 @@ Nfc.prototype = {
gMessageManager.onTagFound(message);
}
gSystemMessenger.broadcastMessage("nfc-manager-tech-discovered", message);
let sysMsg = new NfcTechDiscoveredSysMsg(message.sessionToken,
message.isP2P,
message.records);
gSystemMessenger.broadcastMessage("nfc-manager-tech-discovered", sysMsg);
break;
case "TechLostNotification":
message.type = "techLost";
@ -581,8 +584,11 @@ Nfc.prototype = {
// the data to alternate carrier's (BT / WiFi) 'sendFile' interface.
// Notify system app to initiate BT send file operation
let sysMsg = new NfcSendFileSysMsg(message.data.requestId,
message.data.sessionToken,
message.data.blob);
gSystemMessenger.broadcastMessage("nfc-manager-send-file",
message.data);
sysMsg);
break;
case "NFC:QueryInfo":
return {rfState: this.rfState};
@ -630,6 +636,32 @@ Nfc.prototype = {
}
};
function NfcTechDiscoveredSysMsg(sessionToken, isP2P, records) {
this.sessionToken = sessionToken;
this.isP2P = isP2P;
this.records = records;
}
NfcTechDiscoveredSysMsg.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsINfcTechDiscoveredSysMsg]),
sessionToken: null,
isP2P: null,
records: null
};
function NfcSendFileSysMsg(requestId, sessionToken, blob) {
this.requestId = requestId;
this.sessionToken = sessionToken;
this.blob = blob;
}
NfcSendFileSysMsg.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsINfcSendFileSysMsg]),
requestId: null,
sessionToken: null,
blob: null
};
if (NFC_ENABLED) {
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([Nfc]);
}

View File

@ -0,0 +1,25 @@
/* 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/. */
#include "nsISupports.idl"
interface nsIDOMBlob ;
interface nsIVariant;
[scriptable, uuid(ff0b1622-0e79-4d97-8153-6244a2410eee)]
interface nsINfcTechDiscoveredSysMsg : nsISupports
{
readonly attribute DOMString sessionToken;
readonly attribute boolean isP2P;
readonly attribute nsIVariant records;
};
[scriptable, uuid(31c334f5-f072-451f-9405-19d0ac7ae7d1)]
interface nsINfcSendFileSysMsg : nsISupports
{
readonly attribute DOMString requestId;
readonly attribute DOMString sessionToken;
readonly attribute nsIDOMBlob blob;
};

View File

@ -30,6 +30,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_NFC']:
]
XPIDL_SOURCES += [
'gonk/nsINfcService.idl',
'gonk/nsINfcSystemMessage.idl',
]
EXTRA_COMPONENTS += [
'gonk/Nfc.js',