Fix installation of widgets using "defaultlocale" attribute.
authorZbigniew Kostrzewa <z.kostrzewa@samsung.com>
Thu, 27 Jun 2013 07:02:02 +0000 (09:02 +0200)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Mon, 1 Jul 2013 13:12:20 +0000 (13:12 +0000)
[Issue#] WEB-3324
[Problem] Installation of widgets with attribute "defaultlocale" in
"widget" element fails.
[Cause] Installer backendlib for package-manager does not include all
required sources. To be exact launguage_subtag_rst_tree.cpp which
defines object used only when attribute "defaultlocale" is used. What's
more the language tag verification requires connection to WRT DB which
was not established in this particular case.
[Solution] Add missing dependencies and establish connection to WRT DB.
[SCMRequest] N/A
[Verification]
1. Build the change
2. Install package on the device
3. Run test widgets (from menu screen):
test/webapi/webapi-w3c-widgetpackaging-tests/widgetpackaging/w3c/dlocuse01.wgt
test/webapi/webapi-w3c-widgetpackaging-tests/widgetpackaging/w3c/dlocignore00.wgt
test/webapi/webapi-w3c-widgetpackaging-tests/widgetpackaging/w3c/ta-de-000.wgt
test/webapi/webapi-w3c-widgetpackaging-tests/widgetpackaging/w3c/ta-de-001.wgt
test/webapi/webapi-w3c-widgetpackaging-tests/widgetpackaging/w3c/ta-de-002.wgt
test/webapi/webapi-w3c-widgetpackaging-tests/widgetpackaging/w3c/ta-de-003.wgt
test/webapi/webapi-w3c-widgetpackaging-tests/widgetpackaging/w3c/ta-de-004.wgt

and one other that does not include "defaultlocale" attribute, e.g.
test/webapi/webapi-w3c-widgetpackaging-tests/widgetpackaging/w3c/br.wgt

CAUTION: This commit does not fix the issue entirely. Application that
performs the installation, when it is initiated from menu screen
(i.e. Installer), does not have enough access rights to establish connection
to WRT DB (SMACK issue). Lack of rights results in sqlite returning
SQLITE_BUSY to the application each time the application tries to establish
a connection (this results in an infinite loop in the application).
Temporary fix could be to set SMACK label "*" to WRT DB (label "_" is
not enough for some reason). However, generally the issue should
probably be passed to security team.

Change-Id: I1f16e7ad47830e226bbf57522719cf9e0af77cff

src/pkg-manager/CMakeLists.txt
src/pkg-manager/backendlib.cpp

index c1ce69d..cad802d 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
+    libiri
     REQUIRED)
 
 INCLUDE_DIRECTORIES(
index 48f98d4..f783f8c 100644 (file)
@@ -255,6 +255,16 @@ int getConfigParserData(const std::string &widgetPath, ConfigParserData& configI
     const char* CONFIG_XML = "config.xml";
     const char* WITH_OSP_XML = "res/wgt/config.xml";
 
+    try
+    {
+        WrtDB::WrtDatabase::attachToThreadRO();
+    }
+    catch (const DPL::DB::SqlConnection::Exception::ConnectionBroken& ex)
+    {
+        LogError("Could not attach to DB: " << ex.GetMessage());
+        return FALSE;
+    }
+
     Try {
         ParserRunner parser;
 
@@ -286,35 +296,43 @@ int getConfigParserData(const std::string &widgetPath, ConfigParserData& configI
     }
     Catch(DPL::ZipInput::Exception::OpenFailed)
     {
+        WrtDB::WrtDatabase::detachFromThread();
         LogError("Failed to open widget package");
         return FALSE;
     }
     Catch(DPL::ZipInput::Exception::OpenFileFailed)
     {
+        WrtDB::WrtDatabase::detachFromThread();
         LogError("Failed to open config.xml file");
         return FALSE;
     }
     Catch(DPL::CopyFailed)
     {
+        WrtDB::WrtDatabase::detachFromThread();
         LogError("Failed to extract config.xml file");
         return FALSE;
     }
     Catch(DPL::FileInput::Exception::OpenFailed)
     {
+        WrtDB::WrtDatabase::detachFromThread();
         LogError("Failed to open config.xml file");
         return FALSE;
     }
     Catch(ElementParser::Exception::ParseError)
     {
+        WrtDB::WrtDatabase::detachFromThread();
         LogError("Failed to parse config.xml file");
         return FALSE;
     }
     Catch(DPL::ZipInput::Exception::SeekFileFailed)
     {
+        WrtDB::WrtDatabase::detachFromThread();
         LogError("Failed to seek widget archive - corrupted package?");
         return FALSE;
     }
 
+    WrtDB::WrtDatabase::detachFromThread();
+
     return TRUE;
 }