wrt-plugins-tizen_0.4.23
[framework/web/wrt-plugins-tizen.git] / src / Messaging / JSMessageAttachment.cpp
index e1a9328..846f8dc 100644 (file)
@@ -15,7 +15,6 @@
 // limitations under the License.
 //
 
-#include <dpl/log/log.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/JSUtils.h>
 #include "ConverterMessage.h"
@@ -32,6 +31,7 @@
 
 #include <JSWebAPIError.h>
 #include <ArgumentValidator.h>
+#include <Logger.h>
 
 #if 0
 namespace {
@@ -108,9 +108,9 @@ JSClassRef JSMessageAttachment::getClassRef()
 void JSMessageAttachment::initialize(JSContextRef context,
         JSObjectRef object)
 {
-       LogDebug("enter");
+       LoggerD("enter");
        if (!JSObjectGetPrivate(object)) {
-               LogDebug("Private object not set... setting it.");
+               LoggerD("Private object not set... setting it.");
                IAttachmentPtr attachment(new Attachment());
 
                JSMessageAttachmentPrivate *priv = new JSMessageAttachmentPrivate(context, attachment);
@@ -122,7 +122,7 @@ void JSMessageAttachment::initialize(JSContextRef context,
 
 void JSMessageAttachment::finalize(JSObjectRef object)
 {
-    LogDebug("enter");
+    LoggerD("enter");
     JSMessageAttachmentPrivate* priv = static_cast<JSMessageAttachmentPrivate*>(JSObjectGetPrivate(object));
     JSContextRef gContext = priv->getContext();
 
@@ -153,23 +153,23 @@ JSValueRef JSMessageAttachment::getMIMEType(JSContextRef context,
           JSStringRef propertyName,
           JSValueRef* exception)
 {
-       LogDebug("enter");
+       LoggerD("enter");
        Try
        {
          IAttachmentPtr attachment = getAttachment(context, object);
 
                WrtDeviceApis::CommonsJavaScript::Converter converter(context);
-               LogDebug("mine type :" << attachment->getMimeType());
+               LoggerD("mine type :" << attachment->getMimeType());
                if (attachment->getMimeType().size() == 0)
                {
-                       LogDebug("return NULL");
+                       LoggerD("return NULL");
                        return JSValueMakeNull(context);
                }
                return converter.toJSValueRef(attachment->getMimeType());
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogError("invalid conversion");
+               LoggerE("invalid conversion");
        }
        return JSValueMakeUndefined(context);
 }
@@ -179,29 +179,29 @@ JSValueRef JSMessageAttachment::getMessageID(JSContextRef context,
           JSStringRef propertyName,
           JSValueRef* exception)
 {
-       LogDebug("enter");
+       LoggerD("enter");
        Try
        {
          IAttachmentPtr attachment = getAttachment(context, object);
 
                WrtDeviceApis::CommonsJavaScript::Converter converter(context);
-               LogDebug("Message ID :" << (attachment->getMessage()));
+               LoggerD("Message ID :" << (attachment->getMessage()));
                if ( (attachment->getAttachmentID() < 0) && (attachment->getMessage() == 0))
                {
-                       LogDebug("return NULL");
+                       LoggerD("return NULL");
                        return JSValueMakeNull(context);
                }
                return converter.toJSValueRef(attachment->getMessage()->getId());
        }
        Catch(WrtDeviceApis::Commons::InvalidArgumentException)
        {
-               LogError("invalid value conversion");
+               LoggerE("invalid value conversion");
                return JSTizenExceptionFactory::postException(context, exception,
                JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogError("Unkown Exception");
+               LoggerE("Unkown Exception");
                return JSTizenExceptionFactory::postException(context, exception,
                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
        }
@@ -221,7 +221,7 @@ JSValueRef JSMessageAttachment::getContentID(JSContextRef context,
           JSStringRef propertyName,
           JSValueRef* exception)
 {
-       LogDebug("enter");
+       LoggerD("enter");
        Try
        {
                IAttachmentPtr attachment = getAttachment(context, object);
@@ -229,11 +229,11 @@ JSValueRef JSMessageAttachment::getContentID(JSContextRef context,
 
                ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
 
-               LogDebug("Attachment Loaded :" << (attachment->getDownloaded() ));
+               LoggerD("Attachment Loaded :" << (attachment->getDownloaded() ));
 
                if ( attachment->getAttachmentID() < 0)
                {
-                       LogDebug("return NULL");
+                       LoggerD("return NULL");
                        return JSValueMakeNull(context);
                }
 
@@ -242,13 +242,13 @@ JSValueRef JSMessageAttachment::getContentID(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::InvalidArgumentException)
        {
-               LogError("invalid value conversion");
+               LoggerE("invalid value conversion");
                return JSTizenExceptionFactory::postException(context, exception,
                JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
-               LogError("Unkown Exception");
+               LoggerE("Unkown Exception");
                return JSTizenExceptionFactory::postException(context, exception,
                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
        }
@@ -261,24 +261,24 @@ JSValueRef JSMessageAttachment::getLoaded(JSContextRef context,
           JSValueRef* exception)
 {
 
-         LogDebug("enter");
+         LoggerD("enter");
            Try
            {
                  IAttachmentPtr attachment = getAttachment(context, object);
 
        WrtDeviceApis::CommonsJavaScript::Converter converter(context);
-                 LogDebug("Attachment Loaded :" << (attachment->getDownloaded() ));
+                 LoggerD("Attachment Loaded :" << (attachment->getDownloaded() ));
                  return converter.toJSValueRef(attachment->getDownloaded());
            }
            Catch(WrtDeviceApis::Commons::InvalidArgumentException)
            {
-                  LogError("invalid value conversion");
+                  LoggerE("invalid value conversion");
                   return JSTizenExceptionFactory::postException(context, exception,
                           JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
            }
            Catch(WrtDeviceApis::Commons::Exception)
            {
-               LogError("Unkown Exception");
+               LoggerE("Unkown Exception");
                   return JSTizenExceptionFactory::postException(context, exception,
                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
            }
@@ -290,11 +290,11 @@ JSValueRef JSMessageAttachment::getFilePath(JSContextRef context,
           JSStringRef propertyName,
           JSValueRef* exception)
 {
-       LogDebug("enter");
+       LoggerD("enter");
 
        JSMessageAttachmentPrivate* priv = static_cast<JSMessageAttachmentPrivate*>(JSObjectGetPrivate(object));
        if (priv)
-               LogDebug("priv is vaild");
+               LoggerD("priv is vaild");
 
        JSContextRef globalContext = priv ? priv->getContext() : context;
 
@@ -307,7 +307,7 @@ JSValueRef JSMessageAttachment::getFilePath(JSContextRef context,
                        WrtDeviceApis::CommonsJavaScript::Converter converter(context);
 
                        std::string fullPath = attachment->getFullPath();
-                       LogDebug("fullPath=" << fullPath);
+                       LoggerD("fullPath=" << fullPath);
 
                        if (fullPath.empty()) {
                                return JSValueMakeNull(context);
@@ -317,31 +317,31 @@ JSValueRef JSMessageAttachment::getFilePath(JSContextRef context,
                                std::string filePath;
                                Try {
                                        filePath = DeviceAPI::Filesystem::Utils::toVirtualPath(globalContext, fullPath);
-                                       LogDebug("return virtual path : " << filePath);
+                                       LoggerD("return virtual path : " << filePath);
                                        return converter.toJSValueRef(filePath);
                                }
                                catch (WrtDeviceApis::Commons::ConversionException)
                                {
-                                       LogDebug("return real path : " << fullPath);
+                                       LoggerD("return real path : " << fullPath);
                                        return converter.toJSValueRef(fullPath);
 /*
-                                       LogDebug("It is not in the the list of root locations ");
+                                       LoggerD("It is not in the the list of root locations ");
                                        if (attachment->hasDummyFile())
                                        {
-                                               LogDebug("Get Dummy File Path " << attachment->getDummyFilePath());
+                                               LoggerD("Get Dummy File Path " << attachment->getDummyFilePath());
                                                filePath =      attachment->getDummyFilePath();
                                        }
                                        else
                                        {
-                                               LogDebug("Create DummyFile");
+                                               LoggerD("Create DummyFile");
                                                std::string tmpPath = AttachmentFactory::getDummyFileFromRealPath(globalContext, fullPath);
-                                               LogDebug("tmp Path : " << tmpPath);
+                                               LoggerD("tmp Path : " << tmpPath);
                                                if (tmpPath.length())
                                                {
                                                        attachment->setDummyFilePath(tmpPath);
                                                        if ( !attachment->hasDummyFile())
                                                        {
-                                                               LogDebug("dummy File Path is invalided But Can't access this file.");
+                                                               LoggerD("dummy File Path is invalided But Can't access this file.");
                                                                return JSValueMakeNull(context);
                                                        }
                                                        else
@@ -364,13 +364,13 @@ JSValueRef JSMessageAttachment::getFilePath(JSContextRef context,
                }
                Catch(WrtDeviceApis::Commons::InvalidArgumentException)
                {
-                  LogError("invalid value conversion");
+                  LoggerE("invalid value conversion");
                   return JSTizenExceptionFactory::postException(context, exception,
                           JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
                }
                Catch(WrtDeviceApis::Commons::Exception)
                {
-                   LogError("Unkown Exception");
+                   LoggerE("Unkown Exception");
                    return JSTizenExceptionFactory::postException(context, exception,
                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
                }
@@ -384,7 +384,7 @@ JSValueRef JSMessageAttachment::getFilePath(JSContextRef context,
        }
 
 /* // MESSAGING ATTACHMENT IS BLOCKED
-               LogDebug("enter");
+               LoggerD("enter");
                Try
                {
                  IAttachmentPtr attachment = getAttachment(context, object);
@@ -393,7 +393,7 @@ JSValueRef JSMessageAttachment::getFilePath(JSContextRef context,
                    }
 
                    std::string fullPath = attachment->getFullPath();
-                   LogDebug("full Path = " << fullPath );
+                   LoggerD("full Path = " << fullPath );
                    if (fullPath.empty()) {
                        return JSValueMakeUndefined(context);
                    }
@@ -413,7 +413,7 @@ JSValueRef JSMessageAttachment::getFilePath(JSContextRef context,
 
                    WrtDeviceApis::Commons::ExceptionCodes::Enumeration code = event->getExceptionCode();
                    if (code != WrtDeviceApis::Commons::ExceptionCodes::None) {
-                       LogError("Attachment location not resolved. Exception code: " << code);
+                       LoggerE("Attachment location not resolved. Exception code: " << code);
                           return JSTizenExceptionFactory::postException(context, exception,
                                         JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
 
@@ -421,7 +421,7 @@ JSValueRef JSMessageAttachment::getFilePath(JSContextRef context,
 
                    DeviceAPI::Filesystem::INodePtr node = event->getResult();
                    if (!node) {
-                       LogError("Resolved attachment location is empty.");
+                       LoggerE("Resolved attachment location is empty.");
                           return JSTizenExceptionFactory::postException(context, exception,
                                         JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
 
@@ -429,7 +429,7 @@ JSValueRef JSMessageAttachment::getFilePath(JSContextRef context,
 
                        DeviceAPI::Filesystem::IPathPtr path = node->getPath();
 
-                       LogError(" Path = " << path->getPath()  << " Full Path = " <<  path->getFullPath());
+                       LoggerE(" Path = " << path->getPath()  << " Full Path = " <<  path->getFullPath());
 
                    JSObjectRef result = WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(context,
                                                                      JSFile::getClassRef(),
@@ -439,14 +439,14 @@ JSValueRef JSMessageAttachment::getFilePath(JSContextRef context,
                }
                Catch(WrtDeviceApis::Commons::InvalidArgumentException)
                {
-                  LogError("invalid value conversion");
+                  LoggerE("invalid value conversion");
                   return JSTizenExceptionFactory::postException(context, exception,
                           JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
 
                }
                Catch(WrtDeviceApis::Commons::Exception)
                {
-                   LogError("Unkown Exception");
+                   LoggerE("Unkown Exception");
                    return JSTizenExceptionFactory::postException(context, exception,
                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
                }
@@ -476,7 +476,7 @@ JSMessageAttachmentPrivate* JSMessageAttachment::getPrivate(JSObjectRef thisObje
     JSMessageAttachmentPrivate* thisPrivate =
         static_cast<JSMessageAttachmentPrivate*>(JSObjectGetPrivate(thisObject));
     if (!thisPrivate) {
-        LogError("no private");
+        LoggerE("no private");
                Throw(WrtDeviceApis::Commons::NullPointerException);
     }
     return thisPrivate;
@@ -488,7 +488,7 @@ JSObjectRef JSMessageAttachment::constructor(JSContextRef context,
                const JSValueRef arguments[],
                JSValueRef* exception)
 {
-       LogDebug("entered");
+       LoggerD("entered");
 
 
        try
@@ -498,55 +498,55 @@ JSObjectRef JSMessageAttachment::constructor(JSContextRef context,
                std::string path = validator.toString(0);
                std::string mimetype = validator.toString(1, true);
 
-               LogDebug("path size() : " << path.size());
+               LoggerD("path size() : " << path.size());
 
                if(path.size() != 0)
                {
                        DeviceAPI::Filesystem::IPathPtr src = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, path);
                        if (src)
                        {
-                               LogDebug("path size() : " << path.size());
+                               LoggerD("path size() : " << path.size());
                                path = src->getFullPath();
                        }
                        else
                        {
-                               LogDebug("path size() : " << path.size());
+                               LoggerD("path size() : " << path.size());
                                path = "";      //set empty string.
                        }
                }
                else
                {
-                       LogDebug("path size() : " << path.size());
+                       LoggerD("path size() : " << path.size());
                        path = "";      //set empty string.
                }
 
-               LogDebug("real path = " << path);
+               LoggerD("real path = " << path);
                IAttachmentPtr attachment = AttachmentFactory::createAttachment(
                                                                                path,
                                                                                mimetype);
                if (attachment)
                {
                        JSClassRef jsClassRef = JSClassCreate(getClassInfo());
-                       LogDebug("jsClassRef success");
+                       LoggerD("jsClassRef success");
                        JSMessageAttachmentPrivate* priv = new JSMessageAttachmentPrivate(context, attachment);
-                       LogDebug("priv success");
+                       LoggerD("priv success");
 
                        JSObjectRef jsObjRef = JSObjectMake(context, jsClassRef, static_cast<void*>(priv));
-                       LogDebug("JSObjectMake success");
+                       LoggerD("JSObjectMake success");
                        JSClassRelease(jsClassRef);
                        if (NULL == jsObjRef) {
-                               LogError("object creation error");
+                               LoggerE("object creation error");
                                throw DeviceAPI::Common::UnknownException("JSObject make error");
                        }
                        return jsObjRef;
                }
                else
                {
-                       LogDebug("attachment can't create");
+                       LoggerD("attachment can't create");
                        throw DeviceAPI::Common::UnknownException("attachment create failed");
                }
        }catch(BasePlatformException & e) {
-               LogError("Message creation failed: " << e.getMessage());
+               LoggerE("Message creation failed: " << e.getMessage());
                JSObjectRef error = JSWebAPIError::makeJSWebAPIError(context, e);
                *exception = error;
        }
@@ -563,7 +563,7 @@ JSValueRef JSMessageAttachment::getProperty(JSContextRef context,
                                                                                        JSStringRef propertyName,
                                                                                        JSValueRef* exception)
 {
-       LogDebug("OK");
+       LoggerD("OK");
 
        ConverterMessageFactory::ConverterType converter =  ConverterMessageFactory::getConverter(context);
 //     WrtDeviceApis::CommonsJavaScript::Converter converter(context);
@@ -607,7 +607,7 @@ JSValueRef JSMessageAttachment::getProperty(JSContextRef context,
                }
        }
        catch (const WrtDeviceApis::Commons::Exception& ex) {
-               LogError("Exception: " << ex.GetMessage());
+               LoggerE("Exception: " << ex.GetMessage());
                return JSValueMakeUndefined(context);
        }
        return NULL;
@@ -619,7 +619,7 @@ bool JSMessageAttachment::setProperty(JSContextRef context,
                                                                          JSValueRef value,
                                                                          JSValueRef* exception)
 {
-    LogDebug("entered");
+    LoggerD("entered");
 
     if (JSStringIsEqualToUTF8CString(propertyName, ATTACHMENTID)) {
         return true;
@@ -637,7 +637,7 @@ void JSMessageAttachment::getPropertyNames(JSContextRef context,
                                                                                   JSObjectRef object,
                                                                                   JSPropertyNameAccumulatorRef propertyNames)
 {
-    LogDebug("Entered");
+    LoggerD("Entered");
     JSStringRef propertyName = NULL;
 
     propertyName = JSStringCreateWithUTF8CString(ATTACHMENTID);