// limitations under the License.
//
-
-
-
-#include <dpl/log/log.h>
-
#include <Commons/Exception.h>
#include <JSTizenException.h>
#include "NFCTag.h"
#include "NFCUtil.h"
+#include <Logger.h>
namespace DeviceAPI {
namespace NFC {
* @param this_ User data pointer.
*/
static bool TagInformationCallback(const char *key, const unsigned char *value, int value_size, void *user_data) {
- LogDebug("Callback TagInformationCallback.");
+ LoggerD("Callback TagInformationCallback.");
if (user_data) {
NFCUtil util;
std::vector<unsigned char> tagInfo = util.toVector(value, value_size);
(static_cast<NFCTag*>(user_data))->makeTagProperties(key, tagInfo);
return TRUE;
}
- LogDebug("Error! TagInformationCallback is Null.");
+ LoggerD("Error! TagInformationCallback is Null.");
return false;
}
static void TagReadCallback(nfc_error_e result , nfc_ndef_message_h message , void * data) {
- LogDebug("Callback TagReadCallback.");
+ LoggerD("Callback TagReadCallback.");
if (data) {
NFCTag *tagPtr = (NFCTag *)((EventNFCPtrs<EventTagActionRead> *)data)->getThisPtr();
if (tagPtr) {
EventTagActionReadPtr event = ((EventNFCPtrs<EventTagActionRead> *)data)->getEventPtrs();
- LogDebug("message handler :" << message);
+ LoggerD("message handler :" << message);
unsigned char *rawdata = NULL;
int size;
if (nfc_ndef_message_get_rawdata(message, &rawdata, &size) != NFC_ERROR_NONE) {
- LogError("Can't get record's rawdata");
+ LoggerE("Can't get record's rawdata");
if (rawdata)
free(rawdata);
return;
}
} else {
- LogDebug("Error! TagReadCallback is Null.");
+ LoggerD("Error! TagReadCallback is Null.");
}
}
static void TagWriteCallback(nfc_error_e result, void *data) {
- LogDebug("Callback TagWriteCallback.");
+ LoggerD("Callback TagWriteCallback.");
if (data) {
((NFCTag *)data)->writeNdefManualAnswer((int)result);
} else {
- LogDebug("Error! TagWriteCallback is Null.");
+ LoggerD("Error! TagWriteCallback is Null.");
}
}
static void TagTransceiveCallback(nfc_error_e result, unsigned char *buffer, int buffer_size, void *data) {
- LogDebug("Callback TagTransceiveCallback.");
+ LoggerD("Callback TagTransceiveCallback.");
if (data) {
NFCUtil util;
std::vector<unsigned char> responseData = util.toVector(buffer, buffer_size) ;
((NFCTag *)data)->transceiveManualAnswer((int)result, responseData);
} else {
- LogDebug("Error! TagTransceiveCallback is Null.");
+ LoggerD("Error! TagTransceiveCallback is Null.");
}
}
static void TagFormatCallback(nfc_error_e result, void *data) {
- LogDebug("Callback TagFormatCallback.");
+ LoggerD("Callback TagFormatCallback.");
if (data) {
((NFCTag *)data)->formatManualAnswer((int)result);
} else {
- LogDebug("Error! TagFormatCallback is Null.");
+ LoggerD("Error! TagFormatCallback is Null.");
}
}
}//private namespace
NFCTag::NFCTag(void *tagHandle)
{
- LogDebug("entered");
+ LoggerD("entered");
handle = (nfc_tag_h)tagHandle;
NFCTag::~NFCTag()
{
- LogDebug("entered");
+ LoggerD("entered");
handle = NULL;
}
return static_cast<long>(ndefSize);
}
std::vector<NFCTagProperties> NFCTag::getProperties() {
- LogDebug("Enter");
+ LoggerD("Enter");
props.clear();
int result = nfc_tag_foreach_information(handle, TagInformationCallback, this);
}
void NFCTag::readNdef(const EventTagActionReadPtr& event) {
- LogDebug("Enter");
+ LoggerD("Enter");
if (!isNDEFSupport())
ThrowMsg(WrtDeviceApis::Commons::UnsupportedException, "Not Support NDEF");
}
void NFCTag::writeNdef(const EventTagActionWritePtr& event) {
- LogDebug("Enter");
+ LoggerD("Enter");
if (!isNDEFSupport())
ThrowMsg(WrtDeviceApis::Commons::UnsupportedException, "Not Support NDEF");
}
void NFCTag::transceive(const EventTagActionTransceivePtr& event) {
- LogDebug("Enter");
+ LoggerD("Enter");
if (m_EventTagActionTransceivePtr.Get() != NULL)
EventTagActionTransceives.push_back(event);
}
void NFCTag::format(const EventTagActionFormatPtr& event) {
- LogDebug("Enter");
+ LoggerD("Enter");
EventRequestReceiver<EventTagActionFormat>::PostRequest(event);
}
void NFCTag::readNdefManualAnswer(int result, std::vector<unsigned char> &data, const EventTagActionReadPtr &event)
{
- LogDebug("Enter");
+ LoggerD("Enter");
if ((nfc_error_e)result == NFC_ERROR_NONE) {
event->setResult(TRUE);
event->setReadNdefResult(data);
for (it = EventTagActionsReads.begin(); it != EventTagActionsReads.end(); ++it) {
if ((*it)->getEventPtrs() == event) {
EventTagActionsReads.erase(it);
- LogDebug("event is removed. (" << EventTagActionsReads.size() << ")");
+ LoggerD("event is removed. (" << EventTagActionsReads.size() << ")");
break;
}
}
void NFCTag::writeNdefManualAnswer(int result)
{
- LogDebug("Enter");
+ LoggerD("Enter");
if (m_EventTagActionWritePtr.Get() != NULL) {
if (nfc_ndef_message_destroy(static_cast<nfc_ndef_message_h>(m_EventTagActionWritePtr->getNdefForWriting())) != NFC_ERROR_NONE)
- LogError("Can't destroy NdefMessage");
+ LoggerE("Can't destroy NdefMessage");
if ((nfc_error_e)result == NFC_ERROR_NONE) {
m_EventTagActionWritePtr->setResult(TRUE);
if (EventTagActionWrites.size() > 0) {
EventTagActionWritePtr event = EventTagActionWrites.front();
EventTagActionWrites.erase(EventTagActionWrites.begin());
- LogDebug("EventTagActionWrites is removed. (" << EventTagActionWrites.size() << ")");
+ LoggerD("EventTagActionWrites is removed. (" << EventTagActionWrites.size() << ")");
EventRequestReceiver<EventTagActionWrite>::PostRequest(event);
}
}
void NFCTag::transceiveManualAnswer(int result , std::vector<unsigned char> &data)
{
- LogDebug("Enter");
+ LoggerD("Enter");
if (m_EventTagActionTransceivePtr.Get() != NULL) {
if ((nfc_error_e)result == NFC_ERROR_NONE) {
m_EventTagActionTransceivePtr->setResult(TRUE);
if (EventTagActionTransceives.size() > 0) {
EventTagActionTransceivePtr event = EventTagActionTransceives.front();
EventTagActionTransceives.erase(EventTagActionTransceives.begin());
- LogDebug("EventTagActionWrites is removed. (" << EventTagActionTransceives.size() << ")");
+ LoggerD("EventTagActionWrites is removed. (" << EventTagActionTransceives.size() << ")");
EventRequestReceiver<EventTagActionTransceive>::PostRequest(event);
}
}
void NFCTag::formatManualAnswer(int result)
{
- LogDebug("Enter");
+ LoggerD("Enter");
if (m_EventTagActionFormatPtr.Get() != NULL) {
if ((nfc_error_e)result == NFC_ERROR_NONE) {
m_EventTagActionFormatPtr->setResult(TRUE);
}
void NFCTag::OnRequestReceived(const EventTagActionReadPtr& event) {
- LogDebug("Enter");
+ LoggerD("Enter");
try {
event->switchToManualAnswer();
for (it = EventTagActionsReads.begin(); it != EventTagActionsReads.end(); ++it) {
if ((*it)->getEventPtrs() == event) {
EventTagActionsReads.erase(it);
- LogDebug("event is removed. (" << EventTagActionsReads.size() << ")");
+ LoggerD("event is removed. (" << EventTagActionsReads.size() << ")");
break;
}
}
}
}
catch (const WrtDeviceApis::Commons::Exception& ex) {
- LogError("Exception: " << ex.GetMessage());
+ LoggerE("Exception: " << ex.GetMessage());
event->setResult(false);
EventRequestReceiver<EventTagActionRead>::ManualAnswer(event);
}
}
catch (const WrtDeviceApis::Commons::Exception& ex) {
- LogError("Exception: " << ex.GetMessage());
+ LoggerE("Exception: " << ex.GetMessage());
if (event != m_EventTagActionWritePtr)
m_EventTagActionWritePtr = event;
}
}
catch (const WrtDeviceApis::Commons::Exception& ex) {
- LogError("Exception: " << ex.GetMessage());
+ LoggerE("Exception: " << ex.GetMessage());
std::vector<unsigned char> emptyData;
transceiveManualAnswer(NFC_ERROR_OPERATION_FAILED, emptyData);
m_EventTagActionFormatPtr = event;
NFCUtil util;
- LogDebug("key size :" << event->getKeySize());
+ LoggerD("key size :" << event->getKeySize());
unsigned char *key = util.toCharPtr(event->getKey());
int result = nfc_tag_format_ndef(handle, key, event->getKeySize(), TagFormatCallback, this);
}
}
catch (const WrtDeviceApis::Commons::Exception& ex) {
- LogError("Exception: " << ex.GetMessage());
+ LoggerE("Exception: " << ex.GetMessage());
event->setResult(false);
EventRequestReceiver<EventTagActionFormat>::ManualAnswer(event);