summaryrefslogtreecommitdiff
path: root/src/components/policy/policy_external/src/policy_helper.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/policy/policy_external/src/policy_helper.cc')
-rw-r--r--src/components/policy/policy_external/src/policy_helper.cc49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/components/policy/policy_external/src/policy_helper.cc b/src/components/policy/policy_external/src/policy_helper.cc
index cb27e7f0b3..f9c69f58d3 100644
--- a/src/components/policy/policy_external/src/policy_helper.cc
+++ b/src/components/policy/policy_external/src/policy_helper.cc
@@ -865,4 +865,53 @@ bool UnwrapAppPolicies(policy_table::ApplicationPolicies& app_policies) {
return true;
}
+
+#ifdef SDL_REMOTE_CONTROL
+bool HaveGroupsChanged(const rpc::Optional<policy_table::Strings>& old_groups,
+ const rpc::Optional<policy_table::Strings>& new_groups) {
+ if (!old_groups.is_initialized() && !new_groups.is_initialized()) {
+ return false;
+ }
+ if (!old_groups.is_initialized() || !new_groups.is_initialized()) {
+ return true;
+ }
+ policy_table::Strings old_groups_abs = *old_groups;
+ policy_table::Strings new_groups_abs = *new_groups;
+ if (old_groups_abs.size() != new_groups_abs.size()) {
+ return true;
+ }
+ std::sort(new_groups_abs.begin(), new_groups_abs.end(), Compare);
+ std::sort(old_groups_abs.begin(), old_groups_abs.end(), Compare);
+
+ return std::equal(new_groups_abs.begin(),
+ new_groups_abs.end(),
+ old_groups_abs.begin(),
+ Compare);
}
+
+void ProccessAppGroups::operator()(
+ const policy_table::ApplicationPolicies::value_type& app) {
+ policy_table::ApplicationPolicies::const_iterator i =
+ new_apps_.find(app.first);
+ if (i == new_apps_.end() && default_ != new_apps_.end()) {
+ i = default_;
+ }
+ if (i != new_apps_.end()) {
+ if (HaveGroupsChanged(i->second.groups_primaryRC,
+ app.second.groups_primaryRC)) {
+ LOG4CXX_DEBUG(logger_,
+ "Primary groups for " << app.first << " have changed");
+
+ pm_->OnPrimaryGroupsChanged(app.first);
+ }
+ if (HaveGroupsChanged(i->second.groups_nonPrimaryRC,
+ app.second.groups_nonPrimaryRC)) {
+ LOG4CXX_DEBUG(logger_,
+ "Non-primary groups for " << app.first << " have changed");
+ pm_->OnNonPrimaryGroupsChanged(app.first);
+ }
+ }
+}
+
+#endif // SDL_REMOTE_CONTROL
+} // namespace policy