X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fplugin-loading%2Fplugin_container_support.cpp;h=13dadd0c99a4854d40e78ba98abcd884f4df84ad;hb=5a95fbdfc1425b8b8d2b6d6b3ecc19bf45dec82a;hp=6bc1d318fc96c8eb40eb0e715dc081a54cf5fdb1;hpb=c50824c8c589c5261a10c13f8cd6689d5481f953;p=platform%2Fframework%2Fweb%2Fwrt-plugins-common.git diff --git a/src/plugin-loading/plugin_container_support.cpp b/src/plugin-loading/plugin_container_support.cpp index 6bc1d31..13dadd0 100644 --- a/src/plugin-loading/plugin_container_support.cpp +++ b/src/plugin-loading/plugin_container_support.cpp @@ -27,19 +27,14 @@ #include #include -namespace { -const char *STANDARD_FEATURES_LIST_FILE = "standard-features-list"; -const char *TIZEN_ROOT_FEATURES = "http://tizen.org/privilege/tizen"; -} - -using namespace WrtDB; + using namespace WrtDB; #include -PluginContainerSupport::PluginContainerSupport(): m_initialized(false) +PluginContainerSupport::PluginContainerSupport() : m_initialized(false) { - // Reading standard features list from file - readStandardFeaturesList(); + // Reading root plugins list from so files + readRootPluginsList(); } PluginContainerSupport::~PluginContainerSupport() @@ -49,12 +44,18 @@ PluginContainerSupport::~PluginContainerSupport() // Remove all feature models m_featureModels.clear(); + } - // Clear standard features list - m_standardFeatureList.clear(); +void PluginContainerSupport::Initialize(int widgetHandle) +{ + if (isInitialized() == false) { + readAllowedPlugins(widgetHandle); + readRootPlugins(widgetHandle); + } } -std::list PluginContainerSupport::getAllowedFeatures(int widgetHandle) const +std::list PluginContainerSupport::getAllowedFeatures( + int widgetHandle) const { //TODO it has to return LIST NOT SET!!! WidgetDAOReadOnly widgetDao(widgetHandle); @@ -65,7 +66,7 @@ std::list PluginContainerSupport::getAllowedFeatures(int widgetHand LogInfo("Loading api-feature: " << it->name); if (it->rejected) { LogWarning("Api-feature was rejected by ace. (Api-feature name: " - << it->name << ")" ); + << it->name << ")"); continue; } @@ -76,7 +77,7 @@ std::list PluginContainerSupport::getAllowedFeatures(int widgetHand void PluginContainerSupport::readAllowedPlugins(int widgetHandle) { - std::list allowedFeatures(m_standardFeatureList); + std::list allowedFeatures; auto requested = getAllowedFeatures(widgetHandle); FOREACH(f, requested) { @@ -84,8 +85,11 @@ void PluginContainerSupport::readAllowedPlugins(int widgetHandle) } FeatureData* dt = NULL; - std::map featureDataList = FeatureDAOReadOnly::GetFeatures(allowedFeatures); - DeviceCapList deviceCapabilities = FeatureDAOReadOnly::GetDevCapWithFeatureHandle(); + std::map featureDataList = FeatureDAOReadOnly::GetFeatures( + allowedFeatures); + DeviceCapList deviceCapabilities = + FeatureDAOReadOnly::GetDevCapWithFeatureHandle(); FOREACH(data, featureDataList) { dt = &(data->second); registerPluginModel(dt->pluginHandle); @@ -100,15 +104,22 @@ void PluginContainerSupport::readRootPlugins(int widgetHandle) WidgetDAOReadOnly dao(widgetHandle); WidgetType appType = dao.getWidgetType(); if (appType == WrtDB::APP_TYPE_TIZENWEBAPP) { - WrtDB::FeatureDAOReadOnly dao(TIZEN_ROOT_FEATURES); - registerPluginModel(dao.GetPluginHandle()); + FOREACH(it_rootPluginHandle, m_rootPluginsList) + { + LogDebug("*it_rootPluginHandle: " << *it_rootPluginHandle); + registerPluginModel(*it_rootPluginHandle); + } } else { LogDebug("Not defined app type"); } m_initialized = true; } -void PluginContainerSupport::registerFeatureModel(FeatureHandle handle, FeatureData* data, DeviceCapList deviceCapabilities) +void PluginContainerSupport::registerFeatureModel( + FeatureHandle handle, + FeatureData* data, + DeviceCapList + deviceCapabilities) { LogDebug("Analyzing feature: " << handle); FeatureModelPtr model = getFeatureModel(handle); @@ -156,36 +167,11 @@ void PluginContainerSupport::registerPluginModel(DbPluginHandle handle) m_pluginModels.insert(model); } -void PluginContainerSupport::readStandardFeaturesList() +void PluginContainerSupport::readRootPluginsList() { - LogDebug("Reading standard features list from file..."); - - std::string path = GlobalConfig::GetDevicePluginPath(); - path += "/"; - path += STANDARD_FEATURES_LIST_FILE; + LogDebug("Reading root plugins list from so files..."); - std::ifstream standardFeatureFile; - standardFeatureFile.open(path.c_str(), std::ifstream::in); - - if (!standardFeatureFile.is_open()) { - LogError("Reading standard features list from file FAILED."); - return; - } - - char buffer[1024]; - - while (!standardFeatureFile.eof()) { - standardFeatureFile.getline(buffer, sizeof(buffer)); - - if (buffer[0] == '\0') { - break; - } - - LogDebug("Standard Feature: <" << buffer << ">"); - m_standardFeatureList.push_back(std::string(buffer)); - } - - standardFeatureFile.close(); + m_rootPluginsList = PluginDAOReadOnly::getRootPluginHandleList(); } FeatureModelPtr @@ -230,51 +216,47 @@ PluginContainerSupport::getPluginModelById(DbPluginHandle handle) const PluginModelPtr PluginContainerSupport::getPluginModel(const FeatureModelPtr &feature) const { - LogDebug(""); - Assert(feature && "Null Ptr for feature model"); - LogDebug("Feature located in plugin: " << feature->PHandle.Get()); - - return getPluginModelById(feature->PHandle.Get()); + if (!feature) + { + LogDebug("Null Ptr for feature model"); + return PluginModelPtr(); + } + else + { + LogDebug("Feature located in plugin: " << feature->PHandle.Get()); + return getPluginModelById(feature->PHandle.Get()); + } } -PluginContainerSupport::FeaturesList -PluginContainerSupport::getStandardFeatures() const + PluginContainerSupport::PluginsList +PluginContainerSupport::getRootPlugins() const { - //TODO use move - FeaturesList standardFeatures; + PluginsList plugins; - FOREACH(it, m_standardFeatureList) + FOREACH(it, m_rootPluginsList) { - FeatureModelPtr feature = getFeatureModel(*it); - if (!feature) { - LogWarning("Feature does not exist in DB " << *it); + PluginModelPtr plugin = getPluginModelById(*it); + if (!plugin) { + LogError("PluginModel not found"); continue; } - //TODO maybe it should be sorted - standardFeatures.push_back(feature); + plugins.push_back(plugin); } - return standardFeatures; + return plugins; } PluginContainerSupport::PluginsList -PluginContainerSupport::getStandardPlugins() const +PluginContainerSupport::getPluginsList() const { - PluginsList plugins; + LogDebug(""); - auto features = getStandardFeatures(); + PluginsList plugins; - FOREACH(it, features) + FOREACH(it, m_pluginModels) { - auto plugin = getPluginModel(*it); - if(!plugin) - { - LogError("PluginModel not found"); - continue; - } - - plugins.push_back(plugin); + plugins.push_back(*it); } return plugins; @@ -283,5 +265,5 @@ PluginContainerSupport::getStandardPlugins() const PluginModelPtr PluginContainerSupport::getPluginForFeature(const std::string& featureName) { - return getPluginModel(getFeatureModel(featureName)); + return getPluginModel(getFeatureModel(featureName)); }