Merge "Implement tizen privilege for w3c API"
[framework/web/wrt-installer.git] / src / configuration_parser / WidgetConfigurationManager.cpp
index 54b458c..6044a5f 100644 (file)
@@ -47,10 +47,10 @@ const char *const WRT_WIDGET_CONFIG_FILE_NAME = "config.xml";
 }
 
 bool WidgetConfigurationManager::locateAndParseConfigurationFile(
-        const std::string& _currentPath,
-        WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
-        const std::string& baseFolder,
-        int* pErrCode)
+    const std::string& _currentPath,
+    WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
+    const std::string& baseFolder,
+    int* pErrCode)
 {
     using namespace WrtDB;
 
@@ -63,7 +63,7 @@ bool WidgetConfigurationManager::locateAndParseConfigurationFile(
     // check if this installation from browser, or not.
     size_t pos = _currentPath.rfind("/");
     std::ostringstream infoPath;
-    infoPath << _currentPath.substr(pos+1);
+    infoPath << _currentPath.substr(pos + 1);
 
     ParserRunner parser;
     std::string language = "";
@@ -92,7 +92,8 @@ bool WidgetConfigurationManager::locateAndParseConfigurationFile(
         //TODO why don't we use fopen here
         bool has_config_xml = false;
         errno = 0;
-        while ((ptr = readdir(dir)) != NULL) { //Find configuration file, based on its name
+        while ((ptr = readdir(dir)) != NULL) { //Find configuration file, based
+                                               // on its name
             if (ptr->d_type == DT_REG) {
                 if (!strcmp(ptr->d_name, WRT_WIDGET_CONFIG_FILE_NAME)) {
                     _WrtUtilSetAbsolutePath(cfgAbsPath,
@@ -121,10 +122,15 @@ bool WidgetConfigurationManager::locateAndParseConfigurationFile(
                     }
 
                     //
-                    //                WidgetConfigurationParser & parser = WidgetConfigurationParserSingleton::Instance();
-                    //                if (!parser.parseConfigurationFile(cfgAbsPath, configInfo, baseFolder.c_str(), pWidgetConfigInfo.signature_type)) {
-                    //                    LogDebug("Invalid widget configuration file!");
-                    //                    *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
+                    //                WidgetConfigurationParser & parser =
+                    // WidgetConfigurationParserSingleton::Instance();
+                    //                if
+                    // (!parser.parseConfigurationFile(cfgAbsPath, configInfo,
+                    // baseFolder.c_str(), pWidgetConfigInfo.signature_type)) {
+                    //                    LogDebug("Invalid widget configuration
+                    // file!");
+                    //                    *pErrCode =
+                    // WRT_WM_ERR_INVALID_ARCHIVE;
                     //                    closedir(dir);
                     //                    return false;
                     //                }
@@ -147,11 +153,12 @@ bool WidgetConfigurationManager::locateAndParseConfigurationFile(
         Try
         {
             parser.Parse(_currentPath, ElementParserPtr(new
-                                                      RootParser<
-                                                          WidgetParser>(
-                                                          configInfo,
-                                                          DPL::FromUTF32String(
-                                                              L"widget"))));
+                                                        RootParser<
+                                                            WidgetParser>(
+                                                            configInfo,
+                                                            DPL::
+                                                                FromUTF32String(
+                                                                L"widget"))));
         }
         Catch(ElementParser::Exception::Base)
         {
@@ -162,7 +169,6 @@ bool WidgetConfigurationManager::locateAndParseConfigurationFile(
         }
     }
 
-
     char *tmp_language;
     if (!_WrtUtilStringToLower(baseFolder.c_str(), &tmp_language)) {
         *pErrCode = WRT_ERR_UNKNOWN;
@@ -189,14 +195,10 @@ bool WidgetConfigurationManager::locateAndParseConfigurationFile(
     }
 
     if (!!configInfo.tizenId) {
-        if (!pWidgetConfigInfo.pkgname) {
-            pWidgetConfigInfo.pkgname = configInfo.tizenId;
-        } else {
-            if (pWidgetConfigInfo.pkgname != configInfo.tizenId) {
-                *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
-                LogDebug("Invalid archive - Tizen ID not same error");
-                return false;
-            }
+        if (pWidgetConfigInfo.pkgName != *configInfo.tizenId) {
+            *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
+            LogDebug("Invalid archive - Tizen ID not same error");
+            return false;
         }
     }
 
@@ -221,13 +223,16 @@ bool WidgetConfigurationManager::locateAndParseConfigurationFile(
     return true;
 }
 
-void WidgetConfigurationManager::processFile(const std::string& path,
-        WrtDB::WidgetRegisterInfo &widgetConfiguration)
+void WidgetConfigurationManager::processFile(
+    const std::string& path,
+    WrtDB::WidgetRegisterInfo &
+    widgetConfiguration)
 {
     int pErrCode;
 
     if (!locateAndParseConfigurationFile(path, widgetConfiguration,
-                                         DEFAULT_LANGUAGE, &pErrCode)) {
+                                         DEFAULT_LANGUAGE, &pErrCode))
+    {
         LogWarning("Widget archive: Failed while parsing config file");
         ThrowMsg(Exception::ProcessFailed, path);
     }