wrt-plugins-tizen_0.4.23
[framework/web/wrt-plugins-tizen.git] / src / NFC / JSNdefMessage.cpp
index 0f13e45..784d55c 100644 (file)
@@ -15,7 +15,6 @@
 // limitations under the License.
 //
 
-
 #include "JSNdefMessage.h"
 #include "JSNdefRecord.h"
 #include "JSNdefRecordText.h"
@@ -23,7 +22,6 @@
 #include "JSNdefRecordMedia.h"
 #include "NFCConverter.h"
 #include <GlobalContextManager.h>
-#include <dpl/log/log.h>
 #include <ArgumentValidator.h>
 #include <Commons/Exception.h>
 #include <CommonsJavaScript/PrivateObject.h>
@@ -36,6 +34,7 @@
 
 #include "NFCFactory.h"
 #include "plugin_config.h"
+#include <Logger.h>
 
 using namespace DeviceAPI::Common;
 using namespace WrtDeviceApis::Commons;
@@ -87,21 +86,21 @@ JSStaticFunction JSNdefMessage::m_function[] = {
 JSClassRef JSNdefMessage::m_jsClassRef = JSClassCreate(JSNdefMessage::getClassInfo());
 
 JSObjectRef JSNdefMessage::createJSObject(JSContextRef context, void *messageHandle) {
-       LogDebug("entered");
+       LoggerD("entered");
 
        INdefMessagePtr ndefMessage = NFCFactory::getInstance().createNDEFMessageObject(messageHandle);
        return createJSObject(context, ndefMessage);
 }
 
 JSObjectRef JSNdefMessage::createJSObject(JSContextRef context) {
-       LogDebug("entered");
+       LoggerD("entered");
 
        INdefMessagePtr ndefMessage = NFCFactory::getInstance().createNDEFMessageObject();
        return createJSObject(context, ndefMessage);
 }
 
 JSObjectRef JSNdefMessage::createJSObject(JSContextRef context, INdefMessagePtr message) {
-       LogDebug("entered");
+       LoggerD("entered");
 
        NFCConverter convert(context);
        JSValueRef records = convert.toJSNdefRecordArray(message);
@@ -118,33 +117,33 @@ JSObjectRef JSNdefMessage::createJSObject(JSContextRef context, INdefMessagePtr
 }
 
 JSObjectRef JSNdefMessage::createJSObject(JSContextRef context, std::vector<void *> ndefRcords) {
-       LogDebug("entered");
+       LoggerD("entered");
 
        INdefMessagePtr ndefMessage = NFCFactory::getInstance().createNDEFMessageObject(ndefRcords);
        return createJSObject(context, ndefMessage);
 }
 
 JSObjectRef JSNdefMessage::createJSObject(JSContextRef context, std::vector<unsigned char> rawdata) {
-       LogDebug("entered");
+       LoggerD("entered");
 
        INdefMessagePtr ndefMessage = NFCFactory::getInstance().createNDEFMessageObject(rawdata);
        return createJSObject(context, ndefMessage);
 }
 void JSNdefMessage::initialize(JSContextRef context, JSObjectRef object)
 {
-       LogDebug("entered");
+       LoggerD("entered");
 }
 
 void JSNdefMessage::finalize(JSObjectRef object)
 {
-       LogDebug( "entered" );
+       LoggerD( "entered" );
        NdefMessagePrivObject *priv = static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(object));
        if (priv) {
                INdefMessagePtr ndefMessage(priv->getObject());
-               LogDebug("getRecordesPtr:"<<ndefMessage->getRecordesPtr());
+               LoggerD("getRecordesPtr:"<<ndefMessage->getRecordesPtr());
                JSValueUnprotect(priv->getContext(), (JSValueRef)(ndefMessage->getRecordesPtr()));
                JSObjectSetPrivate(object, NULL);
-               LogDebug("Deleting NdefMessage object");
+               LoggerD("Deleting NdefMessage object");
                delete priv;
        }
 }
@@ -165,7 +164,7 @@ const JSClassDefinition* JSNdefMessage::getClassInfo()
 
 JSObjectRef JSNdefMessage::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-       LogDebug("entered");
+       LoggerD("entered");
 
        Try {
                ArgumentValidator validator(ctx, argumentCount, arguments);
@@ -184,7 +183,7 @@ JSObjectRef JSNdefMessage::constructor(JSContextRef ctx, JSObjectRef constructor
                                for (std::size_t i = 0; i < JSGetArrayLength(ctx, objArg); ++i) {
                                        JSValueRef element = JSGetArrayElement(ctx, objArg, i);
                                        bool bNdefRecord = convert.isNdefRecord(element);
-                                       LogDebug("isNdefRecord : " << bNdefRecord);
+                                       LoggerD("isNdefRecord : " << bNdefRecord);
                                        if (bNdefRecord)
                                                isRecordArray = true;
                                        else
@@ -227,9 +226,9 @@ JSObjectRef JSNdefMessage::constructor(JSContextRef ctx, JSObjectRef constructor
                *exception = error;
                return error;
        } Catch (WrtDeviceApis::Commons::UnknownException) {
-               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               LoggerE("PlatformException: " << _rethrown_exception.GetMessage());
        } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
+               LoggerE("Exception: " << _rethrown_exception.GetMessage());
        }
        JSObjectRef error = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        *exception = error;
@@ -239,19 +238,19 @@ JSObjectRef JSNdefMessage::constructor(JSContextRef ctx, JSObjectRef constructor
 JSValueRef JSNdefMessage::getProperty(JSContextRef context, JSObjectRef object,
         JSStringRef propertyName, JSValueRef* exception)
 {
-       LogDebug("Enter");
+       LoggerD("Enter");
 
        Try     {
                NdefMessagePrivObject* privateObject = static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(object));
                if (!privateObject) {
-                       LogError("Private object is not set.");
+                       LoggerE("Private object is not set.");
                        ThrowMsg(NullPointerException, "Private object not initialized");
                }
 
                INdefMessagePtr ndefMessage(privateObject->getObject());
                NFCConverter convert(context);
 
-               LogDebug("propertyName : " << convert.toString(propertyName));
+               LoggerD("propertyName : " << convert.toString(propertyName));
                if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_NDEFMESSAGE_RECORDCOUNT)) {
                        std::vector<void *> records = convert.toVectorOfRecordHandles(static_cast<JSValueRef>(ndefMessage->getRecordesPtr()));
                        return convert.toJSValueRefLong(records.size());
@@ -259,15 +258,15 @@ JSValueRef JSNdefMessage::getProperty(JSContextRef context, JSObjectRef object,
                        return static_cast<JSValueRef>(ndefMessage->getRecordesPtr());
                }
        } Catch (ConversionException) {
-               LogError("ConversionException: " << _rethrown_exception.GetMessage());
+               LoggerE("ConversionException: " << _rethrown_exception.GetMessage());
        } Catch (NullPointerException) {
-               LogError("NullPointerException: " << _rethrown_exception.GetMessage());
+               LoggerE("NullPointerException: " << _rethrown_exception.GetMessage());
        } Catch (WrtDeviceApis::Commons::UnknownException) {
-               LogError("UnknownExceptionException: " << _rethrown_exception.GetMessage());
+               LoggerE("UnknownExceptionException: " << _rethrown_exception.GetMessage());
        } Catch (PlatformException) {
-               LogError("PlatformExceptionException: " << _rethrown_exception.GetMessage());
+               LoggerE("PlatformExceptionException: " << _rethrown_exception.GetMessage());
        } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
+               LoggerE("Exception: " << _rethrown_exception.GetMessage());
        }
        return JSValueMakeUndefined(context);
 }
@@ -275,13 +274,13 @@ JSValueRef JSNdefMessage::getProperty(JSContextRef context, JSObjectRef object,
 bool JSNdefMessage::setProperty(JSContextRef context, JSObjectRef object,
         JSStringRef propertyName, JSValueRef value,  JSValueRef* exception)
 {
-       LogDebug("Enter");
+       LoggerD("Enter");
 
        Try     {
                if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_NDEFMESSAGE_RECORDS)) {
                        NdefMessagePrivObject* privateObject = static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(object));
                        if (!privateObject) {
-                               LogError("Private object is not set.");
+                               LoggerE("Private object is not set.");
                                ThrowMsg(NullPointerException, "Private object not initialized");
                        }
 
@@ -289,7 +288,7 @@ bool JSNdefMessage::setProperty(JSContextRef context, JSObjectRef object,
 
 
                        if (JSValueIsNull(context, value) || JSValueIsUndefined(context, value) || !JSIsArrayValue(context, value)) {
-                               LogError("value is invald.");
+                               LoggerE("value is invald.");
                                ThrowMsg(ConversionException, "value is invald.");
                        }
                        INdefMessagePtr ndefMessage(privateObject->getObject());
@@ -300,17 +299,17 @@ bool JSNdefMessage::setProperty(JSContextRef context, JSObjectRef object,
                        return true;
                 }
        } Catch (NullPointerException) {
-               LogError("NullPointerException: " << _rethrown_exception.GetMessage());
+               LoggerE("NullPointerException: " << _rethrown_exception.GetMessage());
        } Catch (ConversionException) {
-               LogError("ConversionException: " << _rethrown_exception.GetMessage());
+               LoggerE("ConversionException: " << _rethrown_exception.GetMessage());
        } Catch (InvalidArgumentException) {
-               LogError("InvalidArgumentException: " << _rethrown_exception.GetMessage());
+               LoggerE("InvalidArgumentException: " << _rethrown_exception.GetMessage());
        } Catch (PlatformException) {
-               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               LoggerE("PlatformException: " << _rethrown_exception.GetMessage());
        } Catch (WrtDeviceApis::Commons::UnknownException) {
-               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               LoggerE("PlatformException: " << _rethrown_exception.GetMessage());
        } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
+               LoggerE("Exception: " << _rethrown_exception.GetMessage());
        }
        return false;
 
@@ -323,11 +322,11 @@ JSValueRef JSNdefMessage::toByte(JSContextRef context,
         const JSValueRef arguments[],
         JSValueRef* exception)
 {
-       LogDebug("Entered ");
+       LoggerD("Entered ");
        Try {
                NdefMessagePrivObject* privateObject = static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(thisObject));
                if (NULL == privateObject) {
-                       LogError("private object is null");
+                       LoggerE("private object is null");
                        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
                }
 
@@ -338,18 +337,18 @@ JSValueRef JSNdefMessage::toByte(JSContextRef context,
                INdefMessagePtr newMessage = NFCFactory::getInstance().createNDEFMessageObject(records);
                return convert.toJSValueRef(newMessage->toByte());
        } Catch (ConversionException) {
-               LogError("ConversionException: " << _rethrown_exception.GetMessage());
+               LoggerE("ConversionException: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (WrtDeviceApis::Commons::UnknownException) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
+               LoggerE("Exception: " << _rethrown_exception.GetMessage());
        } Catch (PlatformException) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
+               LoggerE("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available");
        } Catch(NullPointerException) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
+               LoggerE("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
+               LoggerE("Exception: " << _rethrown_exception.GetMessage());
        }
 
        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");