summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Levchenko (GitHub) <slevchenko.work@gmail.com>2017-05-12 14:42:20 +0300
committerSergey Levchenko (GitHub) <slevchenko.work@gmail.com>2017-05-12 14:59:39 +0300
commit66ac0f3f92435fd884fd68e5de1974266db956f2 (patch)
treee5c4a83a6c06dd51a453268ed8ee87c4dde3f6b6
parentfc781b520fe1a2a4680b97d3d02646681df8c0d1 (diff)
downloadsdl_core-66ac0f3f92435fd884fd68e5de1974266db956f2.tar.gz
Fix SDL does not return URLs in response of GetURLs RPC
Fixed absence of URLs in response of GetURLs RPC, which been caused due to wrong URLs processing.
-rw-r--r--src/components/application_manager/src/commands/hmi/get_urls.cc36
1 files changed, 15 insertions, 21 deletions
diff --git a/src/components/application_manager/src/commands/hmi/get_urls.cc b/src/components/application_manager/src/commands/hmi/get_urls.cc
index e7c5244ddc..482c7d5ef1 100644
--- a/src/components/application_manager/src/commands/hmi/get_urls.cc
+++ b/src/components/application_manager/src/commands/hmi/get_urls.cc
@@ -34,6 +34,7 @@
#include "application_manager/message.h"
#include "application_manager/application_manager.h"
#include "application_manager/policies/policy_handler.h"
+#include "utils/helpers.h"
namespace application_manager {
namespace commands {
@@ -190,32 +191,25 @@ void GetUrls::ProcessPolicyServiceURLs(const policy::EndpointUrls& endpoints) {
object[msg_params][hmi_response::urls] = SmartObject(SmartType_Array);
SmartObject& urls = object[msg_params][hmi_response::urls];
const std::string mobile_app_id = app->policy_app_id();
- std::string default_url = "URL is not found";
- // Will use only one URL for particular application if it will be found
- // Otherwise URL from default section will used
- SmartObject service_info = SmartObject(SmartType_Map);
+ size_t index = 0;
+ for (size_t i = 0; i < endpoints.size(); ++i) {
+ using namespace helpers;
- for (size_t e = 0; e < endpoints.size(); ++e) {
- if (mobile_app_id == endpoints[e].app_id) {
- if (endpoints[e].url.size()) {
- service_info[url] = endpoints[e].url[0];
- SendResponseToHMI(Common_Result::SUCCESS);
- return;
- }
- }
- if (policy::kDefaultId == endpoints[e].app_id) {
- if (endpoints[e].url.size()) {
- default_url = endpoints[e].url[0];
+ const bool to_add = Compare<std::string, EQ, ONE>(
+ endpoints[i].app_id, mobile_app_id, policy::kDefaultId);
+ const bool is_default = policy::kDefaultId == endpoints[i].app_id;
+
+ if (to_add) {
+ for (size_t k = 0; k < endpoints[i].url.size(); ++k) {
+ if (!is_default) {
+ urls[index][strings::app_id] = app_id_to_send_to;
+ }
+ urls[index][strings::url] = endpoints[i].url[k];
+ ++index;
}
}
}
-
- service_info[strings::app_id] = app->app_id();
- service_info[strings::url] = default_url;
- urls[0] = service_info;
- // TODO(AOleynik): Issue with absent policy_app_id. Need to fix later on.
- // Possibly related to smart schema
SendResponseToHMI(Common_Result::SUCCESS);
return;
}