m_is_transaction_ese_listener_set(false),
m_is_transaction_uicc_listener_set(false),
m_is_peer_listener_set(false),
+ m_is_tag_listener_set(false),
m_latest_peer_id(0),
m_peer_handle(NULL),
m_is_ndef_listener_set(false),
picojson::object& obj = event.get<picojson::object>();
tools::ReportSuccess(obj);
- string result;
+ string result = "";
switch (se_event) {
case NFC_SE_EVENT_SE_TYPE_CHANGED:
- result = NFCAdapter::GetInstance()->GetActiveSecureElement();
+ NFCAdapter::GetInstance()->GetActiveSecureElement(&result);
obj.insert(make_pair(LISTENER_ID, ACTIVE_SECURE_ELEMENT_CHANGED));
break;
case NFC_SE_EVENT_CARD_EMULATION_CHANGED:
- result = NFCAdapter::GetInstance()->GetCardEmulationMode();
+ NFCAdapter::GetInstance()->GetCardEmulationMode(&result);
obj.insert(make_pair(LISTENER_ID, CARD_EMULATION_MODE_CHANGED));
break;
default:
}
-std::string NFCAdapter::GetCardEmulationMode() {
+PlatformResult NFCAdapter::GetCardEmulationMode(std::string *mode) {
LoggerD("Entered");
- nfc_se_card_emulation_mode_type_e mode;
- int ret = nfc_se_get_card_emulation_mode(&mode);
+ nfc_se_card_emulation_mode_type_e card_mode;
+ int ret = nfc_se_get_card_emulation_mode(&card_mode);
if (NFC_ERROR_NONE != ret) {
LoggerE("Failed to get card emulation mode %d", ret);
- NFCUtil::throwNFCException(ret, "Failed to get card emulation mode");
+ return NFCUtil::CodeToResult(ret, "Failed to get card emulation mode");
}
- return NFCUtil::toStringCardEmulationMode(mode);
+ return NFCUtil::ToStringCardEmulationMode(card_mode, mode);
}
-void NFCAdapter::SetCardEmulationMode(std::string mode) {
+PlatformResult NFCAdapter::SetCardEmulationMode(std::string mode) {
LoggerD("Entered");
NFCUtil::toCardEmulationMode(mode);
LoggerD("Card emulation mode value: %x", (int)new_mode);
- std::string current_mode = GetCardEmulationMode();
+ std::string current_mode = "";
+ PlatformResult result = GetCardEmulationMode(¤t_mode);
+
+ if (result.IsError()) {
+ return result;
+ }
if (mode.compare(current_mode) == 0) {
LoggerD("Card emulation mode already set to given value (%s)",
mode.c_str());
- return;
+ return PlatformResult(ErrorCode::NO_ERROR);
}
int ret = NFC_ERROR_NONE;
break;
default:
// Should never go here - in case of invalid mode
- // exception is thrown from convertert few lines above
+ // platformResult is returned from convertert few lines above
LoggerE("Invalid card emulation mode: %s", mode.c_str());
- throw InvalidValuesException("Invalid card emulation mode given");
+ return PlatformResult(ErrorCode::INVALID_VALUES_ERR,
+ "Invalid card emulation mode given.");
}
if (NFC_ERROR_NONE != ret) {
LoggerE("Failed to set card emulation mode %d", ret);
- NFCUtil::throwNFCException(ret, "Failed to set card emulation mode");
+ return NFCUtil::CodeToResult(ret, "Failed to set card emulation mode");
}
+ return PlatformResult(ErrorCode::NO_ERROR);
}
-std::string NFCAdapter::GetActiveSecureElement() {
+PlatformResult NFCAdapter::GetActiveSecureElement(std::string *type) {
LoggerD("Entered");
- nfc_se_type_e type;
- int ret = nfc_manager_get_se_type(&type);
+ nfc_se_type_e se_type = NFC_SE_TYPE_DISABLE;
+ int ret = nfc_manager_get_se_type(&se_type);
if (NFC_ERROR_NONE != ret) {
LoggerE("Failed to get active secure element type: %d", ret);
- NFCUtil::throwNFCException(ret, "Unable to get active secure element type");
+ return NFCUtil::CodeToResult(ret, "Unable to get active secure element type");
}
- return NFCUtil::toStringSecureElementType(type);
+ return NFCUtil::ToStringSecureElementType(se_type, type);
}
-void NFCAdapter::SetActiveSecureElement(std::string element) {
+PlatformResult NFCAdapter::SetActiveSecureElement(std::string element) {
LoggerD("Entered");
// if given value is not correct secure element type then
// there's no sense to get current value for comparison
- nfc_se_type_e new_type = NFCUtil::toSecureElementType(element);
+ nfc_se_type_e new_type = NFC_SE_TYPE_DISABLE;
+ PlatformResult result = NFCUtil::ToSecureElementType(element, &new_type);
+
+ if (result.IsError()) {
+ return result;
+ }
LoggerD("Secure element type value: %x", (int)new_type);
- std::string current_type = GetActiveSecureElement();
+ std::string current_type = "";
+ result = GetActiveSecureElement(¤t_type);
+
+ if (result.IsError()) {
+ return result;
+ }
+
if (element == current_type) {
LoggerD("Active secure element type already set to: %s", element.c_str());
- return;
+ return PlatformResult(ErrorCode::NO_ERROR);
}
int ret = nfc_manager_set_se_type(new_type);
if (NFC_ERROR_NONE != ret) {
LoggerE("Failed to set active secure element type: %d", ret);
- NFCUtil::throwNFCException(ret,
+ return NFCUtil::CodeToResult(ret,
"Unable to set active secure element type");
}
+ return PlatformResult(ErrorCode::NO_ERROR);
}
-void NFCAdapter::SetExclusiveModeForTransaction(bool exmode) {
+PlatformResult NFCAdapter::SetExclusiveModeForTransaction(bool exmode) {
LoggerD("Entered");
if (NFC_ERROR_NONE != ret) {
LoggerE("Failed to set exclusive mode for transaction: %d", ret);
- NFCUtil::throwNFCException(ret,
+ return NFCUtil::CodeToResult(ret,
"Setting exclusive mode for transaction failed.");
}
+ return PlatformResult(ErrorCode::NO_ERROR);
}
-void NFCAdapter::AddCardEmulationModeChangeListener() {
+PlatformResult NFCAdapter::AddCardEmulationModeChangeListener() {
if (!m_is_listener_set) {
int ret = nfc_manager_set_se_event_cb(se_event_callback, NULL);
if (NFC_ERROR_NONE != ret) {
LOGE("AddCardEmulationModeChangeListener failed: %d", ret);
- NFCUtil::throwNFCException(ret,
+ return NFCUtil::CodeToResult(ret,
NFCUtil::getNFCErrorMessage(ret).c_str());
}
}
m_is_listener_set = true;
+ return PlatformResult(ErrorCode::NO_ERROR);
}
-void NFCAdapter::RemoveCardEmulationModeChangeListener() {
+PlatformResult NFCAdapter::RemoveCardEmulationModeChangeListener() {
if (!nfc_manager_is_supported()) {
- throw NotSupportedException("NFC Not Supported");
+ LOGE("NFC Not Supported");
+ return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "NFC Not Supported");
}
if (m_is_listener_set) {
nfc_manager_unset_se_event_cb();
}
m_is_listener_set = false;
+ return PlatformResult(ErrorCode::NO_ERROR);
}
-void NFCAdapter::AddTransactionEventListener(const picojson::value& args) {
+PlatformResult NFCAdapter::AddTransactionEventListener(const picojson::value& args) {
- nfc_se_type_e se_type = NFCUtil::toSecureElementType(
- args.get("type").get<string>());
+ nfc_se_type_e se_type = NFC_SE_TYPE_DISABLE;
+ PlatformResult result = NFCUtil::ToSecureElementType(
+ args.get("type").get<string>(), &se_type);
+ if (result.IsError()) {
+ return result;
+ }
int ret = NFC_ERROR_NONE;
if (NFC_SE_TYPE_ESE == se_type) {
if (NFC_ERROR_NONE != ret) {
LOGE("AddTransactionEventListener failed: %d", ret);
- NFCUtil::throwNFCException(ret,
+ return NFCUtil::CodeToResult(ret,
NFCUtil::getNFCErrorMessage(ret).c_str());
}
+ return PlatformResult(ErrorCode::NO_ERROR);
}
-void NFCAdapter::RemoveTransactionEventListener(const picojson::value& args) {
+PlatformResult NFCAdapter::RemoveTransactionEventListener(const picojson::value& args) {
- nfc_se_type_e se_type = NFCUtil::toSecureElementType(
- args.get("type").get<string>());
+ nfc_se_type_e se_type = NFC_SE_TYPE_DISABLE;
+ PlatformResult result = NFCUtil::ToSecureElementType(
+ args.get("type").get<string>(), &se_type);
+ if (result.IsError()) {
+ return result;
+ }
nfc_manager_unset_se_transaction_event_cb(se_type);
} else {
m_is_transaction_uicc_listener_set = false;
}
+ return PlatformResult(ErrorCode::NO_ERROR);
}
-void NFCAdapter::AddActiveSecureElementChangeListener() {
+PlatformResult NFCAdapter::AddActiveSecureElementChangeListener() {
if (!m_is_listener_set) {
int ret = nfc_manager_set_se_event_cb(se_event_callback, NULL);
if (NFC_ERROR_NONE != ret) {
LOGE("AddActiveSecureElementChangeListener failed: %d", ret);
- NFCUtil::throwNFCException(ret,
+ return NFCUtil::CodeToResult(ret,
NFCUtil::getNFCErrorMessage(ret).c_str());
}
}
m_is_listener_set = true;
+ return PlatformResult(ErrorCode::NO_ERROR);
}
-void NFCAdapter::RemoveActiveSecureElementChangeListener() {
+PlatformResult NFCAdapter::RemoveActiveSecureElementChangeListener() {
if (!nfc_manager_is_supported()) {
- throw NotSupportedException("NFC Not Supported");
+ LOGE("NFC Not Supported");
+ return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "NFC Not Supported");
}
if (m_is_listener_set) {
nfc_manager_unset_se_event_cb();
}
m_is_listener_set = false;
+ return PlatformResult(ErrorCode::NO_ERROR);
}
void NFCAdapter::SetPeerHandle(nfc_p2p_target_h handle) {
m_latest_peer_id++;
}
-PlatformResult NFCAdapter::PeerIsConnectedGetter(int peer_id, bool &state) {
+PlatformResult NFCAdapter::PeerIsConnectedGetter(int peer_id, bool *state) {
if (m_latest_peer_id != peer_id || !m_peer_handle) {
- state = false;
+ *state = false;
return PlatformResult(ErrorCode::NO_ERROR);
}
return NFCUtil::CodeToResult(ret, "Failed to get connected target.");
}
- state = (m_peer_handle == handle);
+ *state = (m_peer_handle == handle);
return PlatformResult(ErrorCode::NO_ERROR);
}
//check if peer object is still connected
bool is_connected = false;
- PlatformResult result = PeerIsConnectedGetter(peer_id, is_connected);
+ PlatformResult result = PeerIsConnectedGetter(peer_id, &is_connected);
if (result.IsError()) {
return result;
}
//check if peer object is still connected
bool is_connected = false;
- PlatformResult result = PeerIsConnectedGetter(peer_id, is_connected);
+ PlatformResult result = PeerIsConnectedGetter(peer_id, &is_connected);
if (result.IsError()) {
return result;
}
PlatformResult NFCAdapter::sendNDEF(int peer_id, const picojson::value& args) {
bool is_connected = false;
- PlatformResult result = PeerIsConnectedGetter(peer_id, is_connected);
+ PlatformResult result = PeerIsConnectedGetter(peer_id, &is_connected);
if (result.IsError()) {
return result;
}
common::PlatformResult SetPowered(const picojson::value& args);
// cardEmulationMode getter and setter
- std::string GetCardEmulationMode();
- void SetCardEmulationMode(std::string mode);
+ common::PlatformResult GetCardEmulationMode(std::string *mode);
+ common::PlatformResult SetCardEmulationMode(std::string mode);
// activeSecureElement getter and setter
- std::string GetActiveSecureElement();
- void SetActiveSecureElement(std::string element);
+ common::PlatformResult GetActiveSecureElement(std::string *type);
+ common::PlatformResult SetActiveSecureElement(std::string element);
// Adapter methods
- void SetExclusiveModeForTransaction(bool exmode);
-
- void AddCardEmulationModeChangeListener();
- void RemoveCardEmulationModeChangeListener();
- void AddTransactionEventListener(const picojson::value& args);
- void RemoveTransactionEventListener(const picojson::value& args);
- void AddActiveSecureElementChangeListener();
- void RemoveActiveSecureElementChangeListener();
+ common::PlatformResult SetExclusiveModeForTransaction(bool exmode);
+
+ common::PlatformResult AddCardEmulationModeChangeListener();
+ common::PlatformResult RemoveCardEmulationModeChangeListener();
+ common::PlatformResult AddTransactionEventListener(const picojson::value& args);
+ common::PlatformResult RemoveTransactionEventListener(const picojson::value& args);
+ common::PlatformResult AddActiveSecureElementChangeListener();
+ common::PlatformResult RemoveActiveSecureElementChangeListener();
void GetCachedMessage(picojson::object& out);
void SetPeerHandle(nfc_p2p_target_h handle);
nfc_p2p_target_h GetPeerHandle();
int GetPeerId();
void IncreasePeerId();
- common::PlatformResult PeerIsConnectedGetter(int peer_id, bool &state);
+ common::PlatformResult PeerIsConnectedGetter(int peer_id, bool *state);
common::PlatformResult SetPeerListener();
common::PlatformResult UnsetPeerListener();
common::PlatformResult SetReceiveNDEFListener(int peer_id);
var result = native_.callSync('NFCAdapter_cardEmulationModeGetter');
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message, result.error.name);
+ throw native_.getErrorObject(result);
}
return native_.getResultObject(result);
);
if(native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message, result.error.name);
+ throw native_.getErrorObject(result);
}
return;
}
var result = native_.callSync('NFCAdapter_activeSecureElementGetter');
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message, result.error.name);
+ throw native_.getErrorObject(result);
}
return native_.getResultObject(result);
);
if(native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message, result.error.name);
+ throw native_.getErrorObject(result);
}
return;
}
if(!native_.isListenerSet(TAG_LISTENER)) {
var result = native_.callSync('NFCAdapter_setTagListener');
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message, result.error.name);
+ throw native_.getErrorObject(result);
}
}
if (!native_.isListenerSet(PEER_LISTENER)) {
var result = native_.callSync('NFCAdapter_setPeerListener');
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message, result.error.name);
+ throw native_.getErrorObject(result);
}
}
var result = native_.callSync('NFCAdapter_unsetTagListener');
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message, result.error.name);
+ throw native_.getErrorObject(result);
}
return;
var result = native_.callSync('NFCAdapter_unsetPeerListener');
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message, result.error.name);
+ throw native_.getErrorObject(result);
}
return;
var result = native_.callSync('NFCAdapter_getCachedMessage');
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message, result.error.name);
+ throw native_.getErrorObject(result);
}
if (!result.records) {
);
if(native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message, result.error.name);
- // throw native_.getErrorObject(result);
+ throw native_.getErrorObject(result);
}
return;
};
var result = native_.callSync('NFCPeer_setReceiveNDEFListener', {'id' : this._my_id});
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message, result.error.name);
+ throw native_.getErrorObject(result);
}
native_.addListener(RECEIVE_NDEF_LISTENER, listener);
var result = native_.callSync('NFCPeer_unsetReceiveNDEFListener', {'id' : this._my_id});
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message, result.error.name);
+ throw native_.getErrorObject(result);
}
return;
void NFCInstance::SetExclusiveMode(
const picojson::value& args, picojson::object& out) {
+ CHECK_EXIST(args, "exclusiveMode", out);
bool exmode = args.get("exclusiveMode").get<bool>();
int ret = NFC_ERROR_NONE;
void NFCInstance::CardEmulationModeSetter(
const picojson::value& args, picojson::object& out) {
+ CHECK_EXIST(args, "emulationMode", out);
std::string mode = args.get("emulationMode").get<std::string>();
- try {
- NFCAdapter::GetInstance()->SetCardEmulationMode(mode);
+ PlatformResult result = NFCAdapter::GetInstance()->SetCardEmulationMode(mode);
+ if (result.IsSuccess()) {
ReportSuccess(out);
- }
- catch(const common::PlatformException& ex) {
- ReportError(ex, out);
+ } else {
+ ReportError(result, &out);
}
}
void NFCInstance::CardEmulationModeGetter(
const picojson::value& args, picojson::object& out) {
- std::string mode;
- try {
- mode = NFCAdapter::GetInstance()->GetCardEmulationMode();
+ std::string mode = "";
+ PlatformResult result = NFCAdapter::GetInstance()->GetCardEmulationMode(&mode);
+ if (result.IsSuccess()) {
ReportSuccess(picojson::value(mode), out);
- }
- catch(const common::PlatformException& ex) {
- ReportError(ex, out);
+ } else {
+ ReportError(result, &out);
}
}
void NFCInstance::ActiveSecureElementSetter(
const picojson::value& args, picojson::object& out) {
-
+ CHECK_EXIST(args, "secureElement", out);
std::string ase = args.get("secureElement").get<std::string>();
- try {
- NFCAdapter::GetInstance()->SetActiveSecureElement(ase);
+ PlatformResult result = NFCAdapter::GetInstance()->SetActiveSecureElement(ase);
+ if (result.IsSuccess()) {
ReportSuccess(out);
- }
- catch(const common::PlatformException& ex) {
- ReportError(ex, out);
+ } else {
+ ReportError(result, &out);
}
}
void NFCInstance::ActiveSecureElementGetter(
const picojson::value& args, picojson::object& out) {
- std::string ase;
- try {
- ase = NFCAdapter::GetInstance()->GetActiveSecureElement();
+ std::string ase = "";
+ PlatformResult result = NFCAdapter::GetInstance()->GetActiveSecureElement(&ase);
+ if (result.IsSuccess()) {
ReportSuccess(picojson::value(ase), out);
- }
- catch(const common::PlatformException& ex) {
- ReportError(ex, out);
+ } else {
+ ReportError(result, &out);
}
}
int peer_id = (int)args.get("id").get<double>();
bool ret = false;
- PlatformResult result = NFCAdapter::GetInstance()->PeerIsConnectedGetter(peer_id, ret);
+ PlatformResult result = NFCAdapter::GetInstance()->PeerIsConnectedGetter(peer_id, &ret);
if (result.IsSuccess()) {
ReportSuccess(picojson::value(ret), out);
void NFCInstance::UnsetPeerListener(
const picojson::value& args, picojson::object& out) {
- try {
- NFCAdapter::GetInstance()->UnsetPeerListener();
+ PlatformResult result = NFCAdapter::GetInstance()->UnsetPeerListener();
+ if (result.IsSuccess()) {
ReportSuccess(out);
- }
- catch(const common::PlatformException& ex) {
- ReportError(ex, out);
+ } else {
+ ReportError(result, &out);
}
}
void NFCInstance::AddCardEmulationModeChangeListener(
const picojson::value& args, picojson::object& out) {
- try {
- NFCAdapter::GetInstance()->AddCardEmulationModeChangeListener();
+
+ PlatformResult result = NFCAdapter::GetInstance()->AddCardEmulationModeChangeListener();
+ if (result.IsSuccess()) {
ReportSuccess(out);
- } catch(const common::PlatformException& ex) {
- ReportError(ex, out);
+ } else {
+ ReportError(result, &out);
}
}
void NFCInstance::RemoveCardEmulationModeChangeListener(
const picojson::value& args, picojson::object& out) {
- NFCAdapter::GetInstance()->RemoveCardEmulationModeChangeListener();
+ PlatformResult result = NFCAdapter::GetInstance()->RemoveCardEmulationModeChangeListener();
+ if (result.IsSuccess()) {
+ ReportSuccess(out);
+ } else {
+ ReportError(result, &out);
+ }
}
void NFCInstance::AddTransactionEventListener(
const picojson::value& args, picojson::object& out) {
- try {
- NFCAdapter::GetInstance()->AddTransactionEventListener(args);
+ PlatformResult result = NFCAdapter::GetInstance()->AddTransactionEventListener(args);
+ if (result.IsSuccess()) {
ReportSuccess(out);
- } catch(const common::PlatformException& ex) {
- ReportError(ex, out);
+ } else {
+ ReportError(result, &out);
}
}
void NFCInstance::RemoveTransactionEventListener(
const picojson::value& args, picojson::object& out) {
- NFCAdapter::GetInstance()->RemoveTransactionEventListener(args);
+ PlatformResult result = NFCAdapter::GetInstance()->RemoveTransactionEventListener(args);
+ if (result.IsSuccess()) {
+ ReportSuccess(out);
+ } else {
+ ReportError(result, &out);
+ }
}
void NFCInstance::AddActiveSecureElementChangeListener(
const picojson::value& args, picojson::object& out) {
- try {
- NFCAdapter::GetInstance()->AddActiveSecureElementChangeListener();
+ PlatformResult result = NFCAdapter::GetInstance()->AddActiveSecureElementChangeListener();
+ if (result.IsSuccess()) {
ReportSuccess(out);
- } catch(const common::PlatformException& ex) {
- ReportError(ex, out);
+ } else {
+ ReportError(result, &out);
}
}
void NFCInstance::RemoveActiveSecureElementChangeListener(
const picojson::value& args, picojson::object& out) {
- NFCAdapter::GetInstance()->RemoveActiveSecureElementChangeListener();
+ PlatformResult result = NFCAdapter::GetInstance()->RemoveActiveSecureElementChangeListener();
+ if (result.IsSuccess()) {
+ ReportSuccess(out);
+ } else {
+ ReportError(result, &out);
+ }
}
void NFCInstance::GetCachedMessage(
void NFCInstance::SetExclusiveModeForTransaction(
const picojson::value& args, picojson::object& out) {
- bool transaction_mode = args.get("transactionMode").get<bool>();
- int ret = NFC_ERROR_NONE;
+ CHECK_EXIST(args, "transactionMode", out);
- try {
- NFCAdapter::GetInstance()->SetExclusiveModeForTransaction(
+ bool transaction_mode = args.get("transactionMode").get<bool>();
+ PlatformResult result = NFCAdapter::GetInstance()->SetExclusiveModeForTransaction(
transaction_mode);
+ if (result.IsSuccess()) {
ReportSuccess(out);
- }
- catch(const common::PlatformException& ex) {
- ReportError(ex, out);
+ } else {
+ ReportError(result, &out);
}
}
}
}
-std::string NFCUtil::toStringCardEmulationMode(
- const nfc_se_card_emulation_mode_type_e mode)
+PlatformResult NFCUtil::ToStringCardEmulationMode(
+ const nfc_se_card_emulation_mode_type_e card_mode, std::string *mode)
{
- switch (mode)
+ switch (card_mode)
{
case NFC_SE_CARD_EMULATION_MODE_OFF:
- return OFF;
+ *mode = OFF;
+ break;
case NFC_SE_CARD_EMULATION_MODE_ON:
- return ALWAYS_ON;
+ *mode = ALWAYS_ON;
+ break;
default:
- LOGE("No Match Card Emulation mode: %x", mode);
- throw TypeMismatchException("No Match Card Emulation mode");
+ LOGE("No Match Card Emulation mode: %x", card_mode);
+ return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "No Match Card Emulation mode");
}
+ return PlatformResult(ErrorCode::NO_ERROR);
}
nfc_se_card_emulation_mode_type_e NFCUtil::toCardEmulationMode(
}
}
-std::string NFCUtil::toStringSecureElementType(const nfc_se_type_e type)
+PlatformResult NFCUtil::ToStringSecureElementType(const nfc_se_type_e se_type, std::string *type)
{
- switch (type) {
+ switch (se_type) {
case NFC_SE_TYPE_ESE:
- return ESE;
+ *type = ESE;
+ break;
case NFC_SE_TYPE_UICC:
- return UICC;
+ *type = UICC;
+ break;
default:
- LOGE("No Match Secure Element Type: %x", type);
- throw TypeMismatchException("No Match Secure Element Type");
+ LOGE("No Match Secure Element Type: %x", se_type);
+ return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "No Match Secure Element Type");
}
+ return PlatformResult(ErrorCode::NO_ERROR);
}
-nfc_se_type_e NFCUtil::toSecureElementType(const std::string &type_string)
+PlatformResult NFCUtil::ToSecureElementType(const std::string &type_string, nfc_se_type_e *type)
{
if (type_string == ESE) {
- return NFC_SE_TYPE_ESE;
+ *type = NFC_SE_TYPE_ESE;
} else if (type_string == UICC) {
- return NFC_SE_TYPE_UICC;
+ *type = NFC_SE_TYPE_UICC;
} else {
- LOGE("No Match Secure Element Type: %s", type_string.c_str());
- throw TypeMismatchException("No Match Secure Element Type");
+ LoggerE("No Match Secure Element Type: %s", type_string.c_str());
+ return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "No Match Secure Element Type");
}
+ return PlatformResult(ErrorCode::NO_ERROR);
}
void NFCUtil::setDefaultFilterValues(std::vector<nfc_tag_type_e>& filter)
static std::string getNFCErrorMessage(const int error_code);
static std::string toStringNFCTag(const nfc_tag_type_e tag_type);
static nfc_tag_type_e toNfcTagString(const std::string& type_string);
- static std::string toStringCardEmulationMode(
- const nfc_se_card_emulation_mode_type_e mode);
+ static common::PlatformResult ToStringCardEmulationMode(
+ const nfc_se_card_emulation_mode_type_e card_mode, std::string *mode);
static nfc_se_card_emulation_mode_type_e toCardEmulationMode(
const std::string& mode_string);
- static std::string toStringSecureElementType(const nfc_se_type_e type);
- static nfc_se_type_e toSecureElementType(const std::string& type_string);
+ static common::PlatformResult ToStringSecureElementType(const nfc_se_type_e se_type, std::string *type);
+ static common::PlatformResult ToSecureElementType(const std::string& type_string, nfc_se_type_e *type);
static void setDefaultFilterValues(std::vector<nfc_tag_type_e>& filter);
};