diff options
Diffstat (limited to 'src/components/policy')
10 files changed, 93 insertions, 0 deletions
diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index 98f279b345..3344b149e4 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -191,6 +191,14 @@ 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_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index 2a334876ae..6a172e6f4b 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -199,6 +199,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_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index 6d4cbbf773..399c95170d 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -603,6 +603,12 @@ 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_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index dc0838d429..8cec6ef91c 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -1435,6 +1435,25 @@ 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_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index df474268ba..0844edd8eb 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -747,6 +747,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); 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..8c8f0c55c6 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,14 @@ 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..50b546ecc5 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..ca61a338f1 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..9b2392a015 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); |