diff options
author | Herasym Oleh <oolleehh@gmail.com> | 2016-03-24 15:27:24 +0200 |
---|---|---|
committer | Herasym Oleh <oolleehh@gmail.com> | 2016-04-13 09:05:33 +0300 |
commit | 47e02bf586513eccb2ba00656a17b237efb1442c (patch) | |
tree | cf4f5299ae809896e803f1f03f87d8f857b5e73a | |
parent | 021ed56b19de2f284908d09b74bf2ca39ff76a9e (diff) | |
download | sdl_core-47e02bf586513eccb2ba00656a17b237efb1442c.tar.gz |
Add implementation SubscribeWayPoints&UnsubsribeWayPoints
Add mobile request/response SubscribeWayPoints
Add mobile request/response UnSubscribeWayPoints
Add HMI request/response SubscribeWayPoints
Add HMI request/response UnsubscribeWayPoints
Add SendUnsubscribeWayPoints method in MessageHelper
Add save subscribe app status to resumption DB & json
Add Sending UnsubscribeWayPoints in case unexpected disconnect
Related:
APPLINK-21629
Conflicts:
src/components/application_manager/src/application_manager_impl.cc
31 files changed, 1038 insertions, 0 deletions
diff --git a/src/components/application_manager/CMakeLists.txt b/src/components/application_manager/CMakeLists.txt index 963899e809..db8d2d3c79 100644 --- a/src/components/application_manager/CMakeLists.txt +++ b/src/components/application_manager/CMakeLists.txt @@ -237,6 +237,10 @@ file (GLOB MOBILE_COMMANDS_SOURCES ${AM_SOURCE_DIR}/src/commands/hmi/navi_show_constant_tbt_response.cc ${AM_SOURCE_DIR}/src/commands/hmi/navi_send_location_request.cc ${AM_SOURCE_DIR}/src/commands/hmi/navi_send_location_response.cc + ${AM_SOURCE_DIR}/src/commands/hmi/navi_subscribe_way_points_request.cc + ${AM_SOURCE_DIR}/src/commands/hmi/navi_subscribe_way_points_response.cc + ${AM_SOURCE_DIR}/src/commands/hmi/navi_unsubscribe_way_points_request.cc + ${AM_SOURCE_DIR}/src/commands/hmi/navi_unsubscribe_way_points_response.cc ${AM_SOURCE_DIR}/src/commands/hmi/on_ready_notification.cc ${AM_SOURCE_DIR}/src/commands/hmi/on_system_context_notification.cc ${AM_SOURCE_DIR}/src/commands/hmi/on_device_chosen_notification.cc diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 4f176fcc4d..d0e8c99fae 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -281,6 +281,44 @@ class ApplicationManagerImpl bool IsAppTypeExistsInFullOrLimited(ApplicationConstSharedPtr app) const; /** + * @brief Checks if Application is subscribed for way points + * @param Application AppID + * @return true if Application is subscribed for way points + * otherwise false + */ + bool IsAppSubscribedForWayPoints(const uint32_t app); + + /** + * @brief Subscribe Application for way points + * @param Application AppID + */ + void SubscribeAppForWayPoints(const uint32_t app); + + /** + * @brief Unsubscribe Application for way points + * @param Application AppID + */ + void UnSubscribeAppForWayPoints(const uint32_t app); + + /** + * @brief Is Any Application is subscribed for way points + * @return true if some app is subscribed otherwise false + */ + bool IsAnyAppSubscribedForWayPoints() const; + + /** + * @brief Get subscribed for way points + * @return reference to set of subscribed apps for way points + */ + const std::set<int32_t>& GetSubscribedForWayPoints() const; + + /** + * @brief Set subscribed for way points + * @param subscribed_way_points_apps + */ + void SetSubscribedForWayPoints(const std::set<int32_t>& subscribed_way_points_apps); + + /** * @brief Notifies all components interested in Vehicle Data update * i.e. new value of odometer etc and returns list of applications * subscribed for event. @@ -1426,6 +1464,11 @@ typedef utils::SharedPtr<timer::Timer> TimerSPtr; std::map<const int32_t, const uint32_t> appID_list_; /** + * @brief Set AppIDs of subscribed apps for way points + */ + std::set<int32_t> subscribed_way_points_apps_list_; + + /** * @brief Map contains applications which * will send TTS global properties to HMI after timeout */ diff --git a/src/components/application_manager/include/application_manager/commands/hmi/navi_subscribe_way_points_request.h b/src/components/application_manager/include/application_manager/commands/hmi/navi_subscribe_way_points_request.h new file mode 100644 index 0000000000..2e9465b1e3 --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/hmi/navi_subscribe_way_points_request.h @@ -0,0 +1,39 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_NAVI_SUBSCRIBE_WAY_POINTS_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_NAVI_SUBSCRIBE_WAY_POINTS_REQUEST_H_ + +#include "application_manager/commands/hmi/request_to_hmi.h" + +namespace application_manager { + +namespace commands { + +/** + * @brief NaviSubscribeWayPointsRequest command class + **/ +class NaviSubscribeWayPointsRequest + : public RequestToHMI { +public: + /** + * @brief NaviSubscribeWayPointsRequest class constructor + * + * @param message Incoming SmartObject message + **/ + explicit NaviSubscribeWayPointsRequest(const MessageSharedPtr &); + /** + * @brief NaviSubscribeWayPointsRequest class destructor + **/ + virtual ~NaviSubscribeWayPointsRequest(); + /** + * @brief Execute command + **/ + virtual void Run(); + +private: + DISALLOW_COPY_AND_ASSIGN(NaviSubscribeWayPointsRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_NAVI_SUBSCRIBE_WAY_POINTS_REQUEST_H_ diff --git a/src/components/application_manager/include/application_manager/commands/hmi/navi_subscribe_way_points_response.h b/src/components/application_manager/include/application_manager/commands/hmi/navi_subscribe_way_points_response.h new file mode 100644 index 0000000000..716ec8ff4e --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/hmi/navi_subscribe_way_points_response.h @@ -0,0 +1,40 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_NAVI_SUBSCRIBE_WAY_POINTS_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_NAVI_SUBSCRIBE_WAY_POINTS_RESPONSE_H_ + +#include "application_manager/commands/hmi/response_from_hmi.h" + +namespace application_manager { + +namespace commands { + +/** + * @brief NaviSubscribeWaypoints command class + **/ +class NaviSubscribeWaypointsResponse + : public ResponseFromHMI { + public: + /** + * @brief NaviSubscribeWaypoints class constructor + * + * @param message Incoming SmartObject message + **/ + explicit NaviSubscribeWaypointsResponse(const MessageSharedPtr& message); + + /** + * @brief NaviSubscribeWaypoints class destructor + **/ + virtual ~NaviSubscribeWaypointsResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + private: + DISALLOW_COPY_AND_ASSIGN(NaviSubscribeWaypointsResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_NAVI_SUBSCRIBE_WAY_POINTS_RESPONSE_H_ diff --git a/src/components/application_manager/include/application_manager/commands/hmi/navi_unsubscribe_way_points_request.h b/src/components/application_manager/include/application_manager/commands/hmi/navi_unsubscribe_way_points_request.h new file mode 100644 index 0000000000..58d0fc266f --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/hmi/navi_unsubscribe_way_points_request.h @@ -0,0 +1,39 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_NAVI_UNSUBSCRIBE_WAY_POINTS_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_NAVI_UNSUBSCRIBE_WAY_POINTS_REQUEST_H_ + +#include "application_manager/commands/hmi/request_to_hmi.h" + +namespace application_manager { + +namespace commands { + +/** + * @brief NaviSubscribeWayPointsRequest command class + **/ +class NaviUnSubscribeWayPointsRequest + : public RequestToHMI { +public: + /** + * @brief NaviUnSubscribeWayPointsRequest class constructor + * + * @param message Incoming SmartObject message + **/ + explicit NaviUnSubscribeWayPointsRequest(const MessageSharedPtr &); + /** + * @brief NaviUnSubscribeWayPointsRequest class destructor + **/ + virtual ~NaviUnSubscribeWayPointsRequest(); + /** + * @brief Execute command + **/ + virtual void Run(); + +private: + DISALLOW_COPY_AND_ASSIGN(NaviUnSubscribeWayPointsRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_NAVI_UNSUBSCRIBE_WAY_POINTS_REQUEST_H_ diff --git a/src/components/application_manager/include/application_manager/commands/hmi/navi_unsubscribe_way_points_response.h b/src/components/application_manager/include/application_manager/commands/hmi/navi_unsubscribe_way_points_response.h new file mode 100644 index 0000000000..e8a524f78d --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/hmi/navi_unsubscribe_way_points_response.h @@ -0,0 +1,40 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_NAVI_UNSUBSCRIBE_WAY_POINTS_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_NAVI_UNSUBSCRIBE_WAY_POINTS_RESPONSE_H_ + +#include "application_manager/commands/hmi/response_from_hmi.h" + +namespace application_manager { + +namespace commands { + +/** + * @brief NaviUnSubscribeWaypoints command class + **/ +class NaviUnSubscribeWaypointsResponse + : public ResponseFromHMI { + public: + /** + * @brief NaviUnSubscribeWaypoints class constructor + * + * @param message Incoming SmartObject message + **/ + explicit NaviUnSubscribeWaypointsResponse(const MessageSharedPtr& message); + + /** + * @brief NaviUnSubscribeWaypoints class destructor + **/ + virtual ~NaviUnSubscribeWaypointsResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + private: + DISALLOW_COPY_AND_ASSIGN(NaviUnSubscribeWaypointsResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_NAVI_UNSUBSCRIBE_WAY_POINTS_RESPONSE_H_ diff --git a/src/components/application_manager/include/application_manager/commands/mobile/subscribe_way_points_request.h b/src/components/application_manager/include/application_manager/commands/mobile/subscribe_way_points_request.h new file mode 100644 index 0000000000..c665904067 --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/mobile/subscribe_way_points_request.h @@ -0,0 +1,43 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_SUBSCRIBE_WAY_POINTS_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_SUBSCRIBE_WAY_POINTS_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" + +namespace application_manager { + +namespace commands { + +/** + * @brief SubsribeWayPointsRequest command class + **/ +class SubscribeWayPointsRequest : public CommandRequestImpl { +public: + /** + * \brief SubscribeWayPointsRequest class constructor + **/ + explicit SubscribeWayPointsRequest(const MessageSharedPtr& message); + + /** + * \brief SubscribeWayPointsRequest class destructor + **/ + virtual ~SubscribeWayPointsRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + virtual void on_event(const event_engine::Event& event); +private: + DISALLOW_COPY_AND_ASSIGN(SubscribeWayPointsRequest); +}; + +} // commands + +} // application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_SUBSCRIBE_WAY_POINTS_REQUEST_H_ diff --git a/src/components/application_manager/include/application_manager/commands/mobile/subscribe_way_points_response.h b/src/components/application_manager/include/application_manager/commands/mobile/subscribe_way_points_response.h new file mode 100644 index 0000000000..6514a3e7aa --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/mobile/subscribe_way_points_response.h @@ -0,0 +1,38 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_SUBSCRIBE_WAY_POINTS_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_SUBSCRIBE_WAY_POINTS_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "utils/macro.h" + +namespace application_manager { + +namespace commands { + +/** + * @brief SubscribeWayPointsResponse command class + **/ +class SubscribeWayPointsResponse : public CommandResponseImpl { +public: + /** + * \brief SubscribeWayPointsResponse class constructor + **/ + explicit SubscribeWayPointsResponse(const MessageSharedPtr& message); + + /** + * \brief SubscribeWayPointsResponse class destructor + **/ + virtual ~SubscribeWayPointsResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); +private: + DISALLOW_COPY_AND_ASSIGN(SubscribeWayPointsResponse); +}; + +} // commands + +} // application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_SUBSCRIBE_WAY_POINTS_RESPONSE_H_ diff --git a/src/components/application_manager/include/application_manager/commands/mobile/unsubscribe_way_points_request.h b/src/components/application_manager/include/application_manager/commands/mobile/unsubscribe_way_points_request.h new file mode 100644 index 0000000000..25637598e2 --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/mobile/unsubscribe_way_points_request.h @@ -0,0 +1,40 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_UNSUBSCRIBE_WAY_POINTS_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_UNSUBSCRIBE_WAY_POINTS_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" + +namespace application_manager { + +namespace commands { + +class UnSubscribeWayPointsRequest : public CommandRequestImpl { +public: + /** + * \brief UnSubscribeWayPointsRequest class constructor + **/ + explicit UnSubscribeWayPointsRequest(const MessageSharedPtr& message); + + /** + * \brief UnSubscribeWayPointsRequest class destructor + **/ + virtual ~UnSubscribeWayPointsRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + virtual void on_event(const event_engine::Event& event); +private: + DISALLOW_COPY_AND_ASSIGN(UnSubscribeWayPointsRequest); +}; + +} // commands + +} // application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_UNSUBSCRIBE_WAY_POINTS_REQUEST_H_ diff --git a/src/components/application_manager/include/application_manager/commands/mobile/unsubscribe_way_points_response.h b/src/components/application_manager/include/application_manager/commands/mobile/unsubscribe_way_points_response.h new file mode 100644 index 0000000000..219cdb200f --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/mobile/unsubscribe_way_points_response.h @@ -0,0 +1,38 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_UNSUBSCRIBE_WAY_POINTS_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_UNSUBSCRIBE_WAY_POINTS_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "utils/macro.h" + +namespace application_manager { + +namespace commands { + +/** + * @brief UnSubscribeWayPointsResponse command class + **/ +class UnSubscribeWayPointsResponse : public CommandResponseImpl { +public: + /** + * \brief UnSubscribeWayPointsResponse class constructor + **/ + explicit UnSubscribeWayPointsResponse(const MessageSharedPtr& message); + + /** + * \brief UnSubscribeWayPointsResponse class destructor + **/ + virtual ~UnSubscribeWayPointsResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); +private: + DISALLOW_COPY_AND_ASSIGN(UnSubscribeWayPointsResponse); +}; + +} // commands + +} // application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_UNSUBSCRIBE_WAY_POINTS_RESPONSE_H_ diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index 64cd9485cf..3c727faa19 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -480,6 +480,12 @@ class MessageHelper { */ static bool SendStopAudioPathThru(); + /** + * @brief Sends UnsubscribeWayPoints request + * @return true if UnSubscribedWayPoints is send otherwise false + */ + static bool SendUnSubscribedWayPoints(); + static smart_objects::SmartObjectSPtr CreateNegativeResponse( uint32_t connection_key, int32_t function_id, diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data.h b/src/components/application_manager/include/application_manager/resumption/resumption_data.h index 5c4e5ff256..6a9c41c59e 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data.h @@ -237,6 +237,13 @@ class ResumptionData { app_mngr::ApplicationConstSharedPtr application) const; /** + * @brief Retrieves of subscribed apps for way points + * @param reference for set of subscribed for way points + * @return subscribed apps for way points + */ + smart_objects::SmartObject GetSubscribedForWayPoints(const std::set<int32_t>& subscribed_for_way_points); + + /** * @brief Retrieves of subscriptions from application * @param application contains application of which selection subscriptions * @return subscriptions of application diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h b/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h index 18c9369f2e..8b5a36958a 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h @@ -821,6 +821,24 @@ class ResumptionDataDB : public ResumptionData { const std::string& device_id); /** + * @brief Insert subscribed AppIDs for way points to DB + * @return true if query is success otherwise false + */ + bool InsertSubscribedForWayPoints(); + + /** + * @brief Get subscribed AppIDs for way points to DB + * @return true if query is success otherwise false + */ + bool SelectSubscribedForWayPoints() const; + + /** + * @brief Delete from DB subscribed apps for way points + * @return true if query is success otherwise false + */ + bool DeleteSubscribedForWayPoints(); + + /** * @brief Writes data to DB after update */ void WriteDb(); diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h b/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h index c3a17d868c..3f8ca3a416 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h @@ -130,6 +130,9 @@ extern const std::string kUpdateApplicationData; extern const std::string kSelectDBVersion; extern const std::string kUpdateDBVersion; extern const std::string kUpdateGrammarID; +extern const std::string kInsertSubscribedForWayPoints; +extern const std::string kSelectSubscribedForWayPoints; +extern const std::string kDeleteSubscribedForWayPoints; } // namespace resumption #endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUMPTION_SQL_QUERY_H_ diff --git a/src/components/application_manager/include/application_manager/smart_object_keys.h b/src/components/application_manager/include/application_manager/smart_object_keys.h index ec725f05aa..60ddd38cd0 100644 --- a/src/components/application_manager/include/application_manager/smart_object_keys.h +++ b/src/components/application_manager/include/application_manager/smart_object_keys.h @@ -53,6 +53,7 @@ extern const char* info; extern const char* app_id; extern const char* hmi_app_id; extern const char* device_id; +extern const char* subscribed_for_way_points; extern const char* url; extern const char* urlScheme; extern const char* packageName; diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 9b6959bbc2..a8aa4a2731 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1262,6 +1262,11 @@ void ApplicationManagerImpl::OnServiceEndedCallback( break; } } + // SDL sends UnsubscribeWayPoints only for last application + if (subscribed_way_points_apps_list_.size() == 1) { + LOG4CXX_ERROR(logger_, "Send UnsubscribeWayPoints"); + MessageHelper::SendUnSubscribedWayPoints(); + } UnregisterApplication( session_key, reason, is_resuming, is_unexpected_disconnect); return; @@ -3457,6 +3462,47 @@ void ApplicationManagerImpl::ClearTTSGlobalPropertiesList() { tts_global_properties_app_list_.clear(); } +bool ApplicationManagerImpl::IsAppSubscribedForWayPoints(const uint32_t app) { + LOG4CXX_AUTO_TRACE(logger_); + if (subscribed_way_points_apps_list_.find(app) == + subscribed_way_points_apps_list_.end()) { + return false; + } else { + return true; + } +} + +void ApplicationManagerImpl::SubscribeAppForWayPoints(const uint32_t app) { + LOG4CXX_AUTO_TRACE(logger_); + subscribed_way_points_apps_list_.insert(app); +} + +void ApplicationManagerImpl::UnSubscribeAppForWayPoints(const uint32_t app) { + LOG4CXX_AUTO_TRACE(logger_); + subscribed_way_points_apps_list_.erase(app); +} + +bool ApplicationManagerImpl::IsAnyAppSubscribedForWayPoints() const { + LOG4CXX_AUTO_TRACE(logger_); + if (subscribed_way_points_apps_list_.size() == 0) { + return false; + } else { + return true; + } +} + +const std::set<int32_t>& ApplicationManagerImpl::GetSubscribedForWayPoints() + const { + LOG4CXX_AUTO_TRACE(logger_); + return subscribed_way_points_apps_list_; +} + +void ApplicationManagerImpl::SetSubscribedForWayPoints( + const std::set<int32_t>& subscribed_way_points_apps) { + LOG4CXX_AUTO_TRACE(logger_); + subscribed_way_points_apps_list_ = subscribed_way_points_apps; +} + ApplicationManagerImpl::ApplicationListAccessor::~ApplicationListAccessor() {} } // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/navi_subscribe_way_points_request.cc b/src/components/application_manager/src/commands/hmi/navi_subscribe_way_points_request.cc new file mode 100644 index 0000000000..9b98aaec43 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/navi_subscribe_way_points_request.cc @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2016, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "application_manager/commands/hmi/navi_subscribe_way_points_request.h" + +namespace application_manager { + +namespace commands { + +NaviSubscribeWayPointsRequest::NaviSubscribeWayPointsRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) {} + +NaviSubscribeWayPointsRequest::~NaviSubscribeWayPointsRequest() {} + +void NaviSubscribeWayPointsRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/navi_subscribe_way_points_response.cc b/src/components/application_manager/src/commands/hmi/navi_subscribe_way_points_response.cc new file mode 100644 index 0000000000..0d7c544d22 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/navi_subscribe_way_points_response.cc @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2016, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "application_manager/commands/hmi/navi_subscribe_way_points_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +NaviSubscribeWaypointsResponse::NaviSubscribeWaypointsResponse( + const MessageSharedPtr &message) + : ResponseFromHMI(message) {} + +NaviSubscribeWaypointsResponse::~NaviSubscribeWaypointsResponse() {} + +void NaviSubscribeWaypointsResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event( + hmi_apis::FunctionID::Navigation_SubscribeWayPoints); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/navi_unsubscribe_way_points_request.cc b/src/components/application_manager/src/commands/hmi/navi_unsubscribe_way_points_request.cc new file mode 100644 index 0000000000..d6c3e008b1 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/navi_unsubscribe_way_points_request.cc @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2016, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "application_manager/commands/hmi/navi_unsubscribe_way_points_request.h" + +namespace application_manager { + +namespace commands { + +NaviUnSubscribeWayPointsRequest::NaviUnSubscribeWayPointsRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) {} + +NaviUnSubscribeWayPointsRequest::~NaviUnSubscribeWayPointsRequest() {} + +void NaviUnSubscribeWayPointsRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/navi_unsubscribe_way_points_response.cc b/src/components/application_manager/src/commands/hmi/navi_unsubscribe_way_points_response.cc new file mode 100644 index 0000000000..bc3bc403ed --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/navi_unsubscribe_way_points_response.cc @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2016, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "application_manager/commands/hmi/navi_unsubscribe_way_points_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +NaviUnSubscribeWaypointsResponse::NaviUnSubscribeWaypointsResponse( + const MessageSharedPtr &message) + : ResponseFromHMI(message) {} + +NaviUnSubscribeWaypointsResponse::~NaviUnSubscribeWaypointsResponse() {} + +void NaviUnSubscribeWaypointsResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event( + hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc new file mode 100644 index 0000000000..913f97ddcf --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc @@ -0,0 +1,75 @@ +#include "application_manager/application_manager_impl.h" +#include "application_manager/commands/mobile/subscribe_way_points_request.h" + +namespace application_manager { + +namespace commands { + +SubscribeWayPointsRequest::SubscribeWayPointsRequest( + const MessageSharedPtr &message) + : CommandRequestImpl(message) {} + +SubscribeWayPointsRequest::~SubscribeWayPointsRequest() {} + +void SubscribeWayPointsRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = + application_manager::ApplicationManagerImpl::instance()->application( + connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "An application with connection key " + << connection_key() << " is not registered."); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (application_manager::ApplicationManagerImpl::instance() + ->IsAppSubscribedForWayPoints(app->app_id())) { + SendResponse(false, mobile_apis::Result::IGNORED); + return; + } + + if (application_manager::ApplicationManagerImpl::instance() + ->IsAnyAppSubscribedForWayPoints()) { + application_manager::ApplicationManagerImpl::instance() + ->SubscribeAppForWayPoints(app->app_id()); + SendResponse(true, mobile_apis::Result::SUCCESS); + return; + } + + SendHMIRequest(hmi_apis::FunctionID::Navigation_SubscribeWayPoints, NULL, + true); +} + +void SubscribeWayPointsRequest::on_event(const event_engine::Event &event) { + LOG4CXX_AUTO_TRACE(logger_); + ApplicationSharedPtr app = + application_manager::ApplicationManagerImpl::instance()->application( + connection_key()); + const smart_objects::SmartObject &message = event.smart_object(); + switch (event.id()) { + case hmi_apis::FunctionID::Navigation_SubscribeWayPoints: { + LOG4CXX_INFO(logger_, "Received Navigation_SubscribeWayPoints event"); + mobile_apis::Result::eType result_code = + GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asUInt())); + bool result = mobile_apis::Result::SUCCESS == result_code; + if (result) { + application_manager::ApplicationManagerImpl::instance() + ->SubscribeAppForWayPoints(app->app_id()); + } + SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + break; + } + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/subscribe_way_points_response.cc b/src/components/application_manager/src/commands/mobile/subscribe_way_points_response.cc new file mode 100644 index 0000000000..bb0fc77c82 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/subscribe_way_points_response.cc @@ -0,0 +1,24 @@ +#include "application_manager/application_manager_impl.h" +#include "application_manager/commands/mobile/subscribe_way_points_response.h" + +namespace application_manager { + +namespace commands { + +SubscribeWayPointsResponse::SubscribeWayPointsResponse( + const MessageSharedPtr &message) + : CommandResponseImpl(message) { +} + +SubscribeWayPointsResponse::~SubscribeWayPointsResponse() { +} + +void SubscribeWayPointsResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc new file mode 100644 index 0000000000..9e8c1ea505 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc @@ -0,0 +1,67 @@ +#include "application_manager/application_manager_impl.h" +#include "application_manager/commands/mobile/unsubscribe_way_points_request.h" + +namespace application_manager { + +namespace commands { + +UnSubscribeWayPointsRequest::UnSubscribeWayPointsRequest( + const MessageSharedPtr &message) + : CommandRequestImpl(message) {} + +UnSubscribeWayPointsRequest::~UnSubscribeWayPointsRequest() {} + +void UnSubscribeWayPointsRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = + application_manager::ApplicationManagerImpl::instance()->application( + connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "An application with connection key " + << connection_key() << " is not registered."); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (!application_manager::ApplicationManagerImpl::instance() + ->IsAppSubscribedForWayPoints(app->app_id())) { + SendResponse(false, mobile_apis::Result::IGNORED); + return; + } + + SendHMIRequest(hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints, NULL, + true); +} + +void UnSubscribeWayPointsRequest::on_event(const event_engine::Event &event) { + LOG4CXX_AUTO_TRACE(logger_); + ApplicationSharedPtr app = + application_manager::ApplicationManagerImpl::instance()->application( + connection_key()); + const smart_objects::SmartObject &message = event.smart_object(); + switch (event.id()) { + case hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints: { + LOG4CXX_INFO(logger_, "Received Navigation_UnSubscribeWayPoints event"); + mobile_apis::Result::eType result_code = + GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asUInt())); + bool result = mobile_apis::Result::SUCCESS == result_code; + if (result) { + application_manager::ApplicationManagerImpl::instance() + ->UnSubscribeAppForWayPoints(app->app_id()); + } + SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + break; + } + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_response.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_response.cc new file mode 100644 index 0000000000..f761cca491 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_response.cc @@ -0,0 +1,22 @@ +#include "application_manager/application_manager_impl.h" +#include "application_manager/commands/mobile/unsubscribe_way_points_response.h" + +namespace application_manager { + +namespace commands { + +UnSubscribeWayPointsResponse::UnSubscribeWayPointsResponse( + const MessageSharedPtr &message) + : CommandResponseImpl(message) {} + +UnSubscribeWayPointsResponse::~UnSubscribeWayPointsResponse() {} + +void UnSubscribeWayPointsResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/hmi_command_factory.cc b/src/components/application_manager/src/hmi_command_factory.cc index 2ec9de5970..7fe5fb607c 100644 --- a/src/components/application_manager/src/hmi_command_factory.cc +++ b/src/components/application_manager/src/hmi_command_factory.cc @@ -209,6 +209,10 @@ #include "application_manager/commands/hmi/navi_alert_maneuver_response.h" #include "application_manager/commands/hmi/navi_update_turn_list_request.h" #include "application_manager/commands/hmi/navi_update_turn_list_response.h" +#include "application_manager/commands/hmi/navi_subscribe_way_points_request.h" +#include "application_manager/commands/hmi/navi_subscribe_way_points_response.h" +#include "application_manager/commands/hmi/navi_unsubscribe_way_points_request.h" +#include "application_manager/commands/hmi/navi_unsubscribe_way_points_response.h" #include "application_manager/commands/hmi/on_ready_notification.h" #include "application_manager/commands/hmi/on_device_chosen_notification.h" #include "application_manager/commands/hmi/on_file_removed_notification.h" @@ -1057,6 +1061,22 @@ CommandSharedPtr HMICommandFactory::CreateCommand( } break; } + case hmi_apis::FunctionID::Navigation_SubscribeWayPoints: { + if (is_response) { + command.reset(new commands::NaviSubscribeWaypointsResponse(message)); + } else { + command.reset(new commands::NaviSubscribeWayPointsRequest(message)); + } + break; + } + case hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints: { + if (is_response) { + command.reset(new commands::NaviUnSubscribeWaypointsResponse(message)); + } else { + command.reset(new commands::NaviUnSubscribeWayPointsRequest(message)); + } + break; + } case hmi_apis::FunctionID::Buttons_GetCapabilities: { if (is_response) { command.reset(new commands::ButtonGetCapabilitiesResponse(message)); 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 2eff8a0c96..df9edb4fb7 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -1759,6 +1759,18 @@ bool MessageHelper::SendStopAudioPathThru() { return ApplicationManagerImpl::instance()->ManageHMICommand(result); } +bool MessageHelper::SendUnSubscribedWayPoints() { + LOG4CXX_INFO(logger_, "MessageHelper::SendUnSubscribedWayPoints"); + + smart_objects::SmartObjectSPtr result = CreateRequestObject(); + + smart_objects::SmartObject& request = *result; + request[strings::params][strings::function_id] = + hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints; + + return ApplicationManagerImpl::instance()->ManageHMICommand(result); +} + void MessageHelper::SendPolicySnapshotNotification( const unsigned int connection_key, const std::vector<uint8_t>& policy_data, diff --git a/src/components/application_manager/src/mobile_command_factory.cc b/src/components/application_manager/src/mobile_command_factory.cc index dc665bc28b..842f01faf8 100644 --- a/src/components/application_manager/src/mobile_command_factory.cc +++ b/src/components/application_manager/src/mobile_command_factory.cc @@ -107,6 +107,10 @@ #include "application_manager/commands/mobile/subscribe_button_response.h" #include "application_manager/commands/mobile/subscribe_vehicle_data_request.h" #include "application_manager/commands/mobile/subscribe_vehicle_data_response.h" +#include "application_manager/commands/mobile/subscribe_way_points_request.h" +#include "application_manager/commands/mobile/subscribe_way_points_response.h" +#include "application_manager/commands/mobile/unsubscribe_way_points_request.h" +#include "application_manager/commands/mobile/unsubscribe_way_points_response.h" #include "application_manager/commands/mobile/unregister_app_interface_request.h" #include "application_manager/commands/mobile/unregister_app_interface_response.h" #include "application_manager/commands/mobile/unsubscribe_button_request.h" @@ -363,6 +367,24 @@ CommandSharedPtr MobileCommandFactory::CreateCommand( } break; } + case mobile_apis::FunctionID::SubscribeWayPointsID: { + if ((*message)[strings::params][strings::message_type] + == static_cast<int>(application_manager::MessageType::kResponse)) { + command = utils::MakeShared<commands::SubscribeWayPointsResponse>(message); + } else { + command = utils::MakeShared<commands::SubscribeWayPointsRequest>(message); + } + break; + } + case mobile_apis::FunctionID::UnsubscribeWayPointsID: { + if ((*message)[strings::params][strings::message_type] + == static_cast<int>(application_manager::MessageType::kResponse)) { + command = utils::MakeShared<commands::UnSubscribeWayPointsResponse>(message); + } else { + command = utils::MakeShared<commands::UnSubscribeWayPointsRequest>(message); + } + break; + } case mobile_apis::FunctionID::ReadDIDID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { diff --git a/src/components/application_manager/src/resumption/resumption_data.cc b/src/components/application_manager/src/resumption/resumption_data.cc index d068945d6b..1e2ca8e29c 100644 --- a/src/components/application_manager/src/resumption/resumption_data.cc +++ b/src/components/application_manager/src/resumption/resumption_data.cc @@ -137,6 +137,21 @@ smart_objects::SmartObject ResumptionData::GetApplicationGlobalProperties( return global_properties; } +smart_objects::SmartObject ResumptionData::GetSubscribedForWayPoints( + const std::set<int32_t>& subscribed_for_way_points) { + LOG4CXX_AUTO_TRACE(logger_); + smart_objects::SmartObject result = + smart_objects::SmartObject(smart_objects::SmartType_Array); + int app_id_counter = 0; + for (std::set<int32_t>::const_iterator app_id = + subscribed_for_way_points.begin(); + app_id != subscribed_for_way_points.end(); ++app_id) { + result[app_id_counter] = *app_id; + app_id_counter++; + } + return result; +} + smart_objects::SmartObject ResumptionData::GetApplicationSubscriptions( app_mngr::ApplicationConstSharedPtr application) const { using namespace app_mngr; diff --git a/src/components/application_manager/src/resumption/resumption_data_db.cc b/src/components/application_manager/src/resumption/resumption_data_db.cc index 21c9eed3b4..4252e86c4c 100644 --- a/src/components/application_manager/src/resumption/resumption_data_db.cc +++ b/src/components/application_manager/src/resumption/resumption_data_db.cc @@ -32,6 +32,7 @@ #include <string> #include <unistd.h> +#include "application_manager/application_manager_impl.h" #include "application_manager/resumption/resumption_data_db.h" #include "application_manager/resumption/resumption_sql_queries.h" #include "application_manager/smart_object_keys.h" @@ -152,6 +153,11 @@ void ResumptionDataDB::SaveApplication( return; } + if (!InsertSubscribedForWayPoints()) { + LOG4CXX_ERROR(logger_, "Problem with saving SubscribedForWayPoints"); + return; + } + if (application->is_application_data_changed()) { if (application_exist) { if (!DeleteSavedApplication(policy_app_id, device_mac)) { @@ -343,6 +349,11 @@ bool ResumptionDataDB::GetSavedApplication( return false; } + if (!SelectSubscribedForWayPoints()) { + LOG4CXX_ERROR(logger_, "Problem with restoring of SubscribedForWayPoints"); + return false; + } + if (!SelectFilesData(policy_app_id, device_id, saved_app)) { LOG4CXX_ERROR(logger_, "Problem with restoring of files data"); return false; @@ -2712,6 +2723,73 @@ void ResumptionDataDB::UpdateDataOnAwake() { } } +bool ResumptionDataDB::InsertSubscribedForWayPoints() { + LOG4CXX_AUTO_TRACE(logger_); + using namespace app_mngr; + + if (!DeleteSubscribedForWayPoints()) { + LOG4CXX_WARN(logger_, "SubscribedForWayPoints table was not cleaned"); + } + + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(kInsertSubscribedForWayPoints)) { + LOG4CXX_WARN(logger_, + "Problem with verification query " + "for updating some SubscribedForWayPoints data"); + return false; + } + + const std::set<int32_t> apps = + application_manager::ApplicationManagerImpl::instance() + ->GetSubscribedForWayPoints(); + for (std::set<int32_t>::iterator i = apps.begin(); i != apps.end(); i++) { + query.Reset(); + query.Bind(0, *i); + if (!query.Exec()) { + LOG4CXX_WARN(logger_, "Problem with execution query"); + return false; + } + } + LOG4CXX_INFO( + logger_, + "Data were updated successfully in SubscribedForWayPoints table"); + return true; +} + +bool ResumptionDataDB::SelectSubscribedForWayPoints() const { + LOG4CXX_AUTO_TRACE(logger_); + std::set<int32_t> subscribed_for_way_points; + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(kSelectSubscribedForWayPoints)) { + LOG4CXX_WARN( + logger_, + "Problem with verification kSelectSubscribedForWayPoints query"); + return false; + } + while (query.Next()) { + subscribed_for_way_points.insert(query.GetInteger(0)); + } + application_manager::ApplicationManagerImpl::instance() + ->SetSubscribedForWayPoints(subscribed_for_way_points); + return true; +} + +bool ResumptionDataDB::DeleteSubscribedForWayPoints() { + LOG4CXX_AUTO_TRACE(logger_); + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(kDeleteSubscribedForWayPoints)) { + LOG4CXX_WARN( + logger_, + "Problem with verification kDeleteSubscribedForWayPoints query"); + return false; + } + if (!query.Exec()) { + LOG4CXX_WARN(logger_, "Problem with execution query"); + return false; + } + return true; +} + bool ResumptionDataDB::UpdateApplicationData( app_mngr::ApplicationConstSharedPtr application, const std::string& policy_app_id, diff --git a/src/components/application_manager/src/resumption/resumption_data_json.cc b/src/components/application_manager/src/resumption/resumption_data_json.cc index 62297eb2de..883d495c16 100644 --- a/src/components/application_manager/src/resumption/resumption_data_json.cc +++ b/src/components/application_manager/src/resumption/resumption_data_json.cc @@ -30,6 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "application_manager/application_manager_impl.h" #include "application_manager/resumption/resumption_data_json.h" #include "smart_objects/smart_object.h" #include "json/json.h" @@ -62,6 +63,8 @@ void ResumptionDataJson::SaveApplication( const uint32_t time_stamp = (uint32_t)time(NULL); const std::string device_mac = application->mac_address(); const mobile_apis::HMILevel::eType hmi_level = application->hmi_level(); + const std::set<int32_t> subscribed_for_way_points = + app_mngr::ApplicationManagerImpl::instance()->GetSubscribedForWayPoints(); sync_primitives::AutoLock autolock(resumption_lock_); Json::Value tmp; @@ -96,6 +99,10 @@ void ResumptionDataJson::SaveApplication( GetApplicationFiles(application), tmp); json_app[strings::application_files] = tmp; json_app[strings::time_stamp] = time_stamp; + Formatters::CFormatterJsonBase::objToJsonValue( + GetSubscribedForWayPoints(subscribed_for_way_points), tmp); + json_app[strings::subscribed_for_way_points] = tmp; + LOG4CXX_DEBUG(logger_, "SaveApplication : " << json_app.toStyledString()); } @@ -255,6 +262,7 @@ bool ResumptionDataJson::GetSavedApplication( const std::string& policy_app_id, const std::string& device_id, smart_objects::SmartObject& saved_app) const { + using namespace app_mngr; LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock autolock(resumption_lock_); const int idx = GetObjectIndex(policy_app_id, device_id); @@ -263,6 +271,19 @@ bool ResumptionDataJson::GetSavedApplication( } const Json::Value& json_saved_app = GetSavedApplications()[idx]; Formatters::CFormatterJsonBase::jsonValueToObj(json_saved_app, saved_app); + + smart_objects::SmartArray app_id_list = + *(saved_app[strings::subscribed_for_way_points].asArray()); + + std::set<int32_t> subscribed_for_way_points; + + for (smart_objects::SmartArray::iterator i = app_id_list.begin(); + i != app_id_list.end(); ++i) { + subscribed_for_way_points.insert((*i).asInt()); + } + + app_mngr::ApplicationManagerImpl::instance()->SetSubscribedForWayPoints( + subscribed_for_way_points); return true; } diff --git a/src/components/application_manager/src/resumption/resumption_sql_queries.cc b/src/components/application_manager/src/resumption/resumption_sql_queries.cc index 67970fd0c8..1c1bcc3b35 100644 --- a/src/components/application_manager/src/resumption/resumption_sql_queries.cc +++ b/src/components/application_manager/src/resumption/resumption_sql_queries.cc @@ -39,6 +39,9 @@ const std::string kCreateSchema = " `idresumption` INTEGER PRIMARY KEY, " " `last_ign_off_time` INTEGER " " ); " + "CREATE TABLE IF NOT EXISTS `subscribedForWayPoints`( " + " `appID` INTEGER " + " ); " "CREATE TABLE IF NOT EXISTS `image`( " " `idimage` INTEGER PRIMARY KEY NOT NULL, " " `imageType` INTEGER, " @@ -316,6 +319,7 @@ const std::string kDropSchema = "DROP INDEX IF EXISTS " "`message.fk_message_consumer_friendly_messages1_idx`; " "DROP TABLE IF EXISTS `resumption`; " + "DROP TABLE IF EXISTS `subscribedForWayPoints`; " "DROP TABLE IF EXISTS `image`; " "DROP TABLE IF EXISTS `applicationChoiceSet`; " "DROP TABLE IF EXISTS `file`; " @@ -964,4 +968,13 @@ const std::string kUpdateGrammarID = "SET `grammarID` = ? " "WHERE `appID` = ? AND `deviceID` = ?;"; +const std::string kInsertSubscribedForWayPoints = + "INSERT INTO `subscribedForWayPoints` (`appID`) VALUES (?);"; + +const std::string kSelectSubscribedForWayPoints = + "SELECT `appID` FROM `subscribedForWayPoints`;"; + +const std::string kDeleteSubscribedForWayPoints = + "DELETE FROM `subscribedForWayPoints`;"; + } // namespace resumption |