mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1047233 - B2G NFC: handler the errorMsg in NfcService and list errorMsg in WebIDL. r=smaug, allstars.chh
This commit is contained in:
parent
ef177d9898
commit
5f106fa32d
@ -133,7 +133,7 @@ NfcContentHelper.prototype = {
|
||||
let val = cpmm.sendSyncMessage("NFC:CheckSessionToken", {
|
||||
sessionToken: sessionToken
|
||||
});
|
||||
return (val[0] === NFC.NFC_SUCCESS);
|
||||
return (val[0] === NFC.NFC_GECKO_SUCCESS);
|
||||
},
|
||||
|
||||
// NFCTag interface
|
||||
|
@ -314,9 +314,9 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
|
||||
case "NFC:CheckSessionToken":
|
||||
if (!SessionHelper.isValidToken(message.data.sessionToken)) {
|
||||
debug("Received invalid Session Token: " + message.data.sessionToken);
|
||||
return NFC.NFC_ERROR_BAD_SESSION_ID;
|
||||
return NFC.NFC_GECKO_ERROR_BAD_SESSION_ID;
|
||||
}
|
||||
return NFC.NFC_SUCCESS;
|
||||
return NFC.NFC_GECKO_SUCCESS;
|
||||
case "NFC:RegisterPeerReadyTarget":
|
||||
this.registerPeerReadyTarget(message.target, message.data.appId);
|
||||
return null;
|
||||
@ -513,11 +513,6 @@ Nfc.prototype = {
|
||||
let message = Cu.cloneInto(event, this);
|
||||
DEBUG && debug("Received message from NFC Service: " + JSON.stringify(message));
|
||||
|
||||
// mapping error code to error message
|
||||
if (message.status !== undefined && message.status !== NFC.NFC_SUCCESS) {
|
||||
message.errorMsg = this.getErrorMessage(message.status);
|
||||
}
|
||||
|
||||
switch (message.type) {
|
||||
case "InitializedNotification":
|
||||
// Do nothing.
|
||||
@ -561,7 +556,7 @@ Nfc.prototype = {
|
||||
this.notifyHCIEventTransaction(message);
|
||||
break;
|
||||
case "ConfigResponse":
|
||||
if (message.status === NFC.NFC_SUCCESS) {
|
||||
if (!message.errorMsg) {
|
||||
this.powerLevel = message.powerLevel;
|
||||
}
|
||||
|
||||
@ -617,7 +612,7 @@ Nfc.prototype = {
|
||||
// Sanity check on sessionToken.
|
||||
if (!SessionHelper.isValidToken(message.data.sessionToken)) {
|
||||
debug("Invalid Session Token: " + message.data.sessionToken);
|
||||
this.sendNfcErrorResponse(message, NFC.NFC_ERROR_BAD_SESSION_ID);
|
||||
this.sendNfcErrorResponse(message, NFC.NFC_GECKO_ERROR_BAD_SESSION_ID);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
namespace mozilla {
|
||||
|
||||
#define NFCD_MAJOR_VERSION 1
|
||||
#define NFCD_MINOR_VERSION 13
|
||||
#define NFCD_MINOR_VERSION 14
|
||||
|
||||
enum NfcRequest {
|
||||
ConfigReq = 0,
|
||||
@ -41,37 +41,24 @@ enum NfcTechlogy {
|
||||
|
||||
enum NfcErrorCode {
|
||||
Success = 0,
|
||||
IOErr = -1,
|
||||
Cancelled = -2,
|
||||
Timeout = -3,
|
||||
BusyErr = -4,
|
||||
ConnectErr = -5,
|
||||
DisconnectErr = -6,
|
||||
ReadErr = -7,
|
||||
WriteErr = -8,
|
||||
InvalidParam = -9,
|
||||
InsufficientResources = -10,
|
||||
SocketCreation = -11,
|
||||
SocketNotConnected = -12,
|
||||
BufferTooSmall = -13,
|
||||
SapUsed = -14,
|
||||
ServiceNameUsed = -15,
|
||||
SocketOptions = -16,
|
||||
FailEnableDiscovery = -17,
|
||||
FailDisableDiscovery = -18,
|
||||
NotInitialized = -19,
|
||||
InitializeFail = -20,
|
||||
DeinitializeFail = -21,
|
||||
SeConnected = -22,
|
||||
NoSeConnected = -23,
|
||||
NotSupported = -24,
|
||||
BadSessionId = -25,
|
||||
LostTech = -26,
|
||||
BadTechType = -27,
|
||||
SelectSeFail = -28,
|
||||
DeselectSeFail = -29,
|
||||
FailEnableLowPowerMode = -30,
|
||||
FailDisableLowPowerMode = -31,
|
||||
IOErr = 1,
|
||||
Timeout = 2,
|
||||
BusyErr = 3,
|
||||
ConnectErr = 4,
|
||||
DisconnectErr = 5,
|
||||
ReadErr = 6,
|
||||
WriteErr = 7,
|
||||
InvalidParam = 8,
|
||||
InsufficientResources = 9,
|
||||
SocketCreation = 10,
|
||||
FailEnableDiscovery = 11,
|
||||
FailDisableDiscovery = 12,
|
||||
NotInitialized = 13,
|
||||
InitializeFail = 14,
|
||||
DeinitializeFail = 15,
|
||||
NotSupported = 16,
|
||||
FailEnableLowPowerMode = 17,
|
||||
FailDisableLowPowerMode = 18,
|
||||
};
|
||||
|
||||
enum SecureElementOrigin {
|
||||
|
@ -129,7 +129,7 @@ NfcMessageHandler::GeneralResponse(const Parcel& aParcel, EventOptions& aOptions
|
||||
}
|
||||
|
||||
aOptions.mType = NS_ConvertUTF8toUTF16(type);
|
||||
aOptions.mStatus = aParcel.readInt32();
|
||||
aOptions.mErrorCode = aParcel.readInt32();
|
||||
aOptions.mSessionId = aParcel.readInt32();
|
||||
|
||||
NS_ENSURE_TRUE(!mRequestIdQueue.IsEmpty(), false);
|
||||
@ -152,8 +152,7 @@ bool
|
||||
NfcMessageHandler::ConfigResponse(const Parcel& aParcel, EventOptions& aOptions)
|
||||
{
|
||||
aOptions.mType = NS_ConvertUTF8toUTF16(kConfigResponse);
|
||||
aOptions.mStatus = aParcel.readInt32();
|
||||
|
||||
aOptions.mErrorCode = aParcel.readInt32();
|
||||
NS_ENSURE_TRUE(!mRequestIdQueue.IsEmpty(), false);
|
||||
aOptions.mRequestId = mRequestIdQueue[0];
|
||||
mRequestIdQueue.RemoveElementAt(0);
|
||||
@ -177,14 +176,14 @@ bool
|
||||
NfcMessageHandler::ReadNDEFResponse(const Parcel& aParcel, EventOptions& aOptions)
|
||||
{
|
||||
aOptions.mType = NS_ConvertUTF8toUTF16(kReadNDEFResponse);
|
||||
aOptions.mStatus = aParcel.readInt32();
|
||||
aOptions.mErrorCode = aParcel.readInt32();
|
||||
aOptions.mSessionId = aParcel.readInt32();
|
||||
|
||||
NS_ENSURE_TRUE(!mRequestIdQueue.IsEmpty(), false);
|
||||
aOptions.mRequestId = mRequestIdQueue[0];
|
||||
mRequestIdQueue.RemoveElementAt(0);
|
||||
|
||||
if (aOptions.mStatus == NfcErrorCode::Success) {
|
||||
if (aOptions.mErrorCode == NfcErrorCode::Success) {
|
||||
ReadNDEFMessage(aParcel, aOptions);
|
||||
}
|
||||
|
||||
|
@ -85,13 +85,14 @@ struct CommandOptions
|
||||
struct EventOptions
|
||||
{
|
||||
EventOptions()
|
||||
: mType(EmptyString()), mStatus(-1), mSessionId(-1), mRequestId(EmptyString()), mMajorVersion(-1), mMinorVersion(-1),
|
||||
mIsReadOnly(-1), mCanBeMadeReadOnly(-1), mMaxSupportedLength(-1), mPowerLevel(-1),
|
||||
mOriginType(-1), mOriginIndex(-1)
|
||||
: mType(EmptyString()), mStatus(-1), mErrorCode(-1), mSessionId(-1), mRequestId(EmptyString()),
|
||||
mMajorVersion(-1), mMinorVersion(-1), mIsReadOnly(-1), mCanBeMadeReadOnly(-1),
|
||||
mMaxSupportedLength(-1), mPowerLevel(-1), mOriginType(-1), mOriginIndex(-1)
|
||||
{}
|
||||
|
||||
nsString mType;
|
||||
int32_t mStatus;
|
||||
int32_t mErrorCode;
|
||||
int32_t mSessionId;
|
||||
nsString mRequestId;
|
||||
int32_t mMajorVersion;
|
||||
|
@ -106,6 +106,11 @@ public:
|
||||
COPY_OPT_FIELD(mMinorVersion, -1)
|
||||
COPY_OPT_FIELD(mPowerLevel, -1)
|
||||
|
||||
if (mEvent.mErrorCode != -1) {
|
||||
event.mErrorMsg.Construct();
|
||||
event.mErrorMsg.Value() = static_cast<NfcErrorMessage>(mEvent.mErrorCode);
|
||||
}
|
||||
|
||||
if (mEvent.mTechList.Length() > 0) {
|
||||
int length = mEvent.mTechList.Length();
|
||||
event.mTechList.Construct();
|
||||
|
@ -22,58 +22,20 @@ this.DEBUG_ALL = false;
|
||||
this.DEBUG_CONTENT_HELPER = false || DEBUG_ALL;
|
||||
this.DEBUG_NFC = false || DEBUG_ALL;
|
||||
|
||||
// nfcd error codes
|
||||
this.NFC_SUCCESS = 0;
|
||||
this.NFC_ERROR_IO = -1;
|
||||
this.NFC_ERROR_TIMEOUT = -2;
|
||||
this.NFC_ERROR_BUSY = -3;
|
||||
this.NFC_ERROR_CONNECT = -4;
|
||||
this.NFC_ERROR_DISCONNECT = -5;
|
||||
this.NFC_ERROR_READ = -6;
|
||||
this.NFC_ERROR_WRITE = -7;
|
||||
this.NFC_ERROR_INVALID_PARAM = -8;
|
||||
this.NFC_ERROR_INSUFFICIENT_RESOURCES = -9;
|
||||
this.NFC_ERROR_SOCKET_CREATION = -10;
|
||||
this.NFC_ERROR_FAIL_ENABLE_DISCOVERY = -11;
|
||||
this.NFC_ERROR_FAIL_DISABLE_DISCOVERY = -12;
|
||||
this.NFC_ERROR_NOT_INITIALIZED = -13;
|
||||
this.NFC_ERROR_INITIALIZE_FAIL = -14;
|
||||
this.NFC_ERROR_DEINITIALIZE_FAIL = -15;
|
||||
this.NFC_ERROR_NOT_SUPPORTED = -16;
|
||||
this.NFC_ERROR_BAD_SESSION_ID = -17,
|
||||
this.NFC_ERROR_FAIL_ENABLE_LOW_POWER_MODE = -18;
|
||||
this.NFC_ERROR_FAIL_DISABLE_LOW_POWER_MODE = -19;
|
||||
|
||||
// Gecko specific error codes
|
||||
this.NFC_GECKO_SUCCESS = 0;
|
||||
this.NFC_GECKO_ERROR_GENERIC_FAILURE = 1;
|
||||
this.NFC_GECKO_ERROR_P2P_REG_INVALID = 2;
|
||||
this.NFC_GECKO_ERROR_NOT_ENABLED = 3;
|
||||
this.NFC_GECKO_ERROR_SEND_FILE_FAILED = 4;
|
||||
this.NFC_GECKO_ERROR_BAD_SESSION_ID = 5;
|
||||
|
||||
this.NFC_ERROR_MSG = {};
|
||||
this.NFC_ERROR_MSG[this.NFC_ERROR_IO] = "NfcIoError";
|
||||
this.NFC_ERROR_MSG[this.NFC_ERROR_TIMEOUT] = "NfcTimeoutError";
|
||||
this.NFC_ERROR_MSG[this.NFC_ERROR_BUSY] = "NfcBusyError";
|
||||
this.NFC_ERROR_MSG[this.NFC_ERROR_CONNECT] = "NfcConnectError";
|
||||
this.NFC_ERROR_MSG[this.NFC_ERROR_DISCONNECT] = "NfcDisconnectError";
|
||||
this.NFC_ERROR_MSG[this.NFC_ERROR_READ] = "NfcReadError";
|
||||
this.NFC_ERROR_MSG[this.NFC_ERROR_WRITE] = "NfcWriteError";
|
||||
this.NFC_ERROR_MSG[this.NFC_ERROR_INVALID_PARAM] = "NfcInvalidParamError";
|
||||
this.NFC_ERROR_MSG[this.NFC_ERROR_INSUFFICIENT_RESOURCES] = "NfcInsufficentResourcesError";
|
||||
this.NFC_ERROR_MSG[this.NFC_ERROR_SOCKET_CREATION] = "NfcSocketCreationError";
|
||||
this.NFC_ERROR_MSG[this.NFC_ERROR_FAIL_ENABLE_DISCOVERY] = "NfcFailEnableDiscoveryError";
|
||||
this.NFC_ERROR_MSG[this.NFC_ERROR_FAIL_DISABLE_DISCOVERY] = "NfcFailDisableDiscoveryError";
|
||||
this.NFC_ERROR_MSG[this.NFC_ERROR_NOT_INITIALIZED] = "NfcNotInitializedError";
|
||||
this.NFC_ERROR_MSG[this.NFC_ERROR_INITIALIZE_FAIL] = "NfcInitializeFailError";
|
||||
this.NFC_ERROR_MSG[this.NFC_ERROR_DEINITIALIZE_FAIL] = "NfcDeinitializeFailError";
|
||||
this.NFC_ERROR_MSG[this.NFC_ERROR_NOT_SUPPORTED] = "NfcNotSupportedError";
|
||||
this.NFC_ERROR_MSG[this.NFC_ERROR_BAD_SESSION_ID] = "NfcBadSessionIdError";
|
||||
this.NFC_ERROR_MSG[this.NFC_ERROR_FAIL_ENABLE_LOW_POWER_MODE] = "EnableLowPowerModeFail";
|
||||
this.NFC_ERROR_MSG[this.NFC_ERROR_FAIL_DISABLE_LOW_POWER_MODE] = "DisableLowPowerModeFail";
|
||||
this.NFC_ERROR_MSG[this.NFC_GECKO_ERROR_GENERIC_FAILURE] = "NfcGenericFailureError";
|
||||
this.NFC_ERROR_MSG[this.NFC_GECKO_ERROR_P2P_REG_INVALID] = "NfcP2PRegistrationInvalid";
|
||||
this.NFC_ERROR_MSG[this.NFC_GECKO_ERROR_NOT_ENABLED] = "NfcNotEnabledError";
|
||||
this.NFC_ERROR_MSG[this.NFC_GECKO_ERROR_SEND_FILE_FAILED] = "NfcSendFileFailed";
|
||||
this.NFC_ERROR_MSG[this.NFC_GECKO_ERROR_BAD_SESSION_ID] = "NfcBadSessionID";
|
||||
|
||||
// NFC powerlevels must match config PDUs.
|
||||
this.NFC_POWER_LEVEL_UNKNOWN = -1;
|
||||
|
@ -4,6 +4,28 @@
|
||||
|
||||
/* Copyright © 2013 Deutsche Telekom, Inc. */
|
||||
|
||||
enum NfcErrorMessage {
|
||||
"",
|
||||
"IOError",
|
||||
"Timeout",
|
||||
"Busy",
|
||||
"ErrorConnect",
|
||||
"ErrorDisconnect",
|
||||
"ErrorRead",
|
||||
"ErrorWrite",
|
||||
"InvalidParameter",
|
||||
"InsufficientResource",
|
||||
"ErrorSocketCreation",
|
||||
"FailEnableDiscovery",
|
||||
"FailDisableDiscovery",
|
||||
"NotInitialize",
|
||||
"InitializeFail",
|
||||
"DeinitializeFail",
|
||||
"NotSupport",
|
||||
"FailEnableLowPowerMode",
|
||||
"FailDisableLowPowerMode"
|
||||
};
|
||||
|
||||
[NoInterfaceObject]
|
||||
interface MozNFCManager {
|
||||
/**
|
||||
|
@ -22,6 +22,7 @@ dictionary NfcEventOptions
|
||||
DOMString type = "";
|
||||
|
||||
long status;
|
||||
NfcErrorMessage errorMsg;
|
||||
long sessionId;
|
||||
DOMString requestId;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user