diff options
Diffstat (limited to 'src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc')
-rw-r--r-- | src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc index 6902a9d659..d6ad928bf7 100644 --- a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc @@ -1,6 +1,6 @@ /* - Copyright (c) 2013, Ford Motor Company + Copyright (c) 2017, Ford Motor Company All rights reserved. Redistribution and use in source and binary forms, with or without @@ -134,7 +134,7 @@ void UnsubscribeVehicleDataRequest::Run() { if (is_key_enabled) { ++items_to_unsubscribe; - VehicleDataType key_type = it->second; + mobile_apis::VehicleDataType::eType key_type = it->second; if (!app->IsSubscribedToIVI(key_type)) { ++unsubscribed_items; vi_already_unsubscribed_by_this_app_.insert(key_type); @@ -201,16 +201,14 @@ void UnsubscribeVehicleDataRequest::Run() { } if (is_everything_already_unsubscribed) { - mobile_apis::Result::eType result_code = - vi_already_unsubscribed_by_this_app_.size() - ? mobile_apis::Result::IGNORED - : mobile_apis::Result::SUCCESS; - - const char* info = vi_already_unsubscribed_by_this_app_.size() - ? "Already subscribed on some provided VehicleData." - : NULL; - - SendResponse(true, result_code, info, &response_params); + if (!vi_already_unsubscribed_by_this_app_.empty()) { + SendResponse(false, + mobile_apis::Result::IGNORED, + "Some provided VehicleData was not subscribed.", + &response_params); + } else { + SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params); + } return; } @@ -236,6 +234,7 @@ void UnsubscribeVehicleDataRequest::Run() { ++it) SendHMIRequest(it->func_id, &msg_params, true); #else + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData, &msg_params, true); @@ -252,6 +251,15 @@ void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { LOG4CXX_ERROR(logger_, "Received unknown event."); return; } + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); + + ApplicationSharedPtr app = + application_manager_.application(CommandRequestImpl::connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer."); + return; + } #ifdef HMI_DBUS_API for (HmiRequests::iterator it = hmi_requests_.begin(); @@ -308,7 +316,7 @@ void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { } SendResponse(any_arg_success, status, NULL, &response_params); if (true == any_arg_success) { - UpdateHash(); + app->UpdateHash(); } } #else @@ -344,11 +352,17 @@ void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { response_info.empty() ? NULL : response_info.c_str(), &(message[strings::msg_params])); if (result) { - UpdateHash(); + application_manager_.TerminateRequest( + connection_key(), correlation_id(), function_id()); } #endif // #ifdef HMI_DBUS_API } +bool UnsubscribeVehicleDataRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + struct SubscribedToIVIPredicate { int32_t vehicle_info_; SubscribedToIVIPredicate(int32_t vehicle_info) @@ -389,20 +403,5 @@ void UnsubscribeVehicleDataRequest::AddAlreadyUnsubscribedVI( } } -void UnsubscribeVehicleDataRequest::UpdateHash() const { - LOG4CXX_AUTO_TRACE(logger_); - ApplicationSharedPtr application = - application_manager_.application(connection_key()); - if (application) { - application->UpdateHash(); - } else { - LOG4CXX_ERROR(logger_, - "Application with connection_key = " << connection_key() - << " doesn't exist."); - } - application_manager_.TerminateRequest( - connection_key(), correlation_id(), function_id()); -} - } // namespace commands } // namespace application_manager |