[Archive] Fixed fetching widget paths
authorPiotr Kosko <p.kosko@samsung.com>
Thu, 16 Apr 2015 11:47:01 +0000 (13:47 +0200)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Tue, 21 Apr 2015 08:42:35 +0000 (17:42 +0900)
[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 <p.kosko@samsung.com>
src/archive/archive_api.js
src/archive/archive_instance.cc

index 76ce450c093031d1a3e4fad14b7497527cb93086..39e2d4fb45f3fa2f0c5217ea86eaf77ce70917a4 100644 (file)
@@ -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.
index eb94912fd403cecc450b5767ddb8d0d58b6bb8f2..c6227538ab9b77347cf68b736aaf937e78ae1ac9 100644 (file)
@@ -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<picojson::object>();
-    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);
 }