}
NFCManager.prototype.getDefaultAdapter = function() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_COMMON);
+
// First check NFC suppor on C++ level
var result = native_.callSync(
'NFCManager_getDefaultAdapter',
};
NFCManager.prototype.setExclusiveMode = function() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_COMMON);
var args = validator_.validateArgs(arguments, [
{name: 'exclusiveMode', type: types_.BOOLEAN}
}
function cardEmulationModeGetter() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_CARDEMULATION);
+
var result = native_.callSync('NFCAdapter_cardEmulationModeGetter');
if (native_.isFailure(result)) {
}
function cardEmulationModeSetter(cem) {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_CARDEMULATION);
var args = validator_.validateArgs(arguments, [
{name: 'emulationMode', type: types_.STRING}
}
function activeSecureElementGetter() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_CARDEMULATION);
var result = native_.callSync('NFCAdapter_activeSecureElementGetter');
}
function activeSecureElementSetter(ase) {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_CARDEMULATION);
var args = validator_.validateArgs(arguments, [
{name: 'secureElement', type: types_.STRING}
}
NFCAdapter.prototype.setPowered = function() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_ADMIN);
+
var args = validator_.validateArgs(arguments, [
{
name: 'powered',
};
NFCAdapter.prototype.setTagListener = function() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_TAG);
var args = validator_.validateArgs(arguments, [
{
};
NFCAdapter.prototype.setPeerListener = function() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_P2P);
+
var args = validator_.validateArgs(arguments, [
{
name: 'listener',
};
NFCAdapter.prototype.unsetTagListener = function() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_TAG);
native_.removeListener(TAG_LISTENER);
};
NFCAdapter.prototype.unsetPeerListener = function() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_P2P);
+
native_.removeListener(PEER_LISTENER);
var result = native_.callSync('NFCAdapter_unsetPeerListener');
};
NFCAdapter.prototype.addCardEmulationModeChangeListener = function() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_CARDEMULATION);
+
var args = validator_.validateArgs(arguments, [
{
name: 'callback',
};
NFCAdapter.prototype.removeCardEmulationModeChangeListener = function() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_CARDEMULATION);
+
var args = validator_.validateArgs(arguments, [
{
name: 'listenerId',
};
NFCAdapter.prototype.addTransactionEventListener = function() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_CARDEMULATION);
+
var args = validator_.validateArgs(arguments, [
{
name: 'type',
};
NFCAdapter.prototype.removeTransactionEventListener = function() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_CARDEMULATION);
+
var args = validator_.validateArgs(arguments, [
{
name: 'watchId',
};
NFCAdapter.prototype.addActiveSecureElementChangeListener = function() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_CARDEMULATION);
+
var args = validator_.validateArgs(arguments, [
{
name: 'callback',
};
NFCAdapter.prototype.removeActiveSecureElementChangeListener = function() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_CARDEMULATION);
+
var args = validator_.validateArgs(arguments, [
{
name: 'listenerId',
};
NFCAdapter.prototype.getCachedMessage = function() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_COMMON);
+
var result = native_.callSync('NFCAdapter_getCachedMessage');
if (native_.isFailure(result)) {
};
NFCAdapter.prototype.setExclusiveModeForTransaction = function() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_CARDEMULATION);
var args = validator_.validateArgs(arguments, [
{
// Function defined here (not outside Tag "constructor"
// because access to internal _my_id variable is needed)
NFCTag.prototype.readNDEF = function() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_TAG);
var args = validator_.validateArgs(arguments, [
{
};
NFCTag.prototype.writeNDEF = function() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_TAG);
+
var args = validator_.validateArgs(arguments, [
{
name: 'message',
};
NFCTag.prototype.transceive = function() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_TAG);
+
var args = validator_.validateArgs(arguments, [
{
name: 'data',
}
NFCPeer.prototype.sendNDEF = function() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_P2P);
+
var args = validator_.validateArgs(arguments, [
{
name: 'message',
}
NFCPeer.prototype.setReceiveNDEFListener = function() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_P2P);
+
var args = validator_.validateArgs(arguments, [
{
name: 'listener',
};
NFCPeer.prototype.unsetReceiveNDEFListener = function() {
+ xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NFC_P2P);
+
native_.removeListener(RECEIVE_NDEF_LISTENER);
var result = native_.callSync('NFCPeer_unsetReceiveNDEFListener', {'id' : this._my_id});
using namespace common;
using namespace extension::nfc;
-namespace {
-
-const std::string kPrivilegeNfcAdmin = "http://tizen.org/privilege/nfc.admin";
-const std::string kPrivilegeNfcCardEmulation = "http://tizen.org/privilege/nfc.cardemulation";
-const std::string kPrivilegeNfcCommon = "http://tizen.org/privilege/nfc.common";
-const std::string kPrivilegeNfcP2P = "http://tizen.org/privilege/nfc.p2p";
-const std::string kPrivilegeNfcTag = "http://tizen.org/privilege/nfc.tag";
-
-} // namespace
-
void NFCInstance::RespondAsync(const char* msg) {
PostMessage(msg);
}
// Here there's only check for NFC support
LoggerD("Entered");
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcCommon, &out);
-
if(!nfc_manager_is_supported()) {
LoggerE("NFC manager is not supported");
// According to API reference only Security and Unknown
void NFCInstance::SetExclusiveMode(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcCommon, &out);
-
CHECK_EXIST(args, "exclusiveMode", out);
bool exmode = args.get("exclusiveMode").get<bool>();
//TODO(g.rynkowski): Rewrite to asynchronous approach
void NFCInstance::SetPowered(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcAdmin, &out);
-
PlatformResult result = NFCAdapter::GetInstance()->SetPowered(args);
if (result.IsSuccess()) {
ReportSuccess(out);
void NFCInstance::CardEmulationModeSetter(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcCardEmulation, &out);
-
CHECK_EXIST(args, "emulationMode", out);
std::string mode = args.get("emulationMode").get<std::string>();
PlatformResult result = NFCAdapter::GetInstance()->SetCardEmulationMode(mode);
void NFCInstance::CardEmulationModeGetter(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcCardEmulation, &out);
-
std::string mode = "";
PlatformResult result = NFCAdapter::GetInstance()->GetCardEmulationMode(&mode);
if (result.IsSuccess()) {
void NFCInstance::ActiveSecureElementSetter(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcCardEmulation, &out);
-
CHECK_EXIST(args, "secureElement", out);
std::string ase = args.get("secureElement").get<std::string>();
PlatformResult result = NFCAdapter::GetInstance()->SetActiveSecureElement(ase);
void NFCInstance::ActiveSecureElementGetter(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcCardEmulation, &out);
-
std::string ase = "";
PlatformResult result = NFCAdapter::GetInstance()->GetActiveSecureElement(&ase);
if (result.IsSuccess()) {
void NFCInstance::SetTagListener(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcTag, &out);
-
PlatformResult result = NFCAdapter::GetInstance()->SetTagListener();
if (result.IsSuccess()) {
ReportSuccess(out);
void NFCInstance::SetPeerListener(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcP2P, &out);
-
PlatformResult result = NFCAdapter::GetInstance()->SetPeerListener();
if (result.IsSuccess()) {
ReportSuccess(out);
void NFCInstance::UnsetTagListener(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcTag, &out);
-
NFCAdapter::GetInstance()->UnsetTagListener();
ReportSuccess(out);
}
void NFCInstance::UnsetPeerListener(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcP2P, &out);
-
PlatformResult result = NFCAdapter::GetInstance()->UnsetPeerListener();
if (result.IsSuccess()) {
ReportSuccess(out);
void NFCInstance::AddCardEmulationModeChangeListener(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcCardEmulation, &out);
-
PlatformResult result = NFCAdapter::GetInstance()->AddCardEmulationModeChangeListener();
if (result.IsSuccess()) {
ReportSuccess(out);
void NFCInstance::RemoveCardEmulationModeChangeListener(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcCardEmulation, &out);
-
PlatformResult result = NFCAdapter::GetInstance()->RemoveCardEmulationModeChangeListener();
if (result.IsSuccess()) {
ReportSuccess(out);
void NFCInstance::AddTransactionEventListener(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcCardEmulation, &out);
-
PlatformResult result = NFCAdapter::GetInstance()->AddTransactionEventListener(args);
if (result.IsSuccess()) {
ReportSuccess(out);
void NFCInstance::RemoveTransactionEventListener(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcCardEmulation, &out);
-
PlatformResult result = NFCAdapter::GetInstance()->RemoveTransactionEventListener(args);
if (result.IsSuccess()) {
ReportSuccess(out);
void NFCInstance::AddActiveSecureElementChangeListener(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcCardEmulation, &out);
-
PlatformResult result = NFCAdapter::GetInstance()->AddActiveSecureElementChangeListener();
if (result.IsSuccess()) {
ReportSuccess(out);
void NFCInstance::RemoveActiveSecureElementChangeListener(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcCardEmulation, &out);
-
PlatformResult result = NFCAdapter::GetInstance()->RemoveActiveSecureElementChangeListener();
if (result.IsSuccess()) {
ReportSuccess(out);
void NFCInstance::GetCachedMessage(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcCommon, &out);
-
picojson::value result = picojson::value(picojson::object());
picojson::object& result_obj = result.get<picojson::object>();
void NFCInstance::SetExclusiveModeForTransaction(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcCardEmulation, &out);
-
CHECK_EXIST(args, "transactionMode", out);
bool transaction_mode = args.get("transactionMode").get<bool>();
//TODO(g.rynkowski): Rewrite to asynchronous approach
void NFCInstance::ReadNDEF(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcTag, &out);
-
CHECK_EXIST(args, "id", out);
int tag_id = static_cast<int>(args.get("id").get<double>());
//TODO(g.rynkowski): Rewrite to asynchronous approach
void NFCInstance::WriteNDEF(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcTag, &out);
-
CHECK_EXIST(args, "id", out);
int tag_id = static_cast<int>(args.get("id").get<double>());
const picojson::value& args, picojson::object& out) {
LoggerD("Entered");
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcTag, &out);
-
CHECK_EXIST(args, "id", out);
int tag_id = static_cast<int>(args.get("id").get<double>());
LoggerD("Tag id: %d", tag_id);
void NFCInstance::SetReceiveNDEFListener(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcP2P, &out);
-
CHECK_EXIST(args, "id", out);
int peer_id = (int)args.get("id").get<double>();
void NFCInstance::UnsetReceiveNDEFListener(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcP2P, &out);
-
CHECK_EXIST(args, "id", out);
int peer_id = (int)args.get("id").get<double>();
//TODO(g.rynkowski): Rewrite to asynchronous approach
void NFCInstance::SendNDEF(
const picojson::value& args, picojson::object& out) {
- CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcP2P, &out);
-
CHECK_EXIST(args, "id", out);
int peer_id = static_cast<int>(args.get("id").get<double>());