summaryrefslogtreecommitdiff
path: root/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc')
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc
index 6a6a50dc86..a016d1fe16 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc
@@ -31,11 +31,15 @@
*/
#include "app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h"
+#include "app_service_rpc_plugin/app_service_app_extension.h"
#include "application_manager/application_impl.h"
+#include "application_manager/helpers/application_helper.h"
#include "application_manager/message_helper.h"
#include "application_manager/rpc_service.h"
#include "interfaces/MOBILE_API.h"
+#include "smart_objects/enum_schema_item.h"
+
namespace app_service_rpc_plugin {
using namespace application_manager;
namespace commands {
@@ -58,7 +62,38 @@ void OnAppServiceDataNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
LOG4CXX_DEBUG(logger_, "Sending OnAppServiceData to consumer");
MessageHelper::PrintSmartObject(*message_);
- SendNotification();
+
+ std::string service_type =
+ (*message_)[strings::msg_params][strings::service_type].asString();
+
+ auto subscribed_to_app_service_predicate =
+ [service_type](const ApplicationSharedPtr app) {
+ DCHECK_OR_RETURN(app, false);
+ auto& ext = AppServiceAppExtension::ExtractASExtension(*app);
+ LOG4CXX_DEBUG(logger_, "Check subscription for type: " << service_type);
+ return ext.IsSubscribedToAppService(service_type);
+ };
+
+ const std::vector<ApplicationSharedPtr>& applications =
+ application_manager::FindAllApps(application_manager_.applications(),
+ subscribed_to_app_service_predicate);
+
+ std::vector<ApplicationSharedPtr>::const_iterator app_it =
+ applications.begin();
+
+ for (; applications.end() != app_it; ++app_it) {
+ const ApplicationSharedPtr app = *app_it;
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ continue;
+ }
+ LOG4CXX_DEBUG(logger_,
+ "Sending OnAppServiceDataNotification to mobile connection: "
+ << app->app_id());
+ (*message_)[app_mngr::strings::params][app_mngr::strings::connection_key] =
+ app->app_id();
+ SendNotification();
+ }
}
} // namespace commands