From: Piotr Kosko Date: Thu, 16 Apr 2015 11:47:01 +0000 (+0200) Subject: [Archive] Fixed fetching widget paths X-Git-Tag: submit/tizen_tv/20150603.064601~1^2~149 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c00e83aac6f58a4a9cbd5e171700838dc49001bd;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Archive] Fixed fetching widget paths [Bug] Widget paths was fetched incorretly - implementation fixed to use common/virtual_fs [Verification] Code compiles without errors. tizen.archive is visible in tests. TCT passrate increased to 97.17% Change-Id: Ida147f48148b343496d009f1414c6288a345e552 Signed-off-by: Piotr Kosko --- diff --git a/src/archive/archive_api.js b/src/archive/archive_api.js index 76ce450c..39e2d4fb 100644 --- a/src/archive/archive_api.js +++ b/src/archive/archive_api.js @@ -30,18 +30,22 @@ CommonFS.cacheVirtualToReal = { }; function _initializeCache() { - var result = bridge.sync({ - cmd: 'Filesystem_getWidgetPaths' - }); - CommonFS.cacheVirtualToReal['wgt-package'] = { - path: result['wgt-package'] - }; - CommonFS.cacheVirtualToReal['wgt-private'] = { - path: result['wgt-private'] - }; - CommonFS.cacheVirtualToReal['wgt-private-tmp'] = { - path: result['wgt-private-tmp'] - }; + try { + var result = bridge.sync({ + cmd: 'Filesystem_getWidgetPaths' + }); + CommonFS.cacheVirtualToReal['wgt-package'] = { + path: result['wgt-package'] + }; + CommonFS.cacheVirtualToReal['wgt-private'] = { + path: result['wgt-private'] + }; + CommonFS.cacheVirtualToReal['wgt-private-tmp'] = { + path: result['wgt-private-tmp'] + }; + } catch(e) { + console.log("Exception while getting widget paths was thrown: " + e); + } } _initializeCache(); @@ -473,8 +477,8 @@ function ArchiveFile(data) { } -function ArchiveManager() { -} +var ArchiveManager = function () { +}; /** * Opens the archive file. After this operation, it is possible to add or get files to and from the archive. diff --git a/src/archive/archive_instance.cc b/src/archive/archive_instance.cc index eb94912f..c6227538 100644 --- a/src/archive/archive_instance.cc +++ b/src/archive/archive_instance.cc @@ -12,6 +12,7 @@ #include "common/current_application.h" #include "common/picojson.h" #include "common/logger.h" +#include "common/virtual_fs.h" #include "archive_callback_data.h" #include "archive_manager.h" #include "archive_utils.h" @@ -25,6 +26,10 @@ using namespace common; namespace { const std::string kPrivilegeFilesystemRead = "http://tizen.org/privilege/filesystem.read"; const std::string kPrivilegeFilesystemWrite = "http://tizen.org/privilege/filesystem.write"; + +const std::string kWgtPackagePathName = "wgt-package"; +const std::string kWgtPrivatePathName = "wgt-private"; +const std::string kWgtPrivateTmpPathName = "wgt-private-tmp"; } // namespace ArchiveInstance::ArchiveInstance() { @@ -538,31 +543,22 @@ void ArchiveInstance::Extract(const picojson::value& args, picojson::object& out } void ArchiveInstance::GetWidgetPaths(const picojson::value& args, picojson::object& out) { - char *root_path = NULL; - std::string pkg_id = CurrentApplication::GetInstance().GetPackageId(); - - pkgmgrinfo_pkginfo_h handle = NULL; - if (PMINFO_R_OK != pkgmgrinfo_pkginfo_get_pkginfo(pkg_id.c_str(), &handle)) { - ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Error while getting package info"), &out); - return; - } - - if (PMINFO_R_OK != pkgmgrinfo_pkginfo_get_root_path(handle, &root_path)) { - ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Error while getting package info"), &out); - return; - } + std::string wgt_package_path = + *(common::VirtualFs::GetInstance().GetVirtualRootDirectory(kWgtPackagePathName)); + std::string wgt_private_path = + *(common::VirtualFs::GetInstance().GetVirtualRootDirectory(kWgtPrivatePathName)); + std::string wgt_private_tmp_path = + *(common::VirtualFs::GetInstance().GetVirtualRootDirectory(kWgtPrivateTmpPathName)); + LoggerD("wgt-package path: %s", wgt_package_path.c_str()); + LoggerD("wgt-private path: %s", wgt_private_path.c_str()); + LoggerD("wgt-private-tmp path: %s", wgt_private_tmp_path.c_str()); // Construction of the response - std::string root(root_path); - LoggerD("root path: %s", root_path); - - pkgmgrinfo_pkginfo_destroy_pkginfo(handle); - picojson::value result{picojson::object()}; auto& result_obj = result.get(); - result_obj.insert(std::make_pair("wgt-package", picojson::value(root + "/res/wgt"))); - result_obj.insert(std::make_pair("wgt-private", picojson::value(root + "/data"))); - result_obj.insert(std::make_pair("wgt-private-tmp", picojson::value(root + "/tmp"))); + result_obj.insert(std::make_pair(kWgtPackagePathName, picojson::value(wgt_package_path))); + result_obj.insert(std::make_pair(kWgtPrivatePathName, picojson::value(wgt_private_path))); + result_obj.insert(std::make_pair(kWgtPrivateTmpPathName, picojson::value(wgt_private_tmp_path))); ReportSuccess(result, out); }