[NFC] Adjust code to google style.
authorLukasz Bardeli <l.bardeli@samsung.com>
Tue, 17 Feb 2015 13:17:27 +0000 (14:17 +0100)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Tue, 17 Feb 2015 13:30:24 +0000 (22:30 +0900)
[Verification] Code compiles without error.

Change-Id: I2e2dc6037a74bd6214b0abbed5b67b66ccde8a34
Signed-off-by: Lukasz Bardeli <l.bardeli@samsung.com>
src/nfc/nfc_adapter.cc
src/nfc/nfc_adapter.h
src/nfc/nfc_extension.cc
src/nfc/nfc_extension.h
src/nfc/nfc_instance.cc
src/nfc/nfc_instance.h
src/nfc/nfc_message_utils.cc
src/nfc/nfc_message_utils.h
src/nfc/nfc_util.cc
src/nfc/nfc_util.h

index 87478f26affb22daeeacb0714438cabfc58299ac..6997adcfd66b744bfcd02da70220d68615be3fbd 100644 (file)
@@ -35,154 +35,154 @@ const std::string TRANSACTION_EVENT_LISTENER_UICC = "TransactionEventListener_UI
 }
 
 NFCAdapter::NFCAdapter():
-        m_is_listener_set(false),
-        m_is_transaction_ese_listener_set(false),
-        m_is_transaction_uicc_listener_set(false),
-        m_is_peer_listener_set(false),
-        m_latest_peer_id(0),
-        m_peer_handle(NULL),
-        m_is_ndef_listener_set(false),
-        m_latest_tag_id(0),
-        m_last_tag_handle(NULL)
+            m_is_listener_set(false),
+            m_is_transaction_ese_listener_set(false),
+            m_is_transaction_uicc_listener_set(false),
+            m_is_peer_listener_set(false),
+            m_latest_peer_id(0),
+            m_peer_handle(NULL),
+            m_is_ndef_listener_set(false),
+            m_latest_tag_id(0),
+            m_last_tag_handle(NULL)
 {
 }
 
 NFCAdapter::~NFCAdapter() {
-    if (m_is_listener_set) {
-        nfc_manager_unset_se_event_cb();
-    }
-
-    if (m_is_peer_listener_set) {
-        nfc_manager_unset_p2p_target_discovered_cb();
-    }
-    if (m_is_transaction_ese_listener_set) {
-        nfc_manager_unset_se_transaction_event_cb(NFC_SE_TYPE_ESE);
-    }
-    if (m_is_transaction_uicc_listener_set) {
-        nfc_manager_unset_se_transaction_event_cb(NFC_SE_TYPE_UICC);
-    }
-    if (m_is_ndef_listener_set) {
-        nfc_p2p_unset_data_received_cb(m_peer_handle);
-    }
-    if (m_is_tag_listener_set) {
-        nfc_manager_unset_tag_discovered_cb();
-    }
+  if (m_is_listener_set) {
+    nfc_manager_unset_se_event_cb();
+  }
+
+  if (m_is_peer_listener_set) {
+    nfc_manager_unset_p2p_target_discovered_cb();
+  }
+  if (m_is_transaction_ese_listener_set) {
+    nfc_manager_unset_se_transaction_event_cb(NFC_SE_TYPE_ESE);
+  }
+  if (m_is_transaction_uicc_listener_set) {
+    nfc_manager_unset_se_transaction_event_cb(NFC_SE_TYPE_UICC);
+  }
+  if (m_is_ndef_listener_set) {
+    nfc_p2p_unset_data_received_cb(m_peer_handle);
+  }
+  if (m_is_tag_listener_set) {
+    nfc_manager_unset_tag_discovered_cb();
+  }
 }
 
 static picojson::value createEventError(double callbackId, PlatformException ex) {
 
-    picojson::value event = picojson::value(picojson::object());
-    picojson::object& obj = event.get<picojson::object>();
-    NFCInstance::getInstance().InstanceReportError(ex, obj);
-    obj.insert(std::make_pair(CALLBACK_ID, callbackId));
+  picojson::value event = picojson::value(picojson::object());
+  picojson::object& obj = event.get<picojson::object>();
+  NFCInstance::getInstance().InstanceReportError(ex, obj);
+  obj.insert(std::make_pair(CALLBACK_ID, callbackId));
 
-    return event;
+  return event;
 }
 
 static picojson::value createEventSuccess(double callbackId) {
-    picojson::value event = picojson::value(picojson::object());
-    picojson::object& obj = event.get<picojson::object>();
-    NFCInstance::getInstance().InstanceReportSuccess(obj);
-    obj.insert(std::make_pair(CALLBACK_ID, callbackId));
+  picojson::value event = picojson::value(picojson::object());
+  picojson::object& obj = event.get<picojson::object>();
+  NFCInstance::getInstance().InstanceReportSuccess(obj);
+  obj.insert(std::make_pair(CALLBACK_ID, callbackId));
 
-    return event;
+  return event;
 }
 
 static gboolean setPoweredCompleteCB(void * user_data) {
 
-    double* callbackId = static_cast<double*>(user_data);
-    picojson::value event = createEventSuccess(*callbackId);
-    NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+  double* callbackId = static_cast<double*>(user_data);
+  picojson::value event = createEventSuccess(*callbackId);
+  NFCInstance::getInstance().PostMessage(event.serialize().c_str());
 
-    delete callbackId;
-    callbackId = NULL;
-    return false;
+  delete callbackId;
+  callbackId = NULL;
+  return false;
 }
 
 static void targetDetectedCallback(nfc_discovered_type_e type,
-        nfc_p2p_target_h target, void *data) {
+                                   nfc_p2p_target_h target, void *data) {
 
-    picojson::value event = picojson::value(picojson::object());
-    picojson::object& obj = event.get<picojson::object>();
-    obj.insert(make_pair("listenerId", "PeerListener"));
+  picojson::value event = picojson::value(picojson::object());
+  picojson::object& obj = event.get<picojson::object>();
+  obj.insert(make_pair("listenerId", "PeerListener"));
 
-    NFCAdapter* adapter = NFCAdapter::GetInstance();
+  NFCAdapter* adapter = NFCAdapter::GetInstance();
 
-    //unregister previous NDEF listener
-    if (adapter->IsNDEFListenerSet()) {
-        adapter->UnsetReceiveNDEFListener(adapter->GetPeerId());
-    }
+  //unregister previous NDEF listener
+  if (adapter->IsNDEFListenerSet()) {
+    adapter->UnsetReceiveNDEFListener(adapter->GetPeerId());
+  }
 
-    if (NFC_DISCOVERED_TYPE_ATTACHED == type) {
-        adapter->SetPeerHandle(target);
-        obj.insert(make_pair("action", "onattach"));
-        adapter->IncreasePeerId();
-        obj.insert(make_pair("id", static_cast<double>(adapter->GetPeerId())));
-        NFCInstance::getInstance().PostMessage(event.serialize().c_str());
-    } else {
-        adapter->SetPeerHandle(NULL);
-        obj.insert(make_pair("action", "ondetach"));
-        NFCInstance::getInstance().PostMessage(event.serialize().c_str());
-    }
+  if (NFC_DISCOVERED_TYPE_ATTACHED == type) {
+    adapter->SetPeerHandle(target);
+    obj.insert(make_pair("action", "onattach"));
+    adapter->IncreasePeerId();
+    obj.insert(make_pair("id", static_cast<double>(adapter->GetPeerId())));
+    NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+  } else {
+    adapter->SetPeerHandle(NULL);
+    obj.insert(make_pair("action", "ondetach"));
+    NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+  }
 }
 
 NFCAdapter* NFCAdapter::GetInstance() {
-    static NFCAdapter instance;
-    return &instance;
+  static NFCAdapter instance;
+  return &instance;
 }
 
 bool NFCAdapter::GetPowered() {
-    return nfc_manager_is_activated();
+  return nfc_manager_is_activated();
 }
 
 #ifndef APP_CONTROL_SETTING_SUPPORT
 
 static void NFCSetActivationCompletedCallback(nfc_error_e error, void *user_data)
 {
-    double* callbackId = static_cast<double*>(user_data);
+  double* callbackId = static_cast<double*>(user_data);
 
-    if (NFC_ERROR_NONE != error) {
-        auto ex = PlatformException(NFCUtil::getNFCErrorString(error),
-                NFCUtil::getNFCErrorMessage(error));
+  if (NFC_ERROR_NONE != error) {
+    auto ex = PlatformException(NFCUtil::getNFCErrorString(error),
+                                NFCUtil::getNFCErrorMessage(error));
 
-        picojson::value event = createEventError(*callbackId, ex);
+    picojson::value event = createEventError(*callbackId, ex);
 
-        NFCInstance::getInstance().PostMessage(event.serialize().c_str());
-    } else {
-        picojson::value event = createEventSuccess(*callbackId);
+    NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+  } else {
+    picojson::value event = createEventSuccess(*callbackId);
 
-        NFCInstance::getInstance().PostMessage(event.serialize().c_str());
-    }
-    delete callbackId;
-    callbackId = NULL;
+    NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+  }
+  delete callbackId;
+  callbackId = NULL;
 }
 
 #endif
 
 static void se_event_callback(nfc_se_event_e se_event, void *user_data) {
 
-    picojson::value event = picojson::value(picojson::object());
-    picojson::object& obj = event.get<picojson::object>();
-    NFCInstance::getInstance().InstanceReportSuccess(obj);
-
-    string result;
-    switch (se_event) {
-        case NFC_SE_EVENT_SE_TYPE_CHANGED:
-            result = NFCAdapter::GetInstance()->GetActiveSecureElement();
-            obj.insert(make_pair(LISTENER_ID, ACTIVE_SECURE_ELEMENT_CHANGED));
-            break;
-        case NFC_SE_EVENT_CARD_EMULATION_CHANGED:
-            result = NFCAdapter::GetInstance()->GetCardEmulationMode();
-            obj.insert(make_pair(LISTENER_ID, CARD_EMULATION_MODE_CHANGED));
-            break;
-        default:
-            LOGD("se_event_occured: %d", se_event);
-            return;
-    }
-
-    obj.insert(make_pair(TYPE, CARD_ELEMENT));
-    obj.insert(make_pair(MODE, result));
-    NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+  picojson::value event = picojson::value(picojson::object());
+  picojson::object& obj = event.get<picojson::object>();
+  NFCInstance::getInstance().InstanceReportSuccess(obj);
+
+  string result;
+  switch (se_event) {
+    case NFC_SE_EVENT_SE_TYPE_CHANGED:
+      result = NFCAdapter::GetInstance()->GetActiveSecureElement();
+      obj.insert(make_pair(LISTENER_ID, ACTIVE_SECURE_ELEMENT_CHANGED));
+      break;
+    case NFC_SE_EVENT_CARD_EMULATION_CHANGED:
+      result = NFCAdapter::GetInstance()->GetCardEmulationMode();
+      obj.insert(make_pair(LISTENER_ID, CARD_EMULATION_MODE_CHANGED));
+      break;
+    default:
+      LOGD("se_event_occured: %d", se_event);
+      return;
+  }
+
+  obj.insert(make_pair(TYPE, CARD_ELEMENT));
+  obj.insert(make_pair(MODE, result));
+  NFCInstance::getInstance().PostMessage(event.serialize().c_str());
 }
 
 static void transaction_event_callback(nfc_se_type_e type,
@@ -192,984 +192,984 @@ static void transaction_event_callback(nfc_se_type_e type,
                                        int param_size,
                                        void *user_data)
 {
-    picojson::value response = picojson::value(picojson::object());
-    picojson::object& response_obj = response.get<picojson::object>();
-    NFCInstance::getInstance().InstanceReportSuccess(response_obj);
-    picojson::array& aid_array = response_obj.insert(std::make_pair("aid",
-            picojson::value(picojson::array()))).first->second.get<picojson::array>();
-    picojson::array& data_array = response_obj.insert(std::make_pair("data",
-            picojson::value(picojson::array()))).first->second.get<picojson::array>();
-
-    for (unsigned int i = 0; i < aid_size; i++) {
-        aid_array.push_back(picojson::value(static_cast<double>(_aid[i])));
-    }
-
-    for (unsigned int i = 0; i < param_size; i++) {
-        aid_array.push_back(picojson::value(static_cast<double>(param[i])));
-    }
-
-    if (NFC_SE_TYPE_ESE == type) {
-        response_obj.insert(make_pair(LISTENER_ID, TRANSACTION_EVENT_LISTENER_ESE));
-    } else {
-        response_obj.insert(make_pair(LISTENER_ID, TRANSACTION_EVENT_LISTENER_UICC));
-    }
-
-    response_obj.insert(make_pair(TYPE, TRANSACTION));
-    NFCInstance::getInstance().PostMessage(response.serialize().c_str());
+  picojson::value response = picojson::value(picojson::object());
+  picojson::object& response_obj = response.get<picojson::object>();
+  NFCInstance::getInstance().InstanceReportSuccess(response_obj);
+  picojson::array& aid_array = response_obj.insert(std::make_pair("aid",
+                                                                  picojson::value(picojson::array()))).first->second.get<picojson::array>();
+  picojson::array& data_array = response_obj.insert(std::make_pair("data",
+                                                                   picojson::value(picojson::array()))).first->second.get<picojson::array>();
+
+  for (unsigned int i = 0; i < aid_size; i++) {
+    aid_array.push_back(picojson::value(static_cast<double>(_aid[i])));
+  }
+
+  for (unsigned int i = 0; i < param_size; i++) {
+    aid_array.push_back(picojson::value(static_cast<double>(param[i])));
+  }
+
+  if (NFC_SE_TYPE_ESE == type) {
+    response_obj.insert(make_pair(LISTENER_ID, TRANSACTION_EVENT_LISTENER_ESE));
+  } else {
+    response_obj.insert(make_pair(LISTENER_ID, TRANSACTION_EVENT_LISTENER_UICC));
+  }
+
+  response_obj.insert(make_pair(TYPE, TRANSACTION));
+  NFCInstance::getInstance().PostMessage(response.serialize().c_str());
 }
 
 void NFCAdapter::SetPowered(const picojson::value& args) {
 
-    double* callbackId = new double(args.get(CALLBACK_ID).get<double>());
-    bool powered = args.get("powered").get<bool>();
+  double* callbackId = new double(args.get(CALLBACK_ID).get<double>());
+  bool powered = args.get("powered").get<bool>();
 
-    if (nfc_manager_is_activated() == powered) {
-        if (!g_idle_add(setPoweredCompleteCB, static_cast<void *>(callbackId))) {
-            delete callbackId;
-            callbackId = NULL;
-            LOGE("g_idle addition failed");
-            throw UnknownException("SetPowered failed.");
-        }
-        return;
+  if (nfc_manager_is_activated() == powered) {
+    if (!g_idle_add(setPoweredCompleteCB, static_cast<void *>(callbackId))) {
+      delete callbackId;
+      callbackId = NULL;
+      LOGE("g_idle addition failed");
+      throw UnknownException("SetPowered failed.");
     }
+    return;
+  }
 
 #ifdef APP_CONTROL_SETTING_SUPPORT
-    app_control_h service = NULL;
-    int ret = app_control_create(&service);
-    if (ret != APP_CONTROL_ERROR_NONE) {
-        LOGE("app_control_create failed: %d", ret);
-        delete callbackId;
-        callbackId = NULL;
-        throw UnknownException("app_control_create failed");
-    }
-
-    ret = app_control_set_operation(service,
-        "http://tizen.org/appcontrol/operation/setting/nfc");
-    if (ret != APP_CONTROL_ERROR_NONE) {
-        LOGE("app_control_set_operation failed: %d", ret);
-        delete callbackId;
-        callbackId = NULL;
-        throw UnknownException("app_control_set_operation failed");
-    }
+  app_control_h service = NULL;
+  int ret = app_control_create(&service);
+  if (ret != APP_CONTROL_ERROR_NONE) {
+    LOGE("app_control_create failed: %d", ret);
+    delete callbackId;
+    callbackId = NULL;
+    throw UnknownException("app_control_create failed");
+  }
 
-    ret = app_control_add_extra_data(service, "type", "nfc");
-    if (ret != APP_CONTROL_ERROR_NONE) {
-        LOGE("app_control_add_extra_data failed: %d", ret);
-        delete callbackId;
-        callbackId = NULL;
-        throw UnknownException("app_control_add_extra_data failed");
-    }
+  ret = app_control_set_operation(service,
+                                  "http://tizen.org/appcontrol/operation/setting/nfc");
+  if (ret != APP_CONTROL_ERROR_NONE) {
+    LOGE("app_control_set_operation failed: %d", ret);
+    delete callbackId;
+    callbackId = NULL;
+    throw UnknownException("app_control_set_operation failed");
+  }
 
-    ret = app_control_send_launch_request(service, [](app_control_h request,
-        app_control_h reply, app_control_result_e result, void *user_data){
-        double* callbackId = static_cast<double*>(user_data);
-        try {
-            if (result == APP_CONTROL_RESULT_SUCCEEDED) {
-                char *type = NULL;
-                int ret = app_control_get_extra_data(reply, "nfc_status",
-                    &type);
-                if (ret != APP_CONTROL_ERROR_NONE) {
-                    LOGE("app_control_get_extra_data failed: %d", ret);
-                    throw UnknownException("app_control_get_extra_data failed");
-                }
-
-                LOGD("app_control result: %s", type);
-            } else {
-                LOGE("NFC enable app control failed : %d", result);
-                throw UnknownException("NFC enable app control failed");
-            }
-        } catch (PlatformException &ex) {
-            picojson::value event = createEventError(*callbackId, ex);
-            NFCInstance::getInstance().PostMessage(event.serialize().c_str());
-            return;
-        }
+  ret = app_control_add_extra_data(service, "type", "nfc");
+  if (ret != APP_CONTROL_ERROR_NONE) {
+    LOGE("app_control_add_extra_data failed: %d", ret);
+    delete callbackId;
+    callbackId = NULL;
+    throw UnknownException("app_control_add_extra_data failed");
+  }
 
-        if (!g_idle_add(setPoweredCompleteCB, static_cast<void *>(callbackId))) {
-            LOGE("g_idle addition failed");
-            PlatformException ex = PlatformException("UnknownError", "UnknownError");
-            picojson::value event = createEventError(*callbackId, ex);
-            NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+  ret = app_control_send_launch_request(service, [](app_control_h request,
+      app_control_h reply, app_control_result_e result, void *user_data){
+    double* callbackId = static_cast<double*>(user_data);
+    try {
+      if (result == APP_CONTROL_RESULT_SUCCEEDED) {
+        char *type = NULL;
+        int ret = app_control_get_extra_data(reply, "nfc_status",
+                                             &type);
+        if (ret != APP_CONTROL_ERROR_NONE) {
+          LOGE("app_control_get_extra_data failed: %d", ret);
+          throw UnknownException("app_control_get_extra_data failed");
         }
-    }, static_cast<void *>(callbackId));
 
-    if (ret != APP_CONTROL_ERROR_NONE) {
-        LOGE("app_control_send_launch_request failed: %d", ret);
-        delete callbackId;
-        callbackId = NULL;
-        throw UnknownException("app_control_send_operation failed");
+        LOGD("app_control result: %s", type);
+      } else {
+        LOGE("NFC enable app control failed : %d", result);
+        throw UnknownException("NFC enable app control failed");
+      }
+    } catch (PlatformException &ex) {
+      picojson::value event = createEventError(*callbackId, ex);
+      NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+      return;
     }
 
-    ret = app_control_destroy(service);
-    if (ret != APP_CONTROL_ERROR_NONE) {
-        LOGE("app_control_destroy failed: %d", ret);
-        throw UnknownException("app_control_destroy failed");
+    if (!g_idle_add(setPoweredCompleteCB, static_cast<void *>(callbackId))) {
+      LOGE("g_idle addition failed");
+      PlatformException ex = PlatformException("UnknownError", "UnknownError");
+      picojson::value event = createEventError(*callbackId, ex);
+      NFCInstance::getInstance().PostMessage(event.serialize().c_str());
     }
+  }, static_cast<void *>(callbackId));
+
+  if (ret != APP_CONTROL_ERROR_NONE) {
+    LOGE("app_control_send_launch_request failed: %d", ret);
+    delete callbackId;
+    callbackId = NULL;
+    throw UnknownException("app_control_send_operation failed");
+  }
+
+  ret = app_control_destroy(service);
+  if (ret != APP_CONTROL_ERROR_NONE) {
+    LOGE("app_control_destroy failed: %d", ret);
+    throw UnknownException("app_control_destroy failed");
+  }
 #else
-    int ret = nfc_manager_set_activation(powered,
-                NFCSetActivationCompletedCallback, static_cast<void *>(callbackId));
+  int ret = nfc_manager_set_activation(powered,
+                                       NFCSetActivationCompletedCallback, static_cast<void *>(callbackId));
 
-    if (NFC_ERROR_NONE != ret) {
-        LOGE("setPowered failed %d",ret);
-        delete callbackId;
-        callbackId = NULL;
-        NFCUtil::throwNFCException(ret, "setPowered failed.");
-    }
+  if (NFC_ERROR_NONE != ret) {
+    LOGE("setPowered failed %d",ret);
+    delete callbackId;
+    callbackId = NULL;
+    NFCUtil::throwNFCException(ret, "setPowered failed.");
+  }
 #endif
 }
 
 
 std::string NFCAdapter::GetCardEmulationMode() {
 
-    LoggerD("Entered");
+  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 mode;
+  int ret = nfc_se_get_card_emulation_mode(&mode);
 
-    if (NFC_ERROR_NONE != ret) {
-        LoggerE("Failed to get card emulation mode %d", ret);
-        NFCUtil::throwNFCException(ret, "Failed to get card emulation 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::toStringCardEmulationMode(mode);
+  return NFCUtil::toStringCardEmulationMode(mode);
 }
 
 void NFCAdapter::SetCardEmulationMode(std::string mode) {
 
-    LoggerD("Entered");
-
-    nfc_se_card_emulation_mode_type_e new_mode =
-            NFCUtil::toCardEmulationMode(mode);
-    LoggerD("Card emulation mode value: %x", (int)new_mode);
-
-    std::string current_mode = GetCardEmulationMode();
-
-    if (mode.compare(current_mode) == 0) {
-        LoggerD("Card emulation mode already set to given value (%s)",
-                mode.c_str());
-        return;
-    }
-
-    int ret = NFC_ERROR_NONE;
-    switch (new_mode) {
-        case NFC_SE_CARD_EMULATION_MODE_OFF:
-            ret = nfc_se_disable_card_emulation();
-            break;
-        case NFC_SE_CARD_EMULATION_MODE_ON:
-            ret = nfc_se_enable_card_emulation();
-            break;
-        default:
-            // Should never go here - in case of invalid mode
-            // exception is thrown from convertert few lines above
-            LoggerE("Invalid card emulation mode: %s", mode.c_str());
-            throw InvalidValuesException("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");
-    }
+  LoggerD("Entered");
+
+  nfc_se_card_emulation_mode_type_e new_mode =
+      NFCUtil::toCardEmulationMode(mode);
+  LoggerD("Card emulation mode value: %x", (int)new_mode);
+
+  std::string current_mode = GetCardEmulationMode();
+
+  if (mode.compare(current_mode) == 0) {
+    LoggerD("Card emulation mode already set to given value (%s)",
+            mode.c_str());
+    return;
+  }
+
+  int ret = NFC_ERROR_NONE;
+  switch (new_mode) {
+    case NFC_SE_CARD_EMULATION_MODE_OFF:
+      ret = nfc_se_disable_card_emulation();
+      break;
+    case NFC_SE_CARD_EMULATION_MODE_ON:
+      ret = nfc_se_enable_card_emulation();
+      break;
+    default:
+      // Should never go here - in case of invalid mode
+      // exception is thrown from convertert few lines above
+      LoggerE("Invalid card emulation mode: %s", mode.c_str());
+      throw InvalidValuesException("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");
+  }
 }
 
 std::string NFCAdapter::GetActiveSecureElement() {
 
-    LoggerD("Entered");
+  LoggerD("Entered");
 
-    nfc_se_type_e type;
-    int ret = nfc_manager_get_se_type(&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");
-    }
+  nfc_se_type_e type;
+  int ret = nfc_manager_get_se_type(&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::toStringSecureElementType(type);
+  return NFCUtil::toStringSecureElementType(type);
 }
 
 void 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);
-    LoggerD("Secure element type value: %x", (int)new_type);
-
-    std::string current_type = GetActiveSecureElement();
-    if (element == current_type) {
-        LoggerD("Active secure element type already set to: %s", element.c_str());
-        return;
-    }
-
-    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,
-                "Unable to set active secure element type");
-    }
+  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);
+  LoggerD("Secure element type value: %x", (int)new_type);
+
+  std::string current_type = GetActiveSecureElement();
+  if (element == current_type) {
+    LoggerD("Active secure element type already set to: %s", element.c_str());
+    return;
+  }
+
+  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,
+                               "Unable to set active secure element type");
+  }
 }
 
 void NFCAdapter::SetExclusiveModeForTransaction(bool exmode) {
 
-    LoggerD("Entered");
+  LoggerD("Entered");
 
-    int ret = NFC_ERROR_NONE;
-    if (exmode) {
-        ret = nfc_manager_enable_transaction_fg_dispatch();
-    } else {
-        ret = nfc_manager_disable_transaction_fg_dispatch();
-    }
+  int ret = NFC_ERROR_NONE;
+  if (exmode) {
+    ret = nfc_manager_enable_transaction_fg_dispatch();
+  } else {
+    ret = nfc_manager_disable_transaction_fg_dispatch();
+  }
 
-    if (NFC_ERROR_NONE != ret) {
-        LoggerE("Failed to set exclusive mode for transaction: %d", ret);
-        NFCUtil::throwNFCException(ret,
-                "Setting exclusive mode for transaction failed.");
-    }
+  if (NFC_ERROR_NONE != ret) {
+    LoggerE("Failed to set exclusive mode for transaction: %d", ret);
+    NFCUtil::throwNFCException(ret,
+                               "Setting exclusive mode for transaction failed.");
+  }
 }
 
 void 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,
-                NFCUtil::getNFCErrorMessage(ret).c_str());
-        }
+  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,
+                                 NFCUtil::getNFCErrorMessage(ret).c_str());
     }
+  }
 
-    m_is_listener_set = true;
+  m_is_listener_set = true;
 }
 
 void NFCAdapter::RemoveCardEmulationModeChangeListener() {
-    if (!nfc_manager_is_supported()) {
-        throw NotSupportedException("NFC Not Supported");
-    }
-
-    if (m_is_listener_set) {
-        nfc_manager_unset_se_event_cb();
-    }
-    m_is_listener_set = false;
+  if (!nfc_manager_is_supported()) {
+    throw NotSupportedException("NFC Not Supported");
+  }
+
+  if (m_is_listener_set) {
+    nfc_manager_unset_se_event_cb();
+  }
+  m_is_listener_set = false;
 }
 
 
 void NFCAdapter::AddTransactionEventListener(const picojson::value& args) {
 
-    nfc_se_type_e se_type = NFCUtil::toSecureElementType(
-            args.get("type").get<string>());
-    int ret = NFC_ERROR_NONE;
+  nfc_se_type_e se_type = NFCUtil::toSecureElementType(
+      args.get("type").get<string>());
+  int ret = NFC_ERROR_NONE;
 
-    if (NFC_SE_TYPE_ESE == se_type) {
-        if (m_is_transaction_ese_listener_set) {
-            ret = nfc_manager_set_se_transaction_event_cb(se_type,
-                transaction_event_callback, NULL);
-        }
-        m_is_transaction_ese_listener_set = true;
-    } else {
-        if (m_is_transaction_uicc_listener_set) {
-            ret = nfc_manager_set_se_transaction_event_cb(se_type,
-                transaction_event_callback, NULL);
-        }
-        m_is_transaction_uicc_listener_set = true;
+  if (NFC_SE_TYPE_ESE == se_type) {
+    if (m_is_transaction_ese_listener_set) {
+      ret = nfc_manager_set_se_transaction_event_cb(se_type,
+                                                    transaction_event_callback, NULL);
     }
-
-    if (NFC_ERROR_NONE != ret) {
-        LOGE("AddTransactionEventListener failed: %d", ret);
-        NFCUtil::throwNFCException(ret,
-            NFCUtil::getNFCErrorMessage(ret).c_str());
+    m_is_transaction_ese_listener_set = true;
+  } else {
+    if (m_is_transaction_uicc_listener_set) {
+      ret = nfc_manager_set_se_transaction_event_cb(se_type,
+                                                    transaction_event_callback, NULL);
     }
+    m_is_transaction_uicc_listener_set = true;
+  }
+
+  if (NFC_ERROR_NONE != ret) {
+    LOGE("AddTransactionEventListener failed: %d", ret);
+    NFCUtil::throwNFCException(ret,
+                               NFCUtil::getNFCErrorMessage(ret).c_str());
+  }
 }
 
 void 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 = NFCUtil::toSecureElementType(
+      args.get("type").get<string>());
 
-    nfc_manager_unset_se_transaction_event_cb(se_type);
+  nfc_manager_unset_se_transaction_event_cb(se_type);
 
-    if (se_type == NFC_SE_TYPE_ESE) {
-        m_is_transaction_ese_listener_set = false;
-    } else {
-        m_is_transaction_uicc_listener_set = false;
-    }
+  if (se_type == NFC_SE_TYPE_ESE) {
+    m_is_transaction_ese_listener_set = false;
+  } else {
+    m_is_transaction_uicc_listener_set = false;
+  }
 }
 
 void 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,
-                NFCUtil::getNFCErrorMessage(ret).c_str());
-        }
+  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,
+                                 NFCUtil::getNFCErrorMessage(ret).c_str());
     }
+  }
 
-    m_is_listener_set = true;
+  m_is_listener_set = true;
 }
 
 void NFCAdapter::RemoveActiveSecureElementChangeListener() {
-    if (!nfc_manager_is_supported()) {
-        throw NotSupportedException("NFC Not Supported");
-    }
-
-    if (m_is_listener_set) {
-        nfc_manager_unset_se_event_cb();
-    }
-    m_is_listener_set = false;
+  if (!nfc_manager_is_supported()) {
+    throw NotSupportedException("NFC Not Supported");
+  }
+
+  if (m_is_listener_set) {
+    nfc_manager_unset_se_event_cb();
+  }
+  m_is_listener_set = false;
 }
 
 void NFCAdapter::SetPeerHandle(nfc_p2p_target_h handle) {
-    m_peer_handle = handle;
+  m_peer_handle = handle;
 }
 
 nfc_p2p_target_h NFCAdapter::GetPeerHandle() {
-    return m_peer_handle;
+  return m_peer_handle;
 }
 
 int NFCAdapter::GetPeerId() {
-    return m_latest_peer_id;
+  return m_latest_peer_id;
 }
 
 void NFCAdapter::IncreasePeerId() {
-    m_latest_peer_id++;
+  m_latest_peer_id++;
 }
 
 bool NFCAdapter::PeerIsConnectedGetter(int peer_id) {
-    if (m_latest_peer_id != peer_id || !m_peer_handle) {
-        return false;
-    }
+  if (m_latest_peer_id != peer_id || !m_peer_handle) {
+    return false;
+  }
 
-    nfc_p2p_target_h handle = NULL;
-    int ret = nfc_manager_get_connected_target(&handle);
-    if (NFC_ERROR_NONE != ret) {
-        LOGE("Failed to get connected target handle: %d", ret);
-        NFCUtil::throwNFCException(ret, "Failed to get connected target handle.");
-    }
+  nfc_p2p_target_h handle = NULL;
+  int ret = nfc_manager_get_connected_target(&handle);
+  if (NFC_ERROR_NONE != ret) {
+    LOGE("Failed to get connected target handle: %d", ret);
+    NFCUtil::throwNFCException(ret, "Failed to get connected target handle.");
+  }
 
-    if (m_peer_handle == handle) {
-        return true;
-    }
+  if (m_peer_handle == handle) {
+    return true;
+  }
 
-    return false;
+  return false;
 }
 
 void NFCAdapter::SetPeerListener() {
-    if (!nfc_manager_is_supported()) {
-        throw NotSupportedException("NFC Not Supported");
-    }
+  if (!nfc_manager_is_supported()) {
+    throw NotSupportedException("NFC Not Supported");
+  }
 
-    if (!m_is_peer_listener_set) {
-        int ret = nfc_manager_set_p2p_target_discovered_cb (targetDetectedCallback, NULL);
-        if (NFC_ERROR_NONE != ret) {
-            LOGE("Failed to set listener: %d", ret);
-            NFCUtil::throwNFCException(ret, "setPeerListener failed");
-        }
+  if (!m_is_peer_listener_set) {
+    int ret = nfc_manager_set_p2p_target_discovered_cb (targetDetectedCallback, NULL);
+    if (NFC_ERROR_NONE != ret) {
+      LOGE("Failed to set listener: %d", ret);
+      NFCUtil::throwNFCException(ret, "setPeerListener failed");
     }
+  }
 
-    m_is_peer_listener_set = true;
+  m_is_peer_listener_set = true;
 }
 
 void NFCAdapter::UnsetPeerListener() {
-    if (!nfc_manager_is_supported()) {
-        throw NotSupportedException("NFC Not Supported");
-    }
+  if (!nfc_manager_is_supported()) {
+    throw NotSupportedException("NFC Not Supported");
+  }
 
-    if (m_is_peer_listener_set) {
-        nfc_manager_unset_p2p_target_discovered_cb();
-    }
+  if (m_is_peer_listener_set) {
+    nfc_manager_unset_p2p_target_discovered_cb();
+  }
 
-    m_is_peer_listener_set = false;
+  m_is_peer_listener_set = false;
 }
 
 static void targetReceivedCallback(nfc_p2p_target_h target, nfc_ndef_message_h message, void *data)
 {
-    unsigned char *raw_data = NULL;
-    unsigned int size;
-    if (NFC_ERROR_NONE != nfc_ndef_message_get_rawdata(message, &raw_data, &size)) {
-        LOGE("Unknown error while getting raw data of message.");
-        free(raw_data);
-        return;
-    }
+  unsigned char *raw_data = NULL;
+  unsigned int size;
+  if (NFC_ERROR_NONE != nfc_ndef_message_get_rawdata(message, &raw_data, &size)) {
+    LOGE("Unknown error while getting raw data of message.");
+    free(raw_data);
+    return;
+  }
 
-    picojson::value event = picojson::value(picojson::object());
-    picojson::object& obj = event.get<picojson::object>();
-    obj.insert(make_pair("listenerId", "ReceiveNDEFListener"));
-    obj.insert(make_pair("id", static_cast<double>(NFCAdapter::GetInstance()->GetPeerId())));
+  picojson::value event = picojson::value(picojson::object());
+  picojson::object& obj = event.get<picojson::object>();
+  obj.insert(make_pair("listenerId", "ReceiveNDEFListener"));
+  obj.insert(make_pair("id", static_cast<double>(NFCAdapter::GetInstance()->GetPeerId())));
 
-    NFCMessageUtils::ReportNdefMessageFromData(raw_data, size, obj);
+  NFCMessageUtils::ReportNdefMessageFromData(raw_data, size, obj);
 
-    NFCInstance::getInstance().PostMessage(event.serialize().c_str());
-    free(raw_data);
+  NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+  free(raw_data);
 }
 
 void NFCAdapter::SetReceiveNDEFListener(int peer_id) {
 
-    //unregister previous NDEF listener
-    if (m_is_ndef_listener_set) {
-        int ret = nfc_p2p_unset_data_received_cb(m_peer_handle);
-        if (NFC_ERROR_NONE != ret) {
-            LOGW("Unregister ReceiveNDEFListener error: %d", ret);
-        }
-        m_is_ndef_listener_set = false;
+  //unregister previous NDEF listener
+  if (m_is_ndef_listener_set) {
+    int ret = nfc_p2p_unset_data_received_cb(m_peer_handle);
+    if (NFC_ERROR_NONE != ret) {
+      LOGW("Unregister ReceiveNDEFListener error: %d", ret);
     }
+    m_is_ndef_listener_set = false;
+  }
 
-    //check if peer object is still connected
-    if (!PeerIsConnectedGetter(peer_id)) {
-        LOGE("Target is not connected");
-        throw UnknownException("Target is not connected");
-    }
+  //check if peer object is still connected
+  if (!PeerIsConnectedGetter(peer_id)) {
+    LOGE("Target is not connected");
+    throw UnknownException("Target is not connected");
+  }
 
-    int ret = nfc_p2p_set_data_received_cb(m_peer_handle, targetReceivedCallback, NULL);
-    if (NFC_ERROR_NONE != ret) {
-        LOGE("Failed to set NDEF listener: %d", ret);
-        NFCUtil::throwNFCException(ret, "Failed to set NDEF listener");
-    }
+  int ret = nfc_p2p_set_data_received_cb(m_peer_handle, targetReceivedCallback, NULL);
+  if (NFC_ERROR_NONE != ret) {
+    LOGE("Failed to set NDEF listener: %d", ret);
+    NFCUtil::throwNFCException(ret, "Failed to set NDEF listener");
+  }
 
-    m_is_ndef_listener_set = true;
+  m_is_ndef_listener_set = true;
 }
 
 void NFCAdapter::UnsetReceiveNDEFListener(int peer_id) {
-    if (m_is_ndef_listener_set) {
-        //check if peer object is still connected
-        if (!PeerIsConnectedGetter(peer_id)) {
-            LOGE("Target is not connected");
-        }
-
-        int ret = nfc_p2p_unset_data_received_cb(m_peer_handle);
-        if (NFC_ERROR_NONE != ret) {
-            LOGE("Unregister ReceiveNDEFListener error: %d", ret);
-            NFCUtil::throwNFCException(ret, "Unregister ReceiveNDEFListener error");
-        }
+  if (m_is_ndef_listener_set) {
+    //check if peer object is still connected
+    if (!PeerIsConnectedGetter(peer_id)) {
+      LOGE("Target is not connected");
+    }
 
-        m_is_ndef_listener_set = false;
+    int ret = nfc_p2p_unset_data_received_cb(m_peer_handle);
+    if (NFC_ERROR_NONE != ret) {
+      LOGE("Unregister ReceiveNDEFListener error: %d", ret);
+      NFCUtil::throwNFCException(ret, "Unregister ReceiveNDEFListener error");
     }
+
+    m_is_ndef_listener_set = false;
+  }
 }
 
 bool NFCAdapter::IsNDEFListenerSet() {
-    return m_is_ndef_listener_set;
+  return m_is_ndef_listener_set;
 }
 
 
 // NFCTag related functions
 std::string NFCAdapter::TagTypeGetter(int tag_id) {
 
-    LoggerD("Entered");
+  LoggerD("Entered");
 
-    nfc_tag_type_e type = NFC_UNKNOWN_TARGET;
+  nfc_tag_type_e type = NFC_UNKNOWN_TARGET;
 
-    int err = nfc_tag_get_type(m_last_tag_handle, &type);
-    if(NFC_ERROR_NONE != err) {
-        LoggerE("Failed to get tag type: %d", err);
-        NFCUtil::throwNFCException(err, "Failed to get tag type");
-    }
+  int err = nfc_tag_get_type(m_last_tag_handle, &type);
+  if(NFC_ERROR_NONE != err) {
+    LoggerE("Failed to get tag type: %d", err);
+    NFCUtil::throwNFCException(err, "Failed to get tag type");
+  }
 
-    return NFCUtil::toStringNFCTag(type);
+  return NFCUtil::toStringNFCTag(type);
 }
 
 bool NFCAdapter::TagIsSupportedNDEFGetter(int tag_id) {
 
-    LoggerD("Entered");
+  LoggerD("Entered");
 
-    bool result = false;
+  bool result = false;
 
-    int err = nfc_tag_is_support_ndef(m_last_tag_handle, &result);
-    if(NFC_ERROR_NONE != err) {
-        LoggerE("Failed to check if NDEF is supported %d", err);
-        NFCUtil::throwNFCException(err,
-                "Failed to check if NDEF is supported");
-    }
+  int err = nfc_tag_is_support_ndef(m_last_tag_handle, &result);
+  if(NFC_ERROR_NONE != err) {
+    LoggerE("Failed to check if NDEF is supported %d", err);
+    NFCUtil::throwNFCException(err,
+                               "Failed to check if NDEF is supported");
+  }
 
-    return result;
+  return result;
 }
 
 unsigned int NFCAdapter::TagNDEFSizeGetter(int tag_id) {
 
-    LoggerD("Entered");
+  LoggerD("Entered");
 
-    unsigned int result = 0;
+  unsigned int result = 0;
 
-    int err = nfc_tag_get_ndef_size(m_last_tag_handle, &result);
-    if(NFC_ERROR_NONE != err) {
-        LoggerE("Failed to get tag NDEF size: %d, %s", err);
-        NFCUtil::throwNFCException(err,
-                "Failed to get tag NDEF size");
-    }
-    return result;
+  int err = nfc_tag_get_ndef_size(m_last_tag_handle, &result);
+  if(NFC_ERROR_NONE != err) {
+    LoggerE("Failed to get tag NDEF size: %d, %s", err);
+    NFCUtil::throwNFCException(err,
+                               "Failed to get tag NDEF size");
+  }
+  return result;
 }
 
 static bool tagPropertiesGetterCb(const char *key,
-        const unsigned char *value,
-        int value_size,
-        void *user_data)
+                                  const unsigned char *value,
+                                  int value_size,
+                                  void *user_data)
 {
-    if (user_data) {
-        UCharVector tag_info = NFCUtil::toVector(value, value_size);
-        (static_cast<NFCTagPropertiesT*>(user_data))->push_back(
-                std::make_pair(key, tag_info));
-        return true;
-    }
-    return false;
+  if (user_data) {
+    UCharVector tag_info = NFCUtil::toVector(value, value_size);
+    (static_cast<NFCTagPropertiesT*>(user_data))->push_back(
+        std::make_pair(key, tag_info));
+    return true;
+  }
+  return false;
 }
 
 NFCTagPropertiesT NFCAdapter::TagPropertiesGetter(int tag_id) {
 
-    LoggerD("Entered");
+  LoggerD("Entered");
 
-    NFCTagPropertiesT result;
+  NFCTagPropertiesT result;
 
-    int err = nfc_tag_foreach_information(m_last_tag_handle,
-            tagPropertiesGetterCb, (void*)&result);
-    if(NFC_ERROR_NONE != err) {
-        LoggerE("Error occured while getting NFC properties: %d", err);
-        NFCUtil::throwNFCException(err,
-                "Error occured while getting NFC properties");
-    }
+  int err = nfc_tag_foreach_information(m_last_tag_handle,
+                                        tagPropertiesGetterCb, (void*)&result);
+  if(NFC_ERROR_NONE != err) {
+    LoggerE("Error occured while getting NFC properties: %d", err);
+    NFCUtil::throwNFCException(err,
+                               "Error occured while getting NFC properties");
+  }
 
-    return result;
+  return result;
 }
 
 bool NFCAdapter::TagIsConnectedGetter(int tag_id) {
 
-    LoggerD("Entered");
+  LoggerD("Entered");
 
-    if(tag_id != m_latest_tag_id || NULL == m_last_tag_handle) {
-        // internaly stored tag id changed -> new tag has been already connected
-        // internaly stored tag handle NULL -> tag has been disconnected
-        LoggerD("NFCTag () not connected (id differs or invalid handle)");
-        return false;
-    }
+  if(tag_id != m_latest_tag_id || NULL == m_last_tag_handle) {
+    // internaly stored tag id changed -> new tag has been already connected
+    // internaly stored tag handle NULL -> tag has been disconnected
+    LoggerD("NFCTag () not connected (id differs or invalid handle)");
+    return false;
+  }
 
-    nfc_tag_h handle = NULL;
-    int result = nfc_manager_get_connected_tag(&handle);
-    if(NFC_ERROR_NONE != result) {
-        LoggerE("Failed to get connected tag: %s",
+  nfc_tag_h handle = NULL;
+  int result = nfc_manager_get_connected_tag(&handle);
+  if(NFC_ERROR_NONE != result) {
+    LoggerE("Failed to get connected tag: %s",
             NFCUtil::getNFCErrorMessage(result).c_str());
-        // exception is thrown here to return undefined in JS layer
-        // instead of false
-        NFCUtil::throwNFCException(result, "Failed to get connected tag");
-    }
+    // exception is thrown here to return undefined in JS layer
+    // instead of false
+    NFCUtil::throwNFCException(result, "Failed to get connected tag");
+  }
 
-    if(m_last_tag_handle != handle) {
-        LoggerD("Last known handle and current handle differs");
-        return false;
-    }
+  if(m_last_tag_handle != handle) {
+    LoggerD("Last known handle and current handle differs");
+    return false;
+  }
 
-    return true;
+  return true;
 }
 
 
 int NFCAdapter::GetNextTagId() {
 
-    LoggerD("Entered");
-    return ++m_latest_tag_id;
+  LoggerD("Entered");
+  return ++m_latest_tag_id;
 }
 
 
 static void tagEventCallback(nfc_discovered_type_e type, nfc_tag_h tag, void *data)
 {
-    LoggerD("Entered");
-
-    picojson::value event = picojson::value(picojson::object());
-    picojson::object& obj = event.get<picojson::object>();
-    obj.insert(make_pair("listenerId", "TagListener"));
-
-    NFCAdapter* adapter = NFCAdapter::GetInstance();
-    // Tag detected event
-    if (NFC_DISCOVERED_TYPE_ATTACHED == type) {
-        nfc_tag_type_e tag_type;
-
-        int result;
-        result = nfc_tag_get_type(tag, &tag_type);
-        if(NFC_ERROR_NONE != result) {
-            LoggerE("setTagListener failed %d",result);
-            return;
-        }
-        // Fetch new id and set detected tag handle in NFCAdapter
-        int generated_id = adapter->GetNextTagId();
-        adapter->SetTagHandle(tag);
+  LoggerD("Entered");
 
-        obj.insert(make_pair("action", "onattach"));
-        obj.insert(make_pair("id", static_cast<double>(generated_id)));
-        obj.insert(make_pair("type", NFCUtil::toStringNFCTag(tag_type)));
+  picojson::value event = picojson::value(picojson::object());
+  picojson::object& obj = event.get<picojson::object>();
+  obj.insert(make_pair("listenerId", "TagListener"));
 
-        NFCInstance::getInstance().PostMessage(event.serialize().c_str());
-    }
-    // Tag disconnected event
-    else if (NFC_DISCOVERED_TYPE_DETACHED == type) {
-        // Set stored tag handle to NULL
-        adapter->SetTagHandle(NULL);
+  NFCAdapter* adapter = NFCAdapter::GetInstance();
+  // Tag detected event
+  if (NFC_DISCOVERED_TYPE_ATTACHED == type) {
+    nfc_tag_type_e tag_type;
 
-        obj.insert(make_pair("action", "ondetach"));
-        NFCInstance::getInstance().PostMessage(event.serialize().c_str());
-    }
-    // ERROR - should never happen
-    else {
-        LoggerE("Invalid NFC discovered type: %d (%x)", type, type);
+    int result;
+    result = nfc_tag_get_type(tag, &tag_type);
+    if(NFC_ERROR_NONE != result) {
+      LoggerE("setTagListener failed %d",result);
+      return;
     }
+    // Fetch new id and set detected tag handle in NFCAdapter
+    int generated_id = adapter->GetNextTagId();
+    adapter->SetTagHandle(tag);
+
+    obj.insert(make_pair("action", "onattach"));
+    obj.insert(make_pair("id", static_cast<double>(generated_id)));
+    obj.insert(make_pair("type", NFCUtil::toStringNFCTag(tag_type)));
+
+    NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+  }
+  // Tag disconnected event
+  else if (NFC_DISCOVERED_TYPE_DETACHED == type) {
+    // Set stored tag handle to NULL
+    adapter->SetTagHandle(NULL);
+
+    obj.insert(make_pair("action", "ondetach"));
+    NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+  }
+  // ERROR - should never happen
+  else {
+    LoggerE("Invalid NFC discovered type: %d (%x)", type, type);
+  }
 
 }
 
 void NFCAdapter::SetTagListener(){
 
-    LoggerD("Entered");
+  LoggerD("Entered");
 
-    if(!m_is_tag_listener_set) {
-        nfc_manager_set_tag_filter(NFC_TAG_FILTER_ALL_ENABLE);
-        int result = nfc_manager_set_tag_discovered_cb (tagEventCallback, NULL);
-        if (NFC_ERROR_NONE != result) {
-            LoggerE("Failed to register tag listener: %d", result);
-            NFCUtil::throwNFCException(result, "Failed to register tag listene");
-        }
-        m_is_tag_listener_set = true;
+  if(!m_is_tag_listener_set) {
+    nfc_manager_set_tag_filter(NFC_TAG_FILTER_ALL_ENABLE);
+    int result = nfc_manager_set_tag_discovered_cb (tagEventCallback, NULL);
+    if (NFC_ERROR_NONE != result) {
+      LoggerE("Failed to register tag listener: %d", result);
+      NFCUtil::throwNFCException(result, "Failed to register tag listene");
     }
+    m_is_tag_listener_set = true;
+  }
 }
 
 void NFCAdapter::UnsetTagListener(){
 
-    LoggerD("Entered");
+  LoggerD("Entered");
 
-    if(m_is_tag_listener_set) {
-        nfc_manager_unset_tag_discovered_cb();
-        m_is_tag_listener_set = false;
-    }
+  if(m_is_tag_listener_set) {
+    nfc_manager_unset_tag_discovered_cb();
+    m_is_tag_listener_set = false;
+  }
 }
 
 void NFCAdapter::SetTagHandle(nfc_tag_h tag) {
 
-    LoggerD("Entered");
+  LoggerD("Entered");
 
-    m_last_tag_handle = tag;
+  m_last_tag_handle = tag;
 }
 
 static void tagReadNDEFCb(nfc_error_e result , nfc_ndef_message_h message , void *data)
 {
-    LoggerD("Entered");
+  LoggerD("Entered");
 
-    if(!data) {
-        // Can not continue if unable to get callbackId
-        LoggerE("NULL callback id given");
-    }
+  if(!data) {
+    // Can not continue if unable to get callbackId
+    LoggerE("NULL callback id given");
+  }
 
-    double callbackId = *((double*)data);
-    delete (double*)data;
-    data = NULL;
+  double callbackId = *((double*)data);
+  delete (double*)data;
+  data = NULL;
 
-    if(NFC_ERROR_NONE != result) {
-        // create exception and post error message (call error callback)
-        UnknownException ex("Failed to read NDEF message");
-        picojson::value event = createEventError(callbackId, ex);
-        NFCInstance::getInstance().PostMessage(event.serialize().c_str());
-        return;
-    }
+  if(NFC_ERROR_NONE != result) {
+    // create exception and post error message (call error callback)
+    UnknownException ex("Failed to read NDEF message");
+    picojson::value event = createEventError(callbackId, ex);
+    NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+    return;
+  }
 
-    unsigned char *raw_data = NULL;
-    unsigned int size = 0;
+  unsigned char *raw_data = NULL;
+  unsigned int size = 0;
 
-    int ret = nfc_ndef_message_get_rawdata(message, &raw_data, &size);
-    if(NFC_ERROR_NONE != ret) {
-        LoggerE("Failed to get message data: %d", ret);
+  int ret = nfc_ndef_message_get_rawdata(message, &raw_data, &size);
+  if(NFC_ERROR_NONE != ret) {
+    LoggerE("Failed to get message data: %d", ret);
 
-        // release data if any allocated
-        free(raw_data);
+    // release data if any allocated
+    free(raw_data);
 
-        // create exception and post error message (call error callback)
-        auto ex = UnknownException("Failed to retrieve NDEF message data");
-        picojson::value event = createEventError(callbackId, ex);
-        NFCInstance::getInstance().PostMessage(event.serialize().c_str());
-        return;
-    }
+    // create exception and post error message (call error callback)
+    auto ex = UnknownException("Failed to retrieve NDEF message data");
+    picojson::value event = createEventError(callbackId, ex);
+    NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+    return;
+  }
 
-    // create success event, fill it with data and call success callback
-    picojson::value event = createEventSuccess(callbackId);
-    picojson::object& obj = event.get<picojson::object>();
+  // create success event, fill it with data and call success callback
+  picojson::value event = createEventSuccess(callbackId);
+  picojson::object& obj = event.get<picojson::object>();
 
-    NFCMessageUtils::ReportNdefMessageFromData(raw_data, size, obj);
+  NFCMessageUtils::ReportNdefMessageFromData(raw_data, size, obj);
 
-    NFCInstance::getInstance().PostMessage(event.serialize().c_str());
-    free(raw_data);
+  NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+  free(raw_data);
 }
 
 void NFCAdapter::TagReadNDEF(int tag_id, const picojson::value& args) {
 
-    LoggerD("Entered");
-    double callbackId = args.get(CALLBACK_ID).get<double>();
-    LoggerD("Received callback id: %f", callbackId);
-
-    if(!TagIsConnectedGetter(tag_id)) {
-        UnknownException ex("Tag is no more connected");
-
-        picojson::value event = createEventError(callbackId, ex);
-        NFCInstance::getInstance().PostMessage(event.serialize().c_str());
-        return;
-    }
-
-    double* callbackIdPointer = new double(callbackId);
-    int result = nfc_tag_read_ndef(m_last_tag_handle, tagReadNDEFCb,
-            (void*)(callbackIdPointer));
-    if(NFC_ERROR_NONE != result) {
-        LoggerE("Failed to read NDEF message from tag: %d", result);
-        delete callbackIdPointer;
-        callbackIdPointer = NULL;
-
-        // for permission related error throw exception ...
-        if(NFC_ERROR_SECURITY_RESTRICTED == result ||
-                NFC_ERROR_PERMISSION_DENIED == result) {
-            throw SecurityException("Failed to read NDEF - permission denied");
-        }
+  LoggerD("Entered");
+  double callbackId = args.get(CALLBACK_ID).get<double>();
+  LoggerD("Received callback id: %f", callbackId);
 
-        LoggerE("Preparing error callback to call");
-        // ... otherwise call error callback
-        std::string errName = NFCUtil::getNFCErrorString(result);
-        std::string errMessage = NFCUtil::getNFCErrorMessage(result);
-        PlatformException ex(errName, errMessage);
+  if(!TagIsConnectedGetter(tag_id)) {
+    UnknownException ex("Tag is no more connected");
 
-        picojson::value event = createEventError(callbackId, ex);
-        NFCInstance::getInstance().PostMessage(event.serialize().c_str());
-    }
+    picojson::value event = createEventError(callbackId, ex);
+    NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+    return;
+  }
+
+  double* callbackIdPointer = new double(callbackId);
+  int result = nfc_tag_read_ndef(m_last_tag_handle, tagReadNDEFCb,
+                                 (void*)(callbackIdPointer));
+  if(NFC_ERROR_NONE != result) {
+    LoggerE("Failed to read NDEF message from tag: %d", result);
+    delete callbackIdPointer;
+    callbackIdPointer = NULL;
+
+    // for permission related error throw exception ...
+    if(NFC_ERROR_SECURITY_RESTRICTED == result ||
+        NFC_ERROR_PERMISSION_DENIED == result) {
+      throw SecurityException("Failed to read NDEF - permission denied");
+    }
+
+    LoggerE("Preparing error callback to call");
+    // ... otherwise call error callback
+    std::string errName = NFCUtil::getNFCErrorString(result);
+    std::string errMessage = NFCUtil::getNFCErrorMessage(result);
+    PlatformException ex(errName, errMessage);
+
+    picojson::value event = createEventError(callbackId, ex);
+    NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+  }
 
 }
 
 void NFCAdapter::TagWriteNDEF(int tag_id, const picojson::value& args) {
 
-    LoggerD("Entered");
+  LoggerD("Entered");
 
-    double callbackId = args.get(CALLBACK_ID).get<double>();
-    LoggerD("Received callback id: %f", callbackId);
+  double callbackId = args.get(CALLBACK_ID).get<double>();
+  LoggerD("Received callback id: %f", callbackId);
 
-    if(!TagIsConnectedGetter(tag_id)) {
-        UnknownException ex("Tag is no more connected");
+  if(!TagIsConnectedGetter(tag_id)) {
+    UnknownException ex("Tag is no more connected");
 
-        picojson::value event = createEventError(callbackId, ex);
-        NFCInstance::getInstance().PostMessage(event.serialize().c_str());
-        return;
-    }
+    picojson::value event = createEventError(callbackId, ex);
+    NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+    return;
+  }
 
-    const picojson::array& records_array = FromJson<picojson::array>(
-            args.get<picojson::object>(), "records");
+  const picojson::array& records_array = FromJson<picojson::array>(
+      args.get<picojson::object>(), "records");
 
-    const int size = static_cast<int>(args.get("recordsSize").get<double>());
+  const int size = static_cast<int>(args.get("recordsSize").get<double>());
 
-    nfc_ndef_message_h message = NFCMessageUtils::NDEFMessageToStruct(records_array, size);
+  nfc_ndef_message_h message = NFCMessageUtils::NDEFMessageToStruct(records_array, size);
 
-    if(message){
-        int result = nfc_tag_write_ndef(m_last_tag_handle, message, NULL, NULL);
+  if(message){
+    int result = nfc_tag_write_ndef(m_last_tag_handle, message, NULL, NULL);
 
-        NFCMessageUtils::RemoveMessageHandle(message);
-        if (NFC_ERROR_NONE != result){
+    NFCMessageUtils::RemoveMessageHandle(message);
+    if (NFC_ERROR_NONE != result){
 
-            // for permission related error throw exception
-            if(NFC_ERROR_SECURITY_RESTRICTED == result ||
-                    NFC_ERROR_PERMISSION_DENIED == result) {
-                throw SecurityException("Failed to read NDEF - permission denied");
-            }
+      // for permission related error throw exception
+      if(NFC_ERROR_SECURITY_RESTRICTED == result ||
+          NFC_ERROR_PERMISSION_DENIED == result) {
+        throw SecurityException("Failed to read NDEF - permission denied");
+      }
 
-            LoggerE("Error occured when sending message: %d", result);
-            std::string errName = NFCUtil::getNFCErrorString(result);
-            std::string errMessage = NFCUtil::getNFCErrorMessage(result);
-            LoggerE("%s: %s", errName.c_str(), errMessage.c_str());
+      LoggerE("Error occured when sending message: %d", result);
+      std::string errName = NFCUtil::getNFCErrorString(result);
+      std::string errMessage = NFCUtil::getNFCErrorMessage(result);
+      LoggerE("%s: %s", errName.c_str(), errMessage.c_str());
 
-            // create and post error message
-            PlatformException ex(errName, errMessage);
-            picojson::value event = createEventError(callbackId, ex);
-            NFCInstance::getInstance().PostMessage(event.serialize().c_str());
-        }
-        else {
-            // create and post success message
-            picojson::value event = createEventSuccess(callbackId);
-            NFCInstance::getInstance().PostMessage(event.serialize().c_str());
-        }
-    } else {
-        LoggerE("Invalid message handle");
-        InvalidValuesException ex("Message is not valid");
-        picojson::value event = createEventError(callbackId, ex);
-        NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+      // create and post error message
+      PlatformException ex(errName, errMessage);
+      picojson::value event = createEventError(callbackId, ex);
+      NFCInstance::getInstance().PostMessage(event.serialize().c_str());
     }
+    else {
+      // create and post success message
+      picojson::value event = createEventSuccess(callbackId);
+      NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+    }
+  } else {
+    LoggerE("Invalid message handle");
+    InvalidValuesException ex("Message is not valid");
+    picojson::value event = createEventError(callbackId, ex);
+    NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+  }
 }
 
 static void tagTransceiveCb(nfc_error_e err, unsigned char *buffer,
-        int buffer_size, void* data) {
+                            int buffer_size, void* data) {
 
-    LoggerD("Entered");
+  LoggerD("Entered");
 
-    if (!data) {
-        // no callback id - unable to report success, neither error
-        LoggerE("Unable to launch transceive callback");
-        return;
-    }
+  if (!data) {
+    // no callback id - unable to report success, neither error
+    LoggerE("Unable to launch transceive callback");
+    return;
+  }
 
-    double callback_id = *((double*)data);
-    delete (double*)data;
-    data = NULL;
+  double callback_id = *((double*)data);
+  delete (double*)data;
+  data = NULL;
 
-    if (NFC_ERROR_NONE != err) {
+  if (NFC_ERROR_NONE != err) {
 
-        LoggerE("NFCTag transceive failed: %d", err);
+    LoggerE("NFCTag transceive failed: %d", err);
 
-        // create exception and post error message (call error callback)
-        std::string error_name = NFCUtil::getNFCErrorString(err);
-        std::string error_message = NFCUtil::getNFCErrorMessage(err);
+    // create exception and post error message (call error callback)
+    std::string error_name = NFCUtil::getNFCErrorString(err);
+    std::string error_message = NFCUtil::getNFCErrorMessage(err);
 
-        PlatformException ex(error_name, error_message);
-        picojson::value event = createEventError(callback_id, ex);
-        NFCInstance::getInstance().PostMessage(event.serialize().c_str());
-        return;
-    }
+    PlatformException ex(error_name, error_message);
+    picojson::value event = createEventError(callback_id, ex);
+    NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+    return;
+  }
 
-    // create result and push to JS layer
-    picojson::value response = createEventSuccess(callback_id);
-    picojson::object& response_obj = response.get<picojson::object>();
-    NFCInstance::getInstance().InstanceReportSuccess(response_obj);
-    picojson::array& callback_data_array = response_obj.insert(std::make_pair("data",
-            picojson::value(picojson::array()))).first->second.get<picojson::array>();
+  // create result and push to JS layer
+  picojson::value response = createEventSuccess(callback_id);
+  picojson::object& response_obj = response.get<picojson::object>();
+  NFCInstance::getInstance().InstanceReportSuccess(response_obj);
+  picojson::array& callback_data_array = response_obj.insert(std::make_pair("data",
+                                                                            picojson::value(picojson::array()))).first->second.get<picojson::array>();
 
-    for (unsigned int i = 0; i < buffer_size; i++) {
-        callback_data_array.push_back(picojson::value(static_cast<double>(buffer[i])));
-    }
+  for (unsigned int i = 0; i < buffer_size; i++) {
+    callback_data_array.push_back(picojson::value(static_cast<double>(buffer[i])));
+  }
 
-    NFCInstance::getInstance().PostMessage(response.serialize().c_str());
+  NFCInstance::getInstance().PostMessage(response.serialize().c_str());
 }
 
 void NFCAdapter::TagTransceive(int tag_id, const picojson::value& args) {
 
-    LoggerD("Entered");
-    double callback_id = args.get(CALLBACK_ID).get<double>();
-    LoggerD("Received callback id: %f", callback_id);
+  LoggerD("Entered");
+  double callback_id = args.get(CALLBACK_ID).get<double>();
+  LoggerD("Received callback id: %f", callback_id);
 
-    if(!TagIsConnectedGetter(tag_id)) {
-        UnknownException ex("Tag is no more connected");
+  if(!TagIsConnectedGetter(tag_id)) {
+    UnknownException ex("Tag is no more connected");
 
-        picojson::value event = createEventError(callback_id, ex);
-        NFCInstance::getInstance().PostMessage(event.serialize().c_str());
-        return;
-    }
+    picojson::value event = createEventError(callback_id, ex);
+    NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+    return;
+  }
 
-    const picojson::array& data_array = FromJson<picojson::array>(
-            args.get<picojson::object>(), "data");
+  const picojson::array& data_array = FromJson<picojson::array>(
+      args.get<picojson::object>(), "data");
 
-    unsigned char *buffer = new unsigned char[data_array.size()];
-    // unique pointer used to automatically release memory when leaving scope
-    std::unique_ptr<unsigned char> buffer_ptr(buffer);
-    int i = 0;
+  unsigned char *buffer = new unsigned char[data_array.size()];
+  // unique pointer used to automatically release memory when leaving scope
+  std::unique_ptr<unsigned char> buffer_ptr(buffer);
+  int i = 0;
 
-    for(auto it = data_array.begin(); it != data_array.end();
-            ++it, ++i) {
+  for(auto it = data_array.begin(); it != data_array.end();
+      ++it, ++i) {
 
-        unsigned char val = (unsigned char)it->get<double>();
-        buffer[i] = val;
-    }
+    unsigned char val = (unsigned char)it->get<double>();
+    buffer[i] = val;
+  }
 
-    double* callback_id_pointer = new double(callback_id);
+  double* callback_id_pointer = new double(callback_id);
 
-    int result = nfc_tag_transceive(m_last_tag_handle, buffer, data_array.size(),
-            tagTransceiveCb, (void*) callback_id_pointer);
+  int result = nfc_tag_transceive(m_last_tag_handle, buffer, data_array.size(),
+                                  tagTransceiveCb, (void*) callback_id_pointer);
 
-    if (NFC_ERROR_NONE != result) {
-        delete callback_id_pointer;
-        callback_id_pointer = NULL;
+  if (NFC_ERROR_NONE != result) {
+    delete callback_id_pointer;
+    callback_id_pointer = NULL;
 
-        // for permission related error throw exception
-        if(NFC_ERROR_SECURITY_RESTRICTED == result ||
-                NFC_ERROR_PERMISSION_DENIED == result) {
-            throw SecurityException("Failed to read NDEF - permission denied");
-        }
+    // for permission related error throw exception
+    if(NFC_ERROR_SECURITY_RESTRICTED == result ||
+        NFC_ERROR_PERMISSION_DENIED == result) {
+      throw SecurityException("Failed to read NDEF - permission denied");
+    }
 
-        std::string error_name = NFCUtil::getNFCErrorString(result);
-        std::string error_message = NFCUtil::getNFCErrorMessage(result);
+    std::string error_name = NFCUtil::getNFCErrorString(result);
+    std::string error_message = NFCUtil::getNFCErrorMessage(result);
 
-        LoggerE("NFCTag transceive failed: %d", result);
+    LoggerE("NFCTag transceive failed: %d", result);
 
-        PlatformException ex(error_name, error_message);
-        picojson::value event = createEventError(callback_id, ex);
-        NFCInstance::getInstance().PostMessage(event.serialize().c_str());
-        return;
-    }
+    PlatformException ex(error_name, error_message);
+    picojson::value event = createEventError(callback_id, ex);
+    NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+    return;
+  }
 
 }
 
 void NFCAdapter::GetCachedMessage(picojson::object& out) {
 
-    nfc_ndef_message_h message_handle = NULL;
-    int result = nfc_manager_get_cached_message(&message_handle);
-    if (NFC_ERROR_INVALID_NDEF_MESSAGE == result ||
-            NFC_ERROR_NO_NDEF_MESSAGE == result) {
-        NFCMessageUtils::RemoveMessageHandle(message_handle);
-
-        return;
-    }
-    if (NFC_ERROR_NONE != result) {
-        LOGE("Failed to get cached message: %d", result);
-        NFCUtil::throwNFCException(result, "Failed to get cached message");
-    }
-    unsigned char *raw_data = NULL;
-    unsigned int size;
-    if (NFC_ERROR_NONE != nfc_ndef_message_get_rawdata(message_handle,
-            &raw_data, &size)) {
-        LOGE("Unknown error while getting message.");
-        free(raw_data);
-        return;
-    }
-    NFCMessageUtils::ReportNdefMessageFromData(raw_data, size, out);
+  nfc_ndef_message_h message_handle = NULL;
+  int result = nfc_manager_get_cached_message(&message_handle);
+  if (NFC_ERROR_INVALID_NDEF_MESSAGE == result ||
+      NFC_ERROR_NO_NDEF_MESSAGE == result) {
     NFCMessageUtils::RemoveMessageHandle(message_handle);
+
+    return;
+  }
+  if (NFC_ERROR_NONE != result) {
+    LOGE("Failed to get cached message: %d", result);
+    NFCUtil::throwNFCException(result, "Failed to get cached message");
+  }
+  unsigned char *raw_data = NULL;
+  unsigned int size;
+  if (NFC_ERROR_NONE != nfc_ndef_message_get_rawdata(message_handle,
+                                                     &raw_data, &size)) {
+    LOGE("Unknown error while getting message.");
     free(raw_data);
+    return;
+  }
+  NFCMessageUtils::ReportNdefMessageFromData(raw_data, size, out);
+  NFCMessageUtils::RemoveMessageHandle(message_handle);
+  free(raw_data);
 }
 
 static void peerSentCallback(nfc_error_e result, void *user_data) {
-    double* callbackId = static_cast<double*>(user_data);
+  double* callbackId = static_cast<double*>(user_data);
 
-    if (NFC_ERROR_NONE != result){
-        auto ex = PlatformException(NFCUtil::getNFCErrorString(result),
-                NFCUtil::getNFCErrorMessage(result));
+  if (NFC_ERROR_NONE != result){
+    auto ex = PlatformException(NFCUtil::getNFCErrorString(result),
+                                NFCUtil::getNFCErrorMessage(result));
 
-        picojson::value event = createEventError(*callbackId, ex);
+    picojson::value event = createEventError(*callbackId, ex);
 
-        NFCInstance::getInstance().PostMessage(event.serialize().c_str());
-    } else {
-        picojson::value event = createEventSuccess(*callbackId);
+    NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+  } else {
+    picojson::value event = createEventSuccess(*callbackId);
 
-        NFCInstance::getInstance().PostMessage(event.serialize().c_str());
-    }
+    NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+  }
 
-    delete callbackId;
-    callbackId = NULL;
+  delete callbackId;
+  callbackId = NULL;
 }
 
 static gboolean sendNDEFErrorCB(void * user_data) {
-    peerSentCallback(NFC_ERROR_INVALID_NDEF_MESSAGE, user_data);
-    return false;
+  peerSentCallback(NFC_ERROR_INVALID_NDEF_MESSAGE, user_data);
+  return false;
 }
 
 void NFCAdapter::sendNDEF(int peer_id, const picojson::value& args) {
-    double* callbackId = new double(args.get(CALLBACK_ID).get<double>());
-
-    if(!PeerIsConnectedGetter(peer_id)) {
-        UnknownException ex("Peer is no more connected");
-        picojson::value event = createEventError(*callbackId, ex);
-        NFCInstance::getInstance().PostMessage(event.serialize().c_str());
-        delete callbackId;
-        callbackId = NULL;
-        return;
-    }
+  double* callbackId = new double(args.get(CALLBACK_ID).get<double>());
 
-    const picojson::array& records_array =
-        FromJson<picojson::array>(args.get<picojson::object>(), "records");
-    const int size = static_cast<int>(args.get("recordsSize").get<double>());
-
-    nfc_ndef_message_h message = NFCMessageUtils::NDEFMessageToStruct(
-            records_array, size);
-    if (message) {
-        int ret = nfc_p2p_send(m_peer_handle, message,
-                peerSentCallback, static_cast<void *>(callbackId));
-        NFCMessageUtils::RemoveMessageHandle(message);
-        if (NFC_ERROR_NONE != ret) {
-            LOGE("sendNDEF failed %d",ret);
-            delete callbackId;
-            callbackId = NULL;
-            NFCUtil::throwNFCException(ret, "sendNDEF failed.");
-        }
-    } else {
-        if (!g_idle_add(sendNDEFErrorCB, static_cast<void*>(callbackId))) {
-            LOGE("g_idle addition failed");
-            delete callbackId;
-            callbackId = NULL;
-        }
-    }
+  if(!PeerIsConnectedGetter(peer_id)) {
+    UnknownException ex("Peer is no more connected");
+    picojson::value event = createEventError(*callbackId, ex);
+    NFCInstance::getInstance().PostMessage(event.serialize().c_str());
+    delete callbackId;
+    callbackId = NULL;
+    return;
+  }
+
+  const picojson::array& records_array =
+      FromJson<picojson::array>(args.get<picojson::object>(), "records");
+  const int size = static_cast<int>(args.get("recordsSize").get<double>());
+
+  nfc_ndef_message_h message = NFCMessageUtils::NDEFMessageToStruct(
+      records_array, size);
+  if (message) {
+    int ret = nfc_p2p_send(m_peer_handle, message,
+                           peerSentCallback, static_cast<void *>(callbackId));
+    NFCMessageUtils::RemoveMessageHandle(message);
+    if (NFC_ERROR_NONE != ret) {
+      LOGE("sendNDEF failed %d",ret);
+      delete callbackId;
+      callbackId = NULL;
+      NFCUtil::throwNFCException(ret, "sendNDEF failed.");
+    }
+  } else {
+    if (!g_idle_add(sendNDEFErrorCB, static_cast<void*>(callbackId))) {
+      LOGE("g_idle addition failed");
+      delete callbackId;
+      callbackId = NULL;
+    }
+  }
 }
 }// nfc
 }// extension
index 15a5830db50ac8eeb8c2fcc30dc114c2567d9421..8cbf1469333c07ea31f04176eb41e747c88c75dd 100644 (file)
@@ -25,72 +25,72 @@ class NFCInstance;
 typedef std::list<std::pair<std::string, UCharVector>> NFCTagPropertiesT;
 
 class NFCAdapter {
-public:
-    bool GetPowered();
-    void SetPowered(const picojson::value& args);
-
-// cardEmulationMode getter and setter
-    std::string GetCardEmulationMode();
-    void SetCardEmulationMode(std::string mode);
-// activeSecureElement getter and setter
-    std::string GetActiveSecureElement();
-    void 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();
-    void GetCachedMessage(picojson::object& out);
-
-    void SetPeerHandle(nfc_p2p_target_h handle);
-    nfc_p2p_target_h GetPeerHandle();
-    int GetPeerId();
-    void IncreasePeerId();
-    bool PeerIsConnectedGetter(int peer_id);
-    void SetPeerListener();
-    void UnsetPeerListener();
-    void SetReceiveNDEFListener(int peer_id);
-    void UnsetReceiveNDEFListener(int peer_id);
-    void sendNDEF(int peer_id, const picojson::value& args);
-    bool IsNDEFListenerSet();
-
-// NFCTag related methods
-    // attributes
-    std::string TagTypeGetter(int tag_id);
-    bool TagIsSupportedNDEFGetter(int tag_id);
-    unsigned int TagNDEFSizeGetter(int tag_id);
-    NFCTagPropertiesT TagPropertiesGetter(int tag_id);
-    bool TagIsConnectedGetter(int tag_id);
-    // methods
-    void TagReadNDEF(int tag_id, const picojson::value& args);
-    void TagWriteNDEF(int tag_id, const picojson::value& args);
-    void TagTransceive(int tag_id, const picojson::value& args);
-    // listeners
-    void SetTagListener();
-    void UnsetTagListener();
-    int GetNextTagId();
-    void SetTagHandle(nfc_tag_h tag);
-
-    static NFCAdapter* GetInstance();
-private:
-    NFCAdapter();
-    virtual ~NFCAdapter();
-
-    nfc_tag_h m_last_tag_handle;
-    bool m_is_tag_listener_set;
-    int m_latest_tag_id;
-    bool m_is_listener_set;
-    bool m_is_transaction_ese_listener_set;
-    bool m_is_transaction_uicc_listener_set;
-    bool m_is_peer_listener_set;
-    int m_latest_peer_id;
-    nfc_p2p_target_h m_peer_handle;
-    bool m_is_ndef_listener_set;
+ public:
+  bool GetPowered();
+  void SetPowered(const picojson::value& args);
+
+  // cardEmulationMode getter and setter
+  std::string GetCardEmulationMode();
+  void SetCardEmulationMode(std::string mode);
+  // activeSecureElement getter and setter
+  std::string GetActiveSecureElement();
+  void 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();
+  void GetCachedMessage(picojson::object& out);
+
+  void SetPeerHandle(nfc_p2p_target_h handle);
+  nfc_p2p_target_h GetPeerHandle();
+  int GetPeerId();
+  void IncreasePeerId();
+  bool PeerIsConnectedGetter(int peer_id);
+  void SetPeerListener();
+  void UnsetPeerListener();
+  void SetReceiveNDEFListener(int peer_id);
+  void UnsetReceiveNDEFListener(int peer_id);
+  void sendNDEF(int peer_id, const picojson::value& args);
+  bool IsNDEFListenerSet();
+
+  // NFCTag related methods
+  // attributes
+  std::string TagTypeGetter(int tag_id);
+  bool TagIsSupportedNDEFGetter(int tag_id);
+  unsigned int TagNDEFSizeGetter(int tag_id);
+  NFCTagPropertiesT TagPropertiesGetter(int tag_id);
+  bool TagIsConnectedGetter(int tag_id);
+  // methods
+  void TagReadNDEF(int tag_id, const picojson::value& args);
+  void TagWriteNDEF(int tag_id, const picojson::value& args);
+  void TagTransceive(int tag_id, const picojson::value& args);
+  // listeners
+  void SetTagListener();
+  void UnsetTagListener();
+  int GetNextTagId();
+  void SetTagHandle(nfc_tag_h tag);
+
+  static NFCAdapter* GetInstance();
+ private:
+  NFCAdapter();
+  virtual ~NFCAdapter();
+
+  nfc_tag_h m_last_tag_handle;
+  bool m_is_tag_listener_set;
+  int m_latest_tag_id;
+  bool m_is_listener_set;
+  bool m_is_transaction_ese_listener_set;
+  bool m_is_transaction_uicc_listener_set;
+  bool m_is_peer_listener_set;
+  int m_latest_peer_id;
+  nfc_p2p_target_h m_peer_handle;
+  bool m_is_ndef_listener_set;
 };
 
 } // nfc
index 5470adc34544f97d77eeb27c0c1ecafa8a7a070c..fc3c793b4cb265cd9132aad555c6fe5be8f7be1b 100644 (file)
@@ -9,26 +9,26 @@
 extern const char kSource_nfc_api[];
 
 common::Extension* CreateExtension() {
-    return new NFCExtension;
+  return new NFCExtension;
 }
 
 NFCExtension::NFCExtension() {
-    SetExtensionName("tizen.nfc");
-    SetJavaScriptAPI(kSource_nfc_api);
-
-    const char* entry_points[] = {
-            "tizen.NDEFMessage",
-            "tizen.NDEFRecord",
-            "tizen.NDEFRecordText",
-            "tizen.NDEFRecordURI",
-            "tizen.NDEFRecordMedia",
-            NULL
-    };
-    SetExtraJSEntryPoints(entry_points);
+  SetExtensionName("tizen.nfc");
+  SetJavaScriptAPI(kSource_nfc_api);
+
+  const char* entry_points[] = {
+      "tizen.NDEFMessage",
+      "tizen.NDEFRecord",
+      "tizen.NDEFRecordText",
+      "tizen.NDEFRecordURI",
+      "tizen.NDEFRecordMedia",
+      NULL
+  };
+  SetExtraJSEntryPoints(entry_points);
 }
 
 NFCExtension::~NFCExtension() {}
 
 common::Instance* NFCExtension::CreateInstance() {
-    return &extension::nfc::NFCInstance::getInstance();;
+  return &extension::nfc::NFCInstance::getInstance();;
 }
index 12e954bc9d2e95b8951f7d969d9d774d3e2a96db..e7ae137edae6083913bff496e8f635c2422ad79f 100644 (file)
@@ -8,12 +8,12 @@
 #include "common/extension.h"
 
 class NFCExtension : public common::Extension {
-public:
-    NFCExtension();
-    virtual ~NFCExtension();
-private:
-    // common::Extension implementation.
-    virtual common::Instance* CreateInstance();
+ public:
+  NFCExtension();
+  virtual ~NFCExtension();
+ private:
+  // common::Extension implementation.
+  virtual common::Instance* CreateInstance();
 };
 
 #endif  // NFC_NFC_EXTENSION_H_
index 8e43eb2ca660770db85c2447ec787c01dacb46c2..42df1478272999eeb8ac90570f133c5ca17cf2e1 100644 (file)
@@ -21,642 +21,642 @@ using namespace common;
 using namespace extension::nfc;
 
 NFCInstance& NFCInstance::getInstance() {
-    static NFCInstance instance;
-    return instance;
+  static NFCInstance instance;
+  return instance;
 }
 
 NFCInstance::NFCInstance() {
-    using namespace std::placeholders;
+  using namespace std::placeholders;
 #define REGISTER_SYNC(c,x) \
-        RegisterSyncHandler(c, std::bind(&NFCInstance::x, this, _1, _2));
-    REGISTER_SYNC("NFCManager_getDefaultAdapter", GetDefaultAdapter);
-    REGISTER_SYNC("NFCManager_setExclusiveMode", SetExclusiveMode);
-    REGISTER_SYNC("NFCAdapter_getPowered", GetPowered);
-    REGISTER_SYNC("NFCAdapter_cardEmulationModeSetter", CardEmulationModeSetter);
-    REGISTER_SYNC("NFCAdapter_cardEmulationModeGetter", CardEmulationModeGetter);
-    REGISTER_SYNC("NFCAdapter_activeSecureElementSetter", ActiveSecureElementSetter);
-    REGISTER_SYNC("NFCAdapter_activeSecureElementGetter", ActiveSecureElementGetter);
-    REGISTER_SYNC("NFCAdapter_setPeerListener", SetPeerListener);
-    REGISTER_SYNC("NFCAdapter_setTagListener", SetTagListener);
-    REGISTER_SYNC("NFCAdapter_PeerIsConnectedGetter", PeerIsConnectedGetter);
-    REGISTER_SYNC("NFCAdapter_unsetTagListener", UnsetTagListener);
-    REGISTER_SYNC("NFCAdapter_unsetPeerListener", UnsetPeerListener);
-    REGISTER_SYNC("NFCAdapter_addCardEmulationModeChangeListener",
-            AddCardEmulationModeChangeListener);
-    REGISTER_SYNC("NFCAdapter_removeCardEmulationModeChangeListener",
-            RemoveCardEmulationModeChangeListener);
-    REGISTER_SYNC("NFCAdapter_addTransactionEventListener",
-            AddTransactionEventListener);
-    REGISTER_SYNC("NFCAdapter_removeTransactionEventListener",
-            RemoveTransactionEventListener);
-    REGISTER_SYNC("NFCAdapter_addActiveSecureElementChangeListener",
-            AddActiveSecureElementChangeListener);
-    REGISTER_SYNC("NFCAdapter_removeActiveSecureElementChangeListener",
-            RemoveActiveSecureElementChangeListener);
-    REGISTER_SYNC("NFCAdapter_getCachedMessage", GetCachedMessage);
-    REGISTER_SYNC("NFCAdapter_setExclusiveModeForTransaction",
-            SetExclusiveModeForTransaction);
-    REGISTER_SYNC("NFCPeer_setReceiveNDEFListener", SetReceiveNDEFListener);
-    REGISTER_SYNC("NFCPeer_unsetReceiveNDEFListener", UnsetReceiveNDEFListener);
-    REGISTER_SYNC("NDEFMessage_toByte", ToByte);
-    //Message related methods
-    REGISTER_SYNC("NDEFMessage_constructor", NDEFMessageContructor);
-    REGISTER_SYNC("NDEFMessage_toByte", ToByte);
-    REGISTER_SYNC("NDEFRecord_constructor", NDEFRecordContructor);
-    REGISTER_SYNC("NDEFRecordText_constructor", NDEFRecordTextContructor);
-    REGISTER_SYNC("NDEFRecordURI_constructor", NDEFRecordURIContructor);
-    REGISTER_SYNC("NDEFRecordMedia_constructor", NDEFRecordMediaContructor);
-
-    // NFCTag attributes getters
-    REGISTER_SYNC("NFCTag_typeGetter", TagTypeGetter);
-    REGISTER_SYNC("NFCTag_isSupportedNDEFGetter", TagIsSupportedNDEFGetter);
-    REGISTER_SYNC("NFCTag_NDEFSizeGetter", TagNDEFSizeGetter);
-    REGISTER_SYNC("NFCTag_propertiesGetter", TagPropertiesGetter);
-    REGISTER_SYNC("NFCTag_isConnectedGetter", TagIsConnectedGetter);
+    RegisterSyncHandler(c, std::bind(&NFCInstance::x, this, _1, _2));
+  REGISTER_SYNC("NFCManager_getDefaultAdapter", GetDefaultAdapter);
+  REGISTER_SYNC("NFCManager_setExclusiveMode", SetExclusiveMode);
+  REGISTER_SYNC("NFCAdapter_getPowered", GetPowered);
+  REGISTER_SYNC("NFCAdapter_cardEmulationModeSetter", CardEmulationModeSetter);
+  REGISTER_SYNC("NFCAdapter_cardEmulationModeGetter", CardEmulationModeGetter);
+  REGISTER_SYNC("NFCAdapter_activeSecureElementSetter", ActiveSecureElementSetter);
+  REGISTER_SYNC("NFCAdapter_activeSecureElementGetter", ActiveSecureElementGetter);
+  REGISTER_SYNC("NFCAdapter_setPeerListener", SetPeerListener);
+  REGISTER_SYNC("NFCAdapter_setTagListener", SetTagListener);
+  REGISTER_SYNC("NFCAdapter_PeerIsConnectedGetter", PeerIsConnectedGetter);
+  REGISTER_SYNC("NFCAdapter_unsetTagListener", UnsetTagListener);
+  REGISTER_SYNC("NFCAdapter_unsetPeerListener", UnsetPeerListener);
+  REGISTER_SYNC("NFCAdapter_addCardEmulationModeChangeListener",
+                AddCardEmulationModeChangeListener);
+  REGISTER_SYNC("NFCAdapter_removeCardEmulationModeChangeListener",
+                RemoveCardEmulationModeChangeListener);
+  REGISTER_SYNC("NFCAdapter_addTransactionEventListener",
+                AddTransactionEventListener);
+  REGISTER_SYNC("NFCAdapter_removeTransactionEventListener",
+                RemoveTransactionEventListener);
+  REGISTER_SYNC("NFCAdapter_addActiveSecureElementChangeListener",
+                AddActiveSecureElementChangeListener);
+  REGISTER_SYNC("NFCAdapter_removeActiveSecureElementChangeListener",
+                RemoveActiveSecureElementChangeListener);
+  REGISTER_SYNC("NFCAdapter_getCachedMessage", GetCachedMessage);
+  REGISTER_SYNC("NFCAdapter_setExclusiveModeForTransaction",
+                SetExclusiveModeForTransaction);
+  REGISTER_SYNC("NFCPeer_setReceiveNDEFListener", SetReceiveNDEFListener);
+  REGISTER_SYNC("NFCPeer_unsetReceiveNDEFListener", UnsetReceiveNDEFListener);
+  REGISTER_SYNC("NDEFMessage_toByte", ToByte);
+  //Message related methods
+  REGISTER_SYNC("NDEFMessage_constructor", NDEFMessageContructor);
+  REGISTER_SYNC("NDEFMessage_toByte", ToByte);
+  REGISTER_SYNC("NDEFRecord_constructor", NDEFRecordContructor);
+  REGISTER_SYNC("NDEFRecordText_constructor", NDEFRecordTextContructor);
+  REGISTER_SYNC("NDEFRecordURI_constructor", NDEFRecordURIContructor);
+  REGISTER_SYNC("NDEFRecordMedia_constructor", NDEFRecordMediaContructor);
+
+  // NFCTag attributes getters
+  REGISTER_SYNC("NFCTag_typeGetter", TagTypeGetter);
+  REGISTER_SYNC("NFCTag_isSupportedNDEFGetter", TagIsSupportedNDEFGetter);
+  REGISTER_SYNC("NFCTag_NDEFSizeGetter", TagNDEFSizeGetter);
+  REGISTER_SYNC("NFCTag_propertiesGetter", TagPropertiesGetter);
+  REGISTER_SYNC("NFCTag_isConnectedGetter", TagIsConnectedGetter);
 #undef REGISTER_SYNC
 #define REGISTER(c,x) \
     RegisterHandler(c, std::bind(&NFCInstance::x, this, _1, _2));
-    REGISTER("NFCAdapter_setPowered", SetPowered);
-    REGISTER("NFCTag_readNDEF", ReadNDEF);
-    REGISTER("NFCTag_writeNDEF", WriteNDEF);
-    REGISTER("NFCTag_transceive", Transceive );
-    REGISTER("NFCPeer_sendNDEF", SendNDEF);
+  REGISTER("NFCAdapter_setPowered", SetPowered);
+  REGISTER("NFCTag_readNDEF", ReadNDEF);
+  REGISTER("NFCTag_writeNDEF", WriteNDEF);
+  REGISTER("NFCTag_transceive", Transceive );
+  REGISTER("NFCPeer_sendNDEF", SendNDEF);
 #undef REGISTER
-    // NFC library initialization
-    int result = nfc_manager_initialize();
-    if (NFC_ERROR_NONE != result) {
-        LoggerE("Could not initialize NFC Manager.");
-    }
+  // NFC library initialization
+  int result = nfc_manager_initialize();
+  if (NFC_ERROR_NONE != result) {
+    LoggerE("Could not initialize NFC Manager.");
+  }
 }
 
 NFCInstance::~NFCInstance() {
-    int result = nfc_manager_deinitialize();
-    if (NFC_ERROR_NONE != result) {
-        LoggerE("NFC Manager deinitialization failed.");
-    }
+  int result = nfc_manager_deinitialize();
+  if (NFC_ERROR_NONE != result) {
+    LoggerE("NFC Manager deinitialization failed.");
+  }
 }
 
 void NFCInstance::InstanceReportSuccess(picojson::object& out) {
-    out.insert(std::make_pair("status", picojson::value("success")));
+  out.insert(std::make_pair("status", picojson::value("success")));
 }
 
 void NFCInstance::InstanceReportSuccess(const picojson::value& result, picojson::object& out) {
-    out.insert(std::make_pair("status", picojson::value("success")));
-    out.insert(std::make_pair("result", result));
+  out.insert(std::make_pair("status", picojson::value("success")));
+  out.insert(std::make_pair("result", result));
 }
 
 void NFCInstance::InstanceReportError(picojson::object& out) {
-    out.insert(std::make_pair("status", picojson::value("error")));
+  out.insert(std::make_pair("status", picojson::value("error")));
 }
 
 void NFCInstance::InstanceReportError(const PlatformException& ex, picojson::object& out) {
-    out.insert(std::make_pair("status", picojson::value("error")));
-    out.insert(std::make_pair("error", ex.ToJSON()));
+  out.insert(std::make_pair("status", picojson::value("error")));
+  out.insert(std::make_pair("error", ex.ToJSON()));
 }
 
 
 void NFCInstance::GetDefaultAdapter(
-        const picojson::value& args, picojson::object& out) {
-
-    // Default NFC adapter is created at JS level
-    // Here there's only check for NFC support
-    LoggerD("Entered");
-    if(!nfc_manager_is_supported()) {
-        LoggerE("NFC manager is not supported");
-        // According to API reference only Security and Unknown
-        // exceptions are allowed here
-        auto ex = common::UnknownException("NFC manager not supported");
-        ReportError(ex, out);
-    }
-    else {
-        ReportSuccess(out);
-    }
+    const picojson::value& args, picojson::object& out) {
+
+  // Default NFC adapter is created at JS level
+  // Here there's only check for NFC support
+  LoggerD("Entered");
+  if(!nfc_manager_is_supported()) {
+    LoggerE("NFC manager is not supported");
+    // According to API reference only Security and Unknown
+    // exceptions are allowed here
+    auto ex = common::UnknownException("NFC manager not supported");
+    ReportError(ex, out);
+  }
+  else {
+    ReportSuccess(out);
+  }
 }
 
 void NFCInstance::SetExclusiveMode(
-        const picojson::value& args, picojson::object& out) {
+    const picojson::value& args, picojson::object& out) {
 
-    bool exmode = args.get("exclusiveMode").get<bool>();
-    int ret = NFC_ERROR_NONE;
+  bool exmode = args.get("exclusiveMode").get<bool>();
+  int ret = NFC_ERROR_NONE;
 
-    int result = nfc_manager_set_system_handler_enable(!exmode);
-    if (NFC_ERROR_NONE != result) {
-        NFCUtil::throwNFCException(result, "Failed to set exclusive mode.");
-    }
-    ReportSuccess(out);
+  int result = nfc_manager_set_system_handler_enable(!exmode);
+  if (NFC_ERROR_NONE != result) {
+    NFCUtil::throwNFCException(result, "Failed to set exclusive mode.");
+  }
+  ReportSuccess(out);
 }
 
 void NFCInstance::SetPowered(
-        const picojson::value& args, picojson::object& out) {
-    NFCAdapter::GetInstance()->SetPowered(args);
+    const picojson::value& args, picojson::object& out) {
+  NFCAdapter::GetInstance()->SetPowered(args);
 }
 
 void NFCInstance::GetPowered(
-        const picojson::value& args, picojson::object& out) {
-    bool ret = NFCAdapter::GetInstance()->GetPowered();
-    ReportSuccess(picojson::value(ret), out);
+    const picojson::value& args, picojson::object& out) {
+  bool ret = NFCAdapter::GetInstance()->GetPowered();
+  ReportSuccess(picojson::value(ret), out);
 }
 
 void NFCInstance::CardEmulationModeSetter(
-        const picojson::value& args, picojson::object& out) {
+    const picojson::value& args, picojson::object& out) {
 
-    std::string mode = args.get("emulationMode").get<std::string>();
-    try {
-        NFCAdapter::GetInstance()->SetCardEmulationMode(mode);
-        ReportSuccess(out);
-    }
-    catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+  std::string mode = args.get("emulationMode").get<std::string>();
+  try {
+    NFCAdapter::GetInstance()->SetCardEmulationMode(mode);
+    ReportSuccess(out);
+  }
+  catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::CardEmulationModeGetter(
-        const picojson::value& args, picojson::object& out) {
+    const picojson::value& args, picojson::object& out) {
 
-    std::string mode;
-    try {
-        mode = NFCAdapter::GetInstance()->GetCardEmulationMode();
-        ReportSuccess(picojson::value(mode), out);
-    }
-    catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+  std::string mode;
+  try {
+    mode = NFCAdapter::GetInstance()->GetCardEmulationMode();
+    ReportSuccess(picojson::value(mode), out);
+  }
+  catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::ActiveSecureElementSetter(
-        const picojson::value& args, picojson::object& out) {
+    const picojson::value& args, picojson::object& out) {
 
-    std::string ase = args.get("secureElement").get<std::string>();
-    try {
-        NFCAdapter::GetInstance()->SetActiveSecureElement(ase);
-        ReportSuccess(out);
-    }
-    catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+  std::string ase = args.get("secureElement").get<std::string>();
+  try {
+    NFCAdapter::GetInstance()->SetActiveSecureElement(ase);
+    ReportSuccess(out);
+  }
+  catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::ActiveSecureElementGetter(
-        const picojson::value& args, picojson::object& out) {
+    const picojson::value& args, picojson::object& out) {
 
-    std::string ase;
-    try {
-        ase = NFCAdapter::GetInstance()->GetActiveSecureElement();
-        ReportSuccess(picojson::value(ase), out);
-    }
-    catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+  std::string ase;
+  try {
+    ase = NFCAdapter::GetInstance()->GetActiveSecureElement();
+    ReportSuccess(picojson::value(ase), out);
+  }
+  catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::SetTagListener(
-        const picojson::value& args, picojson::object& out) {
+    const picojson::value& args, picojson::object& out) {
 
-    try {
-        NFCAdapter::GetInstance()->SetTagListener();
-        ReportSuccess(out);
-    }
-    catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+  try {
+    NFCAdapter::GetInstance()->SetTagListener();
+    ReportSuccess(out);
+  }
+  catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::PeerIsConnectedGetter(
-        const picojson::value& args, picojson::object& out) {
+    const picojson::value& args, picojson::object& out) {
 
-    try {
-        int peer_id = (int)args.get("id").get<double>();
-        bool ret = NFCAdapter::GetInstance()->PeerIsConnectedGetter(peer_id);
-        ReportSuccess(picojson::value(ret), out);
-    }
-    catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+  try {
+    int peer_id = (int)args.get("id").get<double>();
+    bool ret = NFCAdapter::GetInstance()->PeerIsConnectedGetter(peer_id);
+    ReportSuccess(picojson::value(ret), out);
+  }
+  catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::SetPeerListener(
-        const picojson::value& args, picojson::object& out) {
+    const picojson::value& args, picojson::object& out) {
 
-    try {
-        NFCAdapter::GetInstance()->SetPeerListener();
-        ReportSuccess(out);
-    }
-    catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+  try {
+    NFCAdapter::GetInstance()->SetPeerListener();
+    ReportSuccess(out);
+  }
+  catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::UnsetTagListener(
-        const picojson::value& args, picojson::object& out) {
+    const picojson::value& args, picojson::object& out) {
 
-    NFCAdapter::GetInstance()->UnsetTagListener();
-    ReportSuccess(out);
+  NFCAdapter::GetInstance()->UnsetTagListener();
+  ReportSuccess(out);
 }
 
 void NFCInstance::UnsetPeerListener(
-        const picojson::value& args, picojson::object& out) {
+    const picojson::value& args, picojson::object& out) {
 
-    try {
-        NFCAdapter::GetInstance()->UnsetPeerListener();
-        ReportSuccess(out);
-    }
-    catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+  try {
+    NFCAdapter::GetInstance()->UnsetPeerListener();
+    ReportSuccess(out);
+  }
+  catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::AddCardEmulationModeChangeListener(
-        const picojson::value& args, picojson::object& out) {
-    try {
-        NFCAdapter::GetInstance()->AddCardEmulationModeChangeListener();
-        ReportSuccess(out);
-    } catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+    const picojson::value& args, picojson::object& out) {
+  try {
+    NFCAdapter::GetInstance()->AddCardEmulationModeChangeListener();
+    ReportSuccess(out);
+  } catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::RemoveCardEmulationModeChangeListener(
-        const picojson::value& args, picojson::object& out) {
-    NFCAdapter::GetInstance()->RemoveCardEmulationModeChangeListener();
+    const picojson::value& args, picojson::object& out) {
+  NFCAdapter::GetInstance()->RemoveCardEmulationModeChangeListener();
 }
 
 void NFCInstance::AddTransactionEventListener(
-        const picojson::value& args, picojson::object& out) {
-    try {
-        NFCAdapter::GetInstance()->AddTransactionEventListener(args);
-        ReportSuccess(out);
-    } catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+    const picojson::value& args, picojson::object& out) {
+  try {
+    NFCAdapter::GetInstance()->AddTransactionEventListener(args);
+    ReportSuccess(out);
+  } catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::RemoveTransactionEventListener(
-        const picojson::value& args, picojson::object& out) {
-    NFCAdapter::GetInstance()->RemoveTransactionEventListener(args);
+    const picojson::value& args, picojson::object& out) {
+  NFCAdapter::GetInstance()->RemoveTransactionEventListener(args);
 }
 
 void NFCInstance::AddActiveSecureElementChangeListener(
-        const picojson::value& args, picojson::object& out) {
-    try {
-        NFCAdapter::GetInstance()->AddActiveSecureElementChangeListener();
-        ReportSuccess(out);
-    } catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+    const picojson::value& args, picojson::object& out) {
+  try {
+    NFCAdapter::GetInstance()->AddActiveSecureElementChangeListener();
+    ReportSuccess(out);
+  } catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::RemoveActiveSecureElementChangeListener(
-        const picojson::value& args, picojson::object& out) {
-    NFCAdapter::GetInstance()->RemoveActiveSecureElementChangeListener();
+    const picojson::value& args, picojson::object& out) {
+  NFCAdapter::GetInstance()->RemoveActiveSecureElementChangeListener();
 }
 
 void NFCInstance::GetCachedMessage(
-        const picojson::value& args, picojson::object& out) {
-    LoggerD("Entered");
-    try {
-        picojson::value result = picojson::value(picojson::object());
-        picojson::object& result_obj = result.get<picojson::object>();
-
-        NFCAdapter::GetInstance()->GetCachedMessage(result_obj);
-        ReportSuccess(result, out);
-    }
-    catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+    const picojson::value& args, picojson::object& out) {
+  LoggerD("Entered");
+  try {
+    picojson::value result = picojson::value(picojson::object());
+    picojson::object& result_obj = result.get<picojson::object>();
+
+    NFCAdapter::GetInstance()->GetCachedMessage(result_obj);
+    ReportSuccess(result, out);
+  }
+  catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::SetExclusiveModeForTransaction(
-        const picojson::value& args, picojson::object& out) {
+    const picojson::value& args, picojson::object& out) {
 
-    bool transaction_mode = args.get("transactionMode").get<bool>();
-    int ret = NFC_ERROR_NONE;
+  bool transaction_mode = args.get("transactionMode").get<bool>();
+  int ret = NFC_ERROR_NONE;
 
-    try {
-        NFCAdapter::GetInstance()->SetExclusiveModeForTransaction(
-                transaction_mode);
-        ReportSuccess(out);
-    }
-    catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+  try {
+    NFCAdapter::GetInstance()->SetExclusiveModeForTransaction(
+        transaction_mode);
+    ReportSuccess(out);
+  }
+  catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::ReadNDEF(
-        const picojson::value& args, picojson::object& out) {
+    const picojson::value& args, picojson::object& out) {
 
-    int tag_id = static_cast<int>(args.get("id").get<double>());
-    LoggerD("Tag id: %d", tag_id);
+  int tag_id = static_cast<int>(args.get("id").get<double>());
+  LoggerD("Tag id: %d", tag_id);
 
-    try {
-        NFCAdapter::GetInstance()->TagReadNDEF(tag_id, args);
-        ReportSuccess(out);
-    }
-    catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+  try {
+    NFCAdapter::GetInstance()->TagReadNDEF(tag_id, args);
+    ReportSuccess(out);
+  }
+  catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::WriteNDEF(
-        const picojson::value& args, picojson::object& out) {
+    const picojson::value& args, picojson::object& out) {
 
-    int tag_id = static_cast<int>(args.get("id").get<double>());
-    LoggerD("Tag id: %d", tag_id);
+  int tag_id = static_cast<int>(args.get("id").get<double>());
+  LoggerD("Tag id: %d", tag_id);
 
-    try {
-        NFCAdapter::GetInstance()->TagWriteNDEF(tag_id, args);
-        ReportSuccess(out);
-    }
-    catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+  try {
+    NFCAdapter::GetInstance()->TagWriteNDEF(tag_id, args);
+    ReportSuccess(out);
+  }
+  catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::Transceive(
-        const picojson::value& args, picojson::object& out) {
+    const picojson::value& args, picojson::object& out) {
 
-    LoggerD("Entered");
-    int tag_id = static_cast<int>(args.get("id").get<double>());
-    LoggerD("Tag id: %d", tag_id);
+  LoggerD("Entered");
+  int tag_id = static_cast<int>(args.get("id").get<double>());
+  LoggerD("Tag id: %d", tag_id);
 
-    try {
-        NFCAdapter::GetInstance()->TagTransceive(tag_id, args);
-        ReportSuccess(out);
-    }
-    catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+  try {
+    NFCAdapter::GetInstance()->TagTransceive(tag_id, args);
+    ReportSuccess(out);
+  }
+  catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::SetReceiveNDEFListener(
-        const picojson::value& args, picojson::object& out) {
+    const picojson::value& args, picojson::object& out) {
 
-    try {
-        int peer_id = (int)args.get("id").get<double>();
-        NFCAdapter::GetInstance()->SetReceiveNDEFListener(peer_id);
-        ReportSuccess(out);
-    }
-    catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+  try {
+    int peer_id = (int)args.get("id").get<double>();
+    NFCAdapter::GetInstance()->SetReceiveNDEFListener(peer_id);
+    ReportSuccess(out);
+  }
+  catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::UnsetReceiveNDEFListener(
-        const picojson::value& args, picojson::object& out) {
+    const picojson::value& args, picojson::object& out) {
 
-    try {
-        int peer_id = (int)args.get("id").get<double>();
-        NFCAdapter::GetInstance()->UnsetReceiveNDEFListener(peer_id);
-        ReportSuccess(out);
-    }
-    catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+  try {
+    int peer_id = (int)args.get("id").get<double>();
+    NFCAdapter::GetInstance()->UnsetReceiveNDEFListener(peer_id);
+    ReportSuccess(out);
+  }
+  catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::SendNDEF(
-        const picojson::value& args, picojson::object& out) {
-    int peer_id = static_cast<int>(args.get("id").get<double>());
-    LoggerD("Peer id: %d", peer_id);
+    const picojson::value& args, picojson::object& out) {
+  int peer_id = static_cast<int>(args.get("id").get<double>());
+  LoggerD("Peer id: %d", peer_id);
 
-    try {
-        NFCAdapter::GetInstance()->sendNDEF(peer_id, args);
-        ReportSuccess(out);
-    }
-    catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+  try {
+    NFCAdapter::GetInstance()->sendNDEF(peer_id, args);
+    ReportSuccess(out);
+  }
+  catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::ToByte(
-        const picojson::value& args, picojson::object& out) {
-    LoggerD("Entered");
-    try {
-        picojson::value result = picojson::value(picojson::object());
-        picojson::object& result_obj = result.get<picojson::object>();
-        NFCMessageUtils::NDEFMessageToByte(args, result_obj);
-        ReportSuccess(result, out);
-    }
-    catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+    const picojson::value& args, picojson::object& out) {
+  LoggerD("Entered");
+  try {
+    picojson::value result = picojson::value(picojson::object());
+    picojson::object& result_obj = result.get<picojson::object>();
+    NFCMessageUtils::NDEFMessageToByte(args, result_obj);
+    ReportSuccess(result, out);
+  }
+  catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 //Message related methods
 void NFCInstance::NDEFMessageContructor(const picojson::value& args, picojson::object& out) {
-    LoggerD("Entered");
-    try {
-        picojson::value result = picojson::value(picojson::object());
-        picojson::object& result_obj = result.get<picojson::object>();
-        NFCMessageUtils::ReportNDEFMessage(args, result_obj);
-        ReportSuccess(result, out);
-    }
-    catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+  LoggerD("Entered");
+  try {
+    picojson::value result = picojson::value(picojson::object());
+    picojson::object& result_obj = result.get<picojson::object>();
+    NFCMessageUtils::ReportNDEFMessage(args, result_obj);
+    ReportSuccess(result, out);
+  }
+  catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::NDEFRecordContructor(const picojson::value& args, picojson::object& out) {
-    LoggerD("Entered");
-    try {
-        picojson::value result = picojson::value(picojson::object());
-        picojson::object& result_obj = result.get<picojson::object>();
-        NFCMessageUtils::ReportNDEFRecord(args, result_obj);
-        ReportSuccess(result, out);
-    }
-    catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+  LoggerD("Entered");
+  try {
+    picojson::value result = picojson::value(picojson::object());
+    picojson::object& result_obj = result.get<picojson::object>();
+    NFCMessageUtils::ReportNDEFRecord(args, result_obj);
+    ReportSuccess(result, out);
+  }
+  catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::NDEFRecordTextContructor(const picojson::value& args, picojson::object& out) {
-    LoggerD("Entered");
-    try {
-        picojson::value result = picojson::value(picojson::object());
-        picojson::object& result_obj = result.get<picojson::object>();
-        NFCMessageUtils::ReportNDEFRecordText(args, result_obj);
-        ReportSuccess(result, out);
-    }
-    catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+  LoggerD("Entered");
+  try {
+    picojson::value result = picojson::value(picojson::object());
+    picojson::object& result_obj = result.get<picojson::object>();
+    NFCMessageUtils::ReportNDEFRecordText(args, result_obj);
+    ReportSuccess(result, out);
+  }
+  catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::NDEFRecordURIContructor(const picojson::value& args, picojson::object& out) {
-    LoggerD("Entered");
-    try {
-        picojson::value result = picojson::value(picojson::object());
-        picojson::object& result_obj = result.get<picojson::object>();
-        NFCMessageUtils::ReportNDEFRecordURI(args, result_obj);
-        ReportSuccess(result, out);
-    }
-    catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+  LoggerD("Entered");
+  try {
+    picojson::value result = picojson::value(picojson::object());
+    picojson::object& result_obj = result.get<picojson::object>();
+    NFCMessageUtils::ReportNDEFRecordURI(args, result_obj);
+    ReportSuccess(result, out);
+  }
+  catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::NDEFRecordMediaContructor(const picojson::value& args, picojson::object& out) {
-    LoggerD("Entered");
-    try {
-        picojson::value result = picojson::value(picojson::object());
-        picojson::object& result_obj = result.get<picojson::object>();
-        NFCMessageUtils::ReportNDEFRecordMedia(args, result_obj);
-        ReportSuccess(result, out);
-    }
-    catch(const common::PlatformException& ex) {
-        ReportError(ex, out);
-    }
+  LoggerD("Entered");
+  try {
+    picojson::value result = picojson::value(picojson::object());
+    picojson::object& result_obj = result.get<picojson::object>();
+    NFCMessageUtils::ReportNDEFRecordMedia(args, result_obj);
+    ReportSuccess(result, out);
+  }
+  catch(const common::PlatformException& ex) {
+    ReportError(ex, out);
+  }
 }
 
 // NFCTag attributes getters
 void NFCInstance::TagTypeGetter(
-        const picojson::value& args, picojson::object& out) {
+    const picojson::value& args, picojson::object& out) {
 
-    LoggerD("Entered");
+  LoggerD("Entered");
 
-    int tag_id = (int)args.get("id").get<double>();
-    LoggerD("Tag id: %d", tag_id);
+  int tag_id = (int)args.get("id").get<double>();
+  LoggerD("Tag id: %d", tag_id);
 
-    try {
-        // Function below throws exception if core API call fails
-        if (!NFCAdapter::GetInstance()->TagIsConnectedGetter(tag_id)) {
-            LoggerE("Tag with id %d is not connected anymore", tag_id);
-            // If tag is not connected then attribute's value
-            // should be undefined
-            ReportError(out);
-            return;
-        }
+  try {
+    // Function below throws exception if core API call fails
+    if (!NFCAdapter::GetInstance()->TagIsConnectedGetter(tag_id)) {
+      LoggerE("Tag with id %d is not connected anymore", tag_id);
+      // If tag is not connected then attribute's value
+      // should be undefined
+      ReportError(out);
+      return;
+    }
 
-        std::string tag_type =
-                NFCAdapter::GetInstance()->TagTypeGetter(tag_id);
+    std::string tag_type =
+        NFCAdapter::GetInstance()->TagTypeGetter(tag_id);
 
-        ReportSuccess(picojson::value(tag_type), out);
-    }
-    catch(const PlatformException& ex) {
-        LoggerE("Failed to check tag connection");
-        ReportError(ex, out);
-    }
+    ReportSuccess(picojson::value(tag_type), out);
+  }
+  catch(const PlatformException& ex) {
+    LoggerE("Failed to check tag connection");
+    ReportError(ex, out);
+  }
 }
 
 void NFCInstance::TagIsSupportedNDEFGetter(
-        const picojson::value& args, picojson::object& out) {
+    const picojson::value& args, picojson::object& out) {
 
-    LoggerD("Entered");
+  LoggerD("Entered");
 
-    int tag_id = (int)args.get("id").get<double>();
-    LoggerD("Tag id: %d", tag_id);
+  int tag_id = (int)args.get("id").get<double>();
+  LoggerD("Tag id: %d", tag_id);
 
-    try {
-        // Function below throws exception if core API call fails
-        if (!NFCAdapter::GetInstance()->TagIsConnectedGetter(tag_id)) {
-            LoggerE("Tag with id %d is not connected anymore", tag_id);
-            // If tag is not connected then attribute's value
-            // should be undefined
-            ReportError(out);
-            return;
-        }
+  try {
+    // Function below throws exception if core API call fails
+    if (!NFCAdapter::GetInstance()->TagIsConnectedGetter(tag_id)) {
+      LoggerE("Tag with id %d is not connected anymore", tag_id);
+      // If tag is not connected then attribute's value
+      // should be undefined
+      ReportError(out);
+      return;
+    }
 
-        bool is_supported =
-                NFCAdapter::GetInstance()->TagIsSupportedNDEFGetter(tag_id);
+    bool is_supported =
+        NFCAdapter::GetInstance()->TagIsSupportedNDEFGetter(tag_id);
 
-        ReportSuccess(picojson::value(is_supported), out);
-    }
-    catch(const PlatformException& ex) {
-        LoggerE("Failed to check is NDEF supported");
-        ReportError(ex, out);
-    }
+    ReportSuccess(picojson::value(is_supported), out);
+  }
+  catch(const PlatformException& ex) {
+    LoggerE("Failed to check is NDEF supported");
+    ReportError(ex, out);
+  }
 
 }
 
 void NFCInstance::TagNDEFSizeGetter(
-        const picojson::value& args, picojson::object& out) {
+    const picojson::value& args, picojson::object& out) {
 
-    LoggerD("Entered");
+  LoggerD("Entered");
 
-    int tag_id = (int)args.get("id").get<double>();
-    LoggerD("Tag id: %d", tag_id);
+  int tag_id = (int)args.get("id").get<double>();
+  LoggerD("Tag id: %d", tag_id);
 
-    try {
-        // Function below throws exception if core API call fails
-        if (!NFCAdapter::GetInstance()->TagIsConnectedGetter(tag_id)) {
-            LoggerE("Tag with id %d is not connected anymore", tag_id);
-            // If tag is not connected then attribute's value
-            // should be undefined
-            ReportError(out);
-            return;
-        }
+  try {
+    // Function below throws exception if core API call fails
+    if (!NFCAdapter::GetInstance()->TagIsConnectedGetter(tag_id)) {
+      LoggerE("Tag with id %d is not connected anymore", tag_id);
+      // If tag is not connected then attribute's value
+      // should be undefined
+      ReportError(out);
+      return;
+    }
 
-        unsigned int ndef_size =
-                NFCAdapter::GetInstance()->TagNDEFSizeGetter(tag_id);
+    unsigned int ndef_size =
+        NFCAdapter::GetInstance()->TagNDEFSizeGetter(tag_id);
 
-        ReportSuccess(picojson::value((double)ndef_size), out);
-    }
-    catch(const PlatformException& ex) {
-        LoggerE("Failed to get tag NDEF size");
-        ReportError(ex, out);
-    }
+    ReportSuccess(picojson::value((double)ndef_size), out);
+  }
+  catch(const PlatformException& ex) {
+    LoggerE("Failed to get tag NDEF size");
+    ReportError(ex, out);
+  }
 
 }
 
 void NFCInstance::TagPropertiesGetter(
-        const picojson::value& args, picojson::object& out) {
-
-    LoggerD("Entered");
-
-    int tag_id = (int)args.get("id").get<double>();
-    LoggerD("Tag id: %d", tag_id);
-    try {
-        // Function below throws exception if core API call fails
-        if (!NFCAdapter::GetInstance()->TagIsConnectedGetter(tag_id)) {
-            LoggerE("Tag with id %d is not connected anymore", tag_id);
-            // If tag is not connected then attribute's value
-            // should be undefined
-            ReportError(out);
-            return;
-        }
-
-        NFCTagPropertiesT result =
-                NFCAdapter::GetInstance()->TagPropertiesGetter(tag_id);
-
-        picojson::value properties = picojson::value(picojson::array());
-        picojson::array& properties_array = properties.get<picojson::array>();
-        for (auto it = result.begin() ; it != result.end(); it++) {
-            picojson::value val = picojson::value(picojson::object());
-            picojson::object& obj = val.get<picojson::object>();
-
-            picojson::value value_vector = picojson::value(picojson::array());
-            picojson::array& value_vector_obj = value_vector.get<picojson::array>();
-
-            for (size_t i = 0 ; i < it->second.size(); i++) {
-                value_vector_obj.push_back(picojson::value(
-                        std::to_string(it->second[i])));
-            }
-
-            obj.insert(std::make_pair(it->first, value_vector));
-            properties_array.push_back(val);
-        }
-        ReportSuccess(properties, out);
-    }
-    catch(const PlatformException& ex) {
-        LoggerE("Failed to tag properties");
-        ReportError(ex, out);
+    const picojson::value& args, picojson::object& out) {
+
+  LoggerD("Entered");
+
+  int tag_id = (int)args.get("id").get<double>();
+  LoggerD("Tag id: %d", tag_id);
+  try {
+    // Function below throws exception if core API call fails
+    if (!NFCAdapter::GetInstance()->TagIsConnectedGetter(tag_id)) {
+      LoggerE("Tag with id %d is not connected anymore", tag_id);
+      // If tag is not connected then attribute's value
+      // should be undefined
+      ReportError(out);
+      return;
     }
-}
 
-void NFCInstance::TagIsConnectedGetter(
-        const picojson::value& args, picojson::object& out) {
+    NFCTagPropertiesT result =
+        NFCAdapter::GetInstance()->TagPropertiesGetter(tag_id);
 
-    LoggerD("Entered");
+    picojson::value properties = picojson::value(picojson::array());
+    picojson::array& properties_array = properties.get<picojson::array>();
+    for (auto it = result.begin() ; it != result.end(); it++) {
+      picojson::value val = picojson::value(picojson::object());
+      picojson::object& obj = val.get<picojson::object>();
 
-    int tag_id = (int)args.get("id").get<double>();
-    LoggerD("Tag id: %d", tag_id);
-    try {
-        bool connected = NFCAdapter::GetInstance()->TagIsConnectedGetter(tag_id);
-        ReportSuccess(picojson::value(connected), out);
-    }
-    catch(const PlatformException& ex) {
-        LoggerE("Failed to check tag connection");
-        ReportError(ex, out);
+      picojson::value value_vector = picojson::value(picojson::array());
+      picojson::array& value_vector_obj = value_vector.get<picojson::array>();
+
+      for (size_t i = 0 ; i < it->second.size(); i++) {
+        value_vector_obj.push_back(picojson::value(
+            std::to_string(it->second[i])));
+      }
+
+      obj.insert(std::make_pair(it->first, value_vector));
+      properties_array.push_back(val);
     }
+    ReportSuccess(properties, out);
+  }
+  catch(const PlatformException& ex) {
+    LoggerE("Failed to tag properties");
+    ReportError(ex, out);
+  }
+}
+
+void NFCInstance::TagIsConnectedGetter(
+    const picojson::value& args, picojson::object& out) {
+
+  LoggerD("Entered");
+
+  int tag_id = (int)args.get("id").get<double>();
+  LoggerD("Tag id: %d", tag_id);
+  try {
+    bool connected = NFCAdapter::GetInstance()->TagIsConnectedGetter(tag_id);
+    ReportSuccess(picojson::value(connected), out);
+  }
+  catch(const PlatformException& ex) {
+    LoggerE("Failed to check tag connection");
+    ReportError(ex, out);
+  }
 }
 
 
index cf41d14b8bdabdf20877555657736d3d0260ea16..37d4cb0a9bcd2b1c5d4d5041f4ee9cf3adccf3ae 100644 (file)
@@ -13,60 +13,60 @@ namespace extension {
 namespace nfc {
 
 class NFCInstance: public common::ParsedInstance {
-public:
-    static NFCInstance& getInstance();
+ public:
+  static NFCInstance& getInstance();
 
-    void InstanceReportSuccess(picojson::object& out);
-    void InstanceReportSuccess(const picojson::value& result, picojson::object& out);
-    void InstanceReportError(picojson::object& out);
-    void InstanceReportError(const common::PlatformException& ex, picojson::object& out);
-private:
-    NFCInstance();
-    virtual ~NFCInstance();
+  void InstanceReportSuccess(picojson::object& out);
+  void InstanceReportSuccess(const picojson::value& result, picojson::object& out);
+  void InstanceReportError(picojson::object& out);
+  void InstanceReportError(const common::PlatformException& ex, picojson::object& out);
+ private:
+  NFCInstance();
+  virtual ~NFCInstance();
 
-    void GetDefaultAdapter(const picojson::value& args, picojson::object& out);
-    void SetExclusiveMode(const picojson::value& args, picojson::object& out);
-    void SetPowered(const picojson::value& args, picojson::object& out);
-    void GetPowered(const picojson::value& args, picojson::object& out);
-    void CardEmulationModeSetter(const picojson::value& args, picojson::object& out);
-    void CardEmulationModeGetter(const picojson::value& args, picojson::object& out);
-    void ActiveSecureElementSetter(const picojson::value& args, picojson::object& out);
-    void ActiveSecureElementGetter(const picojson::value& args, picojson::object& out);
-    void SetTagListener(const picojson::value& args, picojson::object& out);
-    void PeerIsConnectedGetter(const picojson::value& args, picojson::object& out);
-    void SetPeerListener(const picojson::value& args, picojson::object& out);
-    void UnsetTagListener(const picojson::value& args, picojson::object& out);
-    void UnsetPeerListener(const picojson::value& args, picojson::object& out);
-    void AddCardEmulationModeChangeListener(const picojson::value& args, picojson::object& out);
-    void RemoveCardEmulationModeChangeListener(const picojson::value& args, picojson::object& out);
-    void AddTransactionEventListener(const picojson::value& args, picojson::object& out);
-    void RemoveTransactionEventListener(const picojson::value& args, picojson::object& out);
-    void AddActiveSecureElementChangeListener(const picojson::value& args, picojson::object& out);
-    void RemoveActiveSecureElementChangeListener(const picojson::value& args, picojson::object& out);
-    void GetCachedMessage(const picojson::value& args, picojson::object& out);
-    void SetExclusiveModeForTransaction(const picojson::value& args, picojson::object& out);
-    void ReadNDEF(const picojson::value& args, picojson::object& out);
-    void WriteNDEF(const picojson::value& args, picojson::object& out);
-    void Transceive(const picojson::value& args, picojson::object& out);
-    void SetReceiveNDEFListener(const picojson::value& args, picojson::object& out);
-    void UnsetReceiveNDEFListener(const picojson::value& args, picojson::object& out);
-    void SendNDEF(const picojson::value& args, picojson::object& out);
-    void ToByte(const picojson::value& args, picojson::object& out);
+  void GetDefaultAdapter(const picojson::value& args, picojson::object& out);
+  void SetExclusiveMode(const picojson::value& args, picojson::object& out);
+  void SetPowered(const picojson::value& args, picojson::object& out);
+  void GetPowered(const picojson::value& args, picojson::object& out);
+  void CardEmulationModeSetter(const picojson::value& args, picojson::object& out);
+  void CardEmulationModeGetter(const picojson::value& args, picojson::object& out);
+  void ActiveSecureElementSetter(const picojson::value& args, picojson::object& out);
+  void ActiveSecureElementGetter(const picojson::value& args, picojson::object& out);
+  void SetTagListener(const picojson::value& args, picojson::object& out);
+  void PeerIsConnectedGetter(const picojson::value& args, picojson::object& out);
+  void SetPeerListener(const picojson::value& args, picojson::object& out);
+  void UnsetTagListener(const picojson::value& args, picojson::object& out);
+  void UnsetPeerListener(const picojson::value& args, picojson::object& out);
+  void AddCardEmulationModeChangeListener(const picojson::value& args, picojson::object& out);
+  void RemoveCardEmulationModeChangeListener(const picojson::value& args, picojson::object& out);
+  void AddTransactionEventListener(const picojson::value& args, picojson::object& out);
+  void RemoveTransactionEventListener(const picojson::value& args, picojson::object& out);
+  void AddActiveSecureElementChangeListener(const picojson::value& args, picojson::object& out);
+  void RemoveActiveSecureElementChangeListener(const picojson::value& args, picojson::object& out);
+  void GetCachedMessage(const picojson::value& args, picojson::object& out);
+  void SetExclusiveModeForTransaction(const picojson::value& args, picojson::object& out);
+  void ReadNDEF(const picojson::value& args, picojson::object& out);
+  void WriteNDEF(const picojson::value& args, picojson::object& out);
+  void Transceive(const picojson::value& args, picojson::object& out);
+  void SetReceiveNDEFListener(const picojson::value& args, picojson::object& out);
+  void UnsetReceiveNDEFListener(const picojson::value& args, picojson::object& out);
+  void SendNDEF(const picojson::value& args, picojson::object& out);
+  void ToByte(const picojson::value& args, picojson::object& out);
 
-    //Message related methods
-    void NDEFMessageContructor(const picojson::value& args, picojson::object& out);
-    void NDEFMessageToByte(const picojson::value& args, picojson::object& out);
-    void NDEFRecordContructor(const picojson::value& args, picojson::object& out);
-    void NDEFRecordTextContructor(const picojson::value& args, picojson::object& out);
-    void NDEFRecordURIContructor(const picojson::value& args, picojson::object& out);
-    void NDEFRecordMediaContructor(const picojson::value& args, picojson::object& out);
+  //Message related methods
+  void NDEFMessageContructor(const picojson::value& args, picojson::object& out);
+  void NDEFMessageToByte(const picojson::value& args, picojson::object& out);
+  void NDEFRecordContructor(const picojson::value& args, picojson::object& out);
+  void NDEFRecordTextContructor(const picojson::value& args, picojson::object& out);
+  void NDEFRecordURIContructor(const picojson::value& args, picojson::object& out);
+  void NDEFRecordMediaContructor(const picojson::value& args, picojson::object& out);
 
-    // NFCTag attributes getters
-    void TagTypeGetter(const picojson::value& args, picojson::object& out);
-    void TagIsSupportedNDEFGetter(const picojson::value& args, picojson::object& out);
-    void TagNDEFSizeGetter(const picojson::value& args, picojson::object& out);
-    void TagPropertiesGetter(const picojson::value& args, picojson::object& out);
-    void TagIsConnectedGetter(const picojson::value& args, picojson::object& out);
+  // NFCTag attributes getters
+  void TagTypeGetter(const picojson::value& args, picojson::object& out);
+  void TagIsSupportedNDEFGetter(const picojson::value& args, picojson::object& out);
+  void TagNDEFSizeGetter(const picojson::value& args, picojson::object& out);
+  void TagPropertiesGetter(const picojson::value& args, picojson::object& out);
+  void TagIsConnectedGetter(const picojson::value& args, picojson::object& out);
 
 };
 
index 8ae98fe93a970838abb88dd25897f7a3ef6dedc7..57577c3af1de06303e8f2781b22f3b4db905c5a0 100644 (file)
@@ -19,728 +19,728 @@ namespace extension {
 namespace nfc {
 
 namespace {
-    const char* NFC_TEXT_UTF16 = "UTF16";
-    const char* NFC_TEXT_UTF8 = "UTF8";
+const char* NFC_TEXT_UTF16 = "UTF16";
+const char* NFC_TEXT_UTF8 = "UTF8";
 
-    const int RECORD_TYPE_TEXT = 0x54;
-    const int RECORD_TYPE_URI = 0x55;
+const int RECORD_TYPE_TEXT = 0x54;
+const int RECORD_TYPE_URI = 0x55;
 
-    const int TNF_MIN = 0;
-    const int TNF_MAX = 6;
+const int TNF_MIN = 0;
+const int TNF_MAX = 6;
 
-    enum nfcTNF{
-        NFC_RECORD_TNF_EMPTY = 0,
-        NFC_RECORD_TNF_WELL_KNOWN = 1,
-        NFC_RECORD_TNF_MIME_MEDIA = 2,
-        NFC_RECORD_TNF_URI = 3,
-        NFC_RECORD_TNF_EXTERNAL_RTD = 4,
-        NFC_RECORD_TNF_UNKNOWN = 5,
-        NFC_RECORD_TNF_UNCHANGED = 6
-    };
+enum nfcTNF{
+  NFC_RECORD_TNF_EMPTY = 0,
+  NFC_RECORD_TNF_WELL_KNOWN = 1,
+  NFC_RECORD_TNF_MIME_MEDIA = 2,
+  NFC_RECORD_TNF_URI = 3,
+  NFC_RECORD_TNF_EXTERNAL_RTD = 4,
+  NFC_RECORD_TNF_UNKNOWN = 5,
+  NFC_RECORD_TNF_UNCHANGED = 6
+};
 }
 
 /* -------------------------------COMMON FUNCTIONS------------------------------------ */
 void NFCMessageUtils::RemoveMessageHandle(nfc_ndef_message_h message_handle)
 {
-    if (message_handle) {
-        int result = nfc_ndef_message_destroy(message_handle);
-        if (NFC_ERROR_NONE != result) {
-            LoggerE("Can't destroy NdefMessage: %d, %s", result,
-                NFCUtil::getNFCErrorMessage(result).c_str());
-        }
-        message_handle = NULL;
+  if (message_handle) {
+    int result = nfc_ndef_message_destroy(message_handle);
+    if (NFC_ERROR_NONE != result) {
+      LoggerE("Can't destroy NdefMessage: %d, %s", result,
+              NFCUtil::getNFCErrorMessage(result).c_str());
     }
+    message_handle = NULL;
+  }
 }
 
 static void removeRecordHandle(nfc_ndef_record_h record_handle)
 {
-    if (record_handle) {
-        int result = nfc_ndef_record_destroy(record_handle);
-        if (NFC_ERROR_NONE != result) {
-            LoggerE("Can't destroy NdefMessage: %d, %s", result,
-                NFCUtil::getNFCErrorMessage(result).c_str());
-        }
-        record_handle = NULL;
+  if (record_handle) {
+    int result = nfc_ndef_record_destroy(record_handle);
+    if (NFC_ERROR_NONE != result) {
+      LoggerE("Can't destroy NdefMessage: %d, %s", result,
+              NFCUtil::getNFCErrorMessage(result).c_str());
     }
+    record_handle = NULL;
+  }
 }
 
 static short getTnfFromHandle(nfc_ndef_record_h handle,
-        nfc_ndef_message_h message_handle = NULL)
+                              nfc_ndef_message_h message_handle = NULL)
 {
-    nfc_record_tnf_e tnf;
-    int result = nfc_ndef_record_get_tnf(handle, &tnf);
-    if (NFC_ERROR_NONE != result) {
-        LoggerE("Can't get record's tnf: %d, %s", result,
+  nfc_record_tnf_e tnf;
+  int result = nfc_ndef_record_get_tnf(handle, &tnf);
+  if (NFC_ERROR_NONE != result) {
+    LoggerE("Can't get record's tnf: %d, %s", result,
             NFCUtil::getNFCErrorMessage(result).c_str());
-        //once record handle must be released - from inherited classes constructors
-        //once record handle cannot be released - from base class constructor
-        if (NULL == message_handle) {
-            removeRecordHandle(handle);
-        }
-        else {
-            NFCMessageUtils::RemoveMessageHandle(message_handle);
-        }
-        NFCUtil::throwNFCException(result, "Can't get record's tnf");
+    //once record handle must be released - from inherited classes constructors
+    //once record handle cannot be released - from base class constructor
+    if (NULL == message_handle) {
+      removeRecordHandle(handle);
+    }
+    else {
+      NFCMessageUtils::RemoveMessageHandle(message_handle);
     }
+    NFCUtil::throwNFCException(result, "Can't get record's tnf");
+  }
 
-    return static_cast<short>(tnf);
+  return static_cast<short>(tnf);
 }
 
 static UCharVector getTypeNameFromHandle(nfc_ndef_record_h handle,
-        nfc_ndef_message_h message_handle = NULL)
+                                         nfc_ndef_message_h message_handle = NULL)
 {
-    unsigned char *type_name;
-    int type_size, result;
+  unsigned char *type_name;
+  int type_size, result;
 
-    result = nfc_ndef_record_get_type(handle, &type_name, &type_size);
-    if (NFC_ERROR_NONE != result) {
-        LoggerE("Can't get record's type: %d, %s", result,
+  result = nfc_ndef_record_get_type(handle, &type_name, &type_size);
+  if (NFC_ERROR_NONE != result) {
+    LoggerE("Can't get record's type: %d, %s", result,
             NFCUtil::getNFCErrorMessage(result).c_str());
-        //once record handle must be released - from inherited classes constructors
-        //once record handle cannot be released - from base class constructor
-        if (NULL == message_handle) {
-            removeRecordHandle(handle);
-        }
-        else {
-            NFCMessageUtils::RemoveMessageHandle(message_handle);
-        }
-        NFCUtil::throwNFCException(result, "Can't get record's type");
+    //once record handle must be released - from inherited classes constructors
+    //once record handle cannot be released - from base class constructor
+    if (NULL == message_handle) {
+      removeRecordHandle(handle);
+    }
+    else {
+      NFCMessageUtils::RemoveMessageHandle(message_handle);
     }
-    return NFCUtil::toVector(type_name, type_size);
+    NFCUtil::throwNFCException(result, "Can't get record's type");
+  }
+  return NFCUtil::toVector(type_name, type_size);
 }
 
 static UCharVector getIdFromHandle(nfc_ndef_record_h handle,
-        nfc_ndef_message_h message_handle = NULL)
+                                   nfc_ndef_message_h message_handle = NULL)
 {
-    unsigned char *id;
-    int id_size, result;
+  unsigned char *id;
+  int id_size, result;
 
-    result = nfc_ndef_record_get_id(handle, &id, &id_size);
-    if (NFC_ERROR_NONE != result) {
-        LoggerE("Can't get record's id: %d, %s", result,
+  result = nfc_ndef_record_get_id(handle, &id, &id_size);
+  if (NFC_ERROR_NONE != result) {
+    LoggerE("Can't get record's id: %d, %s", result,
             NFCUtil::getNFCErrorMessage(result).c_str());
-        //once record handle must be released - from inherited classes constructors
-        //once record handle cannot be released - from base class constructor
-        if (NULL == message_handle) {
-            removeRecordHandle(handle);
-        }
-        else {
-            NFCMessageUtils::RemoveMessageHandle(message_handle);
-        }
-        NFCUtil::throwNFCException(result, "Can't get record's id");
+    //once record handle must be released - from inherited classes constructors
+    //once record handle cannot be released - from base class constructor
+    if (NULL == message_handle) {
+      removeRecordHandle(handle);
+    }
+    else {
+      NFCMessageUtils::RemoveMessageHandle(message_handle);
     }
+    NFCUtil::throwNFCException(result, "Can't get record's id");
+  }
 
-    return NFCUtil::toVector(id, id_size);
+  return NFCUtil::toVector(id, id_size);
 }
 
 static UCharVector getPayloadFromHandle(nfc_ndef_record_h handle,
-        nfc_ndef_message_h message_handle = NULL)
+                                        nfc_ndef_message_h message_handle = NULL)
 {
-    unsigned char *payload;
-    unsigned int payload_size;
-    int result;
+  unsigned char *payload;
+  unsigned int payload_size;
+  int result;
 
-    result = nfc_ndef_record_get_payload(handle, &payload, &payload_size);
-    if (NFC_ERROR_NONE != result) {
-        LoggerE("Can't get record's payload: %d, %s", result,
+  result = nfc_ndef_record_get_payload(handle, &payload, &payload_size);
+  if (NFC_ERROR_NONE != result) {
+    LoggerE("Can't get record's payload: %d, %s", result,
             NFCUtil::getNFCErrorMessage(result).c_str());
-        //once record handle must be released - from inherited classes constructors
-        //once record handle cannot be released - from base class constructor
-        if (NULL == message_handle) {
-            removeRecordHandle(handle);
-        }
-        else {
-            NFCMessageUtils::RemoveMessageHandle(message_handle);
-        }
-        NFCUtil::throwNFCException(result, "Can't get record's payload");
+    //once record handle must be released - from inherited classes constructors
+    //once record handle cannot be released - from base class constructor
+    if (NULL == message_handle) {
+      removeRecordHandle(handle);
     }
+    else {
+      NFCMessageUtils::RemoveMessageHandle(message_handle);
+    }
+    NFCUtil::throwNFCException(result, "Can't get record's payload");
+  }
 
-    return NFCUtil::toVector(payload, payload_size);
+  return NFCUtil::toVector(payload, payload_size);
 }
 
 static nfc_encode_type_e convertToNfcEncodeUTF(const std::string& encode_string)
 {
-    if (NFC_TEXT_UTF16 == encode_string) {
-        return NFC_ENCODE_UTF_16;
-    }
-    else {
-        return NFC_ENCODE_UTF_8;
-    }
+  if (NFC_TEXT_UTF16 == encode_string) {
+    return NFC_ENCODE_UTF_16;
+  }
+  else {
+    return NFC_ENCODE_UTF_8;
+  }
 }
 
 static std::string convertEncodingToString(nfc_encode_type_e encoding)
 {
-    if (encoding == NFC_ENCODE_UTF_16) {
-        return NFC_TEXT_UTF16;
-    } else {
-        return NFC_TEXT_UTF8;
-    }
+  if (encoding == NFC_ENCODE_UTF_16) {
+    return NFC_TEXT_UTF16;
+  } else {
+    return NFC_TEXT_UTF8;
+  }
 }
 
 /* -------------------------------MESSAGE FUNCTIONS------------------------------------ */
 void NFCMessageUtils::ToNdefRecords(const nfc_ndef_message_h message, picojson::array& array)
 {
-    LoggerD("Entered");
-    if (NULL != message) {
-        int count;
-        int result = nfc_ndef_message_get_record_count(message, &count);
-        if (NFC_ERROR_NONE != result) {
-            LoggerE("Can't get record count: %d, %s", result,
+  LoggerD("Entered");
+  if (NULL != message) {
+    int count;
+    int result = nfc_ndef_message_get_record_count(message, &count);
+    if (NFC_ERROR_NONE != result) {
+      LoggerE("Can't get record count: %d, %s", result,
+              NFCUtil::getNFCErrorMessage(result).c_str());
+      RemoveMessageHandle(message);
+      NFCUtil::throwNFCException(result, "Can't get record count");
+    }
+    for (int i = 0; i < count; ++i) {
+      array.push_back(picojson::value(picojson::object()));
+      picojson::object& record_obj = array.back().get<picojson::object>();
+
+      nfc_ndef_record_h record_handle = NULL;
+      int result = nfc_ndef_message_get_record(message, i, &record_handle);
+      if (NFC_ERROR_NONE != result) {
+        LoggerE("Can't get Ndef Record: %d, %s", result,
                 NFCUtil::getNFCErrorMessage(result).c_str());
-            RemoveMessageHandle(message);
-            NFCUtil::throwNFCException(result, "Can't get record count");
-        }
-        for (int i = 0; i < count; ++i) {
-            array.push_back(picojson::value(picojson::object()));
-            picojson::object& record_obj = array.back().get<picojson::object>();
-
-            nfc_ndef_record_h record_handle = NULL;
-            int result = nfc_ndef_message_get_record(message, i, &record_handle);
-            if (NFC_ERROR_NONE != result) {
-                LoggerE("Can't get Ndef Record: %d, %s", result,
-                        NFCUtil::getNFCErrorMessage(result).c_str());
-                RemoveMessageHandle(message);
-                NFCUtil::throwNFCException(result, "Can't get Ndef Record");
-            }
-            short tnf = getTnfFromHandle(record_handle, message);
-            UCharVector type = getTypeNameFromHandle(record_handle, message);
-
-            if (NFC_RECORD_TNF_MIME_MEDIA == tnf) {
-                ReportNdefRecordMediaFromMessage(message, i, record_obj);
-                continue;
-            } else if (NFC_RECORD_TNF_WELL_KNOWN == tnf) {
-                if (!type.empty()) {
-                    if (RECORD_TYPE_TEXT == type[0]) {
-                        ReportNdefRecordTextFromMessage(message, i, record_obj);
-                        continue;
-                    }
-                    if (RECORD_TYPE_URI == type[0]) {
-                        ReportNdefRecordURIFromMessage(message, i, record_obj);
-                        continue;
-                    }
-                }
-            }
-            ConstructNdefRecordFromRecordHandle(record_handle, record_obj);
+        RemoveMessageHandle(message);
+        NFCUtil::throwNFCException(result, "Can't get Ndef Record");
+      }
+      short tnf = getTnfFromHandle(record_handle, message);
+      UCharVector type = getTypeNameFromHandle(record_handle, message);
+
+      if (NFC_RECORD_TNF_MIME_MEDIA == tnf) {
+        ReportNdefRecordMediaFromMessage(message, i, record_obj);
+        continue;
+      } else if (NFC_RECORD_TNF_WELL_KNOWN == tnf) {
+        if (!type.empty()) {
+          if (RECORD_TYPE_TEXT == type[0]) {
+            ReportNdefRecordTextFromMessage(message, i, record_obj);
+            continue;
+          }
+          if (RECORD_TYPE_URI == type[0]) {
+            ReportNdefRecordURIFromMessage(message, i, record_obj);
+            continue;
+          }
         }
+      }
+      ConstructNdefRecordFromRecordHandle(record_handle, record_obj);
     }
+  }
 }
 
 void NFCMessageUtils::ReportNdefMessageFromData(unsigned char* data, unsigned long size,
-        picojson::object& out)
+                                                picojson::object& out)
 {
-    LoggerD("Entered");
-    nfc_ndef_message_h message = NULL;
+  LoggerD("Entered");
+  nfc_ndef_message_h message = NULL;
 
-    int result = nfc_ndef_message_create_from_rawdata(&message, data, size);
-    if (NFC_ERROR_NONE != result) {
-        LoggerE("Can't create Ndef Message from data");
-        NFCUtil::throwNFCException(result, "Can't create Ndef Message from data");
-    }
-    picojson::value records_array = picojson::value(picojson::array());
-    picojson::array& records_array_obj = records_array.get<picojson::array>();
-    ToNdefRecords(message, records_array_obj);
-    out.insert(std::make_pair("records", records_array));
+  int result = nfc_ndef_message_create_from_rawdata(&message, data, size);
+  if (NFC_ERROR_NONE != result) {
+    LoggerE("Can't create Ndef Message from data");
+    NFCUtil::throwNFCException(result, "Can't create Ndef Message from data");
+  }
+  picojson::value records_array = picojson::value(picojson::array());
+  picojson::array& records_array_obj = records_array.get<picojson::array>();
+  ToNdefRecords(message, records_array_obj);
+  out.insert(std::make_pair("records", records_array));
 
-    RemoveMessageHandle(message);
+  RemoveMessageHandle(message);
 }
 
 void NFCMessageUtils::ReportNDEFMessage(const picojson::value& args, picojson::object& out){
-    LoggerD("Entered");
-    const picojson::array& raw_data =
-            FromJson<picojson::array>(args.get<picojson::object>(), "rawData");
-    const int size = static_cast<int>(args.get("rawDataSize").get<double>());
+  LoggerD("Entered");
+  const picojson::array& raw_data =
+      FromJson<picojson::array>(args.get<picojson::object>(), "rawData");
+  const int size = static_cast<int>(args.get("rawDataSize").get<double>());
 
-    std::unique_ptr<unsigned char[]> data(new unsigned char[size]);
+  std::unique_ptr<unsigned char[]> data(new unsigned char[size]);
 
-    for (size_t i = 0; i < size; i++) {
-        data[i] = static_cast<unsigned char>(raw_data[i].get<double>());
-    }
+  for (size_t i = 0; i < size; i++) {
+    data[i] = static_cast<unsigned char>(raw_data[i].get<double>());
+  }
 
-    ReportNdefMessageFromData(data.get(), size, out);
+  ReportNdefMessageFromData(data.get(), size, out);
 }
 
 static nfc_ndef_record_h NdefRecordGetHandle(picojson::value& record)
 {
-    LoggerD("Entered");
-    if (!record.is<picojson::object>() || !record.contains("tnf") || !record.contains("type") ||
-            !record.contains("id") || !record.contains("payload")) {
-        throw TypeMismatchException("Record is empty - could not create platform handle");
-    }
-
-    const picojson::object& record_obj = record.get<picojson::object>();
-
-    short tnf_from_json = static_cast<short>(record.get("tnf").get<double>());
-    nfc_record_tnf_e tnf = static_cast<nfc_record_tnf_e>(tnf_from_json);
-
-    const picojson::array& type_data =
-                FromJson<picojson::array>(record_obj, "type");
-    int type_size = type_data.size();
-    std::unique_ptr<unsigned char[]> type(new unsigned char[type_size]);
-    for (size_t i = 0; i < type_size; i++) {
-        type[i] = static_cast<unsigned char>(type_data[i].get<double>());
-    }
-
-    const picojson::array& id_data =
-            FromJson<picojson::array>(record_obj, "id");
-    int id_size = id_data.size();
-    std::unique_ptr<unsigned char[]> id(new unsigned char[id_size]);
-    for (size_t i = 0; i < id_size; i++) {
-        id[i] = static_cast<unsigned char>(id_data[i].get<double>());
-    }
-
-    const picojson::array& payload_data =
-            FromJson<picojson::array>(record_obj, "payload");
-    int payload_size = payload_data.size();
-    std::unique_ptr<unsigned char[]> payload(new unsigned char[payload_size]);
-    for (size_t i = 0; i < payload_size; i++) {
-        payload[i] = static_cast<unsigned char>(payload_data[i].get<double>());
-    }
-
-    if ((tnf_from_json < TNF_MIN) || (tnf_from_json > TNF_MAX)) {
-        LoggerE("Not supported tnf");
-        throw TypeMismatchException("Type mismatch");
-    }
-
-    const int BYTE_ARRAY_MAX = 255;
-
-    nfc_ndef_record_h record_handle = NULL;
-    int result = nfc_ndef_record_create(&record_handle,
-        tnf, type.get(), type_size > BYTE_ARRAY_MAX ? BYTE_ARRAY_MAX : type_size,
-        id.get(), id_size > BYTE_ARRAY_MAX ? BYTE_ARRAY_MAX : id_size,
-        payload.get(), payload_size);
-
-    if (NFC_ERROR_NONE != result) {
-        removeRecordHandle(record_handle);
-        LoggerE("Can't create Ndef Record: %d, %s", result,
+  LoggerD("Entered");
+  if (!record.is<picojson::object>() || !record.contains("tnf") || !record.contains("type") ||
+      !record.contains("id") || !record.contains("payload")) {
+    throw TypeMismatchException("Record is empty - could not create platform handle");
+  }
+
+  const picojson::object& record_obj = record.get<picojson::object>();
+
+  short tnf_from_json = static_cast<short>(record.get("tnf").get<double>());
+  nfc_record_tnf_e tnf = static_cast<nfc_record_tnf_e>(tnf_from_json);
+
+  const picojson::array& type_data =
+      FromJson<picojson::array>(record_obj, "type");
+  int type_size = type_data.size();
+  std::unique_ptr<unsigned char[]> type(new unsigned char[type_size]);
+  for (size_t i = 0; i < type_size; i++) {
+    type[i] = static_cast<unsigned char>(type_data[i].get<double>());
+  }
+
+  const picojson::array& id_data =
+      FromJson<picojson::array>(record_obj, "id");
+  int id_size = id_data.size();
+  std::unique_ptr<unsigned char[]> id(new unsigned char[id_size]);
+  for (size_t i = 0; i < id_size; i++) {
+    id[i] = static_cast<unsigned char>(id_data[i].get<double>());
+  }
+
+  const picojson::array& payload_data =
+      FromJson<picojson::array>(record_obj, "payload");
+  int payload_size = payload_data.size();
+  std::unique_ptr<unsigned char[]> payload(new unsigned char[payload_size]);
+  for (size_t i = 0; i < payload_size; i++) {
+    payload[i] = static_cast<unsigned char>(payload_data[i].get<double>());
+  }
+
+  if ((tnf_from_json < TNF_MIN) || (tnf_from_json > TNF_MAX)) {
+    LoggerE("Not supported tnf");
+    throw TypeMismatchException("Type mismatch");
+  }
+
+  const int BYTE_ARRAY_MAX = 255;
+
+  nfc_ndef_record_h record_handle = NULL;
+  int result = nfc_ndef_record_create(&record_handle,
+                                      tnf, type.get(), type_size > BYTE_ARRAY_MAX ? BYTE_ARRAY_MAX : type_size,
+                                          id.get(), id_size > BYTE_ARRAY_MAX ? BYTE_ARRAY_MAX : id_size,
+                                              payload.get(), payload_size);
+
+  if (NFC_ERROR_NONE != result) {
+    removeRecordHandle(record_handle);
+    LoggerE("Can't create Ndef Record: %d, %s", result,
             NFCUtil::getNFCErrorMessage(result).c_str());
-        NFCUtil::throwNFCException(result, "Can't create Ndef Record");
-    }
-    return record_handle;
+    NFCUtil::throwNFCException(result, "Can't create Ndef Record");
+  }
+  return record_handle;
 }
 
 nfc_ndef_message_h NFCMessageUtils::NDEFMessageToStruct(const picojson::array& records_array,
-        const int size)
+                                                        const int size)
 {
-    LoggerD("Entered");
-    if (!size) {
-        LoggerE("No records in message");
-        return NULL;
-    }
+  LoggerD("Entered");
+  if (!size) {
+    LoggerE("No records in message");
+    return NULL;
+  }
 
-    nfc_ndef_message_h message = NULL;
-    int result = nfc_ndef_message_create(&message);
+  nfc_ndef_message_h message = NULL;
+  int result = nfc_ndef_message_create(&message);
 
-    if (NFC_ERROR_NONE != result) {
-        RemoveMessageHandle(message);
-        LoggerE("Can't create Ndef Message: %d, %s", result,
+  if (NFC_ERROR_NONE != result) {
+    RemoveMessageHandle(message);
+    LoggerE("Can't create Ndef Message: %d, %s", result,
             NFCUtil::getNFCErrorMessage(result).c_str());
-        NFCUtil::throwNFCException(result, "Can't create Ndef Message");
-    }
+    NFCUtil::throwNFCException(result, "Can't create Ndef Message");
+  }
 
-    for (picojson::value record : records_array) {
-        nfc_ndef_record_h record_handle = NdefRecordGetHandle(record);
+  for (picojson::value record : records_array) {
+    nfc_ndef_record_h record_handle = NdefRecordGetHandle(record);
 
-        result = nfc_ndef_message_append_record(message, record_handle);
-        if (NFC_ERROR_NONE != result) {
-            LoggerE("record can't be inserted: %d, %s", result,
-                NFCUtil::getNFCErrorMessage(result).c_str());
-            removeRecordHandle(record_handle);
-            RemoveMessageHandle(message);
-            NFCUtil::throwNFCException(result, "Invalid NDEF Message");
-        }
+    result = nfc_ndef_message_append_record(message, record_handle);
+    if (NFC_ERROR_NONE != result) {
+      LoggerE("record can't be inserted: %d, %s", result,
+              NFCUtil::getNFCErrorMessage(result).c_str());
+      removeRecordHandle(record_handle);
+      RemoveMessageHandle(message);
+      NFCUtil::throwNFCException(result, "Invalid NDEF Message");
     }
-    return message;
+  }
+  return message;
 }
 
 void NFCMessageUtils::NDEFMessageToByte(const picojson::value& args, picojson::object& out){
-    LoggerD("Entered");
-    //input
-    const picojson::array& records_array =
-            FromJson<picojson::array>(args.get<picojson::object>(), "records");
-    const int size = static_cast<int>(args.get("recordsSize").get<double>());
-
-    //output
-    picojson::value byte_array = picojson::value(picojson::array());
-    picojson::array& byte_array_obj = byte_array.get<picojson::array>();
-
-    nfc_ndef_message_h message = NDEFMessageToStruct(records_array, size);
-    if (!message) {
-        out.insert(std::make_pair("bytes", byte_array));
-        return;
-    }
+  LoggerD("Entered");
+  //input
+  const picojson::array& records_array =
+      FromJson<picojson::array>(args.get<picojson::object>(), "records");
+  const int size = static_cast<int>(args.get("recordsSize").get<double>());
+
+  //output
+  picojson::value byte_array = picojson::value(picojson::array());
+  picojson::array& byte_array_obj = byte_array.get<picojson::array>();
+
+  nfc_ndef_message_h message = NDEFMessageToStruct(records_array, size);
+  if (!message) {
+    out.insert(std::make_pair("bytes", byte_array));
+    return;
+  }
 
-    unsigned char *raw_data = NULL;
+  unsigned char *raw_data = NULL;
 
-    unsigned int raw_data_size = 0;
-    int result = nfc_ndef_message_get_rawdata(message, &raw_data, &raw_data_size);
+  unsigned int raw_data_size = 0;
+  int result = nfc_ndef_message_get_rawdata(message, &raw_data, &raw_data_size);
 
-    RemoveMessageHandle(message);
-    message = NULL;
+  RemoveMessageHandle(message);
+  message = NULL;
 
-    if (NFC_ERROR_NONE != result) {
-        LoggerE("Can't get serial bytes of NDEF message: %d, %s", result,
-                NFCUtil::getNFCErrorMessage(result).c_str());
-        NFCUtil::throwNFCException(result, "Can't get serial bytes of NDEF message");
-    }
+  if (NFC_ERROR_NONE != result) {
+    LoggerE("Can't get serial bytes of NDEF message: %d, %s", result,
+            NFCUtil::getNFCErrorMessage(result).c_str());
+    NFCUtil::throwNFCException(result, "Can't get serial bytes of NDEF message");
+  }
 
-    for (size_t i = 0 ; i < raw_data_size; i++) {
-        byte_array_obj.push_back(picojson::value(std::to_string(raw_data[i])));
-    }
-    if (raw_data) {
-        free(raw_data);
-    }
-    out.insert(std::make_pair("bytes", byte_array));
+  for (size_t i = 0 ; i < raw_data_size; i++) {
+    byte_array_obj.push_back(picojson::value(std::to_string(raw_data[i])));
+  }
+  if (raw_data) {
+    free(raw_data);
+  }
+  out.insert(std::make_pair("bytes", byte_array));
 }
 
 /* -------------------------------RECORD FUNCTIONS------------------------------------ */
 static void ConstructRecordJson(short _tnf, const UCharVector& _type_name,
-        const UCharVector& _id, const UCharVector& _payload, picojson::object& out)
+                                const UCharVector& _id, const UCharVector& _payload, picojson::object& out)
 {
-    LoggerD("Entered");
-    out.insert(std::make_pair("tnf", std::to_string(_tnf)));
-
-    picojson::value type_array = picojson::value(picojson::array());
-    picojson::array& type_array_obj = type_array.get<picojson::array>();
-    for (size_t i = 0 ; i < _type_name.size(); i++) {
-        type_array_obj.push_back(picojson::value(std::to_string(_type_name[i])));
-    }
-    out.insert(std::make_pair("type", type_array));
-
-    picojson::value id_array = picojson::value(picojson::array());
-    picojson::array& id_array_obj = id_array.get<picojson::array>();
-    for (size_t i = 0 ; i < _id.size(); i++) {
-        id_array_obj.push_back(picojson::value(std::to_string(_id[i])));
-    }
-    out.insert(std::make_pair("id", id_array));
-
-    picojson::value payload_array = picojson::value(picojson::array());
-    picojson::array& payload_array_obj = payload_array.get<picojson::array>();
-    for (size_t i = 0 ; i < _payload.size(); i++) {
-        payload_array_obj.push_back(picojson::value(std::to_string(_payload[i])));
-    }
-    out.insert(std::make_pair("payload", payload_array));
+  LoggerD("Entered");
+  out.insert(std::make_pair("tnf", std::to_string(_tnf)));
+
+  picojson::value type_array = picojson::value(picojson::array());
+  picojson::array& type_array_obj = type_array.get<picojson::array>();
+  for (size_t i = 0 ; i < _type_name.size(); i++) {
+    type_array_obj.push_back(picojson::value(std::to_string(_type_name[i])));
+  }
+  out.insert(std::make_pair("type", type_array));
+
+  picojson::value id_array = picojson::value(picojson::array());
+  picojson::array& id_array_obj = id_array.get<picojson::array>();
+  for (size_t i = 0 ; i < _id.size(); i++) {
+    id_array_obj.push_back(picojson::value(std::to_string(_id[i])));
+  }
+  out.insert(std::make_pair("id", id_array));
+
+  picojson::value payload_array = picojson::value(picojson::array());
+  picojson::array& payload_array_obj = payload_array.get<picojson::array>();
+  for (size_t i = 0 ; i < _payload.size(); i++) {
+    payload_array_obj.push_back(picojson::value(std::to_string(_payload[i])));
+  }
+  out.insert(std::make_pair("payload", payload_array));
 }
 
 void NFCMessageUtils::ConstructNdefRecordFromRecordHandle(nfc_ndef_record_h record_handle,
-        picojson::object& out)
+                                                          picojson::object& out)
 {
-    LoggerD("Entered");
-    short _tnf = getTnfFromHandle(record_handle);
-    UCharVector _type_name = getTypeNameFromHandle(record_handle);
-    UCharVector _id = getIdFromHandle(record_handle);
-    UCharVector _payload = getPayloadFromHandle(record_handle);
+  LoggerD("Entered");
+  short _tnf = getTnfFromHandle(record_handle);
+  UCharVector _type_name = getTypeNameFromHandle(record_handle);
+  UCharVector _id = getIdFromHandle(record_handle);
+  UCharVector _payload = getPayloadFromHandle(record_handle);
 
-    //constructing json
-    ConstructRecordJson(_tnf, _type_name, _id, _payload, out);
+  //constructing json
+  ConstructRecordJson(_tnf, _type_name, _id, _payload, out);
 }
 
 void NFCMessageUtils::ReportNdefRecordFromMessage(nfc_ndef_message_h message_handle,
-        const int index, picojson::object& out)
+                                                  const int index, picojson::object& out)
 {
-    LoggerD("Entered");
-    nfc_ndef_record_h record_handle = NULL;
-    int result = nfc_ndef_message_get_record(message_handle, index, &record_handle);
-    if (NFC_ERROR_NONE != result) {
-        LoggerE("Can't get NdefRecord: %d, %s", result,
+  LoggerD("Entered");
+  nfc_ndef_record_h record_handle = NULL;
+  int result = nfc_ndef_message_get_record(message_handle, index, &record_handle);
+  if (NFC_ERROR_NONE != result) {
+    LoggerE("Can't get NdefRecord: %d, %s", result,
             NFCUtil::getNFCErrorMessage(result).c_str());
-        RemoveMessageHandle(message_handle);
-        NFCUtil::throwNFCException(result, "Can't get NdefRecord");
-    }
+    RemoveMessageHandle(message_handle);
+    NFCUtil::throwNFCException(result, "Can't get NdefRecord");
+  }
 
-    ConstructNdefRecordFromRecordHandle(record_handle, out);
+  ConstructNdefRecordFromRecordHandle(record_handle, out);
 }
 
 void NFCMessageUtils::ReportNDEFRecord(const picojson::value& args, picojson::object& out){
-    LoggerD("Entered");
-    const picojson::array& raw_data =
-            FromJson<picojson::array>(args.get<picojson::object>(), "rawData");
-    const int size = static_cast<int>(args.get("rawDataSize").get<double>());
+  LoggerD("Entered");
+  const picojson::array& raw_data =
+      FromJson<picojson::array>(args.get<picojson::object>(), "rawData");
+  const int size = static_cast<int>(args.get("rawDataSize").get<double>());
 
-    std::unique_ptr<unsigned char[]> data(new unsigned char[size]);
+  std::unique_ptr<unsigned char[]> data(new unsigned char[size]);
 
-    for (size_t i = 0; i < size; i++) {
-        data[i] = static_cast<unsigned char>(raw_data[i].get<double>());
-    }
-    nfc_ndef_message_h message_handle = NULL;
+  for (size_t i = 0; i < size; i++) {
+    data[i] = static_cast<unsigned char>(raw_data[i].get<double>());
+  }
+  nfc_ndef_message_h message_handle = NULL;
 
-    int result = nfc_ndef_message_create_from_rawdata(&message_handle, data.get(), size);
-    if (NFC_ERROR_NONE != result) {
-        LoggerE("Can't create NdefMessage from data: %d, %s", result,
+  int result = nfc_ndef_message_create_from_rawdata(&message_handle, data.get(), size);
+  if (NFC_ERROR_NONE != result) {
+    LoggerE("Can't create NdefMessage from data: %d, %s", result,
             NFCUtil::getNFCErrorMessage(result).c_str());
-        NFCUtil::throwNFCException(result, "Can't create NdefMessage from data");
-    }
+    NFCUtil::throwNFCException(result, "Can't create NdefMessage from data");
+  }
 
-    int count;
-    result = nfc_ndef_message_get_record_count(message_handle, &count);
-    if (NFC_ERROR_NONE != result) {
-        LoggerE("Can't get record count: %d, %s", result,
+  int count;
+  result = nfc_ndef_message_get_record_count(message_handle, &count);
+  if (NFC_ERROR_NONE != result) {
+    LoggerE("Can't get record count: %d, %s", result,
             NFCUtil::getNFCErrorMessage(result).c_str());
-        RemoveMessageHandle(message_handle);
-        NFCUtil::throwNFCException(result, "Can't get record count");
-    }
+    RemoveMessageHandle(message_handle);
+    NFCUtil::throwNFCException(result, "Can't get record count");
+  }
 
-    ReportNdefRecordFromMessage(message_handle, 0, out);
+  ReportNdefRecordFromMessage(message_handle, 0, out);
 
-    RemoveMessageHandle(message_handle);
+  RemoveMessageHandle(message_handle);
 }
 
 /* -------------------------------RECORD TEXT FUNCTIONS------------------------------------ */
 static std::string getTextFromHandle(nfc_ndef_record_h handle,
-        nfc_ndef_message_h message_handle)
+                                     nfc_ndef_message_h message_handle)
 {
-    char* text = NULL;
-    int result = nfc_ndef_record_get_text(handle, &text);
-    if (NFC_ERROR_NONE != result) {
-        LoggerE("Can't get record's text: %d, %s", result,
+  char* text = NULL;
+  int result = nfc_ndef_record_get_text(handle, &text);
+  if (NFC_ERROR_NONE != result) {
+    LoggerE("Can't get record's text: %d, %s", result,
             NFCUtil::getNFCErrorMessage(result).c_str());
-        NFCMessageUtils::RemoveMessageHandle(message_handle);
-        NFCUtil::throwNFCException(result, "Can't get record's text");
-    }
+    NFCMessageUtils::RemoveMessageHandle(message_handle);
+    NFCUtil::throwNFCException(result, "Can't get record's text");
+  }
 
-    std::string text_string(text);
-    free(text);
-    text = NULL;
-    return text_string;
+  std::string text_string(text);
+  free(text);
+  text = NULL;
+  return text_string;
 }
 
 static std::string getLanguageCodeFromHandle(nfc_ndef_record_h handle,
-        nfc_ndef_message_h message_handle)
+                                             nfc_ndef_message_h message_handle)
 {
-    char* language_code = NULL;
-    int result = nfc_ndef_record_get_langcode(handle, &language_code);
-    if (NFC_ERROR_NONE != result) {
-        LoggerE("Can't get record's languageCode: %d, %s", result,
+  char* language_code = NULL;
+  int result = nfc_ndef_record_get_langcode(handle, &language_code);
+  if (NFC_ERROR_NONE != result) {
+    LoggerE("Can't get record's languageCode: %d, %s", result,
             NFCUtil::getNFCErrorMessage(result).c_str());
-        NFCMessageUtils::RemoveMessageHandle(message_handle);
-        NFCUtil::throwNFCException(result, "Can't get record's languageCode");
-    }
+    NFCMessageUtils::RemoveMessageHandle(message_handle);
+    NFCUtil::throwNFCException(result, "Can't get record's languageCode");
+  }
 
-    std::string language_string(language_code);
-    free(language_code);
-    language_code = NULL;
-    return language_string;
+  std::string language_string(language_code);
+  free(language_code);
+  language_code = NULL;
+  return language_string;
 }
 
 static nfc_encode_type_e getEncodingFromHandle(nfc_ndef_record_h handle,
-        nfc_ndef_message_h message_handle)
+                                               nfc_ndef_message_h message_handle)
 {
-    nfc_encode_type_e encoding;
-    int result = nfc_ndef_record_get_encode_type(handle, &encoding);
-    if (NFC_ERROR_NONE != result) {
-        LoggerE("Can't get record's encoding: %d, %s", result,
+  nfc_encode_type_e encoding;
+  int result = nfc_ndef_record_get_encode_type(handle, &encoding);
+  if (NFC_ERROR_NONE != result) {
+    LoggerE("Can't get record's encoding: %d, %s", result,
             NFCUtil::getNFCErrorMessage(result).c_str());
-        NFCMessageUtils::RemoveMessageHandle(message_handle);
-        NFCUtil::throwNFCException(result, "Can't get record's encoding");
-    }
+    NFCMessageUtils::RemoveMessageHandle(message_handle);
+    NFCUtil::throwNFCException(result, "Can't get record's encoding");
+  }
 
-    return encoding;
+  return encoding;
 }
 
 static void ReportNDEFRecordTextFromText(const std::string& text, const std::string& language_code,
-        const std::string& encoding_str, picojson::object& out)
+                                         const std::string& encoding_str, picojson::object& out)
 {
-    nfc_encode_type_e encoding = convertToNfcEncodeUTF(encoding_str);
-    nfc_ndef_record_h handle = NULL;
+  nfc_encode_type_e encoding = convertToNfcEncodeUTF(encoding_str);
+  nfc_ndef_record_h handle = NULL;
 
-    int result = nfc_ndef_record_create_text(&handle, text.c_str(),
-            language_code.c_str(), encoding);
-    if (NFC_ERROR_NONE != result) {
-        LoggerE("Unknown error while getting text record: %d, %s", result,
+  int result = nfc_ndef_record_create_text(&handle, text.c_str(),
+                                           language_code.c_str(), encoding);
+  if (NFC_ERROR_NONE != result) {
+    LoggerE("Unknown error while getting text record: %d, %s", result,
             NFCUtil::getNFCErrorMessage(result).c_str());
-        NFCUtil::throwNFCException(result,"Can't create text record");
-    }
+    NFCUtil::throwNFCException(result,"Can't create text record");
+  }
 
-    short _tnf = getTnfFromHandle(handle);
-    UCharVector _type_name = getTypeNameFromHandle(handle);
-    UCharVector _id = getIdFromHandle(handle);
-    UCharVector _payload = getPayloadFromHandle(handle);
+  short _tnf = getTnfFromHandle(handle);
+  UCharVector _type_name = getTypeNameFromHandle(handle);
+  UCharVector _id = getIdFromHandle(handle);
+  UCharVector _payload = getPayloadFromHandle(handle);
 
-    //constructing json
-    ConstructRecordJson(_tnf, _type_name, _id, _payload, out);
+  //constructing json
+  ConstructRecordJson(_tnf, _type_name, _id, _payload, out);
 
-    removeRecordHandle(handle);
+  removeRecordHandle(handle);
 }
 
 void NFCMessageUtils::ReportNdefRecordTextFromMessage(nfc_ndef_message_h message_handle,
-        const int index, picojson::object& out)
+                                                      const int index, picojson::object& out)
 {
-    nfc_ndef_record_h record_handle = NULL;
-    //This function just return the pointer of record.
-    int result = nfc_ndef_message_get_record(message_handle, index, &record_handle);
-    if (NFC_ERROR_NONE != result) {
-        LoggerE("Can't get Ndef Record: %d, %s", result,
+  nfc_ndef_record_h record_handle = NULL;
+  //This function just return the pointer of record.
+  int result = nfc_ndef_message_get_record(message_handle, index, &record_handle);
+  if (NFC_ERROR_NONE != result) {
+    LoggerE("Can't get Ndef Record: %d, %s", result,
             NFCUtil::getNFCErrorMessage(result).c_str());
-        RemoveMessageHandle(message_handle);
-        NFCUtil::throwNFCException(result, "Can't get Ndef Record");
-    }
+    RemoveMessageHandle(message_handle);
+    NFCUtil::throwNFCException(result, "Can't get Ndef Record");
+  }
 
-    std::string text = getTextFromHandle(record_handle, message_handle);
-    std::string language_code = getLanguageCodeFromHandle(record_handle, message_handle);
-    nfc_encode_type_e encoding = getEncodingFromHandle(record_handle, message_handle);
-    std::string encoding_str = convertEncodingToString(encoding);
+  std::string text = getTextFromHandle(record_handle, message_handle);
+  std::string language_code = getLanguageCodeFromHandle(record_handle, message_handle);
+  nfc_encode_type_e encoding = getEncodingFromHandle(record_handle, message_handle);
+  std::string encoding_str = convertEncodingToString(encoding);
 
-    ReportNDEFRecordTextFromText(text, language_code, encoding_str, out);
-    out.insert(std::make_pair("text", text));
-    out.insert(std::make_pair("languageCode", language_code));
-    out.insert(std::make_pair("encoding", encoding_str));
+  ReportNDEFRecordTextFromText(text, language_code, encoding_str, out);
+  out.insert(std::make_pair("text", text));
+  out.insert(std::make_pair("languageCode", language_code));
+  out.insert(std::make_pair("encoding", encoding_str));
 }
 
 void NFCMessageUtils::ReportNDEFRecordText(const picojson::value& args, picojson::object& out){
-    LoggerD("Entered");
-    const std::string& text = args.get("text").get<std::string>();
-    const std::string& language_code = args.get("languageCode").get<std::string>();
-    const std::string& encoding_str = args.get("encoding").get<std::string>();
+  LoggerD("Entered");
+  const std::string& text = args.get("text").get<std::string>();
+  const std::string& language_code = args.get("languageCode").get<std::string>();
+  const std::string& encoding_str = args.get("encoding").get<std::string>();
 
-    ReportNDEFRecordTextFromText(text, language_code, encoding_str, out);
+  ReportNDEFRecordTextFromText(text, language_code, encoding_str, out);
 }
 
 /* -------------------------------RECORD URI FUNCTIONS------------------------------------ */
 static std::string getURIFromHandle(nfc_ndef_record_h handle,
-        nfc_ndef_message_h message_handle)
+                                    nfc_ndef_message_h message_handle)
 {
-    char* uri = NULL;
-    int result = nfc_ndef_record_get_uri(handle, &uri);
-    if (NFC_ERROR_NONE != result) {
-        LoggerE("Can't get record's uri: %d, %s", result,
+  char* uri = NULL;
+  int result = nfc_ndef_record_get_uri(handle, &uri);
+  if (NFC_ERROR_NONE != result) {
+    LoggerE("Can't get record's uri: %d, %s", result,
             NFCUtil::getNFCErrorMessage(result).c_str());
-        NFCMessageUtils::RemoveMessageHandle(message_handle);
-        NFCUtil::throwNFCException(result, "Can't get record's uri");
-    }
+    NFCMessageUtils::RemoveMessageHandle(message_handle);
+    NFCUtil::throwNFCException(result, "Can't get record's uri");
+  }
 
-    std::string uri_string(uri);
-    free(uri);
-    uri = NULL;
-    return uri_string;
+  std::string uri_string(uri);
+  free(uri);
+  uri = NULL;
+  return uri_string;
 }
 
 static void ReportNDEFRecordURIFromURI(const std::string& uri, picojson::object& out)
 {
-    nfc_ndef_record_h handle = NULL;
+  nfc_ndef_record_h handle = NULL;
 
-    int result = nfc_ndef_record_create_uri(&handle, uri.c_str());
-    if(NFC_ERROR_NONE != result) {
-        LoggerE("Unknown error while creating NdefRecordURI: %d, %s", result,
+  int result = nfc_ndef_record_create_uri(&handle, uri.c_str());
+  if(NFC_ERROR_NONE != result) {
+    LoggerE("Unknown error while creating NdefRecordURI: %d, %s", result,
             NFCUtil::getNFCErrorMessage(result).c_str());
-        NFCUtil::throwNFCException(result, "Unknown error while creating NdefRecordURI");
-    }
+    NFCUtil::throwNFCException(result, "Unknown error while creating NdefRecordURI");
+  }
 
-    short _tnf = getTnfFromHandle(handle);
-    UCharVector _type_name = getTypeNameFromHandle(handle);
-    UCharVector _id = getIdFromHandle(handle);
-    UCharVector _payload = getPayloadFromHandle(handle);
+  short _tnf = getTnfFromHandle(handle);
+  UCharVector _type_name = getTypeNameFromHandle(handle);
+  UCharVector _id = getIdFromHandle(handle);
+  UCharVector _payload = getPayloadFromHandle(handle);
 
-    //constructing json
-    ConstructRecordJson(_tnf, _type_name, _id, _payload, out);
+  //constructing json
+  ConstructRecordJson(_tnf, _type_name, _id, _payload, out);
 
-    removeRecordHandle(handle);
+  removeRecordHandle(handle);
 }
 
 void NFCMessageUtils::ReportNdefRecordURIFromMessage(nfc_ndef_message_h message_handle,
-        const int index, picojson::object& out)
+                                                     const int index, picojson::object& out)
 {
-    nfc_ndef_record_h record_handle = NULL;
-    //This function just return the pointer of record.
-    int result = nfc_ndef_message_get_record(message_handle, index, &record_handle);
-    if (NFC_ERROR_NONE != result) {
-        LoggerE("Can't get Ndef Record: %d, %s", result,
+  nfc_ndef_record_h record_handle = NULL;
+  //This function just return the pointer of record.
+  int result = nfc_ndef_message_get_record(message_handle, index, &record_handle);
+  if (NFC_ERROR_NONE != result) {
+    LoggerE("Can't get Ndef Record: %d, %s", result,
             NFCUtil::getNFCErrorMessage(result).c_str());
-        RemoveMessageHandle(message_handle);
-        NFCUtil::throwNFCException(result, "Can't get Ndef Record");
-    }
+    RemoveMessageHandle(message_handle);
+    NFCUtil::throwNFCException(result, "Can't get Ndef Record");
+  }
 
-    std::string uri = getURIFromHandle(record_handle, message_handle);
-    ReportNDEFRecordURIFromURI(uri, out);
-    out.insert(std::make_pair("uri", uri));
+  std::string uri = getURIFromHandle(record_handle, message_handle);
+  ReportNDEFRecordURIFromURI(uri, out);
+  out.insert(std::make_pair("uri", uri));
 }
 
 void NFCMessageUtils::ReportNDEFRecordURI(const picojson::value& args, picojson::object& out){
-    LoggerD("Entered");
+  LoggerD("Entered");
 
-    const std::string& uri = args.get("uri").get<std::string>();
-    ReportNDEFRecordURIFromURI(uri, out);
+  const std::string& uri = args.get("uri").get<std::string>();
+  ReportNDEFRecordURIFromURI(uri, out);
 }
 
 /* -------------------------------RECORD MEDIA FUNCTIONS------------------------------------ */
 static std::string getMimeTypeFromHandle(nfc_ndef_record_h handle,
-        nfc_ndef_message_h message_handle)
+                                         nfc_ndef_message_h message_handle)
 {
-    char* mime_type = NULL;
-    int result = nfc_ndef_record_get_mime_type(handle, &mime_type);
-    if (NFC_ERROR_NONE != result) {
-        LoggerE("Can't get record's mime_type: %d, %s", result,
+  char* mime_type = NULL;
+  int result = nfc_ndef_record_get_mime_type(handle, &mime_type);
+  if (NFC_ERROR_NONE != result) {
+    LoggerE("Can't get record's mime_type: %d, %s", result,
             NFCUtil::getNFCErrorMessage(result).c_str());
-        NFCMessageUtils::RemoveMessageHandle(message_handle);
-        NFCUtil::throwNFCException(result, "Can't get record's mime_type");
-    }
+    NFCMessageUtils::RemoveMessageHandle(message_handle);
+    NFCUtil::throwNFCException(result, "Can't get record's mime_type");
+  }
 
-    std::string mime_string(mime_type);
-    free(mime_type);
-    mime_type = NULL;
-    return mime_string;
+  std::string mime_string(mime_type);
+  free(mime_type);
+  mime_type = NULL;
+  return mime_string;
 }
 
 void NFCMessageUtils::ReportNdefRecordMediaFromMessage(nfc_ndef_message_h message_handle,
-        const int index, picojson::object& out)
+                                                       const int index, picojson::object& out)
 {
-    nfc_ndef_record_h record_handle = NULL;
-    //This function just return the pointer of record.
-    int result = nfc_ndef_message_get_record(message_handle, index, &record_handle);
-    if (NFC_ERROR_NONE != result) {
-        LoggerE("Can't get Ndef Record: %d, %s", result,
+  nfc_ndef_record_h record_handle = NULL;
+  //This function just return the pointer of record.
+  int result = nfc_ndef_message_get_record(message_handle, index, &record_handle);
+  if (NFC_ERROR_NONE != result) {
+    LoggerE("Can't get Ndef Record: %d, %s", result,
             NFCUtil::getNFCErrorMessage(result).c_str());
-        RemoveMessageHandle(message_handle);
-        NFCUtil::throwNFCException(result, "Can't get Ndef Record");
-    }
+    RemoveMessageHandle(message_handle);
+    NFCUtil::throwNFCException(result, "Can't get Ndef Record");
+  }
 
-    std::string mime_type = getMimeTypeFromHandle(record_handle, message_handle);
-    short _tnf = getTnfFromHandle(record_handle, message_handle);
-    UCharVector _type_name = getTypeNameFromHandle(record_handle, message_handle);
-    UCharVector _id = getIdFromHandle(record_handle, message_handle);
-    UCharVector _payload = getPayloadFromHandle(record_handle, message_handle);
-    //constructing json
-    ConstructRecordJson(_tnf, _type_name, _id, _payload, out);
-    out.insert(std::make_pair("mimeType", mime_type));
+  std::string mime_type = getMimeTypeFromHandle(record_handle, message_handle);
+  short _tnf = getTnfFromHandle(record_handle, message_handle);
+  UCharVector _type_name = getTypeNameFromHandle(record_handle, message_handle);
+  UCharVector _id = getIdFromHandle(record_handle, message_handle);
+  UCharVector _payload = getPayloadFromHandle(record_handle, message_handle);
+  //constructing json
+  ConstructRecordJson(_tnf, _type_name, _id, _payload, out);
+  out.insert(std::make_pair("mimeType", mime_type));
 }
 
 void NFCMessageUtils::ReportNDEFRecordMedia(const picojson::value& args, picojson::object& out){
-    LoggerD("Entered");
+  LoggerD("Entered");
 
-    const std::string& mime_type = args.get("mimeType").get<std::string>();
-    const picojson::array& raw_data =
-            FromJson<picojson::array>(args.get<picojson::object>(), "data");
-    const int size = static_cast<int>(args.get("dataSize").get<double>());
+  const std::string& mime_type = args.get("mimeType").get<std::string>();
+  const picojson::array& raw_data =
+      FromJson<picojson::array>(args.get<picojson::object>(), "data");
+  const int size = static_cast<int>(args.get("dataSize").get<double>());
 
-    std::unique_ptr<unsigned char[]> data(new unsigned char[size]);
-    for (size_t i = 0; i < size; i++) {
-        data[i] = static_cast<unsigned char>(raw_data[i].get<double>());
-    }
+  std::unique_ptr<unsigned char[]> data(new unsigned char[size]);
+  for (size_t i = 0; i < size; i++) {
+    data[i] = static_cast<unsigned char>(raw_data[i].get<double>());
+  }
 
-    nfc_ndef_record_h handle = NULL;
+  nfc_ndef_record_h handle = NULL;
 
-    short _tnf = NFC_RECORD_TNF_UNKNOWN;
-    UCharVector _type_name;
-    UCharVector _id;
-    UCharVector _payload;
+  short _tnf = NFC_RECORD_TNF_UNKNOWN;
+  UCharVector _type_name;
+  UCharVector _id;
+  UCharVector _payload;
 
-    int result = nfc_ndef_record_create_mime(&handle, mime_type.c_str(), data.get(),
-            size);
-    if (NFC_ERROR_NONE != result) {
-        LoggerE("Unknown error while getting mimeType: %s - %d: %s",
+  int result = nfc_ndef_record_create_mime(&handle, mime_type.c_str(), data.get(),
+                                           size);
+  if (NFC_ERROR_NONE != result) {
+    LoggerE("Unknown error while getting mimeType: %s - %d: %s",
             mime_type.c_str(), result,
             NFCUtil::getNFCErrorMessage(result).c_str());
-        //Do not throw just return default values
-        //NFCUtil::throwNFCException(result, "Unknown error while getting mimeType");
-    } else {
-        _tnf = getTnfFromHandle(handle);
-        _type_name = getTypeNameFromHandle(handle);
-        _id = getIdFromHandle(handle);
-        _payload = getPayloadFromHandle(handle);
-    }
-
-    //constructing json
-    ConstructRecordJson(_tnf, _type_name, _id, _payload, out);
-
-    removeRecordHandle(handle);
+    //Do not throw just return default values
+    //NFCUtil::throwNFCException(result, "Unknown error while getting mimeType");
+  } else {
+    _tnf = getTnfFromHandle(handle);
+    _type_name = getTypeNameFromHandle(handle);
+    _id = getIdFromHandle(handle);
+    _payload = getPayloadFromHandle(handle);
+  }
+
+  //constructing json
+  ConstructRecordJson(_tnf, _type_name, _id, _payload, out);
+
+  removeRecordHandle(handle);
 }
 
 } // NFC
index 89d38d7f913d559edd517614e73933a6382deabe..c4c6fbc48057620231e852753f060916eb82df88 100644 (file)
@@ -19,29 +19,29 @@ typedef std::vector<unsigned char> UCharVector;
 
 class NFCMessageUtils
 {
-public:
-    static void ToNdefRecords(const nfc_ndef_message_h message, picojson::array& array);
-    static void ReportNdefMessageFromData(unsigned char* data, unsigned long size,
-            picojson::object& out);
-    static void ReportNDEFMessage(const picojson::value& args, picojson::object& out);
-    static nfc_ndef_message_h NDEFMessageToStruct(const picojson::array& records_array,
-            const int size);
-    static void NDEFMessageToByte(const picojson::value& args, picojson::object& out);
-    static void ConstructNdefRecordFromRecordHandle(nfc_ndef_record_h record_handle,
-            picojson::object& out);
-    static void ReportNdefRecordFromMessage(nfc_ndef_message_h message_handle,
-                const int index, picojson::object& out);
-    static void ReportNDEFRecord(const picojson::value& args, picojson::object& out);
-    static void ReportNdefRecordTextFromMessage(nfc_ndef_message_h message_handle,
-                const int index, picojson::object& out);
-    static void ReportNDEFRecordText(const picojson::value& args, picojson::object& out);
-    static void ReportNdefRecordURIFromMessage(nfc_ndef_message_h message_handle,
-                const int index, picojson::object& out);
-    static void ReportNDEFRecordURI(const picojson::value& args, picojson::object& out);
-    static void ReportNdefRecordMediaFromMessage(nfc_ndef_message_h message_handle,
-                const int index, picojson::object& out);
-    static void ReportNDEFRecordMedia(const picojson::value& args, picojson::object& out);
-    static void RemoveMessageHandle(nfc_ndef_message_h message_handle);
+ public:
+  static void ToNdefRecords(const nfc_ndef_message_h message, picojson::array& array);
+  static void ReportNdefMessageFromData(unsigned char* data, unsigned long size,
+                                        picojson::object& out);
+  static void ReportNDEFMessage(const picojson::value& args, picojson::object& out);
+  static nfc_ndef_message_h NDEFMessageToStruct(const picojson::array& records_array,
+                                                const int size);
+  static void NDEFMessageToByte(const picojson::value& args, picojson::object& out);
+  static void ConstructNdefRecordFromRecordHandle(nfc_ndef_record_h record_handle,
+                                                  picojson::object& out);
+  static void ReportNdefRecordFromMessage(nfc_ndef_message_h message_handle,
+                                          const int index, picojson::object& out);
+  static void ReportNDEFRecord(const picojson::value& args, picojson::object& out);
+  static void ReportNdefRecordTextFromMessage(nfc_ndef_message_h message_handle,
+                                              const int index, picojson::object& out);
+  static void ReportNDEFRecordText(const picojson::value& args, picojson::object& out);
+  static void ReportNdefRecordURIFromMessage(nfc_ndef_message_h message_handle,
+                                             const int index, picojson::object& out);
+  static void ReportNDEFRecordURI(const picojson::value& args, picojson::object& out);
+  static void ReportNdefRecordMediaFromMessage(nfc_ndef_message_h message_handle,
+                                               const int index, picojson::object& out);
+  static void ReportNDEFRecordMedia(const picojson::value& args, picojson::object& out);
+  static void RemoveMessageHandle(nfc_ndef_message_h message_handle);
 };
 
 } // nfc
index acdb422e7d6e033f6f002509363a73209f9f8bc1..1582b364c355dcf824597362aa3c7ce8c4f4c733 100644 (file)
@@ -16,270 +16,270 @@ namespace nfc {
 
 UCharVector NFCUtil::toVector(const unsigned char *ch, const int size)
 {
-    UCharVector vec(ch, ch + size / sizeof(char));
-    return vec;
+  UCharVector vec(ch, ch + size / sizeof(char));
+  return vec;
 }
 
 void NFCUtil::throwNFCException(const int errorCode, const char* message)
 {
-    switch(errorCode) {
-        case NFC_ERROR_INVALID_PARAMETER:
-        case NFC_ERROR_INVALID_NDEF_MESSAGE:
-        case NFC_ERROR_INVALID_RECORD_TYPE:
-        case NFC_ERROR_NOT_NDEF_FORMAT:
-            throw InvalidValuesException(message);
-            break;
-        case NFC_ERROR_SECURITY_RESTRICTED:
-        case NFC_ERROR_PERMISSION_DENIED:
-            throw SecurityException(message);
-            break;
-        case NFC_ERROR_NOT_ACTIVATED:
-        case NFC_ERROR_NOT_SUPPORTED:
-        case NFC_ERROR_OPERATION_FAILED:
-        case NFC_ERROR_DEVICE_BUSY:
-        case NFC_ERROR_NO_DEVICE:
-        case NFC_ERROR_TIMED_OUT:
-        case NFC_ERROR_OUT_OF_MEMORY:
-        case NFC_ERROR_NOT_INITIALIZED:
-        default:
-            throw UnknownException(message);
-            break;
-    }
+  switch(errorCode) {
+    case NFC_ERROR_INVALID_PARAMETER:
+    case NFC_ERROR_INVALID_NDEF_MESSAGE:
+    case NFC_ERROR_INVALID_RECORD_TYPE:
+    case NFC_ERROR_NOT_NDEF_FORMAT:
+      throw InvalidValuesException(message);
+      break;
+    case NFC_ERROR_SECURITY_RESTRICTED:
+    case NFC_ERROR_PERMISSION_DENIED:
+      throw SecurityException(message);
+      break;
+    case NFC_ERROR_NOT_ACTIVATED:
+    case NFC_ERROR_NOT_SUPPORTED:
+    case NFC_ERROR_OPERATION_FAILED:
+    case NFC_ERROR_DEVICE_BUSY:
+    case NFC_ERROR_NO_DEVICE:
+    case NFC_ERROR_TIMED_OUT:
+    case NFC_ERROR_OUT_OF_MEMORY:
+    case NFC_ERROR_NOT_INITIALIZED:
+    default:
+      throw UnknownException(message);
+      break;
+  }
 }
 
 std::string NFCUtil::getNFCErrorString(const int error_code)
 {
-    LOGD("Error code : %d",error_code);
-    switch(error_code) {
-        case NFC_ERROR_ALREADY_ACTIVATED:
-        case NFC_ERROR_ALREADY_DEACTIVATED:
-            return "";
-        case NFC_ERROR_INVALID_PARAMETER:
-        case NFC_ERROR_INVALID_NDEF_MESSAGE:
-        case NFC_ERROR_INVALID_RECORD_TYPE:
-        case NFC_ERROR_NOT_NDEF_FORMAT:
-            return INVALID_VALUES_ERROR_NAME_STR;
-        case NFC_ERROR_NO_DEVICE:
-        case NFC_ERROR_OUT_OF_MEMORY:
-        case NFC_ERROR_OPERATION_FAILED:
-        case NFC_ERROR_DEVICE_BUSY:
-            return UNKNOWN_ERROR_NAME_STR;
-        case NFC_ERROR_NOT_ACTIVATED:
-            return SERVICE_NOT_AVAILABLE_ERROR_NAME_STR;
-        case NFC_ERROR_NOT_SUPPORTED:
-            return NOT_SUPPORTED_ERROR_NAME_STR;
-        case NFC_ERROR_TIMED_OUT:
-            return TIMEOUT_ERROR_NAME_STR;
-    }
-    return UNKNOWN_ERROR_NAME_STR;
+  LOGD("Error code : %d",error_code);
+  switch(error_code) {
+    case NFC_ERROR_ALREADY_ACTIVATED:
+    case NFC_ERROR_ALREADY_DEACTIVATED:
+      return "";
+    case NFC_ERROR_INVALID_PARAMETER:
+    case NFC_ERROR_INVALID_NDEF_MESSAGE:
+    case NFC_ERROR_INVALID_RECORD_TYPE:
+    case NFC_ERROR_NOT_NDEF_FORMAT:
+      return INVALID_VALUES_ERROR_NAME_STR;
+    case NFC_ERROR_NO_DEVICE:
+    case NFC_ERROR_OUT_OF_MEMORY:
+    case NFC_ERROR_OPERATION_FAILED:
+    case NFC_ERROR_DEVICE_BUSY:
+      return UNKNOWN_ERROR_NAME_STR;
+    case NFC_ERROR_NOT_ACTIVATED:
+      return SERVICE_NOT_AVAILABLE_ERROR_NAME_STR;
+    case NFC_ERROR_NOT_SUPPORTED:
+      return NOT_SUPPORTED_ERROR_NAME_STR;
+    case NFC_ERROR_TIMED_OUT:
+      return TIMEOUT_ERROR_NAME_STR;
+  }
+  return UNKNOWN_ERROR_NAME_STR;
 }
 
 std::string NFCUtil::getNFCErrorMessage(const int error_code)
 {
-    LOGD("Error code : %d",error_code);
-    switch(error_code) {
-        case NFC_ERROR_ALREADY_ACTIVATED:
-        case NFC_ERROR_ALREADY_DEACTIVATED:
-            return "";
-        case NFC_ERROR_INVALID_PARAMETER:
-            return "Invalid Parameter";
-        case NFC_ERROR_INVALID_NDEF_MESSAGE:
-            return "Invalid NDEF Message";
-        case NFC_ERROR_INVALID_RECORD_TYPE:
-            return "Invalid Record Type";
-        case NFC_ERROR_NO_DEVICE:
-            return "No Device";
-        case NFC_ERROR_OUT_OF_MEMORY:
-            return "Out Of Memory";
-        case NFC_ERROR_NOT_SUPPORTED:
-            return "NFC Not Supported";
-        case NFC_ERROR_OPERATION_FAILED:
-            return "Operation Failed";
-        case NFC_ERROR_DEVICE_BUSY:
-            return "Device Busy";
-        case NFC_ERROR_NOT_ACTIVATED:
-            return "NFC Not Activated";
-        case NFC_ERROR_TIMED_OUT:
-            return "Time Out";
-        case NFC_ERROR_READ_ONLY_NDEF:
-            return "Read Only NDEF";
-        case NFC_ERROR_NO_SPACE_ON_NDEF:
-            return "No Space On NDEF";
-        case NFC_ERROR_NO_NDEF_MESSAGE:
-            return "No NDEF Message";
-        case NFC_ERROR_NOT_NDEF_FORMAT:
-            return "Not NDEF Format";
-        case NFC_ERROR_SECURITY_RESTRICTED:
-            return "Security Restricted";
-    }
-    return "UnknownError";
+  LOGD("Error code : %d",error_code);
+  switch(error_code) {
+    case NFC_ERROR_ALREADY_ACTIVATED:
+    case NFC_ERROR_ALREADY_DEACTIVATED:
+      return "";
+    case NFC_ERROR_INVALID_PARAMETER:
+      return "Invalid Parameter";
+    case NFC_ERROR_INVALID_NDEF_MESSAGE:
+      return "Invalid NDEF Message";
+    case NFC_ERROR_INVALID_RECORD_TYPE:
+      return "Invalid Record Type";
+    case NFC_ERROR_NO_DEVICE:
+      return "No Device";
+    case NFC_ERROR_OUT_OF_MEMORY:
+      return "Out Of Memory";
+    case NFC_ERROR_NOT_SUPPORTED:
+      return "NFC Not Supported";
+    case NFC_ERROR_OPERATION_FAILED:
+      return "Operation Failed";
+    case NFC_ERROR_DEVICE_BUSY:
+      return "Device Busy";
+    case NFC_ERROR_NOT_ACTIVATED:
+      return "NFC Not Activated";
+    case NFC_ERROR_TIMED_OUT:
+      return "Time Out";
+    case NFC_ERROR_READ_ONLY_NDEF:
+      return "Read Only NDEF";
+    case NFC_ERROR_NO_SPACE_ON_NDEF:
+      return "No Space On NDEF";
+    case NFC_ERROR_NO_NDEF_MESSAGE:
+      return "No NDEF Message";
+    case NFC_ERROR_NOT_NDEF_FORMAT:
+      return "Not NDEF Format";
+    case NFC_ERROR_SECURITY_RESTRICTED:
+      return "Security Restricted";
+  }
+  return "UnknownError";
 }
 
 std::string NFCUtil::toStringNFCTag(nfc_tag_type_e tag_type)
 {
-    switch (tag_type) {
-        case NFC_GENERIC_PICC:
-            return GENERIC_TARGET;
-        case NFC_ISO14443_A_PICC:
-            return ISO14443_A;
-        case NFC_ISO14443_4A_PICC:
-            return ISO14443_4A;
-        case NFC_ISO14443_3A_PICC:
-            return ISO14443_3A;
-        case NFC_MIFARE_MINI_PICC:
-            return MIFARE_MINI;
-        case NFC_MIFARE_1K_PICC:
-            return MIFARE_1K;
-        case NFC_MIFARE_4K_PICC:
-            return MIFARE_4K;
-        case NFC_MIFARE_ULTRA_PICC:
-           return MIFARE_ULTRA;
-        case NFC_MIFARE_DESFIRE_PICC:
-            return MIFARE_DESFIRE;
-        case NFC_ISO14443_B_PICC:
-            return ISO14443_B;
-        case NFC_ISO14443_4B_PICC:
-            return ISO14443_4B;
-        case NFC_ISO14443_BPRIME_PICC:
-            return ISO14443_BPRIME;
-        case NFC_FELICA_PICC:
-            return FELICA;
-        case NFC_JEWEL_PICC:
-            return JEWEL;
-        case NFC_ISO15693_PICC:
-            return ISO15693;
-        case NFC_UNKNOWN_TARGET:
-        default:
-            return UNKNOWN_TARGET;
-    }
+  switch (tag_type) {
+    case NFC_GENERIC_PICC:
+      return GENERIC_TARGET;
+    case NFC_ISO14443_A_PICC:
+      return ISO14443_A;
+    case NFC_ISO14443_4A_PICC:
+      return ISO14443_4A;
+    case NFC_ISO14443_3A_PICC:
+      return ISO14443_3A;
+    case NFC_MIFARE_MINI_PICC:
+      return MIFARE_MINI;
+    case NFC_MIFARE_1K_PICC:
+      return MIFARE_1K;
+    case NFC_MIFARE_4K_PICC:
+      return MIFARE_4K;
+    case NFC_MIFARE_ULTRA_PICC:
+      return MIFARE_ULTRA;
+    case NFC_MIFARE_DESFIRE_PICC:
+      return MIFARE_DESFIRE;
+    case NFC_ISO14443_B_PICC:
+      return ISO14443_B;
+    case NFC_ISO14443_4B_PICC:
+      return ISO14443_4B;
+    case NFC_ISO14443_BPRIME_PICC:
+      return ISO14443_BPRIME;
+    case NFC_FELICA_PICC:
+      return FELICA;
+    case NFC_JEWEL_PICC:
+      return JEWEL;
+    case NFC_ISO15693_PICC:
+      return ISO15693;
+    case NFC_UNKNOWN_TARGET:
+    default:
+      return UNKNOWN_TARGET;
+  }
 }
 
 nfc_tag_type_e NFCUtil::toNfcTagString(const std::string& type_string)
 {
-    if (GENERIC_TARGET == type_string) {
-        return NFC_GENERIC_PICC;
-    }
-    else if (ISO14443_A == type_string) {
-        return NFC_ISO14443_A_PICC;
-    }
-    else if (ISO14443_4A == type_string) {
-        return NFC_ISO14443_4A_PICC;
-    }
-    else if (ISO14443_3A == type_string) {
-        return NFC_ISO14443_3A_PICC;
-    }
-    else if (MIFARE_MINI == type_string) {
-        return NFC_MIFARE_MINI_PICC;
-    }
-    else if (MIFARE_1K == type_string) {
-        return NFC_MIFARE_1K_PICC;
-    }
-    else if (MIFARE_4K == type_string) {
-        return NFC_MIFARE_4K_PICC;
-    }
-    else if (MIFARE_ULTRA == type_string) {
-        return NFC_MIFARE_ULTRA_PICC;
-    }
-    else if (MIFARE_DESFIRE == type_string) {
-        return NFC_MIFARE_DESFIRE_PICC;
-    }
-    else if (ISO14443_B == type_string) {
-        return NFC_ISO14443_B_PICC;
-    }
-    else if (ISO14443_4B == type_string) {
-        return NFC_ISO14443_4B_PICC;
-    }
-    else if (ISO14443_BPRIME == type_string) {
-        return NFC_ISO14443_BPRIME_PICC;
-    }
-    else if (FELICA == type_string) {
-        return NFC_FELICA_PICC;
-    }
-    else if (JEWEL == type_string) {
-        return NFC_JEWEL_PICC;
-    }
-    else if (ISO15693 == type_string) {
-        return NFC_ISO15693_PICC;
-    }
-    else if (UNKNOWN_TARGET == type_string) {
-        return NFC_UNKNOWN_TARGET;
-    }
-    else {
-      throw TypeMismatchException("No Match Tag Type");
-    }
+  if (GENERIC_TARGET == type_string) {
+    return NFC_GENERIC_PICC;
+  }
+  else if (ISO14443_A == type_string) {
+    return NFC_ISO14443_A_PICC;
+  }
+  else if (ISO14443_4A == type_string) {
+    return NFC_ISO14443_4A_PICC;
+  }
+  else if (ISO14443_3A == type_string) {
+    return NFC_ISO14443_3A_PICC;
+  }
+  else if (MIFARE_MINI == type_string) {
+    return NFC_MIFARE_MINI_PICC;
+  }
+  else if (MIFARE_1K == type_string) {
+    return NFC_MIFARE_1K_PICC;
+  }
+  else if (MIFARE_4K == type_string) {
+    return NFC_MIFARE_4K_PICC;
+  }
+  else if (MIFARE_ULTRA == type_string) {
+    return NFC_MIFARE_ULTRA_PICC;
+  }
+  else if (MIFARE_DESFIRE == type_string) {
+    return NFC_MIFARE_DESFIRE_PICC;
+  }
+  else if (ISO14443_B == type_string) {
+    return NFC_ISO14443_B_PICC;
+  }
+  else if (ISO14443_4B == type_string) {
+    return NFC_ISO14443_4B_PICC;
+  }
+  else if (ISO14443_BPRIME == type_string) {
+    return NFC_ISO14443_BPRIME_PICC;
+  }
+  else if (FELICA == type_string) {
+    return NFC_FELICA_PICC;
+  }
+  else if (JEWEL == type_string) {
+    return NFC_JEWEL_PICC;
+  }
+  else if (ISO15693 == type_string) {
+    return NFC_ISO15693_PICC;
+  }
+  else if (UNKNOWN_TARGET == type_string) {
+    return NFC_UNKNOWN_TARGET;
+  }
+  else {
+    throw TypeMismatchException("No Match Tag Type");
+  }
 }
 
 std::string NFCUtil::toStringCardEmulationMode(
     const nfc_se_card_emulation_mode_type_e mode)
 {
-    switch (mode)
-    {
-        case NFC_SE_CARD_EMULATION_MODE_OFF:
-            return OFF;
-        case NFC_SE_CARD_EMULATION_MODE_ON:
-            return ALWAYS_ON;
-        default:
-            LOGE("No Match Card Emulation mode: %x", mode);
-            throw TypeMismatchException("No Match Card Emulation mode");
-    }
+  switch (mode)
+  {
+    case NFC_SE_CARD_EMULATION_MODE_OFF:
+      return OFF;
+    case NFC_SE_CARD_EMULATION_MODE_ON:
+      return ALWAYS_ON;
+    default:
+      LOGE("No Match Card Emulation mode: %x", mode);
+      throw TypeMismatchException("No Match Card Emulation mode");
+  }
 }
 
 nfc_se_card_emulation_mode_type_e NFCUtil::toCardEmulationMode(
     const std::string &mode_string)
 {
-    if (mode_string == ALWAYS_ON) {
-        return NFC_SE_CARD_EMULATION_MODE_ON;
-    } else if (mode_string == OFF) {
-        return NFC_SE_CARD_EMULATION_MODE_OFF;
-    } else {
-        LOGE("No Match Card Emulation mode: %s", mode_string.c_str());
-        throw TypeMismatchException("No Match Card Emulation mode");
-    }
+  if (mode_string == ALWAYS_ON) {
+    return NFC_SE_CARD_EMULATION_MODE_ON;
+  } else if (mode_string == OFF) {
+    return NFC_SE_CARD_EMULATION_MODE_OFF;
+  } else {
+    LOGE("No Match Card Emulation mode: %s", mode_string.c_str());
+    throw TypeMismatchException("No Match Card Emulation mode");
+  }
 }
 
 std::string NFCUtil::toStringSecureElementType(const nfc_se_type_e type)
 {
-    switch (type) {
-        case NFC_SE_TYPE_ESE:
-            return ESE;
-        case NFC_SE_TYPE_UICC:
-            return UICC;
-        default:
-            LOGE("No Match Secure Element Type: %x", type);
-            throw TypeMismatchException("No Match Secure Element Type");
-    }
+  switch (type) {
+    case NFC_SE_TYPE_ESE:
+      return ESE;
+    case NFC_SE_TYPE_UICC:
+      return UICC;
+    default:
+      LOGE("No Match Secure Element Type: %x", type);
+      throw TypeMismatchException("No Match Secure Element Type");
+  }
 }
 
 nfc_se_type_e NFCUtil::toSecureElementType(const std::string &type_string)
 {
-    if (type_string == ESE) {
-        return NFC_SE_TYPE_ESE;
-    } else if (type_string == UICC) {
-        return NFC_SE_TYPE_UICC;
-    } else {
-        LOGE("No Match Secure Element Type: %s", type_string.c_str());
-        throw TypeMismatchException("No Match Secure Element Type");
-    }
+  if (type_string == ESE) {
+    return NFC_SE_TYPE_ESE;
+  } else if (type_string == UICC) {
+    return NFC_SE_TYPE_UICC;
+  } else {
+    LOGE("No Match Secure Element Type: %s", type_string.c_str());
+    throw TypeMismatchException("No Match Secure Element Type");
+  }
 }
 
 void NFCUtil::setDefaultFilterValues(std::vector<nfc_tag_type_e>& filter)
 {
-   filter.push_back(NFC_GENERIC_PICC);
-   filter.push_back(NFC_ISO14443_A_PICC);
-   filter.push_back(NFC_ISO14443_3A_PICC);
-   filter.push_back(NFC_ISO14443_3A_PICC);
-   filter.push_back(NFC_MIFARE_MINI_PICC);
-   filter.push_back(NFC_MIFARE_1K_PICC);
-   filter.push_back(NFC_MIFARE_4K_PICC);
-   filter.push_back(NFC_MIFARE_ULTRA_PICC);
-   filter.push_back(NFC_MIFARE_DESFIRE_PICC);
-   filter.push_back(NFC_ISO14443_B_PICC);
-   filter.push_back(NFC_ISO14443_4B_PICC);
-   filter.push_back(NFC_ISO14443_BPRIME_PICC);
-   filter.push_back(NFC_FELICA_PICC);
-   filter.push_back(NFC_JEWEL_PICC);
-   filter.push_back(NFC_ISO15693_PICC);
-   filter.push_back(NFC_UNKNOWN_TARGET);
+  filter.push_back(NFC_GENERIC_PICC);
+  filter.push_back(NFC_ISO14443_A_PICC);
+  filter.push_back(NFC_ISO14443_3A_PICC);
+  filter.push_back(NFC_ISO14443_3A_PICC);
+  filter.push_back(NFC_MIFARE_MINI_PICC);
+  filter.push_back(NFC_MIFARE_1K_PICC);
+  filter.push_back(NFC_MIFARE_4K_PICC);
+  filter.push_back(NFC_MIFARE_ULTRA_PICC);
+  filter.push_back(NFC_MIFARE_DESFIRE_PICC);
+  filter.push_back(NFC_ISO14443_B_PICC);
+  filter.push_back(NFC_ISO14443_4B_PICC);
+  filter.push_back(NFC_ISO14443_BPRIME_PICC);
+  filter.push_back(NFC_FELICA_PICC);
+  filter.push_back(NFC_JEWEL_PICC);
+  filter.push_back(NFC_ISO15693_PICC);
+  filter.push_back(NFC_UNKNOWN_TARGET);
 }
 
 } // NFC
index d41f818047e613f2351edc840cc63c82d239d348..b624e052104deaa67bef0744d9a16f52cdd7eaeb 100644 (file)
@@ -48,20 +48,20 @@ typedef std::vector<unsigned char> UCharVector;
 
 class NFCUtil
 {
-public:
-    static UCharVector toVector(const unsigned char *ch, const int size);
-    static void throwNFCException(const int errorCode, const char * message);
-    static std::string getNFCErrorString(const int error_code);
-    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 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 void setDefaultFilterValues(std::vector<nfc_tag_type_e>& filter);
+ public:
+  static UCharVector toVector(const unsigned char *ch, const int size);
+  static void throwNFCException(const int errorCode, const char * message);
+  static std::string getNFCErrorString(const int error_code);
+  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 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 void setDefaultFilterValues(std::vector<nfc_tag_type_e>& filter);
 };
 
 } // nfc