2014-02-19 07:14:22 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef NfcOptions_h
|
|
|
|
#define NfcOptions_h
|
|
|
|
|
|
|
|
#include "mozilla/dom/NfcOptionsBinding.h"
|
2014-08-20 11:50:29 +00:00
|
|
|
#include "mozilla/dom/MozNDEFRecordBinding.h"
|
2014-02-19 07:14:22 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
struct NDEFRecordStruct
|
|
|
|
{
|
2014-08-20 11:50:29 +00:00
|
|
|
dom::TNF mTnf;
|
2014-02-19 07:14:22 +00:00
|
|
|
nsTArray<uint8_t> mType;
|
|
|
|
nsTArray<uint8_t> mId;
|
|
|
|
nsTArray<uint8_t> mPayload;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CommandOptions
|
|
|
|
{
|
|
|
|
CommandOptions(const mozilla::dom::NfcCommandOptions& aOther) {
|
|
|
|
|
|
|
|
#define COPY_FIELD(prop) prop = aOther.prop;
|
|
|
|
|
|
|
|
#define COPY_OPT_FIELD(prop, defaultValue) \
|
|
|
|
if (aOther.prop.WasPassed()) { \
|
|
|
|
prop = aOther.prop.Value(); \
|
|
|
|
} else { \
|
|
|
|
prop = defaultValue; \
|
|
|
|
}
|
|
|
|
|
|
|
|
COPY_FIELD(mType)
|
|
|
|
COPY_FIELD(mRequestId)
|
|
|
|
COPY_OPT_FIELD(mSessionId, 0)
|
|
|
|
COPY_OPT_FIELD(mPowerLevel, 0)
|
|
|
|
COPY_OPT_FIELD(mTechType, 0)
|
|
|
|
|
|
|
|
if (!aOther.mRecords.WasPassed()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-18 09:31:18 +00:00
|
|
|
mozilla::dom::Sequence<mozilla::dom::MozNDEFRecordOptions> const & currentValue = aOther.mRecords.InternalValue();
|
2014-02-19 07:14:22 +00:00
|
|
|
int count = currentValue.Length();
|
2014-08-18 09:31:18 +00:00
|
|
|
for (int32_t i = 0; i < count; i++) {
|
2014-02-19 07:14:22 +00:00
|
|
|
NDEFRecordStruct record;
|
2014-08-18 09:31:18 +00:00
|
|
|
record.mTnf = currentValue[i].mTnf;
|
2014-02-19 07:14:22 +00:00
|
|
|
|
|
|
|
if (currentValue[i].mType.WasPassed()) {
|
2014-08-18 09:31:18 +00:00
|
|
|
const dom::Uint8Array& type = currentValue[i].mType.Value();
|
|
|
|
type.ComputeLengthAndData();
|
|
|
|
record.mType.AppendElements(type.Data(), type.Length());
|
2014-02-19 07:14:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (currentValue[i].mId.WasPassed()) {
|
2014-08-18 09:31:18 +00:00
|
|
|
const dom::Uint8Array& id = currentValue[i].mId.Value();
|
|
|
|
id.ComputeLengthAndData();
|
|
|
|
record.mId.AppendElements(id.Data(), id.Length());
|
2014-02-19 07:14:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (currentValue[i].mPayload.WasPassed()) {
|
2014-08-18 09:31:18 +00:00
|
|
|
const dom::Uint8Array& payload = currentValue[i].mPayload.Value();
|
|
|
|
payload.ComputeLengthAndData();
|
|
|
|
record.mPayload.AppendElements(payload.Data(), payload.Length());
|
2014-02-19 07:14:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mRecords.AppendElement(record);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef COPY_FIELD
|
|
|
|
#undef COPY_OPT_FIELD
|
|
|
|
}
|
|
|
|
|
|
|
|
nsString mType;
|
|
|
|
int32_t mSessionId;
|
|
|
|
nsString mRequestId;
|
|
|
|
int32_t mPowerLevel;
|
|
|
|
int32_t mTechType;
|
|
|
|
nsTArray<NDEFRecordStruct> mRecords;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct EventOptions
|
|
|
|
{
|
|
|
|
EventOptions()
|
|
|
|
: mType(EmptyString()), mStatus(-1), mSessionId(-1), mRequestId(EmptyString()), mMajorVersion(-1), mMinorVersion(-1),
|
2014-09-03 10:09:43 +00:00
|
|
|
mIsReadOnly(-1), mCanBeMadeReadOnly(-1), mMaxSupportedLength(-1), mPowerLevel(-1),
|
2014-08-27 12:21:00 +00:00
|
|
|
mOriginType(-1), mOriginIndex(-1)
|
2014-02-19 07:14:22 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
nsString mType;
|
|
|
|
int32_t mStatus;
|
|
|
|
int32_t mSessionId;
|
|
|
|
nsString mRequestId;
|
|
|
|
int32_t mMajorVersion;
|
|
|
|
int32_t mMinorVersion;
|
|
|
|
nsTArray<uint8_t> mTechList;
|
|
|
|
nsTArray<NDEFRecordStruct> mRecords;
|
|
|
|
int32_t mIsReadOnly;
|
|
|
|
int32_t mCanBeMadeReadOnly;
|
|
|
|
int32_t mMaxSupportedLength;
|
|
|
|
int32_t mPowerLevel;
|
2014-08-27 12:21:00 +00:00
|
|
|
|
|
|
|
int32_t mOriginType;
|
|
|
|
int32_t mOriginIndex;
|
|
|
|
nsTArray<uint8_t> mAid;
|
|
|
|
nsTArray<uint8_t> mPayload;
|
2014-02-19 07:14:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|