diff options
author | AKalinich-Luxoft <AKalinich@luxoft.com> | 2017-09-20 13:41:16 +0300 |
---|---|---|
committer | Valerii <vmalkov@luxoft.com> | 2018-01-26 15:15:10 +0200 |
commit | 2c3fb437109db06bc91a9277cc011145b3735ca3 (patch) | |
tree | 920fbefff2e35d00f9f23340842ef7e6906045e6 | |
parent | f935f7f449d8647498c5a6bd30c8d8cbf7b41ab5 (diff) | |
download | sdl_core-2c3fb437109db06bc91a9277cc011145b3735ca3.tar.gz |
Update UnsubscribeWayPoints RPC according to proposal
-rw-r--r-- | src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc index dc3404c022..ca5c1f1c65 100644 --- a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc @@ -25,12 +25,25 @@ void UnSubscribeWayPointsRequest::Run() { return; } - if (!application_manager_.IsAppSubscribedForWayPoints(app)) { + if (!CheckHMIInterfaceAvailability(HmiInterfaces::HMI_INTERFACE_Navigation)) { + LOG4CXX_ERROR(logger_, "Navi interface is not available"); + SendResponse(false, + mobile_apis::Result::UNSUPPORTED_RESOURCE, + "Navi is not supported by system"); + return; + } + + if (!application_manager_.IsAppSubscribedForWayPoints(app->app_id())) { SendResponse(false, mobile_apis::Result::IGNORED); return; } - StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); + if (application_manager_.GetAppsSubscribedForWayPoints().size() > 1) { + application_manager_.UnsubscribeAppFromWayPoints(app->app_id()); + SendResponse(true, mobile_apis::Result::SUCCESS); + return; + } + SendHMIRequest( hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints, NULL, true); } @@ -51,7 +64,11 @@ void UnSubscribeWayPointsRequest::on_event(const event_engine::Event& event) { const bool result = PrepareResultForMobileResponse( result_code, HmiInterfaces::HMI_INTERFACE_Navigation); if (result) { - application_manager_.UnsubscribeAppFromWayPoints(app); + application_manager_.UnsubscribeAppFromWayPoints(app->app_id()); + if (application_manager_.GetAppsSubscribedForWayPoints().empty()) { + application_manager_.SetWaypointsInfo( + smart_objects::SmartObject(smart_objects::SmartType_Null)); + } } SendResponse(result, MessageHelper::HMIToMobileResult(result_code), |