[Release] wrt-plugins-common_0.3.104
[platform/framework/web/wrt-plugins-common.git] / src / modules / tizen / PluginManager / PluginManager.cpp
index 2d868d8..6e2c97c 100644 (file)
@@ -31,7 +31,7 @@
 #include <Commons/Exception.h>
 #include <CommonsJavaScript/Converter.h>
 #include <dpl/exception.h>
-#include <dpl/log/log.h>
+#include <dpl/log/secure_log.h>
 #include <dpl/foreach.h>
 
 using namespace std;
@@ -74,14 +74,14 @@ bool PluginManager::hasChild(const string &name) const
 
 bool PluginManager::loadChild(const string &name) const
 {
-    LogInfo("loading " << name);
+    _D("loading %s", name.c_str());
     string localUri = m_objectUri;
     localUri.append(SEPARATOR).append(name);
 
     WrtDB::DbPluginHandle handle =
         WrtDB::PluginDAOReadOnly::getPluginHandleForImplementedObject(localUri);
     if (handle == WrtDB::INVALID_PLUGIN_HANDLE) {
-        LogError("Plugin not found");
+        _E("Plugin not found");
         return false;
     }
 
@@ -97,7 +97,7 @@ bool PluginManager::loadChild(const string &name) const
     {
         // Error while reading database - widget handle may
         // be invalid or some data may be missing in database
-        LogError("Cannot get feature list");
+        _E("Cannot get feature list");
         return false;
     }
 
@@ -113,7 +113,7 @@ bool PluginManager::loadChild(const string &name) const
     {
         if (it->pluginId == handle) {
             if (it->rejected) {
-                LogWarning("Feature rejected by ACE");
+                _E("Feature rejected by ACE");
                 continue;
             }
 
@@ -125,13 +125,13 @@ bool PluginManager::loadChild(const string &name) const
                        const_cast<JSGlobalContextRef>(m_context));
         }
     }
-    LogError("Plugin not loaded");
+    _E("Plugin not loaded");
     return false;
 }
 
 JSValueRef PluginManager::getProperty(const string &name) const
 {
-    LogDebug("getProperty " << name);
+    _D("getProperty %s", name.c_str());
     ObjectList::const_iterator it = m_objectList.find(name);
     if (it != m_objectList.end()) {
         //return already set value
@@ -154,7 +154,7 @@ JSValueRef PluginManager::getProperty(const string &name) const
 bool PluginManager::setProperty(const string &name,
                                 JSValueRef value)
 {
-    LogDebug("setProperty " << name);
+    _D("setProperty %s", name.c_str());
     if (m_objectList.count(name) > 0) {
         JSValueUnprotect(m_context, m_objectList[name]);
     }
@@ -166,7 +166,7 @@ bool PluginManager::setProperty(const string &name,
 bool PluginManager::deleteProperty(const string &name)
 {
     if (m_objectList.count(name) > 0) {
-        LogDebug("deleteProperty " << name);
+        _D("deleteProperty %s", name.c_str());
         JSValueUnprotect(m_context, m_objectList[name]);
         m_objectList.erase(name);
         return true;
@@ -176,59 +176,58 @@ bool PluginManager::deleteProperty(const string &name)
 
 Api::IPluginManager::PropertyList PluginManager::getProperties() const
 {
+    using namespace WrtDB;
+
     if (!m_propertyCache.IsNull()) {
         return *m_propertyCache;
     }
 
     m_propertyCache = PropertyList();
 
-    WrtDB::WidgetDAOReadOnly dao(m_widgetHandle);
+    WidgetDAOReadOnly dao(m_widgetHandle);
     string localUri = m_objectUri + SEPARATOR;
 
-    if (dao.getWidgetType() == WrtDB::APP_TYPE_TIZENWEBAPP) {
-        WrtDB::PluginHandleList pluginHandleList =
-            WrtDB::PluginDAOReadOnly::getPluginHandleList();
+    if (dao.getWidgetType() == APP_TYPE_TIZENWEBAPP)
+    {
+        static ImplementedObjectsList implObjectList =
+            PluginDAOReadOnly::getImplementedObjects();
 
-        FOREACH(it_pluginHandle, pluginHandleList)
+        FOREACH(it_implObject, implObjectList)
         {
-            WrtDB::ImplementedObjectsList implObjectList =
-                WrtDB::PluginDAOReadOnly::getImplementedObjectsForPluginHandle(
-                    *it_pluginHandle);
-
-            FOREACH(it_implObject, implObjectList)
-            {
-                //check if implemented object stats with localUri
-                if (it_implObject->find(localUri) == 0) {
-                    string property = *it_implObject;
-                    //remove local uri that predicts property name.
-                    property.erase(0, localUri.size());
-                    //check if property has its own properties.
-                    size_t pos = property.find(SEPARATOR);
-                    if (pos != string::npos) {
-                        //if so then remove them.
-                        property.erase(pos);
-                    }
-                    m_propertyCache->push_back(property);
+            //check if implemented object stats with localUri
+            if (it_implObject->find(localUri) == 0) {
+                string property = *it_implObject;
+                //remove local uri that predicts property name.
+                property.erase(0, localUri.size());
+                //check if property has its own properties.
+                size_t pos = property.find(SEPARATOR);
+                if (pos != string::npos) {
+                    //if so then remove them.
+                    property.erase(pos);
                 }
+
+                m_propertyCache->push_back(property);
             }
         }
-    } else {
-        WrtDB::DbWidgetFeatureSet features;
+    }
+    else
+    {
+        DbWidgetFeatureSet features;
 
         Try
         {
             features = dao.getFeaturesList();
         }
-        Catch(WrtDB::WidgetDAOReadOnly::Exception::Base)
+        Catch(WidgetDAOReadOnly::Exception::Base)
         {
-            LogError("Cannot get feature list");
+            _E("Cannot get feature list");
             ReThrow(Commons::PlatformException);
         }
 
-        WrtDB::DbWidgetFeatureSet::const_iterator feature = features.begin();
+        DbWidgetFeatureSet::const_iterator feature = features.begin();
         for (; feature != features.end(); ++feature) {
-            WrtDB::ImplementedObjectsList implObjs =
-                WrtDB::PluginDAOReadOnly::getImplementedObjectsForPluginHandle(
+            ImplementedObjectsList implObjs =
+                PluginDAOReadOnly::getImplementedObjectsForPluginHandle(
                     feature->pluginId);
             FOREACH(it, implObjs) {
                 //check if implemented object stats with localUri