wrt-plugins-tizen_0.4.23
[framework/web/wrt-plugins-tizen.git] / src / Contact / JSContact.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 2219cd7..058b154
@@ -22,7 +22,6 @@
  * @brief       Implementation of the JSContact class
  */
 
-#include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 #include <CommonsJavaScript/Validator.h>
 #include <JSTizenExceptionFactory.h>
@@ -36,6 +35,7 @@
 #include <ArgumentValidator.h>
 #include <JSWebAPIError.h>
 #include <TimeTracer.h>
+#include <Logger.h>
 
 #define FILTER_CLASS_NAME "Contact"
 
@@ -171,7 +171,7 @@ JSObjectRef JSContact::createJSObject(JSContextRef context, ContactPtr contact)
        JSContactPriv *priv = new JSContactPriv(context, contact);
        JSObjectRef jsObjectRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
        if (NULL == jsObjectRef) {
-               LogError("object creation error");
+               LoggerE("object creation error");
                return NULL;
        }
        return jsObjectRef;
@@ -196,7 +196,7 @@ JSObjectRef JSContact::constructor(JSContextRef context,
                const JSValueRef arguments[],
                JSValueRef* exception)
 {
-       LogDebug("entered");
+       LoggerD("entered");
 
        bool jsNoParam = false;
        bool js1stParamIsObject = false;
@@ -223,7 +223,7 @@ JSObjectRef JSContact::constructor(JSContextRef context,
                        js1stParamIsString = true;
                else
                {
-                       LogError("Argument type mismatch : 1nd argument must be ContactInit object or string");
+                       LoggerE("Argument type mismatch : 1nd argument must be ContactInit object or string");
                        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "2nd argument must be 'ContactTextFormat'");
                        return NULL;
                }
@@ -238,11 +238,11 @@ JSObjectRef JSContact::constructor(JSContextRef context,
                        contact = converter->toContactFromInit(arguments[0]);
 
                } Catch(ConversionException) {
-                       LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+                       LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
                        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be 'ContactInit object'");
                        return NULL;
                } Catch(Exception) {
-                       LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+                       LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
                        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Internal error");
                        return NULL;
                }
@@ -258,19 +258,19 @@ JSObjectRef JSContact::constructor(JSContextRef context,
                        contact->setContactFromString(stringRepresentation);
 
                } Catch(ConversionException) {
-                       LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+                       LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
                        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "2nd argument must be 'ContactTextFormat'");
                        return NULL;
                } Catch(InvalidArgumentException) {
-                       LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+                       LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
                        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "1st argument must be vCard string");
                        return NULL;
                } Catch(UnsupportedException) {
-                       LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+                       LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
                        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::NOT_SUPPORTED_ERROR, "Only support vCard 3.0");
                        return NULL;
                } Catch(Exception) {
-                       LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+                       LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
                        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Internal error");
                        return NULL;
                }
@@ -280,7 +280,7 @@ JSObjectRef JSContact::constructor(JSContextRef context,
                Try {
                        contact = ContactFactory::getInstance().createContact();
                } Catch(Exception) {
-                       LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+                       LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
                        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Internal error");
                        return NULL;
                }
@@ -291,7 +291,7 @@ JSObjectRef JSContact::constructor(JSContextRef context,
        Try {
                jsobject = createJSObject(gContext, contact);
        } Catch(Exception) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+               LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Internal error");
                return NULL;
        }
@@ -324,7 +324,7 @@ JSValueRef JSContact::getId(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to get incorrect value");
+               LoggerW("trying to get incorrect value");
        }
        return JSValueMakeUndefined(context);
 }
@@ -346,7 +346,7 @@ JSValueRef JSContact::getAddressBookId(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to get incorrect value");
+               LoggerW("trying to get incorrect value");
        }
        return JSValueMakeUndefined(context);
 }
@@ -368,7 +368,7 @@ JSValueRef JSContact::getPersonId(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to get incorrect value");
+               LoggerW("trying to get incorrect value");
        }
        return JSValueMakeUndefined(context);
 }
@@ -390,7 +390,7 @@ JSValueRef JSContact::getLastUpdated(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to get incorrect value");
+               LoggerW("trying to get incorrect value");
        }
 
        return JSValueMakeUndefined(context);
@@ -410,7 +410,7 @@ JSValueRef JSContact::getIsFavorite(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to get incorrect value");
+               LoggerW("trying to get incorrect value");
        }
 
        return JSValueMakeUndefined(context);
@@ -439,7 +439,7 @@ JSValueRef JSContact::getName(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to get incorrect value");
+               LoggerW("trying to get incorrect value");
        }
 
        return JSValueMakeUndefined(context);
@@ -463,7 +463,7 @@ bool JSContact::setName(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to set incorrect value");
+               LoggerW("trying to set incorrect value");
                JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
@@ -503,7 +503,7 @@ JSValueRef JSContact::getAddresses(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to get incorrect value");
+               LoggerW("trying to get incorrect value");
        }
 
        return JSValueMakeUndefined(context);
@@ -525,7 +525,7 @@ bool JSContact::setAddresses(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to set incorrect value");
+               LoggerW("trying to set incorrect value");
                JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
@@ -549,7 +549,7 @@ JSValueRef JSContact::getPhotoURI(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to get incorrect value");
+               LoggerW("trying to get incorrect value");
        }
 
        return JSValueMakeUndefined(context);
@@ -575,7 +575,7 @@ bool JSContact::setPhotoURI(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to set incorrect value");
+               LoggerW("trying to set incorrect value");
                JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
@@ -615,7 +615,7 @@ JSValueRef JSContact::getPhoneNumbers(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to get incorrect value");
+               LoggerW("trying to get incorrect value");
        }
 
        return JSValueMakeUndefined(context);
@@ -637,7 +637,7 @@ bool JSContact::setPhoneNumbers(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to set incorrect value");
+               LoggerW("trying to set incorrect value");
                JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
@@ -662,10 +662,10 @@ JSValueRef JSContact::getEmails(JSContextRef context,
 
                DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
                if(newContactT->EmailsJSObjIsSet()){
-                       LogDebug("return init value");
+                       LoggerD("return init value");
                        return newContactT->getEmailsJSObj();
                }else{
-                       LogDebug("new array");
+                       LoggerD("new array");
                        JSValueRef tempJSValue = newContactT->getEmailsJSValue();
                        tempJSValue = converter->toJSValueRef(newContactT->getEmails());
 
@@ -680,7 +680,7 @@ JSValueRef JSContact::getEmails(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to get incorrect value");
+               LoggerW("trying to get incorrect value");
        }
 
        return JSValueMakeUndefined(context);
@@ -703,7 +703,7 @@ bool JSContact::setEmails(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to set incorrect value");
+               LoggerW("trying to set incorrect value");
                JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
@@ -727,7 +727,7 @@ JSValueRef JSContact::getBirthday(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to get incorrect value");
+               LoggerW("trying to get incorrect value");
        }
 
        return JSValueMakeUndefined(context);
@@ -753,7 +753,7 @@ bool JSContact::setBirthday(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to set incorrect value");
+               LoggerW("trying to set incorrect value");
                JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
@@ -794,7 +794,7 @@ JSValueRef JSContact::getAnniversaries(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to get incorrect value");
+               LoggerW("trying to get incorrect value");
        }
 
        return JSValueMakeUndefined(context);
@@ -816,7 +816,7 @@ bool JSContact::setAnniversaries(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to set incorrect value");
+               LoggerW("trying to set incorrect value");
                JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
@@ -857,7 +857,7 @@ JSValueRef JSContact::getOrganizations(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to get incorrect value");
+               LoggerW("trying to get incorrect value");
        }
 
        return JSValueMakeUndefined(context);
@@ -879,7 +879,7 @@ bool JSContact::setOrganizations(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to set incorrect value");
+               LoggerW("trying to set incorrect value");
                JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
@@ -920,7 +920,7 @@ JSValueRef JSContact::getNotes(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to get incorrect value");
+               LoggerW("trying to get incorrect value");
        }
 
        return JSValueMakeUndefined(context);
@@ -948,7 +948,7 @@ bool JSContact::setNotes(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to set incorrect value");
+               LoggerW("trying to set incorrect value");
                JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
@@ -989,7 +989,7 @@ JSValueRef JSContact::getUrls(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to get incorrect value");
+               LoggerW("trying to get incorrect value");
        }
 
        return JSValueMakeUndefined(context);
@@ -1011,7 +1011,7 @@ bool JSContact::setUrls(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to set incorrect value");
+               LoggerW("trying to set incorrect value");
                JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
@@ -1035,7 +1035,7 @@ JSValueRef JSContact::getRingtoneURI(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to get incorrect value");
+               LoggerW("trying to get incorrect value");
        }
 
        return JSValueMakeUndefined(context);
@@ -1061,7 +1061,7 @@ bool JSContact::setRingtoneURI(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to set incorrect value");
+               LoggerW("trying to set incorrect value");
                JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
@@ -1103,7 +1103,7 @@ JSValueRef JSContact::getGroupIds(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to get incorrect value");
+               LoggerW("trying to get incorrect value");
        }
 
        return JSValueMakeUndefined(context);
@@ -1125,7 +1125,7 @@ bool JSContact::setGroupIds(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogWarning("trying to set incorrect value");
+               LoggerW("trying to set incorrect value");
                JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
@@ -1139,7 +1139,7 @@ JSValueRef JSContact::convertToString(JSContextRef context,
                const JSValueRef arguments[],
                JSValueRef* exception)
 {
-       LogDebug("entered");
+       LoggerD("entered");
        TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
        ContactPtr contact(NULL);
 
@@ -1149,7 +1149,7 @@ JSValueRef JSContact::convertToString(JSContextRef context,
                        ThrowMsg(InvalidArgumentException, "No private object.");
                }
        } Catch(Exception) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+               LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
@@ -1175,13 +1175,13 @@ JSValueRef JSContact::convertToString(JSContextRef context,
        Try {
                vCard = contact->convertToString(format);
        } Catch(ConversionException) {
-               LogError("Error on platform : " << _rethrown_exception.GetMessage());
+               LoggerE("Error on platform : " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be 'ContactTextFormat string'");
        } Catch(UnsupportedException) {
-               LogError("Error on platform : " << _rethrown_exception.GetMessage());
+               LoggerE("Error on platform : " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Only support vCard 3.0");
        } Catch(Exception) {
-               LogError("Error on platform : " << _rethrown_exception.GetMessage());
+               LoggerE("Error on platform : " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
        }
 
@@ -1190,7 +1190,7 @@ JSValueRef JSContact::convertToString(JSContextRef context,
        Try {
                result = converter->toJSValueRef(vCard);
        } Catch(Exception) {
-               LogError("Error on conversion : " << _rethrown_exception.GetMessage());
+               LoggerE("Error on conversion : " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
        }
        TIME_TRACER_ITEM_END(__FUNCTION__, 0);
@@ -1204,7 +1204,7 @@ JSValueRef JSContact::clone(JSContextRef context,
                const JSValueRef arguments[],
                JSValueRef* exception)
 {
-       LogDebug("entered");
+       LoggerD("entered");
        TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
        ContactPtr contact(NULL);
 
@@ -1214,7 +1214,7 @@ JSValueRef JSContact::clone(JSContextRef context,
                        ThrowMsg(InvalidArgumentException, "No private object.");
                }
        } Catch(Exception) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+               LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
@@ -1226,7 +1226,7 @@ JSValueRef JSContact::clone(JSContextRef context,
        Try {
                clonedContact = contact->clone();
        } Catch(Exception) {
-               LogError("Error on conversion : " << _rethrown_exception.GetMessage());
+               LoggerE("Error on conversion : " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
        }
 
@@ -1239,7 +1239,7 @@ JSValueRef JSContact::clone(JSContextRef context,
                JSContextRef gContext = priv->getContext();
                result = createJSObject(gContext, clonedContact);
        } Catch(Exception) {
-               LogError("Error on conversion : " << _rethrown_exception.GetMessage());
+               LoggerE("Error on conversion : " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
        }
        TIME_TRACER_ITEM_END(__FUNCTION__, 0);