tizen 2.4 release
[framework/web/wrt-plugins-common.git] / src / plugin-loading / plugin_container_support.cpp
@@ -49,7 +49,7 @@ PluginContainerSupport::~PluginContainerSupport()
     m_featureModels.clear();
  }
 
-void PluginContainerSupport::Initialize(int widgetHandle)
+void PluginContainerSupport::Initialize(WidgetHandle widgetHandle)
 {
     if (isInitialized() == true && m_widgetHandle != widgetHandle) {
         // re-initialize required
@@ -69,7 +69,7 @@ void PluginContainerSupport::Initialize(int widgetHandle)
 }
 
 std::list<std::string> PluginContainerSupport::getAllowedFeatures(
-    int widgetHandle) const
+    WidgetHandle widgetHandle) const
 {
     //TODO it has to return LIST NOT SET!!!
     WidgetDAOReadOnly widgetDao(widgetHandle);
@@ -77,9 +77,9 @@ std::list<std::string> PluginContainerSupport::getAllowedFeatures(
 
     std::list<std::string> allowedFeatures;
     FOREACH(it, features) {
-        _D("Loading api-feature: %s", DPL::ToUTF8String(it->name).c_str());
+        _D("Loading api-feature: %ls", it->name.c_str());
         if (it->rejected) {
-            _W("Api-feature was rejected by ace. (Api-feature name: %s)",
+            _W("Api-feature was rejected by ace. (Api-feature name: %ls)",
                it->name.c_str());
             continue;
         }
@@ -89,7 +89,7 @@ std::list<std::string> PluginContainerSupport::getAllowedFeatures(
     return allowedFeatures;
 }
 
-void PluginContainerSupport::readAllowedPlugins(int widgetHandle)
+void PluginContainerSupport::readAllowedPlugins(WidgetHandle widgetHandle)
 {
     std::list<std::string> allowedFeatures;
     auto requested = getAllowedFeatures(widgetHandle);
@@ -111,7 +111,7 @@ void PluginContainerSupport::readAllowedPlugins(int widgetHandle)
     }
 }
 
-void PluginContainerSupport::readRootPlugins(int widgetHandle)
+void PluginContainerSupport::readRootPlugins(WidgetHandle widgetHandle)
 {
     WidgetDAOReadOnly dao(widgetHandle);
     WidgetType appType = dao.getWidgetType();
@@ -167,8 +167,13 @@ void PluginContainerSupport::registerPluginModel(DbPluginHandle handle)
         return;
     }
 
-    model.Reset(new PluginModel(handle));
-
+    Try {
+        model.reset(new PluginModel(handle));
+    } Catch(WrtDB::PluginDAOReadOnly::Exception::PluginNotExist) {
+        // database changed between receiving plugin handle and creating PluginModel
+        _E("Failed to create PluginModel - database may be changed");
+        return;
+    }
     \r_D("Model Created. Handle: %d, name: %s",
        handle,
        model->LibraryName.Get().c_str());