[Release] wrt-plugins-common_0.3.112
[platform/framework/web/wrt-plugins-common.git] / src / plugin-loading / explorer.cpp
index a87ceee..a36aecc 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <algorithm>
 #include <dpl/foreach.h>
-#include <dpl/log/log.h>
+#include <dpl/log/secure_log.h>
 #include "explorer.h"
 #include "plugin_property_support.h"
 
@@ -43,7 +43,7 @@ Explorer::Explorer(JSGlobalContextRef context) :
     m_context(context)
 {
     if (!context) {
-        LogError("Context is NULL");
+        _W("Context is NULL");
         return;
     }
 
@@ -71,10 +71,10 @@ JSObjectPtr Explorer::getProperty(
     const string& requestedProperty,
     JSObjectPtr providedObject)
 {
-    LogDebug("Requested Property: " << requestedProperty);
+    _D("Requested Property: %s", requestedProperty.c_str());
 
     if (!providedObject) {
-        LogError("Provided object is empty");
+        _W("Provided object is empty");
         return JSObjectPtr();
     }
 
@@ -92,14 +92,14 @@ JSObjectPtr Explorer::getProperty(
         currentObjectName = currentPropertyRequested.substr(0, pos);
 
         if (currentPropertyRequested.size() <= pos + 1) {
-            LogError("Wrong name of requested property");
+            _W("Wrong name of requested property");
             return JSObjectPtr();
         }
         currentPropertyRequested = currentPropertyRequested.substr(pos + 1);
 
         currentObject = getJSObjectProperty(currentObjectName, currentObject);
         if (!currentObject) {
-            LogError("Failed to get property: " << currentObjectName);
+            _W("Failed to get property: %s", currentObjectName.c_str());
             return JSObjectPtr();
         }
     }
@@ -117,7 +117,7 @@ bool Explorer::registerObject(const JSObjectDeclarationPtr& declaration,
         string masterName = declaration->getParentName();
         auto pos = masterName.find(".");
         if (string::npos != pos) {
-            LogError("ParentName not allowed");
+            _W("ParentName not allowed");
             return false;
         }
         auto masterObject = getJSObjectProperty(masterName, m_globalObject);
@@ -145,31 +145,26 @@ bool Explorer::registerObject(const JSObjectDeclarationPtr& declaration,
                               JSObjectPtr providedObject,
                               JSGlobalContextRef context)
 {
-    LogDebug("'" << providedObjectName << "' <- '" << declaration->getName() << "'");
-
+    _D("%s <- %s", providedObjectName.c_str(), declaration->getName().c_str());
     std::string fullParentName = declaration->getParentName();
 
     if (fullParentName == providedObjectName) {
+        \r_D("Provided object was matched!!");
         return register_(declaration, providedObject, context);
     }
 
-    LogDebug("Provided object was not matched!!");
-
     //check if object exists in fullParentName
     auto pos = fullParentName.find(providedObjectName);
     if (pos == string::npos) {
-        LogError(
-            "Object: " << declaration->getName()
-                       << " should be child of: " <<
-            declaration->getParentName()
-                       << " but you provided object: " <<
-            providedObjectName);
-
+        _W("Object: %s should be child of: %s but you provided object: %s",
+           declaration->getName().c_str(),
+           declaration->getParentName().c_str(),
+           providedObjectName.c_str());
         return false;
     }
 
     if (fullParentName.size() <= pos + providedObjectName.size() + 1) {
-        LogError("Invalid object name");
+        _W("Invalid object name");
         return false;
     }
 
@@ -180,14 +175,10 @@ bool Explorer::registerObject(const JSObjectDeclarationPtr& declaration,
             currentRequesteProperty, providedObject);
 
     if (!jsObject->getObject()) {
-        LogError(
-            "Object: '" << declaration->getName()
-                        << "' should be child of: '" <<
-            declaration->getParentName()
-                        << "'. you provided object: '" <<
-            providedObjectName
-                        << "' but object is null");
-
+        _W("Object: %s should be child of: %s. you provided object: %s but object is null",
+           declaration->getName().c_str(),
+           declaration->getParentName().c_str(),
+           providedObjectName.c_str());
         return false;
     }
 
@@ -198,9 +189,9 @@ bool Explorer::register_(const JSObjectDeclarationPtr& declaration,
                          JSObjectPtr parent,
                          JSGlobalContextRef context)
 {
-    LogDebug("Registration object: " << declaration->getParentName() <<
-            "<-" << declaration->getName());
-
+    _D("Registration object: %s <- %s",
+       declaration->getParentName().c_str(),
+       declaration->getName().c_str());
     Assert(parent && "parent object is NULL");
 
     typedef JSObjectDeclaration::Options JO;
@@ -234,24 +225,24 @@ void Explorer::registerObjectIntoIframe(
     JSGlobalContextRef context)
 {
     if (declaration->getParentName() == GLOBAL_OBJECT_NAME) {
-        LogDebug("Connect to Global object of IFRAME");
+        _D("Connect to Global object of IFRAME");
         register_(declaration, frameObject, context);
         return;
     }
 
     //PIM SUPPORT
     {
-        LogWarning("Connect to NOT global object of IFRAME");
+        _D("Connect to NOT global object of IFRAME");
         //it should be master object name
         string masterName = declaration->getParentName();
         auto pos = masterName.find(".");
         if (string::npos != pos) {
-            LogError("ParentName not allowed");
+            _W("ParentName not allowed");
             return;
         }
         auto masterObject = getJSObjectProperty(masterName, frameObject);
         if (!masterObject->getObject()) {
-            LogError("Object not exist in frame");
+            _W("Object not exist in frame");
             return;
         }
         register_(declaration, masterObject, context);
@@ -260,17 +251,12 @@ void Explorer::registerObjectIntoIframe(
 
 void Explorer::loadFrame(JSGlobalContextRef context)
 {
-    LogDebug("Frame attached");
-
     JSObjectPtr frameObject =
         JavaScriptInterfaceSingleton::Instance().getGlobalObject(context);
 
-    LogDebug("Register main frame");
-    //register main frame;
-
     if (frameObject->getObject() == m_globalObject->getObject()) {
         // Main page was already loaded from constructor
-        LogDebug("Main page loaded");
+        _W("Main page loaded");
         return;
     }
 
@@ -280,38 +266,29 @@ void Explorer::loadFrame(JSGlobalContextRef context)
 
     FOREACH(object, iframeObjects)
     {
-        LogDebug("Register object: " << (*object)->getName() );
-
+        _D("Register object: %s", (*object)->getName().c_str());
         registerObjectIntoIframe(*object, frameObject, context);
     }
 }
 
 void Explorer::unloadFrame(JSGlobalContextRef context)
 {
-    LogDebug("Frame detached");
-
     JSObjectPtr frameObject =
         JavaScriptInterfaceSingleton::Instance().getGlobalObject(context);
-
     m_iframeSupport.unregisterIframe(frameObject);
 }
 
 void Explorer::removePluginsFromIframes()
 {
-    LogDebug("Remove plugins from iframes");
-
     if (m_iframeSupport.hasIframes()) {
-        LogDebug("Removing iframes");
         JavaScriptInterfaceSingleton::Instance().removeIframes(m_context);
     }
 }
 
 void Explorer::deregisterObject(const JSObjectDeclarationPtr& declaration)
 {
-    LogDebug("Deregister object " << declaration->getName());
-
     if (GLOBAL_OBJECT_NAME != declaration->getParentName()) {
-        LogWarning("Ignored remove property " << declaration->getName());
+        _W("Ignored remove property %s", declaration->getName().c_str());
         return;
     }
 
@@ -323,7 +300,6 @@ void Explorer::deregisterObject(const JSObjectDeclarationPtr& declaration)
 
 void Explorer::cleanIframesData()
 {
-    LogDebug("Clean iframes data");
     m_iframeSupport.clean();
 }