}
};
+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) {
#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"
using namespace common;
+
ArchiveInstance& ArchiveInstance::getInstance()
{
static ArchiveInstance instance;
REGISTER_ASYNC("ArchiveFileEntry_extract", Extract);
+ REGISTER_SYNC("Filesystem_getWidgetPaths", GetWidgetPaths);
+
#undef REGISTER_ASYNC
#undef REGISTER_SYNC
}
}
}
+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