serialization: add missing method to serialized storage 71/200971/3
authorAdrian Szyndela <adrian.s@samsung.com>
Wed, 6 Mar 2019 11:37:50 +0000 (12:37 +0100)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Thu, 7 Mar 2019 14:22:41 +0000 (15:22 +0100)
Change-Id: Ieb56be3dd3f303dca7c851c02757fe6ab5eb64ae

src/internal/storage_backend_serialized.cpp
src/internal/storage_backend_serialized.hpp

index ae2b350..0590c4a 100644 (file)
@@ -112,7 +112,7 @@ bool StorageBackendSerialized::StorageBackendSerializedImpl::init(const char *fi
        mmapGuard.dismiss();
 
        file = GetFile(mem);
-       return true;
+       return file != nullptr;
 }
 
 bool StorageBackendSerialized::StorageBackendSerializedImpl::init(const FB::File *f) {
@@ -258,6 +258,11 @@ ldp_xml_parser::DecisionItem StorageBackendSerialized::getDecisionItemGroup(gid_
        return getDecisionItemMaybeNull(item, pimpl->getPolicySet<T>()->group()->LookupByKey(gid));
 }
 
+template <typename T>
+bool StorageBackendSerialized::existsPolicyForGroup(gid_t gid) const {
+       return pimpl->getPolicySet<T>()->group()->LookupByKey(gid) != nullptr;
+}
+
 #define T_INSTANTIATION(T) \
        template ldp_xml_parser::DecisionItem StorageBackendSerialized::getDecisionItemContextMandatory(const ldp_xml_parser::MatchItem##T &item) const; \
        template ldp_xml_parser::DecisionItem StorageBackendSerialized::getDecisionItemContextDefault(const ldp_xml_parser::MatchItem##T &item) const;
@@ -271,7 +276,8 @@ T_INSTANTIATION(Access)
 
 #define T_INSTANTIATION2(T) \
        template ldp_xml_parser::DecisionItem StorageBackendSerialized::getDecisionItemUser(uid_t uid, const ldp_xml_parser::MatchItem##T &item) const; \
-       template ldp_xml_parser::DecisionItem StorageBackendSerialized::getDecisionItemGroup(gid_t gid, const ldp_xml_parser::MatchItem##T &item) const;
+       template ldp_xml_parser::DecisionItem StorageBackendSerialized::getDecisionItemGroup(gid_t gid, const ldp_xml_parser::MatchItem##T &item) const; \
+       template bool StorageBackendSerialized::existsPolicyForGroup<ldp_xml_parser::MatchItem##T>(gid_t) const;
 
 T_INSTANTIATION2(Own)
 T_INSTANTIATION2(Send)
index bf48dd7..2e5422d 100644 (file)
@@ -31,6 +31,12 @@ public:
        ldp_xml_parser::DecisionItem getDecisionItemUser(uid_t uid, const T &item) const;
        template <typename T>
        ldp_xml_parser::DecisionItem getDecisionItemGroup(gid_t gid, const T &item) const;
+
+       // This works with T set to MatchItemOwn, MatchItemSend or MatchItemReceive
+       // This is needed for filtering mapGroups. Check NaivePolicyChecker.
+       template <typename T>
+       bool existsPolicyForGroup(gid_t gid) const;
+
 };
 
 }