mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1074611 - pass NDEF info to Content. r=smaug, dimi.
From 03c850ef46ffd4baeb84596fa219e39788eb0571 Mon Sep 17 00:00:00 2001 --- dom/nfc/NfcContentHelper.js | 19 ++++++++++++++--- dom/nfc/gonk/NfcGonkMessage.h | 9 -------- dom/nfc/gonk/NfcMessageHandler.cpp | 8 +++---- dom/nfc/gonk/NfcOptions.h | 10 +++++---- dom/nfc/gonk/NfcService.cpp | 9 ++++++-- dom/nfc/nsINfcContentHelper.idl | 11 +++++++++- dom/nfc/nsNfc.js | 28 +++++++++++++++++++++---- dom/webidl/MozNFCTag.webidl | 43 ++++++++++++++++++++++++++++++++++++++ dom/webidl/NfcOptions.webidl | 5 +++-- 9 files changed, 113 insertions(+), 29 deletions(-)
This commit is contained in:
parent
d949fabcf7
commit
2b650bafcc
@ -359,7 +359,12 @@ NfcContentHelper.prototype = {
|
||||
this.eventTarget.notifyPeerLost(result.sessionToken);
|
||||
break;
|
||||
case NFC.TAG_EVENT_FOUND:
|
||||
let event = new NfcTagEvent(result.techList);
|
||||
let event = new NfcTagEvent(result.techList,
|
||||
result.tagType,
|
||||
result.maxNDEFSize,
|
||||
result.isReadOnly,
|
||||
result.isFormatable);
|
||||
|
||||
this.eventTarget.notifyTagFound(result.sessionToken, event, result.records);
|
||||
break;
|
||||
case NFC.TAG_EVENT_LOST:
|
||||
@ -413,13 +418,21 @@ NfcContentHelper.prototype = {
|
||||
},
|
||||
};
|
||||
|
||||
function NfcTagEvent(techList) {
|
||||
function NfcTagEvent(techList, tagType, maxNDEFSize, isReadOnly, isFormatable) {
|
||||
this.techList = techList;
|
||||
this.tagType = tagType;
|
||||
this.maxNDEFSize = maxNDEFSize;
|
||||
this.isReadOnly = isReadOnly;
|
||||
this.isFormatable = isFormatable;
|
||||
}
|
||||
NfcTagEvent.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsINfcTagEvent]),
|
||||
|
||||
techList: null
|
||||
techList: null,
|
||||
tagType: null,
|
||||
maxNDEFSize: 0,
|
||||
isReadOnly: false,
|
||||
isFormatable: false
|
||||
};
|
||||
|
||||
if (NFC_ENABLED) {
|
||||
|
@ -68,15 +68,6 @@ enum SecureElementOrigin {
|
||||
OriginEndGuard = 3
|
||||
};
|
||||
|
||||
enum NdefType {
|
||||
UNKNOWN = -1,
|
||||
TYPE1_TAG = 0,
|
||||
TYPE2_TAG = 1,
|
||||
TYPE3_TAG = 2,
|
||||
TYPE4_TAG = 3,
|
||||
MIFARE_CLASSIC_TAG = 4
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // NfcGonkMessage_h
|
||||
|
@ -263,10 +263,10 @@ NfcMessageHandler::TechDiscoveredNotification(const Parcel& aParcel, EventOption
|
||||
|
||||
int32_t ndefInfo = aParcel.readInt32();
|
||||
if (ndefInfo) {
|
||||
NdefType type = static_cast<NdefType>(aParcel.readInt32());
|
||||
int32_t maxSupportLength = aParcel.readInt32();
|
||||
int32_t isReadOnly = aParcel.readInt32();
|
||||
int32_t isFormatable = aParcel.readInt32();
|
||||
aOptions.mTagType = aParcel.readInt32();
|
||||
aOptions.mMaxNDEFSize = aParcel.readInt32();
|
||||
aOptions.mIsReadOnly = aParcel.readInt32();
|
||||
aOptions.mIsFormatable = aParcel.readInt32();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -86,8 +86,9 @@ struct EventOptions
|
||||
{
|
||||
EventOptions()
|
||||
: 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)
|
||||
mMajorVersion(-1), mMinorVersion(-1),
|
||||
mTagType(-1), mMaxNDEFSize(-1), mIsReadOnly(-1), mIsFormatable(-1), mPowerLevel(-1),
|
||||
mOriginType(-1), mOriginIndex(-1)
|
||||
{}
|
||||
|
||||
nsString mType;
|
||||
@ -99,9 +100,10 @@ struct EventOptions
|
||||
int32_t mMinorVersion;
|
||||
nsTArray<uint8_t> mTechList;
|
||||
nsTArray<NDEFRecordStruct> mRecords;
|
||||
int32_t mTagType;
|
||||
int32_t mMaxNDEFSize;
|
||||
int32_t mIsReadOnly;
|
||||
int32_t mCanBeMadeReadOnly;
|
||||
int32_t mMaxSupportedLength;
|
||||
int32_t mIsFormatable;
|
||||
int32_t mPowerLevel;
|
||||
|
||||
int32_t mOriginType;
|
||||
|
@ -157,9 +157,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
if (mEvent.mTagType != -1) {
|
||||
event.mTagType.Construct();
|
||||
event.mTagType.Value() = static_cast<NFCTagType>(mEvent.mTagType);
|
||||
}
|
||||
|
||||
COPY_OPT_FIELD(mMaxNDEFSize, -1)
|
||||
COPY_OPT_FIELD(mIsReadOnly, -1)
|
||||
COPY_OPT_FIELD(mCanBeMadeReadOnly, -1)
|
||||
COPY_OPT_FIELD(mMaxSupportedLength, -1)
|
||||
COPY_OPT_FIELD(mIsFormatable, -1)
|
||||
|
||||
// HCI Event Transaction parameters.
|
||||
if (mEvent.mOriginType != -1) {
|
||||
|
@ -7,10 +7,19 @@
|
||||
|
||||
interface nsIVariant;
|
||||
|
||||
[scriptable, uuid(44eb02f4-6eba-4c12-8ed1-c142513776c9)]
|
||||
[scriptable, uuid(9b43bdda-52f4-4712-b28c-ad7cba736e14)]
|
||||
interface nsINfcTagEvent : nsISupports
|
||||
{
|
||||
readonly attribute nsIVariant techList;
|
||||
|
||||
// one of NFCTagType defined in MozNFCTag.webidl.
|
||||
readonly attribute DOMString tagType;
|
||||
|
||||
readonly attribute long maxNDEFSize;
|
||||
|
||||
readonly attribute boolean isReadOnly;
|
||||
|
||||
readonly attribute boolean isFormatable;
|
||||
};
|
||||
|
||||
[scriptable, uuid(2074503e-f590-4017-a45e-85d3ca766f41)]
|
||||
|
@ -25,17 +25,37 @@ XPCOMUtils.defineLazyServiceGetter(this,
|
||||
|
||||
/**
|
||||
* NFCTag
|
||||
*
|
||||
* @param window global window object.
|
||||
* @param sessionToken session token received from parent process.
|
||||
* @parem event type of nsINfcTagEvent received from parent process.
|
||||
*/
|
||||
function MozNFCTag(aWindow, aSessionToken) {
|
||||
function MozNFCTag(window, sessionToken, event) {
|
||||
debug("In MozNFCTag Constructor");
|
||||
this._nfcContentHelper = Cc["@mozilla.org/nfc/content-helper;1"]
|
||||
.getService(Ci.nsINfcContentHelper);
|
||||
this._window = aWindow;
|
||||
this.session = aSessionToken;
|
||||
this._window = window;
|
||||
this.session = sessionToken;
|
||||
this.techList = event.techList;
|
||||
this.type = event.tagType || null;
|
||||
this.maxNDEFSize = event.maxNDEFSize || null;
|
||||
this.isReadOnly = event.isReadOnly || null;
|
||||
this.isFormatable = event.isFormatable || null;
|
||||
this.canBeMadeReadOnly = this.type ?
|
||||
(this.type == "type1" || this.type == "type2" ||
|
||||
this.type == "mifare_classic") :
|
||||
null;
|
||||
}
|
||||
MozNFCTag.prototype = {
|
||||
_nfcContentHelper: null,
|
||||
_window: null,
|
||||
session: null,
|
||||
techList: null,
|
||||
type: null,
|
||||
maxNDEFSize: 0,
|
||||
isReadOnly: false,
|
||||
isFormatable: false,
|
||||
canBeMadeReadOnly: false,
|
||||
|
||||
// NFCTag interface:
|
||||
readNDEF: function readNDEF() {
|
||||
@ -219,7 +239,7 @@ mozNfc.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
let tag = new MozNFCTag(this._window, sessionToken);
|
||||
let tag = new MozNFCTag(this._window, sessionToken, event);
|
||||
let tagContentObj = this._window.MozNFCTag._create(this._window, tag);
|
||||
|
||||
let length = records ? records.length : 0;
|
||||
|
@ -21,8 +21,51 @@ enum NFCTechType {
|
||||
"NFC_BARCODE"
|
||||
};
|
||||
|
||||
/**
|
||||
* The enumeration of the types of the tag, the type of a tag could be either
|
||||
* one of those types defined in NFC Forum (type1 ~ type 4), or it could be a
|
||||
* NXP-specific tag, like Mifare Classic.
|
||||
*/
|
||||
enum NFCTagType {
|
||||
"type1",
|
||||
"type2",
|
||||
"type3",
|
||||
"type4",
|
||||
"mifare_classic"
|
||||
};
|
||||
|
||||
[JSImplementation="@mozilla.org/nfc/NFCTag;1", AvailableIn="CertifiedApps"]
|
||||
interface MozNFCTag {
|
||||
/**
|
||||
* The supported technologies of this tag, null if unknown.
|
||||
*/
|
||||
[Cached, Pure] readonly attribute sequence<NFCTechType>? techList;
|
||||
|
||||
/**
|
||||
* The type of this tag, null if unknown.
|
||||
*/
|
||||
readonly attribute NFCTagType? type;
|
||||
|
||||
/**
|
||||
* The maximum size of the NDEF supported on this tag, null if unknown.
|
||||
*/
|
||||
readonly attribute long? maxNDEFSize;
|
||||
|
||||
/**
|
||||
* Indicate if this tag is Read-Only, null if unknown.
|
||||
*/
|
||||
readonly attribute boolean? isReadOnly;
|
||||
|
||||
/**
|
||||
* Indicate if this tag is formatable, null if unknown.
|
||||
*/
|
||||
readonly attribute boolean? isFormatable;
|
||||
|
||||
/**
|
||||
* Indicate if this tag could be made Read-Only, null if unknown.
|
||||
*/
|
||||
readonly attribute boolean? canBeMadeReadOnly;
|
||||
|
||||
DOMRequest readNDEF();
|
||||
DOMRequest writeNDEF(sequence<MozNDEFRecord> records);
|
||||
DOMRequest makeReadOnlyNDEF();
|
||||
|
@ -32,9 +32,10 @@ dictionary NfcEventOptions
|
||||
sequence<NFCTechType> techList;
|
||||
sequence<MozNDEFRecordOptions> records;
|
||||
|
||||
NFCTagType tagType;
|
||||
long maxNDEFSize;
|
||||
boolean isReadOnly;
|
||||
boolean canBeMadeReadOnly;
|
||||
long maxSupportedLength;
|
||||
boolean isFormatable;
|
||||
|
||||
long powerLevel;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user