From: Piotr Czaja
Date: Mon, 25 May 2015 08:30:07 +0000 (+0200)
Subject: [NFC] add new feature check code for p2p,tag feature
X-Git-Tag: submit/tizen_mobile/20150612.133019^2~2^2~129^2
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9d77928f1b1f16b7d1f95be062bec5ca24686839;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git
[NFC] add new feature check code for p2p,tag feature
Change-Id: I038eaae8763ac5bdf07e61cc72206ee90423bfa2
Signed-off-by: Piotr Czaja
---
diff --git a/src/nfc/nfc_instance.cc b/src/nfc/nfc_instance.cc
index eaad9168..6d2a6788 100644
--- a/src/nfc/nfc_instance.cc
+++ b/src/nfc/nfc_instance.cc
@@ -15,6 +15,7 @@
#include "nfc/defs.h"
#include "nfc/nfc_message_utils.h"
#include "nfc/nfc_util.h"
+#include
namespace extension {
namespace nfc {
@@ -26,6 +27,28 @@ void NFCInstance::RespondAsync(const char* msg) {
PostMessage(msg);
}
+static bool isTagSupported(){
+ LoggerD("Entered");
+ bool supported = true;
+ if (system_info_get_platform_bool(
+ "http://tizen.org/feature/network.nfc.tag", &supported)
+ != SYSTEM_INFO_ERROR_NONE) {
+ LoggerD("Can't check Tag is supported or not");
+ }
+ return supported;
+}
+
+static bool isP2PSupported(){
+ LoggerD("Entered");
+ bool supported = true;
+ if (system_info_get_platform_bool(
+ "http://tizen.org/feature/network.nfc.p2p", &supported)
+ != SYSTEM_INFO_ERROR_NONE) {
+ LoggerD("Can't check Tag is supported or not");
+ }
+ return supported;
+}
+
NFCInstance::NFCInstance() {
using std::placeholders::_1;
using std::placeholders::_2;
@@ -212,6 +235,17 @@ void NFCInstance::ActiveSecureElementGetter(
void NFCInstance::SetTagListener(
const picojson::value& args, picojson::object& out) {
+ bool supported = isTagSupported();
+ if (supported) {
+ SLoggerE("Tag is supported");
+ } else {
+ SLoggerE("Tag is not supported");
+ ReportError(
+ common::PlatformResult(common::ErrorCode::NOT_SUPPORTED_ERR,
+ "Tag is not supported on this device."),
+ &out);
+ return;
+ }
PlatformResult result = NFCAdapter::GetInstance()->SetTagListener();
if (result.IsSuccess()) {
ReportSuccess(out);
@@ -239,6 +273,17 @@ void NFCInstance::PeerIsConnectedGetter(
void NFCInstance::SetPeerListener(
const picojson::value& args, picojson::object& out) {
+ bool supported = isP2PSupported();
+ if (supported) {
+ SLoggerE("P2P is supported");
+ } else {
+ SLoggerE("P2P is not supported");
+ ReportError(
+ common::PlatformResult(common::ErrorCode::NOT_SUPPORTED_ERR,
+ "P2P is not supported on this device."),
+ &out);
+ return;
+ }
PlatformResult result = NFCAdapter::GetInstance()->SetPeerListener();
if (result.IsSuccess()) {
ReportSuccess(out);
@@ -249,12 +294,34 @@ void NFCInstance::SetPeerListener(
void NFCInstance::UnsetTagListener(
const picojson::value& args, picojson::object& out) {
+ bool supported = isTagSupported();
+ if (supported) {
+ SLoggerE("Tag is supported");
+ } else {
+ SLoggerE("Tag is not supported");
+ ReportError(
+ common::PlatformResult(common::ErrorCode::NOT_SUPPORTED_ERR,
+ "Tag is not supported on this device."),
+ &out);
+ return;
+ }
NFCAdapter::GetInstance()->UnsetTagListener();
ReportSuccess(out);
}
void NFCInstance::UnsetPeerListener(
const picojson::value& args, picojson::object& out) {
+ bool supported = isP2PSupported();
+ if (supported) {
+ SLoggerE("P2P is supported");
+ } else {
+ SLoggerE("P2P is not supported");
+ ReportError(
+ common::PlatformResult(common::ErrorCode::NOT_SUPPORTED_ERR,
+ "P2P is not supported on this device."),
+ &out);
+ return;
+ }
PlatformResult result = NFCAdapter::GetInstance()->UnsetPeerListener();
if (result.IsSuccess()) {
ReportSuccess(out);