Merge "Implement tizen privilege for w3c API"
[framework/web/wrt-installer.git] / src / configuration_parser / WidgetConfigurationManager.cpp
index 30b47bc..6044a5f 100644 (file)
@@ -36,20 +36,21 @@ IMPLEMENT_SINGLETON(WidgetConfigurationManager)
 //TODO Rewrite this as steps/tasks
 namespace // anonymous
 {
-const char * const DEFAULT_LANGUAGE = "default";
+const char *const DEFAULT_LANGUAGE = "default";
 const size_t MAX_WIDGET_PATH_SIZE = 1024;
 
 //#define WRT_WIDGET_DEFAULT_ICON_WIDTH 80
 //#define WRT_WIDGET_DEFAULT_ICON_HEIGHT 80
 
 //#define WRT_WIDGET_CONFIG_BASE_LOCALE "locales"
-const char * const WRT_WIDGET_CONFIG_FILE_NAME = "config.xml";
+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;
 
@@ -91,38 +92,48 @@ 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, _currentPath.c_str(),
-                            ptr->d_name);
+                    _WrtUtilSetAbsolutePath(cfgAbsPath,
+                                            _currentPath.c_str(), ptr->d_name);
                     //Parse widget configuration file
                     LogDebug("Found config: " << cfgAbsPath);
 
                     Try
                     {
-                        parser.Parse(cfgAbsPath,
-                                ElementParserPtr(
-                                        new RootParser<WidgetParser>(configInfo,
-                                                DPL::FromUTF32String(
-                                                        L"widget"))));
+                        parser.Parse(cfgAbsPath, ElementParserPtr(new
+                                                                  RootParser<
+                                                                      WidgetParser>(
+                                                                      configInfo,
+                                                                      DPL
+                                                                          ::
+                                                                          FromUTF32String(
+                                                                          L"widget"))));
+                    }
+                    Catch(ElementParser::Exception::Base)
+                    {
+                        LogDebug("Invalid widget configuration file!");
+                        //                    _rethrown_exception.Dump();
+                        *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
+                        closedir(dir);
+                        return false;
                     }
-                    Catch(ElementParser::Exception::Base){
-                    LogDebug("Invalid widget configuration file!");
-                    //                    _rethrown_exception.Dump();
-                    *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
-                    closedir(dir);
-                    return false;
-                }
 
-                //
-                //                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;
-                //                }
+                    //
+                    //                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;
+                    //                }
 
                     has_config_xml = true;
                     break;
@@ -141,18 +152,22 @@ bool WidgetConfigurationManager::locateAndParseConfigurationFile(
         // in case of browser installation
         Try
         {
-            parser.Parse(_currentPath,
-                    ElementParserPtr(
-                            new RootParser<WidgetParser>(configInfo,
-                                    DPL::FromUTF32String(L"widget"))));
+            parser.Parse(_currentPath, ElementParserPtr(new
+                                                        RootParser<
+                                                            WidgetParser>(
+                                                            configInfo,
+                                                            DPL::
+                                                                FromUTF32String(
+                                                                L"widget"))));
+        }
+        Catch(ElementParser::Exception::Base)
+        {
+            LogDebug("Invalid widget configuration file!");
+            //                    _rethrown_exception.Dump();
+            *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
+            return false;
         }
-        Catch(ElementParser::Exception::Base){
-        LogDebug("Invalid widget configuration file!");
-        //                    _rethrown_exception.Dump();
-        *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
-        return false;
     }
-}
 
     char *tmp_language;
     if (!_WrtUtilStringToLower(baseFolder.c_str(), &tmp_language)) {
@@ -180,7 +195,7 @@ bool WidgetConfigurationManager::locateAndParseConfigurationFile(
     }
 
     if (!!configInfo.tizenId) {
-        if (pWidgetConfigInfo.pkgname_NOTNULL != *configInfo.tizenId) {
+        if (pWidgetConfigInfo.pkgName != *configInfo.tizenId) {
             *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
             LogDebug("Invalid archive - Tizen ID not same error");
             return false;
@@ -208,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);
     }