summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackLivio <jack@livio.io>2018-11-27 14:04:26 -0500
committerJackLivio <jack@livio.io>2018-11-27 14:04:26 -0500
commit848139e3ee4b764def96cc8e41bfb7c45a1161e6 (patch)
tree98ca02ca7c30784f68599450a8459f6e58f358b5
parenta6c0deddae788352f4b0e7bf238b37db43386489 (diff)
parenta751881e1f4e04a6af24552be70d691d8076c933 (diff)
downloadsdl_core-848139e3ee4b764def96cc8e41bfb7c45a1161e6.tar.gz
Merge remote-tracking branch 'origin/feature/cloud_app_transport' into feature/cloud_app_connection_flow
-rw-r--r--src/components/application_manager/include/application_manager/policies/policy_handler.h21
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc2
-rw-r--r--src/components/application_manager/src/policies/policy_handler.cc36
-rw-r--r--src/components/include/application_manager/policies/policy_handler_interface.h9
-rw-r--r--src/components/include/policy/policy_external/policy/policy_manager.h15
-rw-r--r--src/components/include/policy/policy_regular/policy/policy_manager.h16
-rw-r--r--src/components/include/test/application_manager/policies/mock_policy_handler_interface.h15
-rw-r--r--src/components/include/test/policy/policy_external/policy/mock_cache_manager.h16
-rw-r--r--src/components/include/test/policy/policy_external/policy/mock_policy_manager.h16
-rw-r--r--src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h16
-rw-r--r--src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h16
-rw-r--r--src/components/interfaces/MOBILE_API.xml6
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager.h28
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager_interface.h17
-rw-r--r--src/components/policy/policy_external/include/policy/policy_manager_impl.h26
-rw-r--r--src/components/policy/policy_external/src/cache_manager.cc31
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc20
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager.h28
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager_interface.h17
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_manager_impl.h27
-rw-r--r--src/components/policy/policy_regular/src/cache_manager.cc27
-rw-r--r--src/components/policy/policy_regular/src/policy_manager_impl.cc20
22 files changed, 279 insertions, 146 deletions
diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h
index a612c263ca..8ee5ff64f6 100644
--- a/src/components/application_manager/include/application_manager/policies/policy_handler.h
+++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h
@@ -419,26 +419,25 @@ class PolicyHandler : public PolicyHandlerInterface,
* @brief Get cloud app policy information, all fields that aren't set for a
* given app will be filled with empty strings
* @param policy_app_id Unique application id
+ * @param enabled Whether or not the app is enabled
* @param endpoint Filled with the endpoint used to connect to the cloud
* application
* @param certificate Filled with the certificate used to for creating a
- * secure
- * connection to the cloud application
+ * secure connection to the cloud application
* @param auth_token Filled with the token used for authentication when
* reconnecting to the cloud app
* @param cloud_transport_type Filled with the transport type used by the
* cloud application (ex. "WSS")
- * @param cloud_transport_type Filled with the hybrid app preference for the
+ * @param hybrid_app_preference Filled with the hybrid app preference for the
* cloud application set by the user
- * @return true if the cloud app is enabled, false otherwise
*/
- const bool GetCloudAppParameters(
- const std::string& policy_app_id,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference) const OVERRIDE;
+ void GetCloudAppParameters(const std::string& policy_app_id,
+ bool& enabled,
+ std::string& endpoint,
+ std::string& certificate,
+ std::string& auth_token,
+ std::string& cloud_transport_type,
+ std::string& hybrid_app_preference) const OVERRIDE;
/**
* @brief Callback for when a SetCloudAppProperties message is received from a
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc
index ca5a46e3dc..0beb7631c7 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc
@@ -18,6 +18,7 @@ SetCloudAppPropertiesRequest::SetCloudAppPropertiesRequest(
policy_handler) {}
SetCloudAppPropertiesRequest::~SetCloudAppPropertiesRequest() {}
+
void SetCloudAppPropertiesRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
ApplicationSharedPtr app = application_manager_.application(connection_key());
@@ -69,6 +70,7 @@ void SetCloudAppPropertiesRequest::Run() {
}
policy_handler_.OnSetCloudAppProperties(cloud_app_properties);
+
SendResponse(true, mobile_apis::Result::SUCCESS);
}
diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc
index 8c6de5482c..c603659353 100644
--- a/src/components/application_manager/src/policies/policy_handler.cc
+++ b/src/components/application_manager/src/policies/policy_handler.cc
@@ -1852,36 +1852,41 @@ void PolicyHandler::GetEnabledCloudApps(
policy_manager_->GetEnabledCloudApps(enabled_apps);
}
-const bool PolicyHandler::GetCloudAppParameters(
+void PolicyHandler::GetCloudAppParameters(
const std::string& policy_app_id,
+ bool& enabled,
std::string& endpoint,
std::string& certificate,
std::string& auth_token,
std::string& cloud_transport_type,
std::string& hybrid_app_preference) const {
- POLICY_LIB_CHECK(false);
- return policy_manager_->GetCloudAppParameters(policy_app_id,
- endpoint,
- certificate,
- auth_token,
- cloud_transport_type,
- hybrid_app_preference);
+ POLICY_LIB_CHECK_VOID();
+ policy_manager_->GetCloudAppParameters(policy_app_id,
+ enabled,
+ endpoint,
+ certificate,
+ auth_token,
+ cloud_transport_type,
+ hybrid_app_preference);
}
const bool PolicyHandler::CheckCloudAppEnabled(
const std::string& policy_app_id) const {
POLICY_LIB_CHECK(false);
+ bool enabled = false;
std::string endpoint;
std::string auth_token;
std::string certificate;
std::string cloud_transport_type;
std::string hybrid_app_preference;
- return policy_manager_->GetCloudAppParameters(policy_app_id,
- endpoint,
- certificate,
- auth_token,
- cloud_transport_type,
- hybrid_app_preference);
+ policy_manager_->GetCloudAppParameters(policy_app_id,
+ enabled,
+ endpoint,
+ certificate,
+ auth_token,
+ cloud_transport_type,
+ hybrid_app_preference);
+ return enabled;
}
void PolicyHandler::OnSetCloudAppProperties(
@@ -1901,6 +1906,9 @@ void PolicyHandler::OnSetCloudAppProperties(
return;
}
std::string policy_app_id(msg_params[strings::app_id].asString());
+
+ policy_manager_->InitCloudApp(policy_app_id);
+
if (msg_params.keyExists(strings::enabled)) {
policy_manager_->SetCloudAppEnabled(policy_app_id,
msg_params[strings::enabled].asBool());
diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h
index ddeb1da8f7..8c8a12ced3 100644
--- a/src/components/include/application_manager/policies/policy_handler_interface.h
+++ b/src/components/include/application_manager/policies/policy_handler_interface.h
@@ -459,7 +459,8 @@ class PolicyHandlerInterface {
* @brief Get cloud app policy information, all fields that aren't set for a
* given app will be filled with empty strings
* @param policy_app_id Unique application id
- * @param endpoint Filled the endpoint used to connect to the cloud
+ * @param enabled Whether or not the app is enabled
+ * @param endpoint Filled with the endpoint used to connect to the cloud
* application
* @param certificate Filled with the certificate used to for creating a
* secure connection to the cloud application
@@ -467,12 +468,12 @@ class PolicyHandlerInterface {
* reconnecting to the cloud app
* @param cloud_transport_type Filled with the transport type used by the
* cloud application (ex. "WSS")
- * @param cloud_transport_type Filled with the hybrid app preference for the
+ * @param hybrid_app_preference Filled with the hybrid app preference for the
* cloud application set by the user
- * @return true if the cloud app is enabled, false otherwise
*/
- virtual const bool GetCloudAppParameters(
+ virtual void GetCloudAppParameters(
const std::string& policy_app_id,
+ bool& enabled,
std::string& endpoint,
std::string& certificate,
std::string& auth_token,
diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h
index b0fac8eae9..92c0305279 100644
--- a/src/components/include/policy/policy_external/policy/policy_manager.h
+++ b/src/components/include/policy/policy_external/policy/policy_manager.h
@@ -534,7 +534,8 @@ class PolicyManager : public usage_statistics::StatisticsManager {
* @brief Get cloud app policy information, all fields that aren't set for a
* given app will be filled with empty strings
* @param policy_app_id Unique application id
- * @param endpoint Filled the endpoint used to connect to the cloud
+ * @param enabled Whether or not the app is enabled
+ * @param endpoint Filled with the endpoint used to connect to the cloud
* application
* @param certificate Filled with the certificate used to for creating a
* secure connection to the cloud application
@@ -542,12 +543,12 @@ class PolicyManager : public usage_statistics::StatisticsManager {
* reconnecting to the cloud app
* @param cloud_transport_type Filled with the transport type used by the
* cloud application (ex. "WSS")
- * @param cloud_transport_type Filled with the hybrid app preference for the
+ * @param hybrid_app_preference Filled with the hybrid app preference for the
* cloud application set by the user
- * @return true if the cloud app is enabled, false otherwise
*/
- virtual const bool GetCloudAppParameters(
+ virtual void GetCloudAppParameters(
const std::string& policy_app_id,
+ bool& enabled,
std::string& endpoint,
std::string& certificate,
std::string& auth_token,
@@ -555,6 +556,12 @@ class PolicyManager : public usage_statistics::StatisticsManager {
std::string& hybrid_app_preference) const = 0;
/**
+ * @ brief Initialize new cloud app in the policy table
+ * @ param policy_app_id Application ID
+ */
+ 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/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h
index 1f0f520077..b2d48585f4 100644
--- a/src/components/include/policy/policy_regular/policy/policy_manager.h
+++ b/src/components/include/policy/policy_regular/policy/policy_manager.h
@@ -514,7 +514,8 @@ class PolicyManager : public usage_statistics::StatisticsManager {
* @brief Get cloud app policy information, all fields that aren't set for a
* given app will be filled with empty strings
* @param policy_app_id Unique application id
- * @param endpoint Filled the endpoint used to connect to the cloud
+ * @param enabled Whether or not the app is enabled
+ * @param endpoint Filled with the endpoint used to connect to the cloud
* application
* @param certificate Filled with the certificate used to for creating a
* secure connection to the cloud application
@@ -522,12 +523,12 @@ class PolicyManager : public usage_statistics::StatisticsManager {
* reconnecting to the cloud app
* @param cloud_transport_type Filled with the transport type used by the
* cloud application (ex. "WSS")
- * @param cloud_transport_type Filled with the hybrid app preference for the
+ * @param hybrid_app_preference Filled with the hybrid app preference for the
* cloud application set by the user
- * @return true if the cloud app is enabled, false otherwise
*/
- virtual const bool GetCloudAppParameters(
+ virtual void GetCloudAppParameters(
const std::string& policy_app_id,
+ bool& enabled,
std::string& endpoint,
std::string& certificate,
std::string& auth_token,
@@ -535,6 +536,13 @@ class PolicyManager : public usage_statistics::StatisticsManager {
std::string& hybrid_app_preference) const = 0;
/**
+ * @ brief Initialize new cloud app in the policy table
+ * @ param policy_app_id Application ID
+ */
+
+ 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/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h
index cea36082c8..02a0d73086 100644
--- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h
+++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h
@@ -217,13 +217,14 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface {
void(std::vector<std::string>& enabled_apps));
MOCK_CONST_METHOD1(CheckCloudAppEnabled,
const bool(const std::string& policy_app_id));
- MOCK_CONST_METHOD6(GetCloudAppParameters,
- const bool(const std::string& policy_app_id,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference));
+ MOCK_CONST_METHOD7(GetCloudAppParameters,
+ void(const std::string& policy_app_id,
+ bool& enabled,
+ std::string& endpoint,
+ std::string& certificate,
+ std::string& auth_token,
+ std::string& cloud_transport_type,
+ std::string& hybrid_app_preference));
MOCK_METHOD1(OnSetCloudAppProperties,
void(const smart_objects::SmartObject& message));
diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h
index 03e0882129..da2b4cc2a1 100644
--- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h
+++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h
@@ -78,13 +78,15 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface {
MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo());
MOCK_CONST_METHOD1(GetEnabledCloudApps,
void(std::vector<std::string>& enabled_apps));
- MOCK_CONST_METHOD6(GetCloudAppParameters,
- const bool(const std::string& policy_app_id,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference));
+ MOCK_CONST_METHOD7(GetCloudAppParameters,
+ void(const std::string& policy_app_id,
+ bool& enabled,
+ std::string& endpoint,
+ std::string& certificate,
+ std::string& auth_token,
+ std::string& cloud_transport_type,
+ std::string& hybrid_app_preference));
+ MOCK_METHOD1(InitCloudApp, void(const std::string& policy_app_id));
MOCK_METHOD2(SetCloudAppEnabled,
void(const std::string& policy_app_id, const bool enabled));
MOCK_METHOD2(SetAppAuthToken,
diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
index 70dab8e99a..72dcb147e3 100644
--- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
+++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
@@ -186,13 +186,15 @@ class MockPolicyManager : public PolicyManager {
MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo());
MOCK_CONST_METHOD1(GetEnabledCloudApps,
void(std::vector<std::string>& enabled_apps));
- MOCK_CONST_METHOD6(GetCloudAppParameters,
- const bool(const std::string& policy_app_id,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference));
+ MOCK_CONST_METHOD7(GetCloudAppParameters,
+ void(const std::string& policy_app_id,
+ bool& enabled,
+ std::string& endpoint,
+ std::string& certificate,
+ std::string& auth_token,
+ std::string& cloud_transport_type,
+ std::string& hybrid_app_preference));
+ MOCK_METHOD1(InitCloudApp, void(const std::string& policy_app_id));
MOCK_METHOD2(SetCloudAppEnabled,
void(const std::string& policy_app_id, const bool enabled));
MOCK_METHOD2(SetAppAuthToken,
diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
index 7ac94d278d..24fe9b2393 100644
--- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
+++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
@@ -65,13 +65,15 @@ class MockCacheManagerInterface : public CacheManagerInterface {
MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo());
MOCK_CONST_METHOD1(GetEnabledCloudApps,
void(std::vector<std::string>& enabled_apps));
- MOCK_CONST_METHOD6(GetCloudAppParameters,
- const bool(const std::string& policy_app_id,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference));
+ MOCK_CONST_METHOD7(GetCloudAppParameters,
+ void(const std::string& policy_app_id,
+ bool& enabled,
+ std::string& endpoint,
+ std::string& certificate,
+ std::string& auth_token,
+ std::string& cloud_transport_type,
+ std::string& hybrid_app_preference));
+ MOCK_METHOD1(InitCloudApp, void(const std::string& policy_app_id));
MOCK_METHOD2(SetCloudAppEnabled,
void(const std::string& policy_app_id, const bool enabled));
MOCK_METHOD2(SetAppAuthToken,
diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h
index 7441701a34..a5ce488e1a 100644
--- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h
+++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h
@@ -183,13 +183,15 @@ class MockPolicyManager : public PolicyManager {
MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo());
MOCK_CONST_METHOD1(GetEnabledCloudApps,
void(std::vector<std::string>& enabled_apps));
- MOCK_CONST_METHOD6(GetCloudAppParameters,
- const bool(const std::string& policy_app_id,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference));
+ MOCK_CONST_METHOD7(GetCloudAppParameters,
+ void(const std::string& policy_app_id,
+ bool& enabled,
+ std::string& endpoint,
+ std::string& certificate,
+ std::string& auth_token,
+ std::string& cloud_transport_type,
+ std::string& hybrid_app_preference));
+ MOCK_METHOD1(InitCloudApp, void(const std::string& policy_app_id));
MOCK_METHOD2(SetCloudAppEnabled,
void(const std::string& policy_app_id, const bool enabled));
MOCK_METHOD2(SetAppAuthToken,
diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml
index 1707f65bad..714399bce6 100644
--- a/src/components/interfaces/MOBILE_API.xml
+++ b/src/components/interfaces/MOBILE_API.xml
@@ -547,9 +547,9 @@
<enum name="HybridAppPreference" since="5.1">
<description>Enumeration for the user's preference of which app type to use when both are available</description>
- <element name = "MOBILE" />
- <element name = "CLOUD" />
- <element name = "BOTH" />
+ <element name="MOBILE" />
+ <element name="CLOUD" />
+ <element name="BOTH" />
</enum>
<enum name="ButtonName" since="1.0">
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 7660eb2df9..3344b149e4 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager.h
@@ -170,7 +170,8 @@ class CacheManager : public CacheManagerInterface {
* @brief Get cloud app policy information, all fields that aren't set for a
* given app will be filled with empty strings
* @param policy_app_id Unique application id
- * @param endpoint Filled the endpoint used to connect to the cloud
+ * @param enabled Whether or not the app is enabled
+ * @param endpoint Filled with the endpoint used to connect to the cloud
* application
* @param certificate Filled with the certificate used to for creating a
* secure connection to the cloud application
@@ -178,17 +179,24 @@ class CacheManager : public CacheManagerInterface {
* reconnecting to the cloud app
* @param cloud_transport_type Filled with the transport type used by the
* cloud application (ex. "WSS")
- * @param cloud_transport_type Filled with the hybrid app preference for the
+ * @param hybrid_app_preference Filled with the hybrid app preference for the
* cloud application set by the user
- * @return true if the cloud app is enabled, false otherwise
*/
- virtual const bool GetCloudAppParameters(
- const std::string& policy_app_id,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference) const;
+ virtual void GetCloudAppParameters(const std::string& policy_app_id,
+ bool& enabled,
+ std::string& endpoint,
+ std::string& certificate,
+ std::string& auth_token,
+ std::string& cloud_transport_type,
+ 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
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 79d6f4e731..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
@@ -177,7 +177,8 @@ class CacheManagerInterface {
* @brief Get cloud app policy information, all fields that aren't set for a
* given app will be filled with empty strings
* @param policy_app_id Unique application id
- * @param endpoint Filled the endpoint used to connect to the cloud
+ * @param enabled Whether or not the app is enabled
+ * @param endpoint Filled with the endpoint used to connect to the cloud
* application
* @param certificate Filled with the certificate used to for creating a
* secure connection to the cloud application
@@ -185,12 +186,12 @@ class CacheManagerInterface {
* reconnecting to the cloud app
* @param cloud_transport_type Filled with the transport type used by the
* cloud application (ex. "WSS")
- * @param cloud_transport_type Filled with the hybrid app preference for the
+ * @param hybrid_app_preference Filled with the hybrid app preference for the
* cloud application set by the user
- * @return true if the cloud app is enabled, false otherwise
*/
- virtual const bool GetCloudAppParameters(
+ virtual void GetCloudAppParameters(
const std::string& policy_app_id,
+ bool& enabled,
std::string& endpoint,
std::string& certificate,
std::string& auth_token,
@@ -198,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 778892df13..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
@@ -582,7 +582,8 @@ class PolicyManagerImpl : public PolicyManager {
* @brief Get cloud app policy information, all fields that aren't set for a
* given app will be filled with empty strings
* @param policy_app_id Unique application id
- * @param endpoint Filled the endpoint used to connect to the cloud
+ * @param enabled Whether or not the app is enabled
+ * @param endpoint Filled with the endpoint used to connect to the cloud
* application
* @param certificate Filled with the certificate used to for creating a
* secure connection to the cloud application
@@ -590,17 +591,22 @@ class PolicyManagerImpl : public PolicyManager {
* reconnecting to the cloud app
* @param cloud_transport_type Filled with the transport type used by the
* cloud application (ex. "WSS")
- * @param cloud_transport_type Filled with the hybrid app preference for the
+ * @param hybrid_app_preference Filled with the hybrid app preference for the
* cloud application set by the user
- * @return true if the cloud app is enabled, false otherwise
*/
- const bool GetCloudAppParameters(
- const std::string& policy_app_id,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference) const OVERRIDE;
+ void GetCloudAppParameters(const std::string& policy_app_id,
+ bool& enabled,
+ std::string& endpoint,
+ std::string& certificate,
+ std::string& auth_token,
+ std::string& cloud_transport_type,
+ 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
diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc
index 116b315755..8cec6ef91c 100644
--- a/src/components/policy/policy_external/src/cache_manager.cc
+++ b/src/components/policy/policy_external/src/cache_manager.cc
@@ -1403,8 +1403,9 @@ void CacheManager::GetEnabledCloudApps(
}
}
-const bool CacheManager::GetCloudAppParameters(
+void CacheManager::GetCloudAppParameters(
const std::string& policy_app_id,
+ bool& enabled,
std::string& endpoint,
std::string& certificate,
std::string& auth_token,
@@ -1418,21 +1419,39 @@ const bool CacheManager::GetCloudAppParameters(
auto app_policy = (*policy_iter).second;
endpoint = app_policy.endpoint.is_initialized() ? *app_policy.endpoint
: std::string();
- certificate = app_policy.certificate.is_initialized()
- ? *app_policy.certificate
- : std::string();
auth_token = app_policy.auth_token.is_initialized() ? *app_policy.auth_token
: std::string();
cloud_transport_type = app_policy.cloud_transport_type.is_initialized()
? *app_policy.cloud_transport_type
: std::string();
+ certificate = app_policy.certificate.is_initialized()
+ ? *app_policy.certificate
+ : std::string();
hybrid_app_preference =
app_policy.hybrid_app_preference.is_initialized()
? EnumToJsonString(*app_policy.hybrid_app_preference)
: std::string();
- return app_policy.enabled.is_initialized() && *app_policy.enabled;
+ enabled = app_policy.enabled.is_initialized() && *app_policy.enabled;
}
- return false;
+}
+
+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,
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 31cc212254..0844edd8eb 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -730,19 +730,25 @@ void PolicyManagerImpl::GetEnabledCloudApps(
cache_->GetEnabledCloudApps(enabled_apps);
}
-const bool PolicyManagerImpl::GetCloudAppParameters(
+void PolicyManagerImpl::GetCloudAppParameters(
const std::string& policy_app_id,
+ bool& enabled,
std::string& endpoint,
std::string& certificate,
std::string& auth_token,
std::string& cloud_transport_type,
std::string& hybrid_app_preference) const {
- return cache_->GetCloudAppParameters(policy_app_id,
- endpoint,
- certificate,
- auth_token,
- cloud_transport_type,
- hybrid_app_preference);
+ cache_->GetCloudAppParameters(policy_app_id,
+ enabled,
+ endpoint,
+ certificate,
+ auth_token,
+ cloud_transport_type,
+ 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,
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 39f9cc73cd..8c8f0c55c6 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager.h
@@ -158,7 +158,8 @@ class CacheManager : public CacheManagerInterface {
* @brief Get cloud app policy information, all fields that aren't set for a
* given app will be filled with empty strings
* @param policy_app_id Unique application id
- * @param endpoint Filled the endpoint used to connect to the cloud
+ * @param enabled Whether or not the app is enabled
+ * @param endpoint Filled with the endpoint used to connect to the cloud
* application
* @param certificate Filled with the certificate used to for creating a
* secure connection to the cloud application
@@ -166,17 +167,24 @@ class CacheManager : public CacheManagerInterface {
* reconnecting to the cloud app
* @param cloud_transport_type Filled with the transport type used by the
* cloud application (ex. "WSS")
- * @param cloud_transport_type Filled with the hybrid app preference for the
+ * @param hybrid_app_preference Filled with the hybrid app preference for the
* cloud application set by the user
- * @return true if the cloud app is enabled, false otherwise
*/
- virtual const bool GetCloudAppParameters(
- const std::string& policy_app_id,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference) const;
+ virtual void GetCloudAppParameters(const std::string& policy_app_id,
+ bool& enabled,
+ std::string& endpoint,
+ std::string& certificate,
+ std::string& auth_token,
+ std::string& cloud_transport_type,
+ 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
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 3b2b10d0bc..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
@@ -163,7 +163,8 @@ class CacheManagerInterface {
* @brief Get cloud app policy information, all fields that aren't set for a
* given app will be filled with empty strings
* @param policy_app_id Unique application id
- * @param endpoint Filled the endpoint used to connect to the cloud
+ * @param enabled Whether or not the app is enabled
+ * @param endpoint Filled with the endpoint used to connect to the cloud
* application
* @param certificate Filled with the certificate used to for creating a
* secure connection to the cloud application
@@ -171,12 +172,12 @@ class CacheManagerInterface {
* reconnecting to the cloud app
* @param cloud_transport_type Filled with the transport type used by the
* cloud application (ex. "WSS")
- * @param cloud_transport_type Filled with the hybrid app preference for the
+ * @param hybrid_app_preference Filled with the hybrid app preference for the
* cloud application set by the user
- * @return true if the cloud app is enabled, false otherwise
*/
- virtual const bool GetCloudAppParameters(
+ virtual void GetCloudAppParameters(
const std::string& policy_app_id,
+ bool& enabled,
std::string& endpoint,
std::string& certificate,
std::string& auth_token,
@@ -184,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 311ced31d2..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
@@ -576,7 +576,8 @@ class PolicyManagerImpl : public PolicyManager {
* @brief Get cloud app policy information, all fields that aren't set for a
* given app will be filled with empty strings
* @param policy_app_id Unique application id
- * @param endpoint Filled the endpoint used to connect to the cloud
+ * @param enabled Whether or not the app is enabled
+ * @param endpoint Filled with the endpoint used to connect to the cloud
* application
* @param certificate Filled with the certificate used to for creating a
* secure connection to the cloud application
@@ -584,17 +585,23 @@ class PolicyManagerImpl : public PolicyManager {
* reconnecting to the cloud app
* @param cloud_transport_type Filled with the transport type used by the
* cloud application (ex. "WSS")
- * @param cloud_transport_type Filled with the hybrid app preference for the
+ * @param hybrid_app_preference Filled with the hybrid app preference for the
* cloud application set by the user
- * @return true if the cloud app is enabled, false otherwise
*/
- const bool GetCloudAppParameters(
- const std::string& policy_app_id,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference) const OVERRIDE;
+ void GetCloudAppParameters(const std::string& policy_app_id,
+ bool& enabled,
+ std::string& endpoint,
+ std::string& certificate,
+ std::string& auth_token,
+ std::string& cloud_transport_type,
+ 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
diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc
index 9292c389b9..ca61a338f1 100644
--- a/src/components/policy/policy_regular/src/cache_manager.cc
+++ b/src/components/policy/policy_regular/src/cache_manager.cc
@@ -696,8 +696,9 @@ void CacheManager::GetEnabledCloudApps(
}
}
-const bool CacheManager::GetCloudAppParameters(
+void CacheManager::GetCloudAppParameters(
const std::string& policy_app_id,
+ bool& enabled,
std::string& endpoint,
std::string& certificate,
std::string& auth_token,
@@ -723,9 +724,29 @@ const bool CacheManager::GetCloudAppParameters(
app_policy.hybrid_app_preference.is_initialized()
? EnumToJsonString(*app_policy.hybrid_app_preference)
: std::string();
- return app_policy.enabled.is_initialized() && *app_policy.enabled;
+ enabled = app_policy.enabled.is_initialized() && *app_policy.enabled;
}
- return false;
+}
+
+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,
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 5aa29fc896..9b2392a015 100644
--- a/src/components/policy/policy_regular/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc
@@ -549,19 +549,25 @@ void PolicyManagerImpl::GetEnabledCloudApps(
cache_->GetEnabledCloudApps(enabled_apps);
}
-const bool PolicyManagerImpl::GetCloudAppParameters(
+void PolicyManagerImpl::GetCloudAppParameters(
const std::string& policy_app_id,
+ bool& enabled,
std::string& endpoint,
std::string& certificate,
std::string& auth_token,
std::string& cloud_transport_type,
std::string& hybrid_app_preference) const {
- return cache_->GetCloudAppParameters(policy_app_id,
- endpoint,
- certificate,
- auth_token,
- cloud_transport_type,
- hybrid_app_preference);
+ cache_->GetCloudAppParameters(policy_app_id,
+ enabled,
+ endpoint,
+ certificate,
+ auth_token,
+ cloud_transport_type,
+ 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,