Bug 1073416 - B2G NFC: remove getDetailsNDEF impl. r=dimi
From 59914a177ef8efdf569829fd46cbdd5659517bc6 Mon Sep 17 00:00:00 2001
---
dom/nfc/NfcContentHelper.js | 41 --------------------------------------
dom/nfc/gonk/Nfc.js | 5 -----
dom/nfc/gonk/NfcGonkMessage.h | 4 +---
dom/nfc/gonk/NfcMessageHandler.cpp | 36 ---------------------------------
dom/nfc/gonk/NfcMessageHandler.h | 2 --
dom/nfc/nsINfcContentHelper.idl | 3 +--
6 files changed, 2 insertions(+), 89 deletions(-)
--- a/dom/nfc/NfcContentHelper.js
+++ b/dom/nfc/NfcContentHelper.js
@@ -45,41 +45,29 @@ if (DEBUG) {
}
const NFCCONTENTHELPER_CID =
Components.ID("{4d72c120-da5f-11e1-9b23-0800200c9a66}");
const NFC_IPC_MSG_NAMES = [
"NFC:ReadNDEFResponse",
"NFC:WriteNDEFResponse",
- "NFC:GetDetailsNDEFResponse",
"NFC:MakeReadOnlyNDEFResponse",
"NFC:ConnectResponse",
"NFC:CloseResponse",
"NFC:CheckP2PRegistrationResponse",
"NFC:DOMEvent",
"NFC:NotifySendFileStatusResponse",
"NFC:ConfigResponse"
];
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1",
"nsISyncMessageSender");
-function GetDetailsNDEFResponse(details) {
- this.canBeMadeReadOnly = details.canBeMadeReadOnly;
- this.isReadOnly = details.isReadOnly;
- this.maxSupportedLength = details.maxSupportedLength;
-}
-GetDetailsNDEFResponse.prototype = {
- __exposedProps__ : {canBeMadeReadOnly: 'r',
- isReadOnly: 'r',
- maxSupportedLength: 'r'}
-};
-
function NfcContentHelper() {
this.initDOMRequestHelper(/* aWindow */ null, NFC_IPC_MSG_NAMES);
Services.obs.addObserver(this, "xpcom-shutdown", false);
this._requestMap = [];
}
NfcContentHelper.prototype = {
@@ -122,32 +110,16 @@ NfcContentHelper.prototype = {
// Report session to Nfc.js only.
let val = cpmm.sendSyncMessage("NFC:CheckSessionToken", {
sessionToken: sessionToken
});
return (val[0] === NFC.NFC_SUCCESS);
},
// NFCTag interface
- getDetailsNDEF: function getDetailsNDEF(window, sessionToken) {
- if (window == null) {
- throw Components.Exception("Can't get window object",
- Cr.NS_ERROR_UNEXPECTED);
- }
- let request = Services.DOMRequest.createRequest(window);
- let requestId = btoa(this.getRequestId(request));
- this._requestMap[requestId] = window;
-
- cpmm.sendAsyncMessage("NFC:GetDetailsNDEF", {
- requestId: requestId,
- sessionToken: sessionToken
- });
- return request;
- },
-
readNDEF: function readNDEF(window, sessionToken) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
}
let request = Services.DOMRequest.createRequest(window);
let requestId = btoa(this.getRequestId(request));
this._requestMap[requestId] = window;
@@ -390,19 +362,16 @@ NfcContentHelper.prototype = {
receiveMessage: function receiveMessage(message) {
DEBUG && debug("Message received: " + JSON.stringify(message));
let result = message.json;
switch (message.name) {
case "NFC:ReadNDEFResponse":
this.handleReadNDEFResponse(result);
break;
- case "NFC:GetDetailsNDEFResponse":
- this.handleGetDetailsNDEFResponse(result);
- break;
case "NFC:CheckP2PRegistrationResponse":
this.handleCheckP2PRegistrationResponse(result);
break;
case "NFC:ConnectResponse": // Fall through.
case "NFC:CloseResponse":
case "NFC:WriteNDEFResponse":
case "NFC:MakeReadOnlyNDEFResponse":
case "NFC:NotifySendFileStatusResponse":
@@ -447,26 +416,16 @@ NfcContentHelper.prototype = {
ndefMsg.push(new requester.MozNDEFRecord({tnf: record.tnf,
type: record.type,
id: record.id,
payload: record.payload}));
}
this.fireRequestSuccess(requestId, ndefMsg);
},
- handleGetDetailsNDEFResponse: function handleGetDetailsNDEFResponse(result) {
- if (result.errorMsg) {
- this.fireRequestError(atob(result.requestId), result.errorMsg);
- return;
- }
-
- let requestId = atob(result.requestId);
- this.fireRequestSuccess(requestId, new GetDetailsNDEFResponse(result));
- },
-
handleCheckP2PRegistrationResponse: function handleCheckP2PRegistrationResponse(result) {
// Privilaged status API. Always fire success to avoid using exposed props.
// The receiver must check the boolean mapped status code to handle.
let requestId = atob(result.requestId);
this.fireRequestSuccess(requestId, !result.errorMsg);
},
};
--- a/dom/nfc/gonk/Nfc.js
+++ b/dom/nfc/gonk/Nfc.js
@@ -52,17 +52,16 @@ const NFC_IPC_ADD_EVENT_TARGET_MSG_NAMES
];
const NFC_IPC_MSG_NAMES = [
"NFC:CheckSessionToken"
];
const NFC_IPC_READ_PERM_MSG_NAMES = [
"NFC:ReadNDEF",
- "NFC:GetDetailsNDEF",
"NFC:Connect",
"NFC:Close",
];
const NFC_IPC_WRITE_PERM_MSG_NAMES = [
"NFC:WriteNDEF",
"NFC:MakeReadOnlyNDEF",
"NFC:SendFile",
@@ -533,17 +532,16 @@ Nfc.prototype = {
if (message.status === NFC.NFC_SUCCESS) {
this.powerLevel = message.powerLevel;
}
this.sendNfcResponse(message);
break;
case "ConnectResponse": // Fall through.
case "CloseResponse":
- case "GetDetailsNDEFResponse":
case "ReadNDEFResponse":
case "MakeReadOnlyNDEFResponse":
case "WriteNDEFResponse":
this.sendNfcResponse(message);
break;
default:
throw new Error("Don't know about this message type: " + message.type);
}
@@ -603,19 +601,16 @@ Nfc.prototype = {
case "NFC:StopPoll":
this.setConfig({powerLevel: NFC.NFC_POWER_LEVEL_LOW,
requestId: message.data.requestId});
break;
case "NFC:PowerOff":
this.setConfig({powerLevel: NFC.NFC_POWER_LEVEL_DISABLED,
requestId: message.data.requestId});
break;
- case "NFC:GetDetailsNDEF":
- this.sendToNfcService("getDetailsNDEF", message.data);
- break;
case "NFC:ReadNDEF":
this.sendToNfcService("readNDEF", message.data);
break;
case "NFC:WriteNDEF":
this.sendToNfcService("writeNDEF", message.data);
break;
case "NFC:MakeReadOnlyNDEF":
this.sendToNfcService("makeReadOnlyNDEF", message.data);
--- a/dom/nfc/gonk/NfcGonkMessage.h
+++ b/dom/nfc/gonk/NfcGonkMessage.h
@@ -3,32 +3,30 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef NfcGonkMessage_h
#define NfcGonkMessage_h
namespace mozilla {
#define NFCD_MAJOR_VERSION 1
-#define NFCD_MINOR_VERSION 9
+#define NFCD_MINOR_VERSION 10
enum NfcRequest {
ConfigReq = 0,
ConnectReq,
CloseReq,
- GetDetailsNDEFReq,
ReadNDEFReq,
WriteNDEFReq,
MakeReadOnlyNDEFReq,
};
enum NfcResponse {
GeneralRsp = 1000,
ConfigRsp,
- GetDetailsNDEFRsp,
ReadNDEFRsp,
};
enum NfcNotification {
Initialized = 2000,
TechDiscovered,
TechLost,
HCIEventTransaction,
--- a/dom/nfc/gonk/NfcMessageHandler.cpp
+++ b/dom/nfc/gonk/NfcMessageHandler.cpp
@@ -12,25 +12,23 @@
#include <android/log.h>
#define CHROMIUM_LOG(args...) __android_log_print(ANDROID_LOG_INFO, "NfcMessageHandler", args)
using namespace android;
using namespace mozilla;
using namespace mozilla::dom;
static const char* kConfigRequest = "config";
-static const char* kGetDetailsNDEF = "getDetailsNDEF";
static const char* kReadNDEFRequest = "readNDEF";
static const char* kWriteNDEFRequest = "writeNDEF";
static const char* kMakeReadOnlyNDEFRequest = "makeReadOnlyNDEF";
static const char* kConnectRequest = "connect";
static const char* kCloseRequest = "close";
static const char* kConfigResponse = "ConfigResponse";
-static const char* kGetDetailsNDEFResponse = "GetDetailsNDEFResponse";
static const char* kReadNDEFResponse = "ReadNDEFResponse";
static const char* kWriteNDEFResponse = "WriteNDEFResponse";
static const char* kMakeReadOnlyNDEFResponse = "MakeReadOnlyNDEFResponse";
static const char* kConnectResponse = "ConnectResponse";
static const char* kCloseResponse = "CloseResponse";
static const char* kInitializedNotification = "InitializedNotification";
static const char* kTechDiscoveredNotification = "TechDiscoveredNotification";
@@ -41,18 +39,16 @@ static const char* kHCIEventTransactionN
bool
NfcMessageHandler::Marshall(Parcel& aParcel, const CommandOptions& aOptions)
{
bool result;
const char* type = NS_ConvertUTF16toUTF8(aOptions.mType).get();
if (!strcmp(type, kConfigRequest)) {
result = ConfigRequest(aParcel, aOptions);
- } else if (!strcmp(type, kGetDetailsNDEF)) {
- result = GetDetailsNDEFRequest(aParcel, aOptions);
} else if (!strcmp(type, kReadNDEFRequest)) {
result = ReadNDEFRequest(aParcel, aOptions);
} else if (!strcmp(type, kWriteNDEFRequest)) {
result = WriteNDEFRequest(aParcel, aOptions);
mPendingReqQueue.AppendElement(NfcRequest::WriteNDEFReq);
} else if (!strcmp(type, kMakeReadOnlyNDEFRequest)) {
result = MakeReadOnlyNDEFRequest(aParcel, aOptions);
mPendingReqQueue.AppendElement(NfcRequest::MakeReadOnlyNDEFReq);
@@ -78,19 +74,16 @@ NfcMessageHandler::Unmarshall(const Parc
switch (type) {
case NfcResponse::GeneralRsp:
result = GeneralResponse(aParcel, aOptions);
break;
case NfcResponse::ConfigRsp:
result = ConfigResponse(aParcel, aOptions);
break;
- case NfcResponse::GetDetailsNDEFRsp:
- result = GetDetailsNDEFResponse(aParcel, aOptions);
- break;
case NfcResponse::ReadNDEFRsp:
result = ReadNDEFResponse(aParcel, aOptions);
break;
case NfcNotification::Initialized:
result = InitializeNotification(aParcel, aOptions);
break;
case NfcNotification::TechDiscovered:
result = TechDiscoveredNotification(aParcel, aOptions);
@@ -167,45 +160,16 @@ NfcMessageHandler::ConfigResponse(const
NS_ENSURE_TRUE(!mPowerLevelQueue.IsEmpty(), false);
aOptions.mPowerLevel = mPowerLevelQueue[0];
mPowerLevelQueue.RemoveElementAt(0);
return true;
}
bool
-NfcMessageHandler::GetDetailsNDEFRequest(Parcel& aParcel, const CommandOptions& aOptions)
-{
- aParcel.writeInt32(NfcRequest::GetDetailsNDEFReq);
- aParcel.writeInt32(aOptions.mSessionId);
- mRequestIdQueue.AppendElement(aOptions.mRequestId);
- return true;
-}
-
-bool
-NfcMessageHandler::GetDetailsNDEFResponse(const Parcel& aParcel, EventOptions& aOptions)
-{
- aOptions.mType = NS_ConvertUTF8toUTF16(kGetDetailsNDEFResponse);
- aOptions.mStatus = aParcel.readInt32();
- aOptions.mSessionId = aParcel.readInt32();
-
- if (aOptions.mStatus == NfcErrorCode::Success) {
- int readOnly = aParcel.readInt32();
- aOptions.mIsReadOnly = readOnly & 0xff;
- aOptions.mCanBeMadeReadOnly = (readOnly >> 8) & 0xff;
- aOptions.mMaxSupportedLength = aParcel.readInt32();
- }
-
- NS_ENSURE_TRUE(!mRequestIdQueue.IsEmpty(), false);
- aOptions.mRequestId = mRequestIdQueue[0];
- mRequestIdQueue.RemoveElementAt(0);
- return true;
-}
-
-bool
NfcMessageHandler::ReadNDEFRequest(Parcel& aParcel, const CommandOptions& aOptions)
{
aParcel.writeInt32(NfcRequest::ReadNDEFReq);
aParcel.writeInt32(aOptions.mSessionId);
mRequestIdQueue.AppendElement(aOptions.mRequestId);
return true;
}
--- a/dom/nfc/gonk/NfcMessageHandler.h
+++ b/dom/nfc/gonk/NfcMessageHandler.h
@@ -22,18 +22,16 @@ class NfcMessageHandler
public:
bool Marshall(android::Parcel& aParcel, const CommandOptions& aOptions);
bool Unmarshall(const android::Parcel& aParcel, EventOptions& aOptions);
private:
bool GeneralResponse(const android::Parcel& aParcel, EventOptions& aOptions);
bool ConfigRequest(android::Parcel& aParcel, const CommandOptions& options);
bool ConfigResponse(const android::Parcel& aParcel, EventOptions& aOptions);
- bool GetDetailsNDEFRequest(android::Parcel& aParcel, const CommandOptions& options);
- bool GetDetailsNDEFResponse(const android::Parcel& aParcel, EventOptions& aOptions);
bool ReadNDEFRequest(android::Parcel& aParcel, const CommandOptions& options);
bool ReadNDEFResponse(const android::Parcel& aParcel, EventOptions& aOptions);
bool WriteNDEFRequest(android::Parcel& aParcel, const CommandOptions& options);
bool MakeReadOnlyNDEFRequest(android::Parcel& aParcel, const CommandOptions& options);
bool ConnectRequest(android::Parcel& aParcel, const CommandOptions& options);
bool CloseRequest(android::Parcel& aParcel, const CommandOptions& options);
bool InitializeNotification(const android::Parcel& aParcel, EventOptions& aOptions);
--- a/dom/nfc/nsINfcContentHelper.idl
+++ b/dom/nfc/nsINfcContentHelper.idl
@@ -22,25 +22,24 @@ interface nsINfcDOMEventTarget : nsISupp
* Callback function used to notify peerlost.
*
* @param sessionToken
* SessionToken received from Chrome process
*/
void notifyPeerLost(in DOMString sessionToken);
};
-[scriptable, uuid(7eaf4c31-e1d1-422e-aa55-181f4eb156b0)]
+[scriptable, uuid(d3f1bdc1-048f-44a8-abe2-bc386edce40b)]
interface nsINfcContentHelper : nsISupports
{
const long NFC_EVENT_PEER_READY = 0x01;
const long NFC_EVENT_PEER_LOST = 0x02;
boolean checkSessionToken(in DOMString sessionToken);
- nsIDOMDOMRequest getDetailsNDEF(in nsIDOMWindow window, in DOMString sessionToken);
nsIDOMDOMRequest readNDEF(in nsIDOMWindow window, in DOMString sessionToken);
nsIDOMDOMRequest writeNDEF(in nsIDOMWindow window, in nsIVariant records, in DOMString sessionToken);
nsIDOMDOMRequest makeReadOnlyNDEF(in nsIDOMWindow window, in DOMString sessionToken);
nsIDOMDOMRequest connect(in nsIDOMWindow window, in unsigned long techType, in DOMString sessionToken);
nsIDOMDOMRequest close(in nsIDOMWindow window, in DOMString sessionToken);
/**