Add parsing logic for datacontrol privileges 11/129211/10
authorInkyun Kil <inkyun.kil@samsung.com>
Mon, 15 May 2017 11:24:29 +0000 (20:24 +0900)
committerInkyun Kil <inkyun.kil@samsung.com>
Thu, 1 Jun 2017 01:38:15 +0000 (01:38 +0000)
- Related patches
  [pkgmgr-info] https://review.tizen.org/gerrit/#/c/129210/
  [app-installers] https://review.tizen.org/gerrit/#/c/129212/
  [data-control] https://review.tizen.org/gerrit/#/c/129882/
  [amd] https://review.tizen.org/gerrit/#/c/129881/
  [aul-1] https://review.tizen.org/gerrit/#/c/129880/

Change-Id: Ia484c088aa631610cf1664d11fc876430b67b11e
Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
src/tpk_manifest_handlers/common/application_handler.cc
src/tpk_manifest_handlers/common/application_handler.h
src/tpk_manifest_handlers/ui_and_service_application_infos.h

index 716a885eb53c51f4c95525cbee3ecae6cf214c01..fa6728c7e201c757d1ccbaccc5faffb3e876d59a 100644 (file)
@@ -25,6 +25,11 @@ const char kDataControlProviderIDKey[] = "@providerid";
 const char kDataControlTypeKey[] = "@type";
 const char kDataControlTrustedKey[] = "@trusted";
 
+// privilege
+const char kPrivilegeTextKey[] = "#text";
+const char kPrivilegeKey[] = "privilege";
+const char kPrivilegeTypeDefault[] = "tpk";
+
 // icon
 const char kIconKey[] = "icon";
 const char kIconTextKey[] = "#text";
index 940c462fc622cf87497abdee6741b900728e2cbc..7e186cbd90dbd7024e9d3a273b06611f75a19706 100644 (file)
@@ -38,6 +38,11 @@ extern const char kDataControlProviderIDKey[];
 extern const char kDataControlTypeKey[];
 extern const char kDataControlTrustedKey[];
 
+// privilege
+extern const char kPrivilegeTextKey[];
+extern const char kPrivilegeKey[];
+extern const char kPrivilegeTypeDefault[];
+
 // icon
 extern const char kIconKey[];
 extern const char kIconTextKey[];
@@ -201,7 +206,21 @@ bool ParseDataControl(const parser::DictionaryValue& dict,
   dict.GetString(tpk_app_keys::kDataControlTypeKey, &type);
   std::string trusted;
   dict.GetString(tpk_app_keys::kDataControlTrustedKey, &trusted);
-  info->data_control.emplace_back(access, providerid, type, trusted);
+
+  std::shared_ptr<PrivilegesInfo> privileges_info(new PrivilegesInfo());
+  for (auto& item : parser::GetOneOrMany(&dict,
+                                         tpk_app_keys::kPrivilegeKey, "")) {
+    std::string privilege;
+    std::string type = tpk_app_keys::kPrivilegeTypeDefault;
+    if (!item->GetString(tpk_app_keys::kPrivilegeTextKey, &privilege) ||
+        privilege.empty())
+      continue;
+
+    privileges_info->AddPrivilege(privilege, type);
+  }
+
+  info->data_control.emplace_back(access, providerid, type, trusted,
+                                  privileges_info);
   return true;
 }
 
index 98e253c5fbbc3d04e2a345c4e46f422cb4ddfb7d..c4896a1da1c710f4d482cd5c28164f63f5dc1b94 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "manifest_parser/manifest_handler.h"
 #include "manifest_parser/values.h"
+#include "tpk_manifest_handlers/privileges_handler.h"
 
 namespace tpk {
 namespace parse {
@@ -61,11 +62,13 @@ class DataControlInfo : public parser::ManifestData {
   DataControlInfo(const std::string& access,
                   const std::string& providerid,
                   const std::string& type,
-                  const std::string& trusted)
+                  const std::string& trusted,
+                  const std::shared_ptr<PrivilegesInfo>& privileges)
                   : access_(access),
                     providerid_(providerid),
                     type_(type),
-                    trusted_(trusted) {}
+                    trusted_(trusted),
+                    privileges_(privileges) {}
 
   const std::string& access() const {
     return access_;
@@ -79,12 +82,16 @@ class DataControlInfo : public parser::ManifestData {
   const std::string& trusted() const {
     return trusted_;
   }
+  const std::shared_ptr<PrivilegesInfo> privileges() const {
+    return privileges_;
+  }
 
  private:
   std::string access_;
   std::string providerid_;
   std::string type_;
   std::string trusted_;
+  std::shared_ptr<PrivilegesInfo> privileges_;
 };
 
 // MetaData