Fix installation of widgets with defaultlocale
authorZbigniew Kostrzewa <z.kostrzewa@samsung.com>
Tue, 8 Oct 2013 10:01:16 +0000 (12:01 +0200)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Tue, 15 Oct 2013 08:08:52 +0000 (08:08 +0000)
[Issue#]   WGL-560, WGL-563
[Problem]  Installation of test widgets (with defaultlocale attribute in
configuration file) fails
[Cause] Installer application does not have access to WRT I18N DB and
backendlib does not attach to WRT I18N DB
[Solution] Restore LanguageSubtagRstTreeSingleton used for checking
language tag validity

[Verification]
1. Build repository
2. Run test widgets from WGL-560
(https://bugs.tizendev.org/jira/browse/WGL-560)

[SCMRequest] Depends on: https://review.tizendev.org/gerrit/92271

Change-Id: I3c8d97e62c5f292b00b71874fe73a56aaedbea44

src/configuration_parser/widget_parser.cpp
src/pkg-manager/CMakeLists.txt
src/wrt-installer/CMakeLists.txt
src/wrt-installer/wrt_installer_api.cpp

index 77eff90..4cb2503 100644 (file)
@@ -2867,16 +2867,18 @@ void WidgetParser::Accept(const XmlAttribute& attribute)
         if (!m_defaultlocale) {
             m_defaultlocale = attribute.value;
             NormalizeString(m_defaultlocale);
-            if( I18n::DB::I18nDAOReadOnly::IsValidSubTag
-                    (attribute.value, RECORD_TYPE_LANGUAGE)) {
-                _D("Default Locale Found %ls", (*m_defaultlocale).c_str());
+            std::string dl = DPL::ToUTF8String(*m_defaultlocale);
+
+            if (!LanguageSubtagRstTreeSingleton::Instance().
+                    ValidateLanguageTag(dl)) {
+                _W("Language tag: %s is not valid", dl.c_str());
+                m_defaultlocale = DPL::OptionalString::Null;
             } else {
-                _W("Default Locate Is Invalid");
+                _D("Default locale found %s", dl.c_str());
             }
         } else {
             _W("Ignoring subsequent default locale");
         }
-
         //Any other value consider as a namespace definition
     } else if (attribute.name == L"xmlns" || attribute.prefix == L"xmlns") {
         _D("Namespace domain: %ls", attribute.name.c_str());
index c1ce69d..d65c064 100755 (executable)
@@ -21,6 +21,7 @@ SET(BACKLIB_SRCS
     ${PROJECT_SOURCE_DIR}/src/configuration_parser/ignoring_parser.cpp
     ${PROJECT_SOURCE_DIR}/src/configuration_parser/deny_all_parser.cpp
     ${PROJECT_SOURCE_DIR}/src/configuration_parser/libiriwrapper.cpp
+    ${PROJECT_SOURCE_DIR}/src/wrt-installer/language_subtag_rst_tree.cpp
 )
 
 PKG_CHECK_MODULES(WRT_BACKLIB_PKGS
@@ -33,6 +34,7 @@ PKG_CHECK_MODULES(WRT_BACKLIB_PKGS
     pkgmgr
     dlog
     libpcrecpp
+    wrt-commons-i18n-dao-ro
     REQUIRED)
 
 INCLUDE_DIRECTORIES(
index 0bd83bb..e22fdc5 100644 (file)
@@ -31,7 +31,7 @@ SET(WRT_INSTALLER_SOURCES
     ${WRT_INSTALLER_DIR}/wrt_installer_api.cpp
     ${WRT_INSTALLER_DIR}/installer_callbacks_translate.cpp
     ${WRT_INSTALLER_DIR}/plugin_utils.cpp
-#    ${WRT_INSTALLER_DIR}/language_subtag_rst_tree.cpp
+    ${WRT_INSTALLER_DIR}/language_subtag_rst_tree.cpp
     ${WRT_INSTALLER_DIR}/installer_main_thread.cpp
     ${WRT_INSTALLER_DIR}/option_parser.cpp
     ${PKG_MANAGER_DIR}/pkgmgr_signal.cpp
index bbd0c3f..19b83d3 100644 (file)
@@ -106,13 +106,12 @@ void wrt_installer_init(void *userdata,
             std::string(GlobalConfig::GetVCoreDatabaseFilePath()));
 
         InstallerMainThreadSingleton::Instance().AttachDatabases();
-        I18n::DB::Interface::attachDatabaseRO();
 
         _D("Prepare libxml2 to work in multithreaded program.");
         xmlInitParser();
 
-//        // Initialize Language Subtag registry
-//        LanguageSubtagRstTreeSingleton::Instance().Initialize();
+        // Initialize Language Subtag registry
+        LanguageSubtagRstTreeSingleton::Instance().Initialize();
 
         // Installer init
         CONTROLLER_POST_SYNC_EVENT(
@@ -147,7 +146,6 @@ void wrt_installer_shutdown()
                 TerminateEvent());
 
         InstallerMainThreadSingleton::Instance().DetachDatabases();
-        I18n::DB::Interface::detachDatabase();
 
         // This must be done after DetachDatabase
         ValidationCore::VCoreDeinit();