wrt-plugins-tizen_0.4.23
[framework/web/wrt-plugins-tizen.git] / src / Systeminfo / JSSysteminfo.cpp
old mode 100644 (file)
new mode 100755 (executable)
index a05df24..0339b0c
@@ -91,13 +91,13 @@ void JSSysteminfo::initialize(JSContextRef context, JSObjectRef object)
         ISysteminfoPtr Systeminfos(SysteminfoFactory::getInstance().getSysteminfos());
         JSSysteminfoPriv* priv = new JSSysteminfoPriv(context, Systeminfos);
         if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
-            LogError("Object can't store private data.");
+            LoggerE("Object can't store private data.");
             delete priv;
         }
 
-        LogDebug("JSSysteminfo::initialize ");
+        LoggerD("JSSysteminfo::initialize ");
     } else {
-        LogDebug("Private object already set.");
+        LoggerD("Private object already set.");
     }
 }
 
@@ -106,7 +106,7 @@ void JSSysteminfo::finalize(JSObjectRef object)
     JSSysteminfoPriv* priv = static_cast<JSSysteminfoPriv*>(JSObjectGetPrivate(object));
     
     JSObjectSetPrivate(object, NULL);
-    LogDebug("Deleting gallery");
+    LoggerD("Deleting gallery");
     delete priv;
 }
 
@@ -119,7 +119,7 @@ JSValueRef JSSysteminfo::getCapabilities(JSContextRef context, JSObjectRef objec
     Validator check(context, exception);
 
     if (!priv) {
-        LogError("private object is null");
+        LoggerE("private object is null");
         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
     }
     Try
@@ -153,7 +153,7 @@ JSValueRef JSSysteminfo::getPropertyValue(JSContextRef context, JSObjectRef obje
     std::string property;
 
     if (!priv) {
-        LogError("private object is null");
+        LoggerE("private object is null");
         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Wrong Object");
     }
     if (argumentCount < 2) {
@@ -168,7 +168,7 @@ JSValueRef JSSysteminfo::getPropertyValue(JSContextRef context, JSObjectRef obje
     if (argumentCount == 3) {
         if (check.isCallback(arguments[2])) {
             onErrorForCbm = arguments[2];
-        } else if (!JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2])) {
+        } else if (!JSValueIsNull(context, arguments[2])) {
             return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
         }
     }
@@ -178,9 +178,10 @@ JSValueRef JSSysteminfo::getPropertyValue(JSContextRef context, JSObjectRef obje
 
     Try {
         ISysteminfoPtr Systeminfos(priv->getObject());
+        BasePropertyPtr baseProperty = Systeminfos->getBasePropertyPtr(priv->getContext(), arguments[0]);
         
         EventGetSysteminfoPtr event(new EventGetSysteminfo());
-        event->setBasePropertyPtr(Systeminfos->getBasePropertyPtr(priv->getContext(), arguments[0]));
+        event->setBasePropertyPtr(baseProperty);
                TIME_TRACER_ITEM_BEGIN(event->getProperty(), 0);
         event->setPrivateData(StaticPointerCast<IEventPrivateData>(cbm));
 
@@ -193,14 +194,8 @@ JSValueRef JSSysteminfo::getPropertyValue(JSContextRef context, JSObjectRef obje
         return JSValueMakeUndefined(context);
     }
     
-    Catch(WrtDeviceApis::Commons::PendingOperationException) {
-        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Unknown error"));
-    }
     Catch(WrtDeviceApis::Commons::ConversionException) {
-        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error"));
-    }
-    Catch(WrtDeviceApis::Commons::InvalidArgumentException){
-        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error"));
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
     }
     Catch(WrtDeviceApis::Commons::Exception) {
         cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Unknown error"));
@@ -218,7 +213,7 @@ JSValueRef JSSysteminfo::addPropertyValueChangeListener(JSContextRef context, JS
     Validator check(context, exception);
 
     if (!priv) {
-        LogError("private object is null");
+        LoggerE("private object is null");
         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Wrong Object");
     }
     if (argumentCount < 2) {
@@ -239,22 +234,23 @@ JSValueRef JSSysteminfo::addPropertyValueChangeListener(JSContextRef context, JS
                 option.timeout = converter.toULong(JSUtils::getJSProperty(context, arguments[2], "timeout", exception));
                 option.highThreshold = converter.toDouble(JSUtils::getJSProperty(context, arguments[2], "highThreshold", exception));
                 option.lowThreshold = converter.toDouble(JSUtils::getJSProperty(context, arguments[2], "lowThreshold", exception));
-            } else if (!JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2])) {
+            } else if (!JSValueIsNull(context, arguments[2])) {
                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");        
             }
         }
         ISysteminfoPtr Systeminfos(priv->getObject());
+        BasePropertyPtr baseProperty = Systeminfos->getBasePropertyPtr(priv->getContext(), arguments[0]);
 
         EventWatchSysteminfoPtr event(new EventWatchSysteminfo);
         event->setWatchOption(option);
-        event->setBasePropertyPtr(Systeminfos->getBasePropertyPtr(priv->getContext(), arguments[0]));
+        event->setBasePropertyPtr(baseProperty);
         event->setPrivateData(StaticPointerCast<IEventPrivateData>(cbm));
 
         SysteminfoListener& listener = SysteminfoListener::getInstance();
         event->setForAsynchronousCall(&listener);        
             
         Systeminfos->watch(event);
-        LogDebug("event->getId()" << event->getId());
+        LoggerD("event->getId()" << event->getId());
 
         SysteminfoListenerCancellerPtr canceller = SysteminfoListenerCancellerPtr(new SysteminfoListenerCanceller(priv->getContext(), thisObject, event->getId()));
         DeviceAPI::Common::IListenerItemPtr listenerItem = DPL::StaticPointerCast<DeviceAPI::Common::IListenerItem>(canceller);
@@ -264,7 +260,7 @@ JSValueRef JSSysteminfo::addPropertyValueChangeListener(JSContextRef context, JS
     }
 
     Catch(WrtDeviceApis::Commons::ConversionException) {
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
     }
     Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
@@ -282,7 +278,7 @@ JSValueRef JSSysteminfo::removePropertyValueChangeListener(JSContextRef context,
 
     Converter converter(context);
     if (!priv) {
-        LogError("private object is null");
+        LoggerE("private object is null");
         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Wrong Object");
     }
     if (argumentCount < 1) {
@@ -293,7 +289,7 @@ JSValueRef JSSysteminfo::removePropertyValueChangeListener(JSContextRef context,
         ISysteminfoPtr Systeminfos(priv->getObject());
         id = static_cast<long>(converter.toLong(arguments[0]));
 
-               LogDebug("clearWatch id = " << id );
+               LoggerD("clearWatch id = " << id );
                Systeminfos->clearWatch(id);
 
                SysteminfoListenerCancellerPtr canceller = SysteminfoListenerCancellerPtr(new SysteminfoListenerCanceller(priv->getContext(), thisObject, id));