summaryrefslogtreecommitdiff
path: root/src/components/application_manager/rpc_plugins/vehicle_info_plugin
diff options
context:
space:
mode:
authorAlexander <akutsan@luxoft.com>2018-06-16 19:45:29 +0300
committerIra Lytvynenko (GitHub) <ILytvynenko@luxoft.com>2018-06-26 12:01:48 +0300
commitac86aa9a064bce07c5cec933fb27dfd9f92c7bc0 (patch)
treea859328a22b0753a593538da43e34f6906bf7286 /src/components/application_manager/rpc_plugins/vehicle_info_plugin
parenta79ca65ed1171f9abbdf3443843dae79151e97a3 (diff)
downloadsdl_core-ac86aa9a064bce07c5cec933fb27dfd9f92c7bc0.tar.gz
Replace all of application SubscribeToIVI to app extension subscribeToVehicleInfo
Diffstat (limited to 'src/components/application_manager/rpc_plugins/vehicle_info_plugin')
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_app_extension.h9
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc8
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc26
3 files changed, 33 insertions, 10 deletions
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_app_extension.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_app_extension.h
index fd9aea5321..497fe5e904 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_app_extension.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_app_extension.h
@@ -47,12 +47,12 @@ typedef mobile_apis::VehicleDataType::eType VehicleDataType;
*/
typedef std::set<mobile_apis::VehicleDataType::eType> VehicleInfoSubscriptions;
-class VehicleInfoAppExtension : app_mngr::AppExtension {
+class VehicleInfoAppExtension : public app_mngr::AppExtension {
public:
- explicit VehicleInfoAppExtension(app_mngr::AppExtensionUID uid);
+ explicit VehicleInfoAppExtension();
virtual ~VehicleInfoAppExtension();
- void subscribeToVehicleInfo(const VehicleDataType vehicle_data);
+ bool subscribeToVehicleInfo(const VehicleDataType vehicle_data);
void unsubscribeFromVehicleInfo(const VehicleDataType vehicle_data);
void unsubscribeFromVehicleInfo();
bool isSubscribedToVehicleInfo(const VehicleDataType vehicle_data_type) const;
@@ -61,6 +61,9 @@ class VehicleInfoAppExtension : app_mngr::AppExtension {
void SaveResumptionData(
NsSmartDeviceLink::NsSmartObjects::SmartObject& resumption_data) OVERRIDE;
void PorcessResumption(const smart_objects::SmartObject& resumption_data) OVERRIDE;
+ static unsigned VehicleInfoAppExtensionUID;
+ static VehicleInfoAppExtension& ExtractVIExtension(
+ application_manager::Application& app);
private:
VehicleInfoSubscriptions subscribed_data_;
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc
index 766e720217..51c5fab6fe 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc
@@ -39,6 +39,7 @@
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
#include "utils/helpers.h"
+#include "vehicle_info_plugin/vehicle_info_app_extension.h"
namespace vehicle_info_plugin {
using namespace application_manager;
@@ -269,7 +270,8 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
app_mngr::VehicleInfoSubscriptions::const_iterator key =
vi_waiting_for_subscribe_.begin();
for (; key != vi_waiting_for_subscribe_.end(); ++key) {
- app->SubscribeToIVI(*key);
+ auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app);
+ ext.subscribeToVehicleInfo(*key);
}
}
}
@@ -436,7 +438,9 @@ void SubscribeVehicleDataRequest::CheckVISubscriptions(
"There are apps subscribed already for "
"VehicleDataType: "
<< key_type);
- if (!app->SubscribeToIVI(static_cast<uint32_t>(key_type))) {
+ auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app);
+
+ if (!ext.subscribeToVehicleInfo(key_type)) {
LOG4CXX_ERROR(
logger_,
"Unable to subscribe for VehicleDataType: " << key_type);
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc
index f182e3258a..3cce05190a 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc
@@ -31,14 +31,17 @@
*/
#include "vehicle_info_plugin/vehicle_info_app_extension.h"
+#include "vehicle_info_plugin/vehicle_info_plugin.h"
CREATE_LOGGERPTR_GLOBAL(logger_, "VehicleInfoPlugin")
namespace vehicle_info_plugin {
-VehicleInfoAppExtension::VehicleInfoAppExtension(
- application_manager::AppExtensionUID uid)
- : app_mngr::AppExtension(uid) {
+unsigned VehicleInfoAppExtension::VehicleInfoAppExtensionUID = 146;
+
+VehicleInfoAppExtension::VehicleInfoAppExtension()
+ : app_mngr::AppExtension(
+ VehicleInfoAppExtension::VehicleInfoAppExtensionUID) {
LOG4CXX_AUTO_TRACE(logger_);
}
@@ -46,10 +49,10 @@ VehicleInfoAppExtension::~VehicleInfoAppExtension() {
LOG4CXX_AUTO_TRACE(logger_);
}
-void VehicleInfoAppExtension::subscribeToVehicleInfo(
+bool VehicleInfoAppExtension::subscribeToVehicleInfo(
const VehicleDataType vehicle_data) {
LOG4CXX_DEBUG(logger_, vehicle_data);
- subscribed_data_.insert(vehicle_data);
+ return subscribed_data_.insert(vehicle_data).second;
}
void VehicleInfoAppExtension::unsubscribeFromVehicleInfo(
@@ -103,4 +106,17 @@ void VehicleInfoAppExtension::PorcessResumption(
// application, application_manager_));
}
}
+
+VehicleInfoAppExtension& VehicleInfoAppExtension::ExtractVIExtension(
+ application_manager::Application& app) {
+ auto ext_ptr =
+ app.QueryInterface(VehicleInfoAppExtension::VehicleInfoAppExtensionUID);
+ DCHECK(ext_ptr);
+ DCHECK(dynamic_cast<VehicleInfoAppExtension*>(ext_ptr.get()));
+ auto vi_app_extension =
+ application_manager::AppExtensionPtr::static_pointer_cast<
+ VehicleInfoAppExtension>(ext_ptr);
+ DCHECK(vi_app_extension);
+ return *vi_app_extension;
+}
}