From ee8a0abc3be4fce07d3ed21ebfbc698fdcf8e466 Mon Sep 17 00:00:00 2001 From: AKalinich-Luxoft Date: Wed, 30 Aug 2017 14:17:33 +0300 Subject: Rename Subject struct for policy_external --- .../policy_external/include/policy/access_remote.h | 18 +++++++++++------- .../include/policy/access_remote_impl.h | 11 ++++++----- .../include/policy/policy_manager_impl.h | 2 +- .../policy/policy_external/src/policy_manager_impl.cc | 10 +++++----- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/components/policy/policy_external/include/policy/access_remote.h b/src/components/policy/policy_external/include/policy/access_remote.h index 9e84508603..fd185af075 100644 --- a/src/components/policy/policy_external/include/policy/access_remote.h +++ b/src/components/policy/policy_external/include/policy/access_remote.h @@ -58,17 +58,20 @@ inline std::ostream& operator<<(std::ostream& output, TypeAccess x) { return output; } -struct Subject { +struct ApplicationOnDevice { PTString dev_id; PTString app_id; }; -inline bool operator<(const Subject& x, const Subject& y) { +inline bool operator<(const ApplicationOnDevice& x, + const ApplicationOnDevice& y) { return x.dev_id < y.dev_id || (x.dev_id == y.dev_id && x.app_id < y.app_id); } -inline bool operator==(const Subject& x, const Subject& y) { +inline bool operator==(const ApplicationOnDevice& x, + const ApplicationOnDevice& y) { return x.dev_id == y.dev_id && x.app_id == y.app_id; } -inline std::ostream& operator<<(std::ostream& output, const Subject& who) { +inline std::ostream& operator<<(std::ostream& output, + const ApplicationOnDevice& who) { output << "Subject(dev:" << who.dev_id << ", app:" << who.app_id << ")"; return output; } @@ -92,7 +95,7 @@ class AccessRemote { * @param who application on specific device * @param hmi_types hmi types list */ - virtual void SetDefaultHmiTypes(const Subject& who, + virtual void SetDefaultHmiTypes(const ApplicationOnDevice& who, const std::vector& hmi_types) = 0; /** @@ -100,7 +103,8 @@ class AccessRemote { * @param who application on specific device * @return list of groups */ - virtual const policy_table::Strings& GetGroups(const Subject& who) = 0; + virtual const policy_table::Strings& GetGroups( + const ApplicationOnDevice& who) = 0; /** * @brief GetPermissionsForApp read list of permissions for application @@ -118,7 +122,7 @@ class AccessRemote { * @param who application on specific device * @return true is remote controll aotherwise return false */ - virtual bool IsAppRemoteControl(const Subject& who) = 0; + virtual bool IsAppRemoteControl(const ApplicationOnDevice& who) = 0; /** * @brief GetModuleTypes get list of module types of application diff --git a/src/components/policy/policy_external/include/policy/access_remote_impl.h b/src/components/policy/policy_external/include/policy/access_remote_impl.h index 14d25a5bd1..0fa53b0237 100644 --- a/src/components/policy/policy_external/include/policy/access_remote_impl.h +++ b/src/components/policy/policy_external/include/policy/access_remote_impl.h @@ -61,7 +61,7 @@ class AccessRemoteImpl : public AccessRemote { * @param who application on specific device * @param hmi_types hmi types list */ - void SetDefaultHmiTypes(const Subject& who, + void SetDefaultHmiTypes(const ApplicationOnDevice& who, const std::vector& hmi_types) OVERRIDE; /** @@ -69,7 +69,8 @@ class AccessRemoteImpl : public AccessRemote { * @param who application on specific device * @return list of groups */ - const policy_table::Strings& GetGroups(const Subject& who) OVERRIDE; + const policy_table::Strings& GetGroups( + const ApplicationOnDevice& who) OVERRIDE; /** * @brief GetPermissionsForApp read list of permissions for application @@ -87,7 +88,7 @@ class AccessRemoteImpl : public AccessRemote { * @param who application on specific device * @return true is remote controll aotherwise return false */ - bool IsAppRemoteControl(const Subject& who) OVERRIDE; + bool IsAppRemoteControl(const ApplicationOnDevice& who) OVERRIDE; /** * @brief GetModuleTypes get list of module types of application @@ -106,7 +107,7 @@ class AccessRemoteImpl : public AccessRemote { * @param who application on specific device * @return list of hmi types */ - const policy_table::AppHMITypes& HmiTypes(const Subject& who); + const policy_table::AppHMITypes& HmiTypes(const ApplicationOnDevice& who); /** * @brief GetGroupsIds get list of groups for application @@ -148,7 +149,7 @@ class AccessRemoteImpl : public AccessRemote { /** * @brief hmi_types_ contains list of default HMI types for applications */ - typedef std::map HMIList; + typedef std::map HMIList; HMIList hmi_types_; #ifdef BUILD_TESTS diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index 00cccb4c24..f8d226c86a 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -482,7 +482,7 @@ class PolicyManagerImpl : public PolicyManager { * @brief Sends notification about application HMI level changed * @param who application information structure */ - void SendHMILevelChanged(const Subject& who); + void SendHMILevelChanged(const ApplicationOnDevice& who); /** * @brief Sends notification if application permissions were changed diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index 315ac223a0..db858cd2e4 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -597,7 +597,7 @@ void PolicyManagerImpl::CheckPermissions(const PTString& app_id, cache_->GetFunctionalGroupings(functional_groupings); #ifdef SDL_REMOTE_CONTROL - Subject who = {device_id, app_id}; + ApplicationOnDevice who = {device_id, app_id}; const policy_table::Strings app_groups = access_remote_->GetGroups(who); #else // SDL_REMOTE_CONTROL const policy_table::Strings app_groups = @@ -782,7 +782,7 @@ void PolicyManagerImpl::SendNotificationOnPermissionsUpdated( "Send notification for application_id:" << application_id); #ifdef SDL_REMOTE_CONTROL - const Subject who = {device_id, application_id}; + const ApplicationOnDevice who = {device_id, application_id}; if (access_remote_->IsAppRemoteControl(who)) { listener()->OnPermissionsUpdated(application_id, notification_data); return; @@ -1937,7 +1937,7 @@ void PolicyManagerImpl::SetDefaultHmiTypes(const std::string& application_id, const std::vector& hmi_types) { LOG4CXX_INFO(logger_, "SetDefaultHmiTypes"); const std::string device_id = GetCurrentDeviceId(application_id); - Subject who = {device_id, application_id}; + ApplicationOnDevice who = {device_id, application_id}; access_remote_->SetDefaultHmiTypes(who, hmi_types); } @@ -1972,7 +1972,7 @@ bool PolicyManagerImpl::CheckModule(const PTString& app_id, access_remote_->CheckModuleType(app_id, module_type); } -void PolicyManagerImpl::SendHMILevelChanged(const Subject& who) { +void PolicyManagerImpl::SendHMILevelChanged(const ApplicationOnDevice& who) { std::string default_hmi("NONE"); if (GetDefaultHmi(who.app_id, &default_hmi)) { listener()->OnUpdateHMIStatus(who.dev_id, who.app_id, default_hmi); @@ -2021,7 +2021,7 @@ void PolicyManagerImpl::OnPrimaryGroupsChanged( for (std::vector::const_iterator i = devices.begin(); i != devices.end(); ++i) { - const Subject who = {*i, application_id}; + const ApplicationOnDevice who = {*i, application_id}; if (access_remote_->IsAppRemoteControl(who)) { SendAppPermissionsChanged(who.dev_id, who.app_id); } -- cgit v1.2.1 From b5e476b09754ac4050421a27343c5cf63ede94d7 Mon Sep 17 00:00:00 2001 From: AKalinich-Luxoft Date: Wed, 30 Aug 2017 14:18:27 +0300 Subject: Rename Subject struct for policy_regular --- .../policy_regular/include/policy/access_remote.h | 18 +++++++++++------- .../policy_regular/include/policy/access_remote_impl.h | 11 ++++++----- .../include/policy/policy_manager_impl.h | 2 +- .../policy/policy_regular/src/access_remote_impl.cc | 11 ++++++----- .../policy/policy_regular/src/policy_manager_impl.cc | 10 +++++----- .../policy_regular/test/access_remote_impl_test.cc | 4 ++-- .../test/include/policy/mock_access_remote.h | 14 ++++++++------ 7 files changed, 39 insertions(+), 31 deletions(-) diff --git a/src/components/policy/policy_regular/include/policy/access_remote.h b/src/components/policy/policy_regular/include/policy/access_remote.h index 7b7cf57d5f..c4de9b7e1f 100644 --- a/src/components/policy/policy_regular/include/policy/access_remote.h +++ b/src/components/policy/policy_regular/include/policy/access_remote.h @@ -41,17 +41,20 @@ namespace policy_table = ::rpc::policy_table_interface_base; namespace policy { -struct Subject { +struct ApplicationOnDevice { PTString dev_id; PTString app_id; }; -inline bool operator<(const Subject& x, const Subject& y) { +inline bool operator<(const ApplicationOnDevice& x, + const ApplicationOnDevice& y) { return x.dev_id < y.dev_id || (x.dev_id == y.dev_id && x.app_id < y.app_id); } -inline bool operator==(const Subject& x, const Subject& y) { +inline bool operator==(const ApplicationOnDevice& x, + const ApplicationOnDevice& y) { return x.dev_id == y.dev_id && x.app_id == y.app_id; } -inline std::ostream& operator<<(std::ostream& output, const Subject& who) { +inline std::ostream& operator<<(std::ostream& output, + const ApplicationOnDevice& who) { output << "Subject(dev:" << who.dev_id << ", app:" << who.app_id << ")"; return output; } @@ -75,7 +78,7 @@ class AccessRemote { * @param who application on specific device * @param hmi_types hmi types list */ - virtual void SetDefaultHmiTypes(const Subject& who, + virtual void SetDefaultHmiTypes(const ApplicationOnDevice& who, const std::vector& hmi_types) = 0; /** @@ -83,7 +86,8 @@ class AccessRemote { * @param who application on specific device * @return list of groups */ - virtual const policy_table::Strings& GetGroups(const Subject& who) = 0; + virtual const policy_table::Strings& GetGroups( + const ApplicationOnDevice& who) = 0; /** * @brief GetPermissionsForApp read list of permissions for application @@ -101,7 +105,7 @@ class AccessRemote { * @param who application on specific device * @return true is remote controll aotherwise return false */ - virtual bool IsAppRemoteControl(const Subject& who) = 0; + virtual bool IsAppRemoteControl(const ApplicationOnDevice& who) = 0; /** * @brief GetModuleTypes get list of module types of application diff --git a/src/components/policy/policy_regular/include/policy/access_remote_impl.h b/src/components/policy/policy_regular/include/policy/access_remote_impl.h index 694b680374..933690dc49 100644 --- a/src/components/policy/policy_regular/include/policy/access_remote_impl.h +++ b/src/components/policy/policy_regular/include/policy/access_remote_impl.h @@ -60,14 +60,15 @@ class AccessRemoteImpl : public AccessRemote { * @param who application on specific device * @param hmi_types hmi types list */ - void SetDefaultHmiTypes(const Subject& who, + void SetDefaultHmiTypes(const ApplicationOnDevice& who, const std::vector& hmi_types) OVERRIDE; /** * @brief GetGroups return list of groups for applicaiton * @param who application on specific device * @return list of groups */ - const policy_table::Strings& GetGroups(const Subject& who) OVERRIDE; + const policy_table::Strings& GetGroups( + const ApplicationOnDevice& who) OVERRIDE; /** * @brief GetPermissionsForApp read list of permissions for application @@ -85,7 +86,7 @@ class AccessRemoteImpl : public AccessRemote { * @param who application on specific device * @return true is remote controll aotherwise return false */ - bool IsAppRemoteControl(const Subject& who) OVERRIDE; + bool IsAppRemoteControl(const ApplicationOnDevice& who) OVERRIDE; /** * @brief GetModuleTypes get list of module types of application @@ -102,7 +103,7 @@ class AccessRemoteImpl : public AccessRemote { * @param who application on specific device * @return list of hmi types */ - const policy_table::AppHMITypes& HmiTypes(const Subject& who); + const policy_table::AppHMITypes& HmiTypes(const ApplicationOnDevice& who); /** * @brief GetGroupsIds get list of groups for application @@ -143,7 +144,7 @@ class AccessRemoteImpl : public AccessRemote { /** * @brief hmi_types_ contains list of default HMI types for applications */ - typedef std::map HMIList; + typedef std::map HMIList; HMIList hmi_types_; #ifdef BUILD_TESTS diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index 0e81ed26df..1b39392c0c 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -476,7 +476,7 @@ class PolicyManagerImpl : public PolicyManager { * @brief Sends notification about application HMI level changed * @param who application information structure */ - void SendHMILevelChanged(const Subject& who); + void SendHMILevelChanged(const ApplicationOnDevice& who); /** * @brief Sends notification if application permissions were changed diff --git a/src/components/policy/policy_regular/src/access_remote_impl.cc b/src/components/policy/policy_regular/src/access_remote_impl.cc index f77a8e02cd..f99b226f2e 100644 --- a/src/components/policy/policy_regular/src/access_remote_impl.cc +++ b/src/components/policy/policy_regular/src/access_remote_impl.cc @@ -155,7 +155,7 @@ bool AccessRemoteImpl::CompareParameters( return input->empty(); } -void AccessRemoteImpl::SetDefaultHmiTypes(const Subject& who, +void AccessRemoteImpl::SetDefaultHmiTypes(const ApplicationOnDevice& who, const std::vector& hmi_types) { LOG4CXX_AUTO_TRACE(logger_); HMIList::mapped_type types; @@ -167,7 +167,7 @@ void AccessRemoteImpl::SetDefaultHmiTypes(const Subject& who, } const policy_table::AppHMITypes& AccessRemoteImpl::HmiTypes( - const Subject& who) { + const ApplicationOnDevice& who) { LOG4CXX_AUTO_TRACE(logger_); if (cache_->IsDefaultPolicy(who.app_id)) { return hmi_types_[who]; @@ -178,12 +178,13 @@ const policy_table::AppHMITypes& AccessRemoteImpl::HmiTypes( } } -const policy_table::Strings& AccessRemoteImpl::GetGroups(const Subject& who) { +const policy_table::Strings& AccessRemoteImpl::GetGroups( + const ApplicationOnDevice& who) { LOG4CXX_AUTO_TRACE(logger_); return cache_->GetGroups(who.app_id); } -bool AccessRemoteImpl::IsAppRemoteControl(const Subject& who) { +bool AccessRemoteImpl::IsAppRemoteControl(const ApplicationOnDevice& who) { LOG4CXX_AUTO_TRACE(logger_); const policy_table::AppHMITypes& hmi_types = HmiTypes(who); return std::find(hmi_types.begin(), @@ -213,7 +214,7 @@ std::ostream& operator<<(std::ostream& output, void AccessRemoteImpl::GetGroupsIds(const std::string& device_id, const std::string& app_id, FunctionalGroupIDs& groups_ids) { - Subject who = {device_id, app_id}; + ApplicationOnDevice who = {device_id, app_id}; const policy_table::Strings& groups = GetGroups(who); groups_ids.resize(groups.size()); std::transform(groups.begin(), diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index 6716da2983..93e831acda 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -395,7 +395,7 @@ void PolicyManagerImpl::CheckPermissions(const PTString& device_id, << " for " << hmi_level << " level."); #ifdef SDL_REMOTE_CONTROL - Subject who = {device_id, app_id}; + ApplicationOnDevice who = {device_id, app_id}; const policy_table::Strings& groups = access_remote_->GetGroups(who); #else // SDL_REMOTE_CONTROL const policy_table::Strings& groups = cache_->GetGroups(app_id); @@ -458,7 +458,7 @@ void PolicyManagerImpl::SendNotificationOnPermissionsUpdated( default_hmi = "NONE"; #ifdef SDL_REMOTE_CONTROL - const Subject who = {device_id, application_id}; + const ApplicationOnDevice who = {device_id, application_id}; if (access_remote_->IsAppRemoteControl(who)) { listener()->OnPermissionsUpdated(application_id, notification_data); return; @@ -1169,7 +1169,7 @@ void PolicyManagerImpl::SetDefaultHmiTypes(const std::string& application_id, const std::vector& hmi_types) { LOG4CXX_INFO(logger_, "SetDefaultHmiTypes"); const std::string device_id = GetCurrentDeviceId(application_id); - Subject who = {device_id, application_id}; + ApplicationOnDevice who = {device_id, application_id}; access_remote_->SetDefaultHmiTypes(who, hmi_types); } @@ -1204,7 +1204,7 @@ bool PolicyManagerImpl::CheckModule(const PTString& app_id, access_remote_->CheckModuleType(app_id, module_type); } -void PolicyManagerImpl::SendHMILevelChanged(const Subject& who) { +void PolicyManagerImpl::SendHMILevelChanged(const ApplicationOnDevice& who) { std::string default_hmi("NONE"); if (GetDefaultHmi(who.app_id, &default_hmi)) { listener()->OnUpdateHMIStatus(who.dev_id, who.app_id, default_hmi); @@ -1253,7 +1253,7 @@ void PolicyManagerImpl::OnPrimaryGroupsChanged( for (std::vector::const_iterator i = devices.begin(); i != devices.end(); ++i) { - const Subject who = {*i, application_id}; + const ApplicationOnDevice who = {*i, application_id}; if (access_remote_->IsAppRemoteControl(who)) { SendAppPermissionsChanged(who.dev_id, who.app_id); } diff --git a/src/components/policy/policy_regular/test/access_remote_impl_test.cc b/src/components/policy/policy_regular/test/access_remote_impl_test.cc index 605799d463..d086144d86 100644 --- a/src/components/policy/policy_regular/test/access_remote_impl_test.cc +++ b/src/components/policy/policy_regular/test/access_remote_impl_test.cc @@ -66,7 +66,7 @@ TEST(AccessRemoteImplTest, SetDefaultHmiTypes) { std::vector hmi_expected; hmi_expected.push_back(2); hmi_expected.push_back(6); - Subject who = {"dev1", "1234"}; + ApplicationOnDevice who = {"dev1", "1234"}; access_remote.SetDefaultHmiTypes(who, hmi_expected); EXPECT_NE(access_remote.hmi_types_.end(), access_remote.hmi_types_.find(who)); @@ -78,7 +78,7 @@ TEST(AccessRemoteImplTest, SetDefaultHmiTypes) { TEST(AccessRemoteImplTest, GetGroups) { AccessRemoteImpl access_remote; - Subject who = {"dev1", "1234"}; + ApplicationOnDevice who = {"dev1", "1234"}; access_remote.hmi_types_[who].push_back(policy_table::AHT_REMOTE_CONTROL); access_remote.cache_->pt_ = new policy_table::Table(); diff --git a/src/components/policy/policy_regular/test/include/policy/mock_access_remote.h b/src/components/policy/policy_regular/test/include/policy/mock_access_remote.h index c7ad82da40..8dc3e2d3a0 100644 --- a/src/components/policy/policy_regular/test/include/policy/mock_access_remote.h +++ b/src/components/policy/policy_regular/test/include/policy/mock_access_remote.h @@ -39,7 +39,7 @@ namespace test { namespace components { namespace access_remote_test { -class MockSubject : public policy::Subject { +class MockSubject : public policy::ApplicationOnDevice { public: }; @@ -47,14 +47,15 @@ class MockAccessRemote : public policy::AccessRemote { public: MOCK_CONST_METHOD3( FindGroup, - policy::PTString(const policy::Subject& who, + policy::PTString(const policy::ApplicationOnDevice& who, const policy::PTString& rpc, const policy::RemoteControlParams& params)); MOCK_METHOD2(SetDefaultHmiTypes, - void(const policy::Subject& who, + void(const policy::ApplicationOnDevice& who, const std::vector& hmi_types)); - MOCK_METHOD1(GetGroups, - const policy_table::Strings&(const policy::Subject& who)); + MOCK_METHOD1( + GetGroups, + const policy_table::Strings&(const policy::ApplicationOnDevice& who)); MOCK_METHOD3(GetPermissionsForApp, bool(const std::string& device_id, const std::string& app_id, @@ -62,7 +63,8 @@ class MockAccessRemote : public policy::AccessRemote { MOCK_CONST_METHOD2(CheckModuleType, bool(const policy::PTString& app_id, policy_table::ModuleType module)); - MOCK_METHOD1(IsAppRemoteControl, bool(const policy::Subject& who)); + MOCK_METHOD1(IsAppRemoteControl, + bool(const policy::ApplicationOnDevice& who)); MOCK_METHOD2(GetModuleTypes, bool(const std::string& application_id, std::vector* modules)); -- cgit v1.2.1