mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1141457 - Part 3: add a CommandMsgTable. r=dimi
From 7650a8e6a0ab634b90c85c0fa85a096e7d0f4ec9 Mon Sep 17 00:00:00 2001 --- dom/nfc/gonk/Nfc.js | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-)
This commit is contained in:
parent
18606077c9
commit
1f2cf2602d
@ -91,6 +91,14 @@ const NfcRequestType = {
|
||||
TRANSCEIVE: "transceive"
|
||||
};
|
||||
|
||||
const CommandMsgTable = {};
|
||||
CommandMsgTable["NFC:ChangeRFState"] = NfcRequestType.CHANGE_RF_STATE;
|
||||
CommandMsgTable["NFC:ReadNDEF"] = NfcRequestType.READ_NDEF;
|
||||
CommandMsgTable["NFC:WriteNDEF"] = NfcRequestType.WRITE_NDEF;
|
||||
CommandMsgTable["NFC:MakeReadOnly"] = NfcRequestType.MAKE_READ_ONLY;
|
||||
CommandMsgTable["NFC:Format"] = NfcRequestType.FORMAT;
|
||||
CommandMsgTable["NFC:Transceive"] = NfcRequestType.TRANSCEIVE;
|
||||
|
||||
// Should be consistent with NfcResponseType defined in NfcOptions.webidl.
|
||||
const NfcResponseType = {
|
||||
CHANGE_RF_STATE_RSP: "changeRFStateRsp",
|
||||
@ -690,31 +698,13 @@ Nfc.prototype = {
|
||||
message.data.sessionId = SessionHelper.getId(message.data.sessionToken);
|
||||
}
|
||||
|
||||
switch (message.name) {
|
||||
case "NFC:ChangeRFState":
|
||||
this.sendToNfcService(NfcRequestType.CHANGE_RF_STATE, message.data);
|
||||
break;
|
||||
case "NFC:ReadNDEF":
|
||||
this.sendToNfcService(NfcRequestType.READ_NDEF, message.data);
|
||||
break;
|
||||
case "NFC:WriteNDEF":
|
||||
this.sendToNfcService(NfcRequestType.WRITE_NDEF, message.data);
|
||||
break;
|
||||
case "NFC:MakeReadOnly":
|
||||
this.sendToNfcService(NfcRequestType.MAKE_READ_ONLY, message.data);
|
||||
break;
|
||||
case "NFC:Format":
|
||||
this.sendToNfcService(NfcRequestType.FORMAT, message.data);
|
||||
break;
|
||||
case "NFC:Transceive":
|
||||
this.sendToNfcService(NfcRequestType.TRANSCEIVE, message.data);
|
||||
break;
|
||||
default:
|
||||
debug("UnSupported : Message Name " + message.name);
|
||||
return null;
|
||||
let command = CommandMsgTable[message.name];
|
||||
if (!command) {
|
||||
debug("Unknown message: " + message.name);
|
||||
return null;
|
||||
}
|
||||
this.targetsByRequestId[message.data.requestId] = message.target;
|
||||
|
||||
this.sendToNfcService(command, message.data);
|
||||
return null;
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user