Make wgt lib support hybrid package 47/108847/3 accepted/tizen/3.0/common/20170109.195923 accepted/tizen/3.0/ivi/20170109.073433 accepted/tizen/3.0/tv/20170110.055306 accepted/tizen/3.0/wearable/20170109.073230 submit/tizen_3.0/20170106.072144 submit/tizen_3.0/20170106.102334
authorSangyoon Jang <s89.jang@samsung.com>
Fri, 6 Jan 2017 04:55:10 +0000 (13:55 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Fri, 6 Jan 2017 06:17:14 +0000 (22:17 -0800)
Change-Id: Id0fe7f2ed6a736104f1683547fe80a0010662b6a
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
src/lib/wgt_archive_info.cc

index 4ae49df..5e95b1f 100644 (file)
@@ -30,6 +30,7 @@ namespace {
 
 const char kVconfLanguageKey[] = "db/menu_widget/language";
 const char kConfigFileName[] = "config.xml";
+const char kHybridConfigFileName[] = "res/wgt/config.xml";
 
 bool ExtractPackageArchive(const char* file_path, const char* file,
     const bf::path& tmp_dir) {
@@ -177,11 +178,22 @@ bool WgtArchiveInfo::GetArchiveInfo(const char* file_path,
   if (!ci::CreateDir(tmp_dir))
     return false;
   LOG(DEBUG) << "Unpack at temporary dir: " << tmp_dir;
-  if (!ExtractPackageArchive(file_path, kConfigFileName, tmp_dir))
+  bool is_hybrid = false;
+  if (!ExtractPackageArchive(file_path, kHybridConfigFileName, tmp_dir))
     return false;
+  if (bf::exists(tmp_dir / kHybridConfigFileName)) {
+    is_hybrid = true;
+  } else {
+    if (!ExtractPackageArchive(file_path, kConfigFileName, tmp_dir))
+      return false;
+  }
 
   wgt::parse::WidgetConfigParser parser;
-  bf::path manifest_path = tmp_dir / kConfigFileName;
+  bf::path manifest_path;
+  if (is_hybrid)
+    manifest_path = tmp_dir / kHybridConfigFileName;
+  else
+    manifest_path = tmp_dir / kConfigFileName;
   if (!parser.ParseManifest(manifest_path)) {
     LOG(ERROR) << "Failed to parse";
     bf::remove_all(tmp_dir);
@@ -197,11 +209,16 @@ bool WgtArchiveInfo::GetArchiveInfo(const char* file_path,
     LOG(WARNING) << "Failed to get privileges info";
   std::string icon = GetIconInfo(parser);
   if (!icon.empty()) {
-    if (!ExtractPackageArchive(file_path, icon.c_str(), tmp_dir)) {
+    std::string icon_path;
+    if (is_hybrid)
+      icon_path = "res/wgt/" + icon;
+    else
+      icon_path = icon;
+    if (!ExtractPackageArchive(file_path, icon_path.c_str(), tmp_dir)) {
       bf::remove_all(tmp_dir);
       return false;
     }
-    if (!ReadIcon(icon, tmp_dir, info)) {
+    if (!ReadIcon(icon_path, tmp_dir, info)) {
       LOG(WARNING) << "Failed to get icon info";
       bf::remove_all(tmp_dir);
       return false;