summaryrefslogtreecommitdiff
path: root/src/components/policy/policy_external/src/policy_manager_impl.cc
diff options
context:
space:
mode:
authorTeodora Kireva <tkireva@luxoft.com>2017-02-03 18:44:02 +0200
committerIra Lytvynenko <ILytvynenko@luxoft.com>2017-04-10 18:20:04 +0300
commit69a14b99f68a03bb71857d0e619b547d3bc653c0 (patch)
tree51dddef248d4f297f36c35fe1717710625931419 /src/components/policy/policy_external/src/policy_manager_impl.cc
parent9e7a39af22c3587580cb2dcff44e6a9b6956d02c (diff)
downloadsdl_core-69a14b99f68a03bb71857d0e619b547d3bc653c0.tar.gz
Fix OnSystemRequest cycling urls refactoring
Required refactoring of the functionality that is responsible for sending different application URL on each OnSystemRequest. The logic was placed in OnSnapshotCreated method. Now it is separated on two methods - GetNextUpdateUrl - returns pair of policy application id and url from the Endpoints vector that potentially will be sent, IsUrlAppIdValid - checks if given policy application id is assigned to a registered application or it is the default id.
Diffstat (limited to 'src/components/policy/policy_external/src/policy_manager_impl.cc')
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc25
1 files changed, 24 insertions, 1 deletions
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 88d810ecc2..fa27c95607 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -66,7 +66,9 @@ PolicyManagerImpl::PolicyManagerImpl()
, cache_(new CacheManager)
, retry_sequence_timeout_(60)
, retry_sequence_index_(0)
- , ignition_check(true) {}
+ , ignition_check(true)
+ , retry_sequence_url_(0, 0) {
+}
PolicyManagerImpl::PolicyManagerImpl(bool in_memory)
: PolicyManager()
@@ -1190,6 +1192,27 @@ void PolicyManagerImpl::SetDecryptedCertificate(
cache_->SetDecryptedCertificate(certificate);
}
+AppIdURL PolicyManagerImpl::GetNextUpdateUrl(const EndpointUrls& urls) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ AppIdURL next_app_url;
+ uint32_t url = retry_sequence_url_.url;
+ uint32_t app = retry_sequence_url_.app;
+
+ if (url >= urls[app].url.size()) {
+ url = 0;
+ if (++app >= urls.size()) {
+ app = 0;
+ }
+ }
+
+ next_app_url = std::make_pair(urls[app].app_id, urls[app].url[url]);
+ retry_sequence_url_.url = url + 1;
+ retry_sequence_url_.app = app;
+
+ return next_app_url;
+}
+
/**
* @brief The CallStatusChange class notify update manager aboun new application
*/