diff options
author | Andriy Byzhynar <AByzhynar@luxoft.com> | 2017-11-02 16:59:03 +0200 |
---|---|---|
committer | Andriy Byzhynar <AByzhynar@luxoft.com> | 2018-01-26 11:38:09 +0200 |
commit | 59515fd84f0a0337a6d6724b00d95060dc9d3a5b (patch) | |
tree | d42e16e96988b4eaa2e2c09a60436fced4da4fdb | |
parent | 311f3959c94f9f1b9d50aad0fd1b8f181bc154e8 (diff) | |
download | sdl_core-59515fd84f0a0337a6d6724b00d95060dc9d3a5b.tar.gz |
Fix response generation for DeleteFile & PutFile RPCs
Fixed response generation for DeleteFile & PutFile RPCs
There was added mobile responses check according to smart schema in
latest changes of SDL.
Due to these changes we need to generate correct responses before this
check.
Also responses with all result codes(even not successful) must match
Mobile API. Therefore space_available parameter was added to all these
responses as it is mandatory parameter of DeleteFile & PutFile
responses.
3 files changed, 41 insertions, 11 deletions
diff --git a/src/components/application_manager/src/commands/mobile/delete_file_request.cc b/src/components/application_manager/src/commands/mobile/delete_file_request.cc index 984c7a1725..92e9a169f7 100644 --- a/src/components/application_manager/src/commands/mobile/delete_file_request.cc +++ b/src/components/application_manager/src/commands/mobile/delete_file_request.cc @@ -53,9 +53,18 @@ void DeleteFileRequest::Run() { ApplicationSharedPtr application = application_manager_.application(connection_key()); + smart_objects::SmartObject response_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + response_params[strings::space_available] = + static_cast<uint32_t>(application->GetAvailableDiskSpace()); + if (!application) { - SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, + mobile_apis::Result::APPLICATION_NOT_REGISTERED, + "Application is not registered", + &response_params); return; } @@ -66,7 +75,10 @@ void DeleteFileRequest::Run() { // DeleteFile request is limited by the configuration profile LOG4CXX_ERROR(logger_, "Too many requests from the app with HMILevel HMI_NONE "); - SendResponse(false, mobile_apis::Result::REJECTED); + SendResponse(false, + mobile_apis::Result::REJECTED, + "Too many requests from the app with HMILevel HMI_NONE", + &response_params); return; } @@ -76,7 +88,10 @@ void DeleteFileRequest::Run() { if (!file_system::IsFileNameValid(sync_file_name)) { const std::string err_msg = "Sync file name contains forbidden symbols."; LOG4CXX_ERROR(logger_, err_msg); - SendResponse(false, mobile_apis::Result::INVALID_DATA, err_msg.c_str()); + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + err_msg.c_str(), + &response_params); return; } @@ -95,16 +110,28 @@ void DeleteFileRequest::Run() { application->DeleteFile(full_file_path); application->increment_delete_file_in_none_count(); - SendResponse(true, mobile_apis::Result::SUCCESS); + response_params[strings::space_available] = + static_cast<uint32_t>(application->GetAvailableDiskSpace()); + SendResponse(true, + mobile_apis::Result::SUCCESS, + "File successfully deleted", + &response_params); } else { - SendResponse(false, mobile_apis::Result::GENERIC_ERROR); + SendResponse(false, + mobile_apis::Result::GENERIC_ERROR, + "File not deleted!", + &response_params); } } else { - SendResponse(false, mobile_apis::Result::REJECTED); + SendResponse(false, + mobile_apis::Result::REJECTED, + "File does not exist!", + &response_params); } } void DeleteFileRequest::SendFileRemovedNotification(const AppFile* file) const { + LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); diff --git a/src/components/application_manager/src/commands/mobile/delete_file_response.cc b/src/components/application_manager/src/commands/mobile/delete_file_response.cc index 8ed6f7ba2e..01d7b83364 100644 --- a/src/components/application_manager/src/commands/mobile/delete_file_response.cc +++ b/src/components/application_manager/src/commands/mobile/delete_file_response.cc @@ -56,11 +56,8 @@ void DeleteFileResponse::Run() { return; } - (*message_)[strings::msg_params][strings::space_available] = - static_cast<uint32_t>(app->GetAvailableDiskSpace()); SendResponse((*message_)[strings::msg_params][strings::success].asBool()); } } // namespace commands - } // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/put_file_request.cc b/src/components/application_manager/src/commands/mobile/put_file_request.cc index 602b420ba0..999994118f 100644 --- a/src/components/application_manager/src/commands/mobile/put_file_request.cc +++ b/src/components/application_manager/src/commands/mobile/put_file_request.cc @@ -62,9 +62,15 @@ void PutFileRequest::Run() { smart_objects::SmartObject response_params = smart_objects::SmartObject(smart_objects::SmartType_Map); + response_params[strings::space_available] = + static_cast<uint32_t>(application->GetAvailableDiskSpace()); + if (!application) { LOG4CXX_ERROR(logger_, "Application is not registered"); - SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + SendResponse(false, + mobile_apis::Result::APPLICATION_NOT_REGISTERED, + "Application is not registered", + &response_params); return; } @@ -163,7 +169,7 @@ void PutFileRequest::Run() { file_path = application_manager_.get_settings().app_storage_folder(); file_path += "/" + application->folder_name(); - uint32_t space_available = application->GetAvailableDiskSpace(); + const uint32_t space_available = application->GetAvailableDiskSpace(); if (binary_data.size() > space_available) { response_params[strings::space_available] = |