2013-11-05 22:18:56 +00:00
|
|
|
/* Copyright 2012 Mozilla Foundation and Mozilla contributors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Copyright © 2013, Deutsche Telekom, Inc. */
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
|
|
|
|
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
|
|
|
Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
|
|
|
|
|
2014-05-07 22:53:16 +00:00
|
|
|
XPCOMUtils.defineLazyGetter(this, "NFC", function () {
|
|
|
|
let obj = {};
|
|
|
|
Cu.import("resource://gre/modules/nfc_consts.js", obj);
|
|
|
|
return obj;
|
|
|
|
});
|
2013-11-05 22:18:56 +00:00
|
|
|
|
2013-12-11 06:04:27 +00:00
|
|
|
Cu.import("resource://gre/modules/systemlibs.js");
|
|
|
|
const NFC_ENABLED = libcutils.property_get("ro.moz.nfc.enabled", "false") === "true";
|
|
|
|
|
2013-11-05 22:18:56 +00:00
|
|
|
// set to true to in nfc_consts.js to see debug messages
|
|
|
|
let DEBUG = NFC.DEBUG_CONTENT_HELPER;
|
|
|
|
|
|
|
|
let debug;
|
2014-10-14 08:37:50 +00:00
|
|
|
function updateDebug() {
|
2014-11-24 02:10:32 +00:00
|
|
|
if (DEBUG || NFC.DEBUG_CONTENT_HELPER) {
|
2014-10-14 08:37:50 +00:00
|
|
|
debug = function (s) {
|
|
|
|
dump("-*- NfcContentHelper: " + s + "\n");
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
debug = function (s) {};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
updateDebug();
|
2013-11-05 22:18:56 +00:00
|
|
|
|
|
|
|
const NFCCONTENTHELPER_CID =
|
|
|
|
Components.ID("{4d72c120-da5f-11e1-9b23-0800200c9a66}");
|
|
|
|
|
|
|
|
const NFC_IPC_MSG_NAMES = [
|
|
|
|
"NFC:ReadNDEFResponse",
|
|
|
|
"NFC:WriteNDEFResponse",
|
2014-10-31 06:51:41 +00:00
|
|
|
"NFC:MakeReadOnlyResponse",
|
2014-11-18 01:52:39 +00:00
|
|
|
"NFC:FormatResponse",
|
2013-11-05 22:18:56 +00:00
|
|
|
"NFC:ConnectResponse",
|
2013-12-03 21:22:21 +00:00
|
|
|
"NFC:CloseResponse",
|
|
|
|
"NFC:CheckP2PRegistrationResponse",
|
2014-09-24 06:52:04 +00:00
|
|
|
"NFC:DOMEvent",
|
2014-01-15 23:42:49 +00:00
|
|
|
"NFC:NotifySendFileStatusResponse",
|
2014-11-12 02:13:33 +00:00
|
|
|
"NFC:ChangeRFStateResponse"
|
2013-11-05 22:18:56 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
|
|
|
"@mozilla.org/childprocessmessagemanager;1",
|
|
|
|
"nsISyncMessageSender");
|
|
|
|
|
|
|
|
function NfcContentHelper() {
|
2014-10-14 08:37:50 +00:00
|
|
|
Services.obs.addObserver(this, NFC.TOPIC_MOZSETTINGS_CHANGED, false);
|
2013-11-05 22:18:56 +00:00
|
|
|
Services.obs.addObserver(this, "xpcom-shutdown", false);
|
|
|
|
|
|
|
|
this._requestMap = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
NfcContentHelper.prototype = {
|
|
|
|
__proto__: DOMRequestIpcHelper.prototype,
|
|
|
|
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsINfcContentHelper,
|
|
|
|
Ci.nsISupportsWeakReference,
|
|
|
|
Ci.nsIObserver]),
|
|
|
|
classID: NFCCONTENTHELPER_CID,
|
|
|
|
classInfo: XPCOMUtils.generateCI({
|
|
|
|
classID: NFCCONTENTHELPER_CID,
|
|
|
|
classDescription: "NfcContentHelper",
|
|
|
|
interfaces: [Ci.nsINfcContentHelper]
|
|
|
|
}),
|
|
|
|
|
2014-10-30 10:46:41 +00:00
|
|
|
_window: null,
|
2013-11-05 22:18:56 +00:00
|
|
|
_requestMap: null,
|
2014-11-25 07:10:34 +00:00
|
|
|
_rfState: null,
|
2014-11-12 02:26:09 +00:00
|
|
|
eventListener: null,
|
2013-11-05 22:18:56 +00:00
|
|
|
|
2014-10-14 08:37:50 +00:00
|
|
|
init: function init(aWindow) {
|
2014-10-30 10:46:41 +00:00
|
|
|
if (aWindow == null) {
|
|
|
|
throw Components.Exception("Can't get window object",
|
|
|
|
Cr.NS_ERROR_UNEXPECTED);
|
|
|
|
}
|
|
|
|
this._window = aWindow;
|
|
|
|
this.initDOMRequestHelper(this._window, NFC_IPC_MSG_NAMES);
|
|
|
|
|
2014-11-24 02:10:32 +00:00
|
|
|
if (!NFC.DEBUG_CONTENT_HELPER && this._window.navigator.mozSettings) {
|
2014-10-30 10:46:41 +00:00
|
|
|
let lock = this._window.navigator.mozSettings.createLock();
|
2014-10-14 08:37:50 +00:00
|
|
|
var nfcDebug = lock.get(NFC.SETTING_NFC_DEBUG);
|
|
|
|
nfcDebug.onsuccess = function _nfcDebug() {
|
|
|
|
DEBUG = nfcDebug.result[NFC.SETTING_NFC_DEBUG];
|
|
|
|
updateDebug();
|
|
|
|
};
|
|
|
|
}
|
2014-11-25 07:10:34 +00:00
|
|
|
|
|
|
|
let info = cpmm.sendSyncMessage("NFC:QueryInfo")[0];
|
|
|
|
this._rfState = info.rfState;
|
|
|
|
},
|
|
|
|
|
|
|
|
queryRFState: function queryRFState() {
|
|
|
|
return this._rfState;
|
2014-10-14 08:37:50 +00:00
|
|
|
},
|
|
|
|
|
2014-01-29 00:20:17 +00:00
|
|
|
encodeNDEFRecords: function encodeNDEFRecords(records) {
|
2013-11-05 22:18:56 +00:00
|
|
|
let encodedRecords = [];
|
|
|
|
for (let i = 0; i < records.length; i++) {
|
|
|
|
let record = records[i];
|
|
|
|
encodedRecords.push({
|
|
|
|
tnf: record.tnf,
|
2014-08-18 09:31:18 +00:00
|
|
|
type: record.type || undefined,
|
|
|
|
id: record.id || undefined,
|
|
|
|
payload: record.payload || undefined,
|
2013-11-05 22:18:56 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
return encodedRecords;
|
|
|
|
},
|
|
|
|
|
|
|
|
// NFCTag interface
|
2014-11-21 09:54:04 +00:00
|
|
|
readNDEF: function readNDEF(sessionToken, callback) {
|
|
|
|
let requestId = callback.getCallbackId();
|
|
|
|
this._requestMap[requestId] = callback;
|
2013-11-05 22:18:56 +00:00
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("NFC:ReadNDEF", {
|
|
|
|
requestId: requestId,
|
|
|
|
sessionToken: sessionToken
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-11-21 09:54:04 +00:00
|
|
|
writeNDEF: function writeNDEF(records, sessionToken, callback) {
|
|
|
|
let requestId = callback.getCallbackId();
|
|
|
|
this._requestMap[requestId] = callback;
|
2013-11-05 22:18:56 +00:00
|
|
|
|
2014-01-29 00:20:17 +00:00
|
|
|
let encodedRecords = this.encodeNDEFRecords(records);
|
2013-11-05 22:18:56 +00:00
|
|
|
cpmm.sendAsyncMessage("NFC:WriteNDEF", {
|
|
|
|
requestId: requestId,
|
|
|
|
sessionToken: sessionToken,
|
|
|
|
records: encodedRecords
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-11-21 09:54:04 +00:00
|
|
|
makeReadOnly: function makeReadOnly(sessionToken, callback) {
|
|
|
|
let requestId = callback.getCallbackId();
|
|
|
|
this._requestMap[requestId] = callback;
|
2013-11-05 22:18:56 +00:00
|
|
|
|
2014-10-31 06:51:41 +00:00
|
|
|
cpmm.sendAsyncMessage("NFC:MakeReadOnly", {
|
2013-11-05 22:18:56 +00:00
|
|
|
requestId: requestId,
|
|
|
|
sessionToken: sessionToken
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-11-21 09:54:04 +00:00
|
|
|
format: function format(sessionToken, callback) {
|
|
|
|
let requestId = callback.getCallbackId();
|
|
|
|
this._requestMap[requestId] = callback;
|
2014-11-18 01:52:39 +00:00
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("NFC:Format", {
|
|
|
|
requestId: requestId,
|
|
|
|
sessionToken: sessionToken
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-11-21 09:54:04 +00:00
|
|
|
connect: function connect(techType, sessionToken, callback) {
|
|
|
|
let requestId = callback.getCallbackId();
|
|
|
|
this._requestMap[requestId] = callback;
|
2013-11-05 22:18:56 +00:00
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("NFC:Connect", {
|
|
|
|
requestId: requestId,
|
|
|
|
sessionToken: sessionToken,
|
|
|
|
techType: techType
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-11-21 09:54:04 +00:00
|
|
|
close: function close(sessionToken, callback) {
|
|
|
|
let requestId = callback.getCallbackId();
|
|
|
|
this._requestMap[requestId] = callback;
|
2013-11-05 22:18:56 +00:00
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("NFC:Close", {
|
|
|
|
requestId: requestId,
|
|
|
|
sessionToken: sessionToken
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-11-21 09:54:04 +00:00
|
|
|
sendFile: function sendFile(data, sessionToken, callback) {
|
|
|
|
let requestId = callback.getCallbackId();
|
|
|
|
this._requestMap[requestId] = callback;
|
2013-12-14 08:57:11 +00:00
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("NFC:SendFile", {
|
|
|
|
requestId: requestId,
|
|
|
|
sessionToken: sessionToken,
|
|
|
|
blob: data.blob
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-10-30 10:46:41 +00:00
|
|
|
notifySendFileStatus: function notifySendFileStatus(status, requestId) {
|
2014-01-15 23:42:49 +00:00
|
|
|
cpmm.sendAsyncMessage("NFC:NotifySendFileStatus", {
|
|
|
|
status: status,
|
|
|
|
requestId: requestId
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-11-12 02:26:09 +00:00
|
|
|
addEventListener: function addEventListener(listener) {
|
|
|
|
this.eventListener = listener;
|
|
|
|
cpmm.sendAsyncMessage("NFC:AddEventListener");
|
2014-07-24 04:16:02 +00:00
|
|
|
},
|
|
|
|
|
2014-10-30 10:46:41 +00:00
|
|
|
registerTargetForPeerReady: function registerTargetForPeerReady(appId) {
|
2014-07-24 10:11:42 +00:00
|
|
|
cpmm.sendAsyncMessage("NFC:RegisterPeerReadyTarget", { appId: appId });
|
2013-12-03 21:22:21 +00:00
|
|
|
},
|
|
|
|
|
2014-10-30 10:46:41 +00:00
|
|
|
unregisterTargetForPeerReady: function unregisterTargetForPeerReady(appId) {
|
2014-07-24 10:11:42 +00:00
|
|
|
cpmm.sendAsyncMessage("NFC:UnregisterPeerReadyTarget", { appId: appId });
|
2013-12-03 21:22:21 +00:00
|
|
|
},
|
|
|
|
|
2014-11-21 09:54:04 +00:00
|
|
|
checkP2PRegistration: function checkP2PRegistration(appId, callback) {
|
|
|
|
let requestId = callback.getCallbackId();
|
|
|
|
this._requestMap[requestId] = callback;
|
2013-12-03 21:22:21 +00:00
|
|
|
|
|
|
|
cpmm.sendAsyncMessage("NFC:CheckP2PRegistration", {
|
|
|
|
appId: appId,
|
|
|
|
requestId: requestId
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-10-30 10:46:41 +00:00
|
|
|
notifyUserAcceptedP2P: function notifyUserAcceptedP2P(appId) {
|
2013-12-03 21:22:21 +00:00
|
|
|
cpmm.sendAsyncMessage("NFC:NotifyUserAcceptedP2P", {
|
|
|
|
appId: appId
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-11-21 09:54:04 +00:00
|
|
|
changeRFState: function changeRFState(rfState, callback) {
|
|
|
|
let requestId = callback.getCallbackId();
|
|
|
|
this._requestMap[requestId] = callback;
|
2014-04-15 06:47:42 +00:00
|
|
|
|
2014-11-12 02:13:33 +00:00
|
|
|
cpmm.sendAsyncMessage("NFC:ChangeRFState",
|
|
|
|
{requestId: requestId,
|
|
|
|
rfState: rfState});
|
2014-04-15 06:47:42 +00:00
|
|
|
},
|
|
|
|
|
2013-11-05 22:18:56 +00:00
|
|
|
// nsIObserver
|
|
|
|
observe: function observe(subject, topic, data) {
|
|
|
|
if (topic == "xpcom-shutdown") {
|
2014-04-24 03:14:58 +00:00
|
|
|
this.destroyDOMRequestHelper();
|
2014-10-14 08:37:50 +00:00
|
|
|
Services.obs.removeObserver(this, NFC.TOPIC_MOZSETTINGS_CHANGED);
|
2013-11-05 22:18:56 +00:00
|
|
|
Services.obs.removeObserver(this, "xpcom-shutdown");
|
|
|
|
cpmm = null;
|
2014-10-14 08:37:50 +00:00
|
|
|
} else if (topic == NFC.TOPIC_MOZSETTINGS_CHANGED) {
|
|
|
|
if ("wrappedJSObject" in subject) {
|
|
|
|
subject = subject.wrappedJSObject;
|
|
|
|
}
|
|
|
|
if (subject) {
|
|
|
|
this.handle(subject.key, subject.value);
|
|
|
|
}
|
2013-11-05 22:18:56 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// nsIMessageListener
|
|
|
|
receiveMessage: function receiveMessage(message) {
|
2014-09-05 04:21:00 +00:00
|
|
|
DEBUG && debug("Message received: " + JSON.stringify(message));
|
2014-02-20 10:13:40 +00:00
|
|
|
let result = message.json;
|
|
|
|
|
2013-11-05 22:18:56 +00:00
|
|
|
switch (message.name) {
|
|
|
|
case "NFC:ReadNDEFResponse":
|
2014-03-25 11:14:41 +00:00
|
|
|
this.handleReadNDEFResponse(result);
|
2014-02-20 10:13:40 +00:00
|
|
|
break;
|
2014-04-30 08:18:00 +00:00
|
|
|
case "NFC:CheckP2PRegistrationResponse":
|
|
|
|
this.handleCheckP2PRegistrationResponse(result);
|
|
|
|
break;
|
2013-11-05 22:18:56 +00:00
|
|
|
case "NFC:ConnectResponse": // Fall through.
|
|
|
|
case "NFC:CloseResponse":
|
|
|
|
case "NFC:WriteNDEFResponse":
|
2014-10-31 06:51:41 +00:00
|
|
|
case "NFC:MakeReadOnlyResponse":
|
2014-11-18 01:52:39 +00:00
|
|
|
case "NFC:FormatResponse":
|
2014-01-15 23:42:49 +00:00
|
|
|
case "NFC:NotifySendFileStatusResponse":
|
2014-11-12 02:13:33 +00:00
|
|
|
case "NFC:ChangeRFStateResponse":
|
2014-11-21 09:54:04 +00:00
|
|
|
this.handleGeneralResponse(result);
|
2013-11-05 22:18:56 +00:00
|
|
|
break;
|
2014-09-24 06:52:04 +00:00
|
|
|
case "NFC:DOMEvent":
|
2014-07-24 04:16:02 +00:00
|
|
|
switch (result.event) {
|
2014-10-20 09:53:39 +00:00
|
|
|
case NFC.PEER_EVENT_READY:
|
2014-11-12 02:26:09 +00:00
|
|
|
this.eventListener.notifyPeerFound(result.sessionToken, /* isPeerReady */ true);
|
2014-10-30 06:08:00 +00:00
|
|
|
break;
|
|
|
|
case NFC.PEER_EVENT_FOUND:
|
2014-11-12 02:26:09 +00:00
|
|
|
this.eventListener.notifyPeerFound(result.sessionToken);
|
2014-07-24 04:16:02 +00:00
|
|
|
break;
|
2014-10-20 09:53:39 +00:00
|
|
|
case NFC.PEER_EVENT_LOST:
|
2014-11-12 02:26:09 +00:00
|
|
|
this.eventListener.notifyPeerLost(result.sessionToken);
|
2014-07-24 04:16:02 +00:00
|
|
|
break;
|
2014-10-20 09:53:39 +00:00
|
|
|
case NFC.TAG_EVENT_FOUND:
|
2014-12-26 03:50:12 +00:00
|
|
|
let ndefInfo = null;
|
|
|
|
if (result.tagType !== undefined &&
|
|
|
|
result.maxNDEFSize !== undefined &&
|
|
|
|
result.isReadOnly !== undefined &&
|
|
|
|
result.isFormatable !== undefined) {
|
|
|
|
ndefInfo = new TagNDEFInfo(result.tagType,
|
|
|
|
result.maxNDEFSize,
|
|
|
|
result.isReadOnly,
|
|
|
|
result.isFormatable);
|
|
|
|
}
|
|
|
|
|
2014-12-26 08:07:45 +00:00
|
|
|
let tagInfo = new TagInfo(result.techList, result.tagId);
|
2014-12-26 03:50:12 +00:00
|
|
|
this.eventListener.notifyTagFound(result.sessionToken,
|
|
|
|
tagInfo,
|
|
|
|
ndefInfo,
|
|
|
|
result.records);
|
2014-10-20 09:53:39 +00:00
|
|
|
break;
|
|
|
|
case NFC.TAG_EVENT_LOST:
|
2014-11-12 02:26:09 +00:00
|
|
|
this.eventListener.notifyTagLost(result.sessionToken);
|
2014-10-20 09:53:39 +00:00
|
|
|
break;
|
2014-11-25 07:10:34 +00:00
|
|
|
case NFC.RF_EVENT_STATE_CHANGE:
|
|
|
|
this._rfState = result.rfState;
|
|
|
|
this.eventListener.notifyRFStateChange(this._rfState);
|
|
|
|
break;
|
2013-12-03 21:22:21 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-11-05 22:18:56 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-10-14 08:37:50 +00:00
|
|
|
handle: function handle(name, result) {
|
|
|
|
switch (name) {
|
|
|
|
case NFC.SETTING_NFC_DEBUG:
|
|
|
|
DEBUG = result;
|
|
|
|
updateDebug();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-11-21 09:54:04 +00:00
|
|
|
handleGeneralResponse: function handleReadNDEFResponse(result) {
|
|
|
|
let requestId = result.requestId;
|
|
|
|
let callback = this._requestMap[requestId];
|
|
|
|
if (!callback) {
|
|
|
|
debug("not firing message " + result.type + " for id: " + requestId);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
delete this._requestMap[requestId];
|
|
|
|
|
|
|
|
if (result.errorMsg) {
|
|
|
|
callback.notifyError(result.errorMsg);
|
|
|
|
} else {
|
|
|
|
callback.notifySuccess();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-03-25 11:14:41 +00:00
|
|
|
handleReadNDEFResponse: function handleReadNDEFResponse(result) {
|
2014-11-21 09:54:04 +00:00
|
|
|
let requestId = result.requestId;
|
|
|
|
let callback = this._requestMap[requestId];
|
|
|
|
if (!callback) {
|
|
|
|
debug("not firing message handleReadNDEFResponse for id: " + requestId);
|
2014-03-25 11:14:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-11-21 09:54:04 +00:00
|
|
|
delete this._requestMap[requestId];
|
2014-03-25 11:14:41 +00:00
|
|
|
|
2014-05-23 07:11:38 +00:00
|
|
|
if (result.errorMsg) {
|
2014-11-21 09:54:04 +00:00
|
|
|
callback.notifyError(result.errorMsg);
|
2014-03-25 11:14:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-20 10:13:40 +00:00
|
|
|
let ndefMsg = [];
|
|
|
|
let records = result.records;
|
|
|
|
for (let i = 0; i < records.length; i++) {
|
|
|
|
let record = records[i];
|
2014-11-21 09:54:04 +00:00
|
|
|
ndefMsg.push(new this._window.MozNDEFRecord({tnf: record.tnf,
|
|
|
|
type: record.type,
|
|
|
|
id: record.id,
|
|
|
|
payload: record.payload}));
|
2013-11-05 22:18:56 +00:00
|
|
|
}
|
2014-11-21 09:54:04 +00:00
|
|
|
callback.notifySuccessWithNDEFRecords(ndefMsg);
|
2013-11-05 22:18:56 +00:00
|
|
|
},
|
|
|
|
|
2014-04-30 08:18:00 +00:00
|
|
|
handleCheckP2PRegistrationResponse: function handleCheckP2PRegistrationResponse(result) {
|
2014-11-21 09:54:04 +00:00
|
|
|
let requestId = result.requestId;
|
|
|
|
let callback = this._requestMap[requestId];
|
|
|
|
if (!callback) {
|
|
|
|
debug("not firing message handleCheckP2PRegistrationResponse for id: " + requestId);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
delete this._requestMap[requestId];
|
|
|
|
|
2014-04-30 08:18:00 +00:00
|
|
|
// Privilaged status API. Always fire success to avoid using exposed props.
|
|
|
|
// The receiver must check the boolean mapped status code to handle.
|
2014-11-21 09:54:04 +00:00
|
|
|
callback.notifySuccessWithBoolean(!result.errorMsg);
|
2014-04-30 08:18:00 +00:00
|
|
|
},
|
2013-11-05 22:18:56 +00:00
|
|
|
};
|
|
|
|
|
2014-12-26 03:50:12 +00:00
|
|
|
function TagNDEFInfo(tagType, maxNDEFSize, isReadOnly, isFormatable) {
|
2014-10-22 03:48:40 +00:00
|
|
|
this.tagType = tagType;
|
|
|
|
this.maxNDEFSize = maxNDEFSize;
|
|
|
|
this.isReadOnly = isReadOnly;
|
|
|
|
this.isFormatable = isFormatable;
|
2014-10-20 09:53:39 +00:00
|
|
|
}
|
2014-12-26 03:50:12 +00:00
|
|
|
TagNDEFInfo.prototype = {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsITagNDEFInfo]),
|
2014-10-20 09:53:39 +00:00
|
|
|
|
2014-10-22 03:48:40 +00:00
|
|
|
tagType: null,
|
|
|
|
maxNDEFSize: 0,
|
|
|
|
isReadOnly: false,
|
|
|
|
isFormatable: false
|
2014-10-20 09:53:39 +00:00
|
|
|
};
|
|
|
|
|
2014-12-26 08:07:45 +00:00
|
|
|
function TagInfo(techList, tagId) {
|
2014-12-26 03:50:12 +00:00
|
|
|
this.techList = techList;
|
2014-12-26 08:07:45 +00:00
|
|
|
this.tagId = tagId;
|
2014-12-26 03:50:12 +00:00
|
|
|
}
|
|
|
|
TagInfo.prototype = {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsITagInfo]),
|
|
|
|
|
|
|
|
techList: null,
|
2014-12-26 08:07:45 +00:00
|
|
|
tagId: null,
|
2014-12-26 03:50:12 +00:00
|
|
|
};
|
|
|
|
|
2013-12-11 06:04:27 +00:00
|
|
|
if (NFC_ENABLED) {
|
|
|
|
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([NfcContentHelper]);
|
|
|
|
}
|