APPLINK-6502 APPLINK-6529 OnSystemRequest and grammarID
authorAlexander Kutsan <AKutsan@luxoft.com>
Tue, 1 Apr 2014 14:07:02 +0000 (17:07 +0300)
committerJustin Dickow <jjdickow@gmail.com>
Tue, 8 Jul 2014 22:36:07 +0000 (18:36 -0400)
Signed-off-by: Justin Dickow <jjdickow@gmail.com>
Conflicts:
src/components/application_manager/src/application_impl.cc
src/components/application_manager/src/commands/mobile/perform_interaction_request.cc

19 files changed:
src/components/application_manager/include/application_manager/application.h
src/components/application_manager/include/application_manager/application_manager_impl.h
src/components/application_manager/include/application_manager/commands/mobile/create_interaction_choice_set_request.h
src/components/application_manager/include/application_manager/commands/mobile/perform_interaction_request.h
src/components/application_manager/include/application_manager/commands/mobile/put_file_request.h
src/components/application_manager/include/application_manager/smart_object_keys.h
src/components/application_manager/src/application_impl.cc
src/components/application_manager/src/application_manager_impl.cc
src/components/application_manager/src/commands/hmi/on_put_file_notification.cc
src/components/application_manager/src/commands/hmi/on_system_request_notification.cc
src/components/application_manager/src/commands/mobile/add_command_request.cc
src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc
src/components/application_manager/src/commands/mobile/on_system_request_notification.cc
src/components/application_manager/src/commands/mobile/perform_interaction_request.cc
src/components/application_manager/src/commands/mobile/put_file_request.cc
src/components/application_manager/src/resume_ctrl.cpp
src/components/interfaces/HMI_API.xml
src/components/interfaces/MOBILE_API.xml
src/components/interfaces/QT_HMI_API.xml

index 159732a..d4fcbe1 100644 (file)
@@ -76,7 +76,7 @@ struct AppFile {
     AppFile() {
     }
     AppFile(const std::string& name, bool persistent, bool download_complete,
-          mobile_apis::FileType::eType  type)
+          mobile_apis::FileType::eType type)
       : is_persistent(persistent),
         is_download_complete(download_complete),
         file_name(name),
index 33a0659..1c41d61 100644 (file)
@@ -447,6 +447,7 @@ class ApplicationManagerImpl : public ApplicationManager,
       */
     ResumeCtrl& resume_controller() { return resume_ctrl_; }
 
+    uint32_t GetGrammarID();
     /*
      * @brief Save binary data to specified directory
      *
index 1eca8d5..df15874 100644 (file)
@@ -69,6 +69,14 @@ class CreateInteractionChoiceSetRequest : public CommandRequestImpl {
 
  private:
 
+    /*
+     * @brief Sends VR AddCommand request to HMI
+     *
+     * @param app_id Application ID
+     *
+     */
+   void SendVRAddCommandRequest(application_manager::ApplicationSharedPtr const app);
+
   /*
    * @brief Checks incoming choiseSet params.
    * @param app Registred mobile application
index 652e73f..175e551 100644 (file)
@@ -129,13 +129,6 @@ class PerformInteractionRequest : public CommandRequestImpl  {
   void ProcessPerformInteractionResponse
   (const smart_objects::SmartObject& message);
 
-  /*
-   * @brief Sends VR AddCommand request to HMI
-   *
-   * @param app_id Application ID
-   *
-   */
-  void SendVRAddCommandRequest(application_manager::ApplicationSharedPtr const app);
 
   /*
    * @brief Sends UI PerformInteraction request to HMI
index 50913e2..7589578 100644 (file)
@@ -101,6 +101,7 @@ const char interaction_choice_set_id[] = "interactionChoiceSetID";
 const char interaction_choice_set_id_list[] = "interactionChoiceSetIDList";
 const char choice_set[] = "choiceSet";
 const char choice_id[] = "choiceID";
+const char grammar_id[] = "grammarID";
 const char navigation_text_1[] = "navigationText1";
 const char navigation_text_2[] = "navigationText2";
 const char alert_text1[] = "alertText1";
@@ -149,6 +150,8 @@ const char audio_pass_thru_capabilities[] = "audioPassThruCapabilities";
 const char sync_file_name[] = "syncFileName";
 const char file_name[] = "fileName";
 const char file_type[] = "fileType";
+const char file_size[] = "fileSize";
+const char request_type[] = "requestType";
 const char persistent_file[] = "persistentFile";
 const char file_data[] = "fileData";
 const char space_available[] = "spaceAvailable";
index ab487fb..b82467d 100644 (file)
@@ -44,10 +44,7 @@ log4cxx::LoggerPtr g_logger = log4cxx::Logger::getLogger("ApplicationManager");
 
 namespace application_manager {
 
-ApplicationImpl::ApplicationImpl(
-    uint32_t application_id,
-    const std::string& global_app_id,
-    usage_statistics::StatisticsManager* statistics_manager)
+ApplicationImpl::ApplicationImpl(uint32_t application_id)
     : app_id_(application_id),
       active_message_(NULL),
       is_media_(false),
@@ -62,8 +59,7 @@ ApplicationImpl::ApplicationImpl(
       is_app_allowed_(true),
       has_been_activated_(false),
       tts_speak_state_(false),
-      device_(0),
-      usage_report_(global_app_id, statistics_manager) {
+      device_(0) {
 }
 
 ApplicationImpl::~ApplicationImpl() {
@@ -197,7 +193,6 @@ void ApplicationImpl::set_hmi_level(
   }
 
   hmi_level_ = hmi_level;
-  usage_report_.RecordHmiStateChanged(hmi_level);
 }
 
 void ApplicationImpl::set_hmi_supports_navi_streaming(const bool& supports) {
@@ -327,10 +322,6 @@ bool ApplicationImpl::UnsubscribeFromIVI(uint32_t vehicle_info_type_) {
   return (subscribed_vehicle_info_.size() == old_size - 1);
 }
 
-ApplicationUsageReport& ApplicationImpl::usage_report() {
-  return usage_report_;
-}
-
 const std::set<mobile_apis::ButtonName::eType>& ApplicationImpl::SubscribedButtons() const {
   return subscribed_buttons_;
 }
index 85251ee..651bce3 100644 (file)
@@ -88,6 +88,7 @@ ApplicationManagerImpl::ApplicationManagerImpl()
     resume_ctrl_(this)
 {
   LOG4CXX_INFO(logger_, "Creating ApplicationManager");
+  srand(time(NULL));
   if (!policies_manager_.Init()) {
     LOG4CXX_ERROR(logger_, "Policies manager initialization failed.");
     return;
@@ -747,6 +748,10 @@ bool ApplicationManagerImpl::IsVideoStreamingAllowed(uint32_t connection_key) co
   return false;
 }
 
+uint32_t ApplicationManagerImpl::GetGrammarID() {
+  return rand();
+}
+
 bool ApplicationManagerImpl::OnServiceStartedCallback(
     const connection_handler::DeviceHandle& device_handle,
     const int32_t& session_key,
index ec1588e..2fecbec 100644 (file)
@@ -47,9 +47,6 @@ OnPutFileNotification::~OnPutFileNotification() {
 
 void OnPutFileNotification::Run() {
   LOG4CXX_INFO(logger_, "OnPutFileNotification::Run");
-
-  //(*message_)[strings::params][strings::function_id] =
-  //        static_cast<int32_t>(mobile_apis::FunctionID::eType::OnSystemRequestID);
   SendNotification();
 }
 
index b993399..ac0b03c 100644 (file)
@@ -53,14 +53,9 @@ void OnSystemRequestNotification::Run() {
   (*message_)[strings::params][strings::function_id] =
           static_cast<int32_t>(mobile_apis::FunctionID::eType::OnSystemRequestID);
 
-  ApplicationManagerImpl* app_mgr = ApplicationManagerImpl::instance();
-  const std::set<ApplicationSharedPtr>& app_list = app_mgr->applications();
-  std::set<ApplicationSharedPtr>::const_iterator it = app_list.begin();
-  for (; app_list.end() != it; ++it) {
-    (*message_)[strings::params][strings::connection_key] =
-      static_cast<int32_t>((*it)->app_id());
-    SendNotificationToMobile(message_);
-  }
+  (*message_)[strings::params][strings::connection_key] =
+      (*message_)[strings::msg_params][strings::app_id];
+  SendNotificationToMobile(message_);
 }
 
 }  // namespace commands
index 999d0d4..f4f3eeb 100644 (file)
@@ -168,6 +168,7 @@ void AddCommandRequest::Run() {
     vr_msg_params[strings::app_id] = app->app_id();
 
     vr_msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command;
+    vr_msg_params[strings::grammar_id] = ApplicationManagerImpl::instance()->GetGrammarID();
 
     send_vr_ = true;
   }
index ae88656..6f2a7e6 100644 (file)
@@ -94,9 +94,10 @@ void CreateInteractionChoiceSetRequest::Run() {
     SendResponse(false, result);
     return;
   }
-
+  uint32_t grammar_id = ApplicationManagerImpl::instance()->GetGrammarID();
+  (*message_)[strings::msg_params][strings::grammar_id] = grammar_id;
   app->AddChoiceSet(choice_set_id, (*message_)[strings::msg_params]);
-
+  SendVRAddCommandRequest(app);
   SendResponse(true, result_);
   app->UpdateHash();
 }
@@ -238,6 +239,30 @@ bool CreateInteractionChoiceSetRequest::compareStr(
   return 0 == strcasecmp(str1.asCharArray(), str2.asCharArray());
 }
 
+void CreateInteractionChoiceSetRequest::SendVRAddCommandRequest(
+    application_manager::ApplicationSharedPtr const app) {
+
+  smart_objects::SmartObject* choice_set = &(*message_)[strings::msg_params];
+
+  for (size_t j = 0; j < (*choice_set)[strings::choice_set].length(); ++j) {
+    smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+                                              smart_objects::SmartType_Map);
+    msg_params[strings::app_id] = app->app_id();
+    msg_params[strings::cmd_id] =
+        (*choice_set)[strings::choice_set][j][strings::choice_id];
+    msg_params[strings::vr_commands] = smart_objects::SmartObject(
+                                         smart_objects::SmartType_Array);
+    msg_params[strings::vr_commands] =
+        (*choice_set)[strings::choice_set][j][strings::vr_commands];
+
+    msg_params[strings::type] = hmi_apis::Common_VRCommandType::Choice;
+    msg_params[strings::grammar_id] =  (*choice_set)[strings::grammar_id];
+
+    SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &msg_params);
+  }
+
+}
+
 
 }  // namespace commands
 
index a40f1c1..0de0ad5 100644 (file)
@@ -32,6 +32,8 @@
  */
 
 #include "application_manager/commands/mobile/on_system_request_notification.h"
+#include "interfaces/MOBILE_API.h"
+#include "utils/file_system.h"
 
 namespace application_manager {
 
@@ -50,6 +52,20 @@ OnSystemRequestNotification::~OnSystemRequestNotification() {
 void OnSystemRequestNotification::Run() {
   LOG4CXX_INFO(logger_, "OnSystemRequestNotification::Run");
 
+  mobile_apis::RequestType::eType request_type = static_cast<mobile_apis::RequestType::eType>
+      ((*message_)[strings::msg_params][strings::request_type].asInt());
+
+  if (false == (*message_)[strings::msg_params].keyExists(strings::file_name)) {
+    return;
+  }
+  std::string filename = (*message_)[strings::msg_params][strings::file_name].asString();
+
+  if (mobile_apis::RequestType::PROPRIETARY == request_type) {
+    std::vector<uint8_t> binary_data;
+    file_system::ReadBinaryFile(filename, binary_data);
+    (*message_)[strings::msg_params][strings::binary_data] = binary_data;
+  }
+
   SendNotification();
 }
 
index cfe0dc8..c35c73a 100644 (file)
@@ -90,8 +90,8 @@ void PerformInteractionRequest::Run() {
 
   // timer_.start(2);
 
-  ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
-      (*message_)[strings::params][strings::connection_key].asUInt());
+  ApplicationSharedPtr app =
+      ApplicationManagerImpl::instance()->application(connection_key());
 
   if (!app) {
     LOG4CXX_ERROR(logger_, "Application is not registered");
@@ -155,7 +155,6 @@ void PerformInteractionRequest::Run() {
       }
 
       app->set_perform_interaction_active(correlation_id);
-      SendVRAddCommandRequest(app);
       SendTTSPerformInteractionRequest(app);
       SendUIPerformInteractionRequest(app);
       break;
@@ -183,7 +182,6 @@ void PerformInteractionRequest::Run() {
 
       // TODO(DK): need to implement timeout
       app->set_perform_interaction_active(correlation_id);
-      SendVRAddCommandRequest(app);
       SendTTSPerformInteractionRequest(app);
       SendUIPerformInteractionRequest(app);
       break;
@@ -238,21 +236,15 @@ void PerformInteractionRequest::on_event(const event_engine::Event& event) {
 
 void PerformInteractionRequest::onTimeOut() {
   LOG4CXX_INFO(logger_, "PerformInteractionRequest::onTimeOut");
-  ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
-        (*message_)[strings::params][strings::connection_key].asUInt());
-  if (app) {
-
-    // Unsubscribe from event on UIPerformInteractionResponse to
-    // avoid of double execution of SendVrDeleteCommand()
-    unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction);
-    SendVrDeleteCommand(app);
-    app->set_perform_interaction_active(0);
-    app->set_perform_interaction_mode(-1);
-    app->DeletePerformInteractionChoiceSetMap();
-  }
+
+  // Unsubscribe from event on UIPerformInteractionResponse to
+  // avoid of double execution of SendVrDeleteCommand()
+  unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction);
+  DisablePerformInteraction();
   CommandRequestImpl::onTimeOut();
 }
 
+
 void PerformInteractionRequest::ProcessVRNotification(
     const smart_objects::SmartObject& message) {
   LOG4CXX_INFO(logger_, "PerformInteractionRequest::ProcessVRNotification");
@@ -286,10 +278,7 @@ void PerformInteractionRequest::ProcessVRNotification(
         smart_objects::SmartType_Map);
     c_p_request_so[hmi_request::method_name] = "UI.PerformInteraction";
     SendHMIRequest(hmi_apis::FunctionID::UI_ClosePopUp, &(c_p_request_so));
-    SendVrDeleteCommand(app);
-    app->set_perform_interaction_mode(-1);
-    app->DeletePerformInteractionChoiceSetMap();
-    app->set_perform_interaction_active(0);
+    DisablePerformInteraction();
 
     (*message_)[strings::params][strings::function_id] =
         static_cast<int32_t>(mobile_apis::FunctionID::PerformInteractionID);
@@ -324,23 +313,9 @@ void PerformInteractionRequest::ProcessAppUnregisteredNotification
   (const smart_objects::SmartObject& message) {
   LOG4CXX_INFO(logger_,
                "PerformInteractionRequest::ProcessAppUnregisteredNotification");
-  const uint32_t app_id = (*message_)[strings::params]
-                                          [strings::connection_key].asUInt();
+  const uint32_t app_id = connection_key();
   if (app_id == message[strings::msg_params][strings::app_id].asUInt()) {
-    ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
-    if (!app) {
-      LOG4CXX_ERROR(logger_, "NULL pointer");
-      return;
-    }
-    if (app->is_perform_interaction_active()) {
-      if (static_cast<int32_t>(mobile_apis::InteractionMode::MANUAL_ONLY) !=
-          app->perform_interaction_mode()) {
-        SendVrDeleteCommand(app);
-      }
-      app->set_perform_interaction_mode(-1);
-      app->DeletePerformInteractionChoiceSetMap();
-      app->set_perform_interaction_active(0);
-    }
+    DisablePerformInteraction();
   } else {
     LOG4CXX_INFO(logger_, "Notification was sent from another application");
   }
@@ -349,8 +324,10 @@ void PerformInteractionRequest::ProcessAppUnregisteredNotification
 void PerformInteractionRequest::SendVrDeleteCommand(
     application_manager::ApplicationSharedPtr const app) {
   LOG4CXX_INFO(logger_, "PerformInteractionRequest::SendVrDeleteCommand");
-  const PerformChoiceSetMap& choice_set_map = app
-      ->performinteraction_choice_set_map();
+
+  const PerformChoiceSetMap& choice_set_map =
+      app->performinteraction_choice_set_map();
+
   PerformChoiceSetMap::const_iterator it = choice_set_map.begin();
   for (; choice_set_map.end() != it; ++it) {
     const smart_objects::SmartObject& choice_set = (*it->second).getElement(
@@ -370,96 +347,43 @@ void PerformInteractionRequest::ProcessPerformInteractionResponse(
     const smart_objects::SmartObject& message) {
   LOG4CXX_INFO(logger_,
                "PerformInteractionRequest::ProcessPerformInteractionResponse");
-  ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
-        (*message_)[strings::params][strings::connection_key].asUInt());
-    if (!app) {
-      LOG4CXX_ERROR(logger_, "NULL pointer");
-      return;
-    }
-    if (app->is_perform_interaction_active()) {
-      if (static_cast<int32_t>(mobile_apis::InteractionMode::MANUAL_ONLY)
-          != app->perform_interaction_mode()) {
-        SendVrDeleteCommand(app);
-      }
-      app->set_perform_interaction_mode(-1);
-      app->DeletePerformInteractionChoiceSetMap();
-      app->set_perform_interaction_active(0);
-    }
-    (*message_)[strings::params][strings::function_id] =
-            static_cast<int32_t>(mobile_apis::FunctionID::PerformInteractionID);
-    smart_objects::SmartObject msg_params = smart_objects::SmartObject(
-        smart_objects::SmartType_Map);
-    msg_params = message[strings::msg_params];
-    bool result = false;
-    int32_t hmi_response_code =
-        message[strings::params][hmi_response::code].asInt();
-    if (hmi_apis::Common_Result::SUCCESS ==
-        hmi_apis::Common_Result::eType(hmi_response_code)) {
-      if (message[strings::msg_params].keyExists(strings::manual_text_entry)) {
-        msg_params[strings::trigger_source] = mobile_apis::TriggerSource::TS_KEYBOARD;
-      } else {
-        msg_params[strings::trigger_source] = mobile_apis::TriggerSource::TS_MENU;
-      }
-      result = true;
-    }
-
-    const char* return_info = NULL;
-     mobile_apis::Result::eType result_code =
-        static_cast<mobile_apis::Result::eType>(hmi_response_code);
-    if (result) {
-      if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE ==
-          hmi_apis::Common_Result::eType(hmi_response_code)) {
-        result_code = mobile_apis::Result::WARNINGS;
-        return_info = std::string(
-            "Unsupported phoneme type sent in any item").c_str();
-      }
-    }
 
-    SendResponse(result,
-                 result_code,
-                 return_info,
-                 &(msg_params));
-}
+  DisablePerformInteraction();
 
-void PerformInteractionRequest::SendVRAddCommandRequest(
-    application_manager::ApplicationSharedPtr const app) {
-  smart_objects::SmartObject& choice_list =
-      (*message_)[strings::msg_params][strings::interaction_choice_set_id_list];
-
-  mobile_apis::InteractionMode::eType mode =
-      static_cast<mobile_apis::InteractionMode::eType>(
-      (*message_)[strings::msg_params][strings::interaction_mode].asInt());
-
-  if (mobile_apis::InteractionMode::VR_ONLY == mode) {
-    // TODO(DK): We need subscribe perform interaction with on command
-    // notification
-    /*CreateHMIRequest(hmi_apis::FunctionID::UI_PerformInteraction,
-     smart_objects::SmartObject(smart_objects::SmartType_Map), true, 1);*/
+  smart_objects::SmartObject msg_params =
+      smart_objects::SmartObject(smart_objects::SmartType_Map);
+  msg_params = message[strings::msg_params];
+
+  bool result = false;
+  int32_t hmi_response_code =
+      message[strings::params][hmi_response::code].asInt();
+  if (hmi_apis::Common_Result::SUCCESS ==
+      hmi_apis::Common_Result::eType(hmi_response_code)) {
+    if (message[strings::msg_params].keyExists(strings::manual_text_entry)) {
+      msg_params[strings::trigger_source] = mobile_apis::TriggerSource::TS_KEYBOARD;
+    } else {
+      msg_params[strings::trigger_source] = mobile_apis::TriggerSource::TS_MENU;
+    }
+    result = true;
   }
 
-  for (size_t i = 0; i < choice_list.length(); ++i) {
-    smart_objects::SmartObject* choice_set = app->FindChoiceSet(
-        choice_list[i].asInt());
-
-    if (choice_set) {
-      for (size_t j = 0; j < (*choice_set)[strings::choice_set].length(); ++j) {
-        smart_objects::SmartObject msg_params = smart_objects::SmartObject(
-            smart_objects::SmartType_Map);
-        msg_params[strings::app_id] = app->app_id();
-        msg_params[strings::cmd_id] =
-            (*choice_set)[strings::choice_set][j][strings::choice_id];
-        msg_params[strings::vr_commands] = smart_objects::SmartObject(
-            smart_objects::SmartType_Array);
-        msg_params[strings::vr_commands] =
-            (*choice_set)[strings::choice_set][j][strings::vr_commands];
-
-        msg_params[strings::type] = hmi_apis::Common_VRCommandType::Choice;
-        SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &msg_params);
-      }
+  const char* return_info = NULL;
+  mobile_apis::Result::eType result_code =
+      static_cast<mobile_apis::Result::eType>(hmi_response_code);
+  if (result) {
+    if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE ==
+        hmi_apis::Common_Result::eType(hmi_response_code)) {
+      result_code = mobile_apis::Result::WARNINGS;
+      return_info = std::string(
+          "Unsupported phoneme type sent in any item").c_str();
     }
   }
+
+  SendResponse(result, result_code, return_info, &(msg_params));
 }
 
+
+
 void PerformInteractionRequest::SendUIPerformInteractionRequest(
     application_manager::ApplicationSharedPtr const app) {
   smart_objects::SmartObject& choice_set_id_list =
@@ -569,6 +493,9 @@ void PerformInteractionRequest::SendTTSPerformInteractionRequest(
         smart_objects::SmartObject(smart_objects::SmartType_Array);
 
     int32_t index = 0;
+    int32_t grammar_id_index = 0;
+
+    msg_params[strings::grammar_id] = smart_objects::SmartObject(smart_objects::SmartType_Array);
     for (uint32_t i = 0; i < choice_list.length(); ++i) {
       smart_objects::SmartObject* choice_set =
           app->FindChoiceSet(choice_list[i].asInt());
@@ -586,6 +513,9 @@ void PerformInteractionRequest::SendTTSPerformInteractionRequest(
             msg_params[strings::help_prompt][index++] = item;
           }
         }
+         msg_params[strings::grammar_id][grammar_id_index++]= (*choice_set)[strings::grammar_id];
+      } else {
+        LOG4CXX_ERROR(logger_, "Can't found choiset!")
       }
     }
   }
@@ -760,6 +690,21 @@ bool PerformInteractionRequest::CheckVrHelpItemPositions(
   return true;
 }
 
+void PerformInteractionRequest::DisablePerformInteraction() {
+  ApplicationSharedPtr app =
+      ApplicationManagerImpl::instance()->application(connection_key());
+  if (!app) {
+    LOG4CXX_ERROR(logger_, "NULL pointer");
+    return;
+  }
+
+  if (app->is_perform_interaction_active()) {
+    app->set_perform_interaction_active(0);
+    app->set_perform_interaction_mode(-1);
+    app->DeletePerformInteractionChoiceSetMap();
+  }
+}
+
 }  // namespace commands
 
 }  // namespace application_manager
index 5d5549d..b2651a6 100644 (file)
@@ -116,10 +116,7 @@ void PutFileRequest::Run() {
   if (offset_exist) {
     offset_ = (*message_)[strings::msg_params][strings::offset].asInt();
   }
-  if ((*message_)[strings::msg_params].keyExists(strings::length)) {
-      length_ =
-            (*message_)[strings::msg_params][strings::length].asInt();
-  }
+
   if ((*message_)[strings::msg_params].
       keyExists(strings::persistent_file)) {
     is_persistent_file_ =
@@ -194,18 +191,8 @@ void PutFileRequest::Run() {
           application->increment_put_file_in_none_count();
         }
       }
-//      For future implementation ( when length will contains file size)
-//      if (offset + binary_data.size() == length) {
-//        LOG4CXX_INFO(logger_, "File is Fully downloaded");
-//        if (!application->UpdateFile(file)) {
-//          // If it is impossible to update file, application doesn't know about existing this file
-//          SendResponse(false, mobile_apis::Result::INVALID_DATA);
-//          return;
-//        }
-//      } else {
-//        //TODO: Maybe need to save in AppFile information about downloading progress
-//      }
-      SendResponse(true, save_result, "File downloaded", &response_params);
+
+      SendResponse(true, save_result, "File is downloaded", &response_params);
       if (is_system_file) {
         SendOnPutFileNotification();
       }
@@ -219,7 +206,7 @@ void PutFileRequest::Run() {
 }
 
 void PutFileRequest::SendOnPutFileNotification() {
-
+  LOG4CXX_INFO(logger_, "SendOnPutFileNotification" );
   smart_objects::SmartObject* notification = new smart_objects::SmartObject(
     smart_objects::SmartType_Map);
 
@@ -231,13 +218,13 @@ void PutFileRequest::SendOnPutFileNotification() {
   message[strings::msg_params][strings::app_id] = connection_key();
   message[strings::msg_params][strings::sync_file_name] = sync_file_name_;
   message[strings::msg_params][strings::offset] = offset_;
+  if ( offset_ == 0 ) {
+    message[strings::msg_params][strings::file_size] =
+        (*message_)[strings::msg_params][strings::length];
+  }
   message[strings::msg_params][strings::length] = length_;
   message[strings::msg_params][strings::persistent_file] = is_persistent_file_;
   message[strings::msg_params][strings::file_type] = file_type_;
-
-
-
-
   ApplicationManagerImpl::instance()->ManageHMICommand(&message);
 }
 
index e9d8ffe..7e9668b 100644 (file)
@@ -235,7 +235,25 @@ bool ResumeCtrl::RestoreApplicationData(ApplicationSharedPtr application) {
     Formatters::CFormatterJsonBase::jsonValueToObj(json_choiset , msg_param);
     const int32_t choice_set_id = msg_param
         [strings::interaction_choice_set_id].asInt();
+    uint32_t grammar_id = msg_param[strings::grammar_id].asUInt();
     application->AddChoiceSet(choice_set_id, msg_param);
+
+    for (size_t j = 0; j < msg_param[strings::choice_set].length(); ++j) {
+      smart_objects::SmartObject choise_params = smart_objects::SmartObject(
+                                                smart_objects::SmartType_Map);
+      choise_params[strings::app_id] = application->app_id();
+      choise_params[strings::cmd_id] =
+          msg_param[strings::choice_set][j][strings::choice_id];
+      choise_params[strings::vr_commands] = smart_objects::SmartObject(
+                                           smart_objects::SmartType_Array);
+      choise_params[strings::vr_commands] =
+          msg_param[strings::choice_set][j][strings::vr_commands];
+
+      choise_params[strings::type] = hmi_apis::Common_VRCommandType::Choice;
+      choise_params[strings::grammar_id] =  grammar_id;
+
+      SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &choise_params);
+    }
   }
 
   //setglobal properties
index 26dae94..ee3fba5 100644 (file)
     <element name="FILE_RESUME" />
     <element name="AUTH_REQUEST" />       
     <element name="AUTH_CHALLENGE" />       
-    <element name="AUTH_ACK" />       
+    <element name="AUTH_ACK" />
+    <element name="PROPRIETARY" />
   </enum>
 
 <enum name="ECallConfirmationStatus">
         <description>Must be true if allowed</description>
       </param>
     </function>
+
     <function name="OnSystemRequest" messagetype="notification" >
       <description>
         An asynchronous request from the system for specific data from the device or the cloud or response to a request from the device or cloud
       </param>
       <param name="timeout" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="false">
       </param>
+      <param name="fileName" type="String" maxlength="255" mandatory="true">
+        <description>File reference name.</description>
+      </param>
+      <param name="appID" type="Integer" mandatory="true">
+        <description>ID of application that requested this RPC.</description>
+      </param>
     </function>
+
     <function name="OnSDLClose" messagetype="notification">
       <description>SDL must notify HMI about finish working application</description>
     </function>
index dd5b7a6..28a1de6 100644 (file)
     <element name="FILE_RESUME" />
     <element name="AUTH_REQUEST" />       
     <element name="AUTH_CHALLENGE" />       
-    <element name="AUTH_ACK" />       
+    <element name="AUTH_ACK" />
+    <element name="PROPRIETARY" />
   </enum>
 
   <enum name="AppHMIType">
     </param>
     <param name="length" type="Integer" minvalue="0" maxvalue="100000000000" mandatory="false">
        <description>Optional length in bytes for resuming partial data chunks</description>
-    </param>    
+    </param>
   </function>  
 
 <!-- ~~~~~~~~~~~~~~~~~~ -->
index 055a6e0..5886c8d 100644 (file)
     <element name="FILE_RESUME" />
     <element name="AUTH_REQUEST" />       
     <element name="AUTH_CHALLENGE" />       
-    <element name="AUTH_ACK" />       
+    <element name="AUTH_ACK" />
+    <element name="PROPRIETARY" />
   </enum>
 
 <enum name="ECallConfirmationStatus">
       </param>
       <param name="timeout" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="false">
       </param>
+      <param name="fileName" type="String" maxlength="255" mandatory="true">
+        <description>File reference name.</description>
+      </param>
+      <param name="appID" type="Integer" mandatory="true">
+        <description>ID of application that requested this RPC.</description>
+      </param>
     </function>
 
     <function name="OnPutFile" messagetype="notification" >