mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1137107
- Part 2: Add NfcResponseType and NfcNotificationType. r=smaug, dimi
This commit is contained in:
parent
4cf97dac15
commit
3c9cfd2a18
@ -91,6 +91,32 @@ const NfcRequestType = {
|
|||||||
TRANSCEIVE: "transceive"
|
TRANSCEIVE: "transceive"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Should be consistent with NfcResponseType defined in NfcOptions.webidl.
|
||||||
|
const NfcResponseType = {
|
||||||
|
CHANGE_RF_STATE_RSP: "changeRFStateRsp",
|
||||||
|
READ_NDEF_RSP: "readNDEFRsp",
|
||||||
|
WRITE_NDEF_RSP: "writeNDEFRsp",
|
||||||
|
MAKE_READ_ONLY_RSP: "makeReadOnlyRsp",
|
||||||
|
FORMAT_RSP: "formatRsp",
|
||||||
|
TRANSCEIVE_RSP: "transceiveRsp",
|
||||||
|
};
|
||||||
|
|
||||||
|
const EventMsgTable = {};
|
||||||
|
EventMsgTable[NfcResponseType.CHANGE_RF_STATE_RSP] = "NFC:ChangeRFStateResponse";
|
||||||
|
EventMsgTable[NfcResponseType.READ_NDEF_RSP] = "NFC:ReadNDEFResponse";
|
||||||
|
EventMsgTable[NfcResponseType.WRITE_NDEF_RSP] = "NFC:WriteNDEFResponse";
|
||||||
|
EventMsgTable[NfcResponseType.MAKE_READ_ONLY_RSP] = "NFC:MakeReadOnlyResponse";
|
||||||
|
EventMsgTable[NfcResponseType.FORMAT_RSP] = "NFC:FormatResponse";
|
||||||
|
EventMsgTable[NfcResponseType.TRANSCEIVE_RSP] = "NFC:TransceiveResponse";
|
||||||
|
|
||||||
|
// Should be consistent with NfcNotificationType defined in NfcOptions.webidl.
|
||||||
|
const NfcNotificationType = {
|
||||||
|
INITIALIZED: "initialized",
|
||||||
|
TECH_DISCOVERED: "techDiscovered",
|
||||||
|
TECH_LOST: "techLost",
|
||||||
|
HCI_EVENT_TRANSACTION: "hciEventTransaction"
|
||||||
|
};
|
||||||
|
|
||||||
XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
|
XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
|
||||||
"@mozilla.org/parentprocessmessagemanager;1",
|
"@mozilla.org/parentprocessmessagemanager;1",
|
||||||
"nsIMessageBroadcaster");
|
"nsIMessageBroadcaster");
|
||||||
@ -251,6 +277,14 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
|
|||||||
sessionToken: sessionToken});
|
sessionToken: sessionToken});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
notifySendFileStatus: function notifySendFileStatus(message) {
|
||||||
|
if (message.data.status) {
|
||||||
|
message.data.errorMsg =
|
||||||
|
this.nfc.getErrorMessage(NFC.NFC_GECKO_ERROR_SEND_FILE_FAILED);
|
||||||
|
}
|
||||||
|
this.nfc.sendFileStatusResponse(message.data);
|
||||||
|
},
|
||||||
|
|
||||||
callDefaultFoundHandler: function callDefaultFoundHandler(message) {
|
callDefaultFoundHandler: function callDefaultFoundHandler(message) {
|
||||||
let sysMsg = new NfcTechDiscoveredSysMsg(message.sessionToken,
|
let sysMsg = new NfcTechDiscoveredSysMsg(message.sessionToken,
|
||||||
message.isP2P,
|
message.isP2P,
|
||||||
@ -356,12 +390,7 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
|
|||||||
case "NFC:NotifySendFileStatus":
|
case "NFC:NotifySendFileStatus":
|
||||||
// Upon receiving the status of sendFile operation, send the response
|
// Upon receiving the status of sendFile operation, send the response
|
||||||
// to appropriate content process.
|
// to appropriate content process.
|
||||||
message.data.type = "NotifySendFileStatusResponse";
|
this.notifySendFileStatus(message);
|
||||||
if (message.data.status) {
|
|
||||||
message.data.errorMsg =
|
|
||||||
this.nfc.getErrorMessage(NFC.NFC_GECKO_ERROR_SEND_FILE_FAILED);
|
|
||||||
}
|
|
||||||
this.nfc.sendNfcResponse(message.data);
|
|
||||||
return null;
|
return null;
|
||||||
case "NFC:CallDefaultFoundHandler":
|
case "NFC:CallDefaultFoundHandler":
|
||||||
this.callDefaultFoundHandler(message.data);
|
this.callDefaultFoundHandler(message.data);
|
||||||
@ -492,15 +521,33 @@ Nfc.prototype = {
|
|||||||
this.nfcService.sendCommand(message);
|
this.nfcService.sendCommand(message);
|
||||||
},
|
},
|
||||||
|
|
||||||
sendNfcResponse: function sendNfcResponse(message) {
|
sendFileStatusResponse: function sendFileStatusResponse(message) {
|
||||||
let target = this.targetsByRequestId[message.requestId];
|
let target = this.getTargetByRequestId(message.requestId);
|
||||||
if (!target) {
|
if (!target) {
|
||||||
debug("No target for requestId: " + message.requestId);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
delete this.targetsByRequestId[message.requestId];
|
|
||||||
|
|
||||||
target.sendAsyncMessage("NFC:" + message.type, message);
|
target.sendAsyncMessage("NFC:NotifySendFileStatusResponse", message);
|
||||||
|
},
|
||||||
|
|
||||||
|
sendNfcResponse: function sendNfcResponse(message) {
|
||||||
|
let target = this.getTargetByRequestId(message.requestId);
|
||||||
|
if (!target) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
target.sendAsyncMessage(EventMsgTable[message.type], message);
|
||||||
|
},
|
||||||
|
|
||||||
|
getTargetByRequestId: function getTargetByRequestId(requestId) {
|
||||||
|
let target = this.targetsByRequestId[requestId];
|
||||||
|
if (!target) {
|
||||||
|
debug("No target for requestId: " + requestId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
delete this.targetsByRequestId[requestId];
|
||||||
|
|
||||||
|
return target;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -532,12 +579,12 @@ Nfc.prototype = {
|
|||||||
let message = Cu.cloneInto(event, this);
|
let message = Cu.cloneInto(event, this);
|
||||||
DEBUG && debug("Received message from NFC Service: " + JSON.stringify(message));
|
DEBUG && debug("Received message from NFC Service: " + JSON.stringify(message));
|
||||||
|
|
||||||
|
message.type = message.rspType || message.ntfType;
|
||||||
switch (message.type) {
|
switch (message.type) {
|
||||||
case "InitializedNotification":
|
case NfcNotificationType.INITIALIZED:
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
break;
|
break;
|
||||||
case "TechDiscoveredNotification":
|
case NfcNotificationType.TECH_DISCOVERED:
|
||||||
message.type = "techDiscovered";
|
|
||||||
// Update the upper layers with a session token (alias)
|
// Update the upper layers with a session token (alias)
|
||||||
message.sessionToken =
|
message.sessionToken =
|
||||||
SessionHelper.registerSession(message.sessionId, message.isP2P);
|
SessionHelper.registerSession(message.sessionId, message.isP2P);
|
||||||
@ -558,9 +605,7 @@ Nfc.prototype = {
|
|||||||
gMessageManager.onTagFound(message);
|
gMessageManager.onTagFound(message);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "TechLostNotification":
|
case NfcNotificationType.TECH_LOST:
|
||||||
message.type = "techLost";
|
|
||||||
|
|
||||||
// Update the upper layers with a session token (alias)
|
// Update the upper layers with a session token (alias)
|
||||||
message.sessionToken = SessionHelper.getToken(message.sessionId);
|
message.sessionToken = SessionHelper.getToken(message.sessionId);
|
||||||
if (SessionHelper.isP2PSession(message.sessionId)) {
|
if (SessionHelper.isP2PSession(message.sessionId)) {
|
||||||
@ -571,10 +616,10 @@ Nfc.prototype = {
|
|||||||
|
|
||||||
SessionHelper.unregisterSession(message.sessionId);
|
SessionHelper.unregisterSession(message.sessionId);
|
||||||
break;
|
break;
|
||||||
case "HCIEventTransactionNotification":
|
case NfcNotificationType.HCI_EVENT_TRANSACTION:
|
||||||
this.notifyHCIEventTransaction(message);
|
this.notifyHCIEventTransaction(message);
|
||||||
break;
|
break;
|
||||||
case "ChangeRFStateResponse":
|
case NfcResponseType.CHANGE_RF_STATE_RSP:
|
||||||
this.sendNfcResponse(message);
|
this.sendNfcResponse(message);
|
||||||
|
|
||||||
if (!message.errorMsg) {
|
if (!message.errorMsg) {
|
||||||
@ -582,11 +627,11 @@ Nfc.prototype = {
|
|||||||
gMessageManager.onRFStateChanged(this.rfState);
|
gMessageManager.onRFStateChanged(this.rfState);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "ReadNDEFResponse": // Fall through.
|
case NfcResponseType.READ_NDEF_RSP: // Fall through.
|
||||||
case "MakeReadOnlyResponse":
|
case NfcResponseType.WRITE_NDEF_RSP:
|
||||||
case "FormatResponse":
|
case NfcResponseType.MAKE_READ_ONLY_RSP:
|
||||||
case "TransceiveResponse":
|
case NfcResponseType.FORMAT_RSP:
|
||||||
case "WriteNDEFResponse":
|
case NfcResponseType.TRANSCEIVE_RSP:
|
||||||
this.sendNfcResponse(message);
|
this.sendNfcResponse(message);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -10,22 +10,6 @@ namespace mozilla {
|
|||||||
#define NFCD_MAJOR_VERSION 1
|
#define NFCD_MAJOR_VERSION 1
|
||||||
#define NFCD_MINOR_VERSION 21
|
#define NFCD_MINOR_VERSION 21
|
||||||
|
|
||||||
enum NfcResponse {
|
|
||||||
ChangeRFStateRsp,
|
|
||||||
ReadNDEFRsp,
|
|
||||||
WriteNDEFRsp,
|
|
||||||
MakeReadOnlyRsp,
|
|
||||||
FormatRsp,
|
|
||||||
TransceiveRsp,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum NfcNotification {
|
|
||||||
Initialized,
|
|
||||||
TechDiscovered,
|
|
||||||
TechLost,
|
|
||||||
HCIEventTransaction,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum NfcTechlogy {
|
enum NfcTechlogy {
|
||||||
NDEF = 0,
|
NDEF = 0,
|
||||||
NDEFWritable,
|
NDEFWritable,
|
||||||
|
@ -17,19 +17,6 @@ using namespace android;
|
|||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
|
|
||||||
static const char* kChangeRFStateResponse = "ChangeRFStateResponse";
|
|
||||||
static const char* kReadNDEFResponse = "ReadNDEFResponse";
|
|
||||||
static const char* kWriteNDEFResponse = "WriteNDEFResponse";
|
|
||||||
static const char* kMakeReadOnlyResponse = "MakeReadOnlyResponse";
|
|
||||||
static const char* kFormatResponse = "FormatResponse";
|
|
||||||
static const char* kTransceiveResponse = "TransceiveResponse";
|
|
||||||
|
|
||||||
static const char* kInitializedNotification = "InitializedNotification";
|
|
||||||
static const char* kTechDiscoveredNotification = "TechDiscoveredNotification";
|
|
||||||
static const char* kTechLostNotification = "TechLostNotification";
|
|
||||||
static const char* kHCIEventTransactionNotification =
|
|
||||||
"HCIEventTransactionNotification";
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
NfcMessageHandler::Marshall(Parcel& aParcel, const CommandOptions& aOptions)
|
NfcMessageHandler::Marshall(Parcel& aParcel, const CommandOptions& aOptions)
|
||||||
{
|
{
|
||||||
@ -66,30 +53,31 @@ NfcMessageHandler::Unmarshall(const Parcel& aParcel, EventOptions& aOptions)
|
|||||||
{
|
{
|
||||||
mozilla::unused << htonl(aParcel.readInt32()); // parcel size
|
mozilla::unused << htonl(aParcel.readInt32()); // parcel size
|
||||||
int32_t type = aParcel.readInt32();
|
int32_t type = aParcel.readInt32();
|
||||||
bool isNotification = type >> 31;
|
bool isNtf = type >> 31;
|
||||||
int32_t msgType = type & ~(1 << 31);
|
int32_t msgType = type & ~(1 << 31);
|
||||||
|
|
||||||
return isNotification ? ProcessNotification(msgType, aParcel, aOptions) :
|
return isNtf ? ProcessNotification(msgType, aParcel, aOptions) :
|
||||||
ProcessResponse(msgType, aParcel, aOptions);
|
ProcessResponse(msgType, aParcel, aOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
NfcMessageHandler::ProcessResponse(int32_t aType, const Parcel& aParcel, EventOptions& aOptions)
|
NfcMessageHandler::ProcessResponse(int32_t aType, const Parcel& aParcel, EventOptions& aOptions)
|
||||||
{
|
{
|
||||||
bool result;
|
bool result;
|
||||||
switch (aType) {
|
aOptions.mRspType = static_cast<NfcResponseType>(aType);
|
||||||
case NfcResponse::ChangeRFStateRsp:
|
switch (aOptions.mRspType) {
|
||||||
|
case NfcResponseType::ChangeRFStateRsp:
|
||||||
result = ChangeRFStateResponse(aParcel, aOptions);
|
result = ChangeRFStateResponse(aParcel, aOptions);
|
||||||
break;
|
break;
|
||||||
case NfcResponse::ReadNDEFRsp:
|
case NfcResponseType::ReadNDEFRsp:
|
||||||
result = ReadNDEFResponse(aParcel, aOptions);
|
result = ReadNDEFResponse(aParcel, aOptions);
|
||||||
break;
|
break;
|
||||||
case NfcResponse::WriteNDEFRsp: // Fall through.
|
case NfcResponseType::WriteNDEFRsp: // Fall through.
|
||||||
case NfcResponse::MakeReadOnlyRsp:
|
case NfcResponseType::MakeReadOnlyRsp:
|
||||||
case NfcResponse::FormatRsp:
|
case NfcResponseType::FormatRsp:
|
||||||
result = GeneralResponse(aType, aParcel, aOptions);
|
result = GeneralResponse(aParcel, aOptions);
|
||||||
break;
|
break;
|
||||||
case NfcResponse::TransceiveRsp:
|
case NfcResponseType::TransceiveRsp:
|
||||||
result = TransceiveResponse(aParcel, aOptions);
|
result = TransceiveResponse(aParcel, aOptions);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -103,17 +91,18 @@ bool
|
|||||||
NfcMessageHandler::ProcessNotification(int32_t aType, const Parcel& aParcel, EventOptions& aOptions)
|
NfcMessageHandler::ProcessNotification(int32_t aType, const Parcel& aParcel, EventOptions& aOptions)
|
||||||
{
|
{
|
||||||
bool result;
|
bool result;
|
||||||
switch (aType) {
|
aOptions.mNtfType = static_cast<NfcNotificationType>(aType);
|
||||||
case NfcNotification::Initialized:
|
switch (aOptions.mNtfType) {
|
||||||
|
case NfcNotificationType::Initialized:
|
||||||
result = InitializeNotification(aParcel, aOptions);
|
result = InitializeNotification(aParcel, aOptions);
|
||||||
break;
|
break;
|
||||||
case NfcNotification::TechDiscovered:
|
case NfcNotificationType::TechDiscovered:
|
||||||
result = TechDiscoveredNotification(aParcel, aOptions);
|
result = TechDiscoveredNotification(aParcel, aOptions);
|
||||||
break;
|
break;
|
||||||
case NfcNotification::TechLost:
|
case NfcNotificationType::TechLost:
|
||||||
result = TechLostNotification(aParcel, aOptions);
|
result = TechLostNotification(aParcel, aOptions);
|
||||||
break;
|
break;
|
||||||
case NfcNotification::HCIEventTransaction:
|
case NfcNotificationType::HciEventTransaction:
|
||||||
result = HCIEventTransactionNotification(aParcel, aOptions);
|
result = HCIEventTransactionNotification(aParcel, aOptions);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -125,25 +114,8 @@ NfcMessageHandler::ProcessNotification(int32_t aType, const Parcel& aParcel, Eve
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
NfcMessageHandler::GeneralResponse(const int32_t aResponse, const Parcel& aParcel, EventOptions& aOptions)
|
NfcMessageHandler::GeneralResponse(const Parcel& aParcel, EventOptions& aOptions)
|
||||||
{
|
{
|
||||||
const char* type;
|
|
||||||
switch (aResponse) {
|
|
||||||
case NfcResponse::WriteNDEFRsp:
|
|
||||||
type = kWriteNDEFResponse;
|
|
||||||
break;
|
|
||||||
case NfcResponse::MakeReadOnlyRsp:
|
|
||||||
type = kMakeReadOnlyResponse;
|
|
||||||
break;
|
|
||||||
case NfcResponse::FormatRsp:
|
|
||||||
type = kFormatResponse;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
NMH_LOG("Nfcd, unknown general aResponse %d", aResponse);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
aOptions.mType = NS_ConvertUTF8toUTF16(type);
|
|
||||||
aOptions.mErrorCode = aParcel.readInt32();
|
aOptions.mErrorCode = aParcel.readInt32();
|
||||||
aOptions.mSessionId = aParcel.readInt32();
|
aOptions.mSessionId = aParcel.readInt32();
|
||||||
|
|
||||||
@ -165,7 +137,6 @@ NfcMessageHandler::ChangeRFStateRequest(Parcel& aParcel, const CommandOptions& a
|
|||||||
bool
|
bool
|
||||||
NfcMessageHandler::ChangeRFStateResponse(const Parcel& aParcel, EventOptions& aOptions)
|
NfcMessageHandler::ChangeRFStateResponse(const Parcel& aParcel, EventOptions& aOptions)
|
||||||
{
|
{
|
||||||
aOptions.mType = NS_ConvertUTF8toUTF16(kChangeRFStateResponse);
|
|
||||||
aOptions.mErrorCode = aParcel.readInt32();
|
aOptions.mErrorCode = aParcel.readInt32();
|
||||||
NS_ENSURE_TRUE(!mRequestIdQueue.IsEmpty(), false);
|
NS_ENSURE_TRUE(!mRequestIdQueue.IsEmpty(), false);
|
||||||
aOptions.mRequestId = mRequestIdQueue[0];
|
aOptions.mRequestId = mRequestIdQueue[0];
|
||||||
@ -187,7 +158,6 @@ NfcMessageHandler::ReadNDEFRequest(Parcel& aParcel, const CommandOptions& aOptio
|
|||||||
bool
|
bool
|
||||||
NfcMessageHandler::ReadNDEFResponse(const Parcel& aParcel, EventOptions& aOptions)
|
NfcMessageHandler::ReadNDEFResponse(const Parcel& aParcel, EventOptions& aOptions)
|
||||||
{
|
{
|
||||||
aOptions.mType = NS_ConvertUTF8toUTF16(kReadNDEFResponse);
|
|
||||||
aOptions.mErrorCode = aParcel.readInt32();
|
aOptions.mErrorCode = aParcel.readInt32();
|
||||||
aOptions.mSessionId = aParcel.readInt32();
|
aOptions.mSessionId = aParcel.readInt32();
|
||||||
|
|
||||||
@ -222,7 +192,6 @@ NfcMessageHandler::TransceiveRequest(Parcel& aParcel, const CommandOptions& aOpt
|
|||||||
bool
|
bool
|
||||||
NfcMessageHandler::TransceiveResponse(const Parcel& aParcel, EventOptions& aOptions)
|
NfcMessageHandler::TransceiveResponse(const Parcel& aParcel, EventOptions& aOptions)
|
||||||
{
|
{
|
||||||
aOptions.mType = NS_ConvertUTF8toUTF16(kTransceiveResponse);
|
|
||||||
aOptions.mErrorCode = aParcel.readInt32();
|
aOptions.mErrorCode = aParcel.readInt32();
|
||||||
aOptions.mSessionId = aParcel.readInt32();
|
aOptions.mSessionId = aParcel.readInt32();
|
||||||
|
|
||||||
@ -269,7 +238,6 @@ NfcMessageHandler::FormatRequest(Parcel& aParcel, const CommandOptions& aOptions
|
|||||||
bool
|
bool
|
||||||
NfcMessageHandler::InitializeNotification(const Parcel& aParcel, EventOptions& aOptions)
|
NfcMessageHandler::InitializeNotification(const Parcel& aParcel, EventOptions& aOptions)
|
||||||
{
|
{
|
||||||
aOptions.mType = NS_ConvertUTF8toUTF16(kInitializedNotification);
|
|
||||||
aOptions.mStatus = aParcel.readInt32();
|
aOptions.mStatus = aParcel.readInt32();
|
||||||
aOptions.mMajorVersion = aParcel.readInt32();
|
aOptions.mMajorVersion = aParcel.readInt32();
|
||||||
aOptions.mMinorVersion = aParcel.readInt32();
|
aOptions.mMinorVersion = aParcel.readInt32();
|
||||||
@ -286,7 +254,6 @@ NfcMessageHandler::InitializeNotification(const Parcel& aParcel, EventOptions& a
|
|||||||
bool
|
bool
|
||||||
NfcMessageHandler::TechDiscoveredNotification(const Parcel& aParcel, EventOptions& aOptions)
|
NfcMessageHandler::TechDiscoveredNotification(const Parcel& aParcel, EventOptions& aOptions)
|
||||||
{
|
{
|
||||||
aOptions.mType = NS_ConvertUTF8toUTF16(kTechDiscoveredNotification);
|
|
||||||
aOptions.mSessionId = aParcel.readInt32();
|
aOptions.mSessionId = aParcel.readInt32();
|
||||||
aOptions.mIsP2P = aParcel.readInt32();
|
aOptions.mIsP2P = aParcel.readInt32();
|
||||||
|
|
||||||
@ -317,7 +284,6 @@ NfcMessageHandler::TechDiscoveredNotification(const Parcel& aParcel, EventOption
|
|||||||
bool
|
bool
|
||||||
NfcMessageHandler::TechLostNotification(const Parcel& aParcel, EventOptions& aOptions)
|
NfcMessageHandler::TechLostNotification(const Parcel& aParcel, EventOptions& aOptions)
|
||||||
{
|
{
|
||||||
aOptions.mType = NS_ConvertUTF8toUTF16(kTechLostNotification);
|
|
||||||
aOptions.mSessionId = aParcel.readInt32();
|
aOptions.mSessionId = aParcel.readInt32();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -325,8 +291,6 @@ NfcMessageHandler::TechLostNotification(const Parcel& aParcel, EventOptions& aOp
|
|||||||
bool
|
bool
|
||||||
NfcMessageHandler::HCIEventTransactionNotification(const Parcel& aParcel, EventOptions& aOptions)
|
NfcMessageHandler::HCIEventTransactionNotification(const Parcel& aParcel, EventOptions& aOptions)
|
||||||
{
|
{
|
||||||
aOptions.mType = NS_ConvertUTF8toUTF16(kHCIEventTransactionNotification);
|
|
||||||
|
|
||||||
aOptions.mOriginType = aParcel.readInt32();
|
aOptions.mOriginType = aParcel.readInt32();
|
||||||
aOptions.mOriginIndex = aParcel.readInt32();
|
aOptions.mOriginIndex = aParcel.readInt32();
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool ProcessResponse(int32_t aType, const android::Parcel& aParcel, EventOptions& aOptions);
|
bool ProcessResponse(int32_t aType, const android::Parcel& aParcel, EventOptions& aOptions);
|
||||||
bool GeneralResponse(int32_t aResponse, const android::Parcel& aParcel, EventOptions& aOptions);
|
bool GeneralResponse(const android::Parcel& aParcel, EventOptions& aOptions);
|
||||||
bool ChangeRFStateRequest(android::Parcel& aParcel, const CommandOptions& options);
|
bool ChangeRFStateRequest(android::Parcel& aParcel, const CommandOptions& options);
|
||||||
bool ChangeRFStateResponse(const android::Parcel& aParcel, EventOptions& aOptions);
|
bool ChangeRFStateResponse(const android::Parcel& aParcel, EventOptions& aOptions);
|
||||||
bool ReadNDEFRequest(android::Parcel& aParcel, const CommandOptions& options);
|
bool ReadNDEFRequest(android::Parcel& aParcel, const CommandOptions& options);
|
||||||
|
@ -97,13 +97,16 @@ struct CommandOptions
|
|||||||
struct EventOptions
|
struct EventOptions
|
||||||
{
|
{
|
||||||
EventOptions()
|
EventOptions()
|
||||||
: mType(EmptyString()), mStatus(-1), mErrorCode(-1), mSessionId(-1), mRequestId(EmptyString()),
|
: mRspType(dom::NfcResponseType::EndGuard_),
|
||||||
|
mNtfType(dom::NfcNotificationType::EndGuard_),
|
||||||
|
mStatus(-1), mErrorCode(-1), mSessionId(-1), mRequestId(EmptyString()),
|
||||||
mMajorVersion(-1), mMinorVersion(-1), mIsP2P(-1),
|
mMajorVersion(-1), mMinorVersion(-1), mIsP2P(-1),
|
||||||
mTagType(-1), mMaxNDEFSize(-1), mIsReadOnly(-1), mIsFormatable(-1), mRfState(-1),
|
mTagType(-1), mMaxNDEFSize(-1), mIsReadOnly(-1), mIsFormatable(-1), mRfState(-1),
|
||||||
mOriginType(-1), mOriginIndex(-1)
|
mOriginType(-1), mOriginIndex(-1)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
nsString mType;
|
dom::NfcResponseType mRspType;
|
||||||
|
dom::NfcNotificationType mNtfType;
|
||||||
int32_t mStatus;
|
int32_t mStatus;
|
||||||
int32_t mErrorCode;
|
int32_t mErrorCode;
|
||||||
int32_t mSessionId;
|
int32_t mSessionId;
|
||||||
|
@ -98,7 +98,15 @@ public:
|
|||||||
event.prop.Value() = mEvent.prop; \
|
event.prop.Value() = mEvent.prop; \
|
||||||
}
|
}
|
||||||
|
|
||||||
COPY_FIELD(mType)
|
COPY_OPT_FIELD(mRspType, NfcResponseType::EndGuard_)
|
||||||
|
COPY_OPT_FIELD(mNtfType, NfcNotificationType::EndGuard_)
|
||||||
|
|
||||||
|
// Only one of rspType and ntfType should be used.
|
||||||
|
MOZ_ASSERT(((mEvent.mRspType != NfcResponseType::EndGuard_) ||
|
||||||
|
(mEvent.mNtfType != NfcNotificationType::EndGuard_)) &&
|
||||||
|
((mEvent.mRspType == NfcResponseType::EndGuard_) ||
|
||||||
|
(mEvent.mNtfType == NfcNotificationType::EndGuard_)));
|
||||||
|
|
||||||
COPY_OPT_FIELD(mRequestId, EmptyString())
|
COPY_OPT_FIELD(mRequestId, EmptyString())
|
||||||
COPY_OPT_FIELD(mStatus, -1)
|
COPY_OPT_FIELD(mStatus, -1)
|
||||||
COPY_OPT_FIELD(mSessionId, -1)
|
COPY_OPT_FIELD(mSessionId, -1)
|
||||||
|
@ -20,6 +20,28 @@ enum NfcRequestType {
|
|||||||
"transceive"
|
"transceive"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of the Response used in NfcEventOptions.
|
||||||
|
*/
|
||||||
|
enum NfcResponseType {
|
||||||
|
"changeRFStateRsp",
|
||||||
|
"readNDEFRsp",
|
||||||
|
"writeNDEFRsp",
|
||||||
|
"makeReadOnlyRsp",
|
||||||
|
"formatRsp",
|
||||||
|
"transceiveRsp",
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of the Notification used in NfcEventOptions.
|
||||||
|
*/
|
||||||
|
enum NfcNotificationType {
|
||||||
|
"initialized",
|
||||||
|
"techDiscovered",
|
||||||
|
"techLost",
|
||||||
|
"hciEventTransaction"
|
||||||
|
};
|
||||||
|
|
||||||
dictionary NfcCommandOptions
|
dictionary NfcCommandOptions
|
||||||
{
|
{
|
||||||
required NfcRequestType type;
|
required NfcRequestType type;
|
||||||
@ -40,7 +62,8 @@ dictionary NfcCommandOptions
|
|||||||
|
|
||||||
dictionary NfcEventOptions
|
dictionary NfcEventOptions
|
||||||
{
|
{
|
||||||
DOMString type = "";
|
NfcResponseType rspType;
|
||||||
|
NfcNotificationType ntfType;
|
||||||
|
|
||||||
long status;
|
long status;
|
||||||
NfcErrorMessage errorMsg;
|
NfcErrorMessage errorMsg;
|
||||||
|
Loading…
Reference in New Issue
Block a user