[Archive] Added support for widget paths.
authorPawel Andruszkiewicz <p.andruszkie@samsung.com>
Mon, 22 Dec 2014 14:21:40 +0000 (15:21 +0100)
committerPiotr Kosko <p.kosko@samsung.com>
Mon, 29 Dec 2014 12:44:20 +0000 (13:44 +0100)
[Verification] TCT pass rate 80/106.

Change-Id: If0e2c62fd63aaf6ec07704deb3abe35b75ac7880
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
src/archive/archive_api.js
src/archive/archive_instance.cc
src/archive/archive_instance.h

index 0d0e71c8721cae1b5a10af9eb39ffac98e2295f1..c54bdb89c663c387fd94c7632916451a6193107c 100644 (file)
@@ -29,6 +29,23 @@ 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']
+    };
+}
+
+_initializeCache();
+
 CommonFS.toRealPath = function(aPath) {
     var _fileRealPath = '', _uriPrefix = 'file://', i;
     if (aPath.indexOf(_uriPrefix) === 0) {
index 13cbc0da93c2355ad15d344b46efabaf955ba8bb..dc88057eab2dedaa5ed7c4b2327a1043d861756f 100644 (file)
@@ -10,6 +10,9 @@
 #include <functional>
 #include <memory>
 
+#include <pkgmgr-info.h>
+
+#include "common/current_application.h"
 #include "common/picojson.h"
 #include "common/logger.h"
 #include "common/platform_exception.h"
@@ -24,6 +27,7 @@ namespace archive {
 
 using namespace common;
 
+
 ArchiveInstance& ArchiveInstance::getInstance()
 {
     static ArchiveInstance instance;
@@ -50,6 +54,8 @@ ArchiveInstance::ArchiveInstance() {
 
     REGISTER_ASYNC("ArchiveFileEntry_extract", Extract);
 
+    REGISTER_SYNC("Filesystem_getWidgetPaths", GetWidgetPaths);
+
     #undef REGISTER_ASYNC
     #undef REGISTER_SYNC
 }
@@ -411,5 +417,33 @@ 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)) {
+        throw UnknownException("Error while getting package info");
+    }
+
+    if (PMINFO_R_OK != pkgmgrinfo_pkginfo_get_root_path(handle, &root_path)) {
+        throw UnknownException("Error while getting package info");
+    }
+
+    // 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", root + "/res/wgt"));
+    result_obj.insert(std::make_pair("wgt-private", root + "/data"));
+    result_obj.insert(std::make_pair("wgt-private-tmp", root + "/tmp"));
+
+    ReportSuccess(result, out);
+}
+
 } // namespace archive
 } // namespace extension
index e21ec5f4043e926c6cbb36aa230acaf3f7cdd24d..6cdfe14921bd7a2e1340aae342854ef5a50e752d 100644 (file)
@@ -33,6 +33,9 @@ private:
 
     /* ArchiveFileEntry methods */
     void Extract(const picojson::value& args, picojson::object& out);
+
+    /* Filesystem related method */
+    void GetWidgetPaths(const picojson::value& args, picojson::object& out);
 };
 
 } // namespace archive