summaryrefslogtreecommitdiff
path: root/src/components/application_manager/src/commands/mobile/list_files_request.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/src/commands/mobile/list_files_request.cc')
-rw-r--r--src/components/application_manager/src/commands/mobile/list_files_request.cc58
1 files changed, 34 insertions, 24 deletions
diff --git a/src/components/application_manager/src/commands/mobile/list_files_request.cc b/src/components/application_manager/src/commands/mobile/list_files_request.cc
index 427443e3e9..425f1ddb46 100644
--- a/src/components/application_manager/src/commands/mobile/list_files_request.cc
+++ b/src/components/application_manager/src/commands/mobile/list_files_request.cc
@@ -31,10 +31,11 @@
POSSIBILITY OF SUCH DAMAGE.
*/
+#include <string>
#include "application_manager/commands/mobile/list_files_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
-#include "config_profile/profile.h"
+
#include "application_manager/mobile_command_factory.h"
#include "utils/file_system.h"
@@ -42,18 +43,17 @@ namespace application_manager {
namespace commands {
-ListFilesRequest::ListFilesRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+ListFilesRequest::ListFilesRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-ListFilesRequest::~ListFilesRequest() {
-}
+ListFilesRequest::~ListFilesRequest() {}
void ListFilesRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(connection_key());
+ application_manager_.application(connection_key());
if (!application) {
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
@@ -62,33 +62,43 @@ void ListFilesRequest::Run() {
}
if ((mobile_api::HMILevel::HMI_NONE == application->hmi_level()) &&
- (profile::Profile::instance()->list_files_in_none() <=
+ (application_manager_.get_settings().list_files_in_none() <=
application->list_files_in_none_count())) {
- // If application is in the HMI_NONE level the quantity of allowed
- // 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);
- return;
+ // If application is in the HMI_NONE level the quantity of allowed
+ // 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);
+ return;
}
application->increment_list_files_in_none_count();
(*message_)[strings::msg_params][strings::space_available] =
- static_cast<int32_t>(ApplicationManagerImpl::instance()->
- GetAvailableSpaceForApp(application->folder_name()));
- int32_t i = 0;
+ static_cast<int32_t>(application->GetAvailableDiskSpace());
+ uint32_t i = 0;
const AppFilesMap& app_files = application->getAppFiles();
for (AppFilesMap::const_iterator it = app_files.begin();
- it != app_files.end(); ++it) {
- //In AppFile to application stored full path to file. In message required
- //to write only name file.
- //Plus one required for move to next letter after '/'.
- (*message_)[strings::msg_params][strings::filenames][i++] =
- it->first.substr(it->first.find_last_of('/') + 1);
+ it != app_files.end();
+ ++it) {
+ std::string filename = it->first.substr(it->first.find_last_of('/') + 1);
+ // In AppFile to application stored full path to file. In message required
+ // to write only name file.
+ // Plus one required for move to next letter after '/'.
+ if (i < application_manager_.get_settings().list_files_response_size()) {
+ LOG4CXX_DEBUG(logger_,
+ "File " + filename + " added to ListFiles response");
+ (*message_)[strings::msg_params][strings::filenames][i++] = filename;
+ } else {
+ LOG4CXX_DEBUG(logger_,
+ "File " + filename + " not added to ListFiles response");
+ }
}
(*message_)[strings::params][strings::message_type] =
application_manager::MessageType::kResponse;
- SendResponse(true, mobile_apis::Result::SUCCESS, NULL,
+ SendResponse(true,
+ mobile_apis::Result::SUCCESS,
+ NULL,
&(*message_)[strings::msg_params]);
}