summaryrefslogtreecommitdiff
path: root/src/components/application_manager/src/message_helper/message_helper.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/src/message_helper/message_helper.cc')
-rw-r--r--src/components/application_manager/src/message_helper/message_helper.cc42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc
index a848cf9ad9..d10ede4637 100644
--- a/src/components/application_manager/src/message_helper/message_helper.cc
+++ b/src/components/application_manager/src/message_helper/message_helper.cc
@@ -2745,11 +2745,24 @@ mobile_apis::Result::eType MessageHelper::VerifyImageApplyPath(
}
const std::string& file_name = image[strings::value].asString();
+ const utils::SharedPtr<std::string> full_file_path =
+ CheckAppFileExists(file_name, app, app_mngr);
+ if (full_file_path) {
+ image[strings::value] = *full_file_path;
+ return mobile_apis::Result::SUCCESS;
+ }
+ return mobile_apis::Result::INVALID_DATA;
+}
+utils::SharedPtr<std::string> MessageHelper::CheckAppFileExists(
+ std::string file_name,
+ ApplicationConstSharedPtr app,
+ ApplicationManager& app_mngr) {
std::string str = file_name;
+ // Verify that file name is not only space characters
str.erase(remove(str.begin(), str.end(), ' '), str.end());
if (0 == str.size()) {
- return mobile_apis::Result::INVALID_DATA;
+ return utils::SharedPtr<std::string>();
}
std::string full_file_path;
@@ -2775,12 +2788,31 @@ mobile_apis::Result::eType MessageHelper::VerifyImageApplyPath(
full_file_path += file_name;
}
- image[strings::value] = full_file_path;
if (!file_system::FileExists(full_file_path)) {
- return mobile_apis::Result::INVALID_DATA;
+ return utils::SharedPtr<std::string>();
}
- return mobile_apis::Result::SUCCESS;
+ utils::SharedPtr<std::string> path_ptr(new std::string(full_file_path));
+ return path_ptr;
+}
+
+mobile_apis::Result::eType MessageHelper::VerifyTtsFiles(
+ smart_objects::SmartObject& tts_chunks,
+ ApplicationConstSharedPtr app,
+ ApplicationManager& app_mngr) {
+ mobile_apis::Result::eType result = mobile_apis::Result::SUCCESS;
+ for (auto& tts_chunk : *(tts_chunks.asArray())) {
+ if (tts_chunk[strings::type] == mobile_apis::SpeechCapabilities::FILE) {
+ utils::SharedPtr<std::string> full_file_path = CheckAppFileExists(
+ tts_chunk[strings::text].asString(), app, app_mngr);
+ if (!full_file_path) {
+ result = mobile_apis::Result::FILE_NOT_FOUND;
+ } else {
+ tts_chunk[strings::text] = *full_file_path;
+ }
+ }
+ }
+ return result;
}
mobile_apis::Result::eType MessageHelper::VerifyImage(
@@ -3024,4 +3056,4 @@ bool MessageHelper::PrintSmartObject(const smart_objects::SmartObject& object) {
return true;
}
-} // namespace application_manager
+} // namespace application_manager \ No newline at end of file