summaryrefslogtreecommitdiff
path: root/src/components/policy/policy_regular
diff options
context:
space:
mode:
authorShobhitAd <adlakhashobhit@gmail.com>2018-11-16 12:54:22 -0500
committerShobhitAd <adlakhashobhit@gmail.com>2018-11-16 13:40:42 -0500
commitbb46d3110e06067466a25dcc9973e79909552996 (patch)
treee56af222eb248ba01edf6813e1d4e74f530e2c10 /src/components/policy/policy_regular
parent2360fbdd7d634214a4ea86864bf7acfed0bc646d (diff)
downloadsdl_core-bb46d3110e06067466a25dcc9973e79909552996.tar.gz
Implemented InitCloudApp in policy_regular
Diffstat (limited to 'src/components/policy/policy_regular')
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager.h9
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager_interface.h8
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_manager_impl.h7
-rw-r--r--src/components/policy/policy_regular/src/cache_manager.cc21
-rw-r--r--src/components/policy/policy_regular/src/policy_manager_impl.cc4
5 files changed, 49 insertions, 0 deletions
diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h
index a4ae45d604..0ce35b5beb 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager.h
@@ -179,6 +179,15 @@ class CacheManager : public CacheManagerInterface {
std::string& hybrid_app_preference) const;
/**
+ * Initializes a new cloud application with default policies
+ * Then adds cloud specific policies
+ * @param app_id application id
+ * @return true if success
+ */
+ virtual void InitCloudApp(const std::string& policy_app_id);
+
+
+ /**
* @brief Enable or disable a cloud application in the HMI
* @param enabled Cloud app enabled state
*/
diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
index f0ee9c2b25..bf0f17d83c 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
@@ -185,6 +185,14 @@ class CacheManagerInterface {
std::string& hybrid_app_preference) const = 0;
/**
+ * Initializes a new cloud application with default policies
+ * Then adds cloud specific policies
+ * @param app_id application id
+ * @return true if success
+ */
+ virtual void InitCloudApp(const std::string& policy_app_id) = 0;
+
+ /**
* @brief Enable or disable a cloud application in the HMI
* @param enabled Cloud app enabled state
*/
diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
index 0a0c260a96..20a37717a7 100644
--- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
+++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
@@ -597,6 +597,13 @@ class PolicyManagerImpl : public PolicyManager {
std::string& hybrid_app_preference) const OVERRIDE;
/**
+ * @ brief Initialize new cloud app in the policy table
+ * @ param policy_app_id Application ID
+ */
+
+ void InitCloudApp(const std::string& policy_app_id) OVERRIDE;
+
+ /**
* @brief Enable or disable a cloud application in the HMI
* @param enabled Cloud app enabled state
*/
diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc
index c4b3d8db53..2c37279baa 100644
--- a/src/components/policy/policy_regular/src/cache_manager.cc
+++ b/src/components/policy/policy_regular/src/cache_manager.cc
@@ -728,6 +728,27 @@ void CacheManager::GetCloudAppParameters(
}
}
+void CacheManager::InitCloudApp(const std::string& policy_app_id) {
+ CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+
+ policy_table::ApplicationPolicies& policies =
+ pt_->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::const_iterator default_iter =
+ policies.find(kDefaultId);
+ policy_table::ApplicationPolicies::const_iterator app_iter =
+ policies.find(policy_app_id);
+
+ if (default_iter != policies.end()) {
+ if (app_iter == policies.end()){
+ policies[policy_app_id] = policies[kDefaultId];
+ }
+ }
+ //Add cloud app specific policies
+
+ Backup();
+}
+
void CacheManager::SetCloudAppEnabled(const std::string& policy_app_id,
const bool enabled) {
policy_table::ApplicationPolicies& policies =
diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc
index 6e635b7f36..e2adde4524 100644
--- a/src/components/policy/policy_regular/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc
@@ -566,6 +566,10 @@ void PolicyManagerImpl::GetCloudAppParameters(
hybrid_app_preference);
}
+void PolicyManagerImpl::InitCloudApp(const std::string& policy_app_id){
+ cache_->InitCloudApp(policy_app_id);
+}
+
void PolicyManagerImpl::SetCloudAppEnabled(const std::string& policy_app_id,
const bool enabled) {
cache_->SetCloudAppEnabled(policy_app_id, enabled);