Extracting whole files can cause memory issue.
Instead of extracting whole files, wgt lib will extract manifest first
and find icon file from manifest, and then extract icon file.
Change-Id: I2b7a5c1039dc94411e68c7bdffb61d139aa43ef9
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
namespace {
const char kVconfLanguageKey[] = "db/menu_widget/language";
namespace {
const char kVconfLanguageKey[] = "db/menu_widget/language";
+const char kConfigFileName[] = "config.xml";
-bool ExtractPackageArchive(const char* file_path, const bf::path& tmp_dir) {
- if (!ci::ExtractToTmpDir(file_path, tmp_dir)) {
+bool ExtractPackageArchive(const char* file_path, const char* file,
+ const bf::path& tmp_dir) {
+ if (!ci::ExtractToTmpDir(file_path, tmp_dir, file)) {
LOG(ERROR) << "Failed to extract";
return false;
}
LOG(ERROR) << "Failed to extract";
return false;
}
bool ReadIcon(const bf::path& icon, const bf::path& tmp_dir,
package_manager_pkg_detail_info_t* info) {
bool ReadIcon(const bf::path& icon, const bf::path& tmp_dir,
package_manager_pkg_detail_info_t* info) {
- bf::path icon_path;
- if (icon.is_absolute())
- icon_path = icon;
- else
- icon_path = tmp_dir / icon;
+ bf::path icon_path = tmp_dir / icon;
LOG(INFO) << "Icon file path: " << icon_path;
LOG(INFO) << "Icon file path: " << icon_path;
-bool GetIconInfo(const wgt::parse::WidgetConfigParser& parser,
- const bf::path& tmp_dir, package_manager_pkg_detail_info_t* info) {
+std::string GetIconInfo(const wgt::parse::WidgetConfigParser& parser) {
auto icons_info =
std::static_pointer_cast<const wgt::parse::ApplicationIconsInfo>(
parser.GetManifestData(wgt::parse::ApplicationIconsInfo::Key()));
if (!icons_info)
auto icons_info =
std::static_pointer_cast<const wgt::parse::ApplicationIconsInfo>(
parser.GetManifestData(wgt::parse::ApplicationIconsInfo::Key()));
if (!icons_info)
- return ReadIcon(icons_info->icons().front().path(), tmp_dir, info);
+ return std::string(icons_info->icons().front().path());
if (!ci::CreateDir(tmp_dir))
return false;
LOG(DEBUG) << "Unpack at temporary dir: " << tmp_dir;
if (!ci::CreateDir(tmp_dir))
return false;
LOG(DEBUG) << "Unpack at temporary dir: " << tmp_dir;
- if (!ExtractPackageArchive(file_path, tmp_dir))
+ if (!ExtractPackageArchive(file_path, kConfigFileName, tmp_dir))
return false;
wgt::parse::WidgetConfigParser parser;
return false;
wgt::parse::WidgetConfigParser parser;
- bf::path manifest_path = tmp_dir / "config.xml";
+ bf::path manifest_path = tmp_dir / kConfigFileName;
if (!parser.ParseManifest(manifest_path)) {
LOG(ERROR) << "Failed to parse";
bf::remove_all(tmp_dir);
if (!parser.ParseManifest(manifest_path)) {
LOG(ERROR) << "Failed to parse";
bf::remove_all(tmp_dir);
}
if (!GetPrivilegesInfo(parser, info))
LOG(WARNING) << "Failed to get privileges info";
}
if (!GetPrivilegesInfo(parser, info))
LOG(WARNING) << "Failed to get privileges info";
- if (!GetIconInfo(parser, tmp_dir, info))
- LOG(WARNING) << "Failed to get icon info";
+ std::string icon = GetIconInfo(parser);
+ if (!icon.empty()) {
+ if (!ExtractPackageArchive(file_path, icon.c_str(), tmp_dir))
+ return false;
+ if (!ReadIcon(icon, tmp_dir, info)) {
+ LOG(WARNING) << "Failed to get icon info";
+ return false;
+ }
+ }
char* locale = vconf_get_str(kVconfLanguageKey);
if (!GetLabelInfo(parser, locale, info))
char* locale = vconf_get_str(kVconfLanguageKey);
if (!GetLabelInfo(parser, locale, info))