-namespace WrtDB {
-namespace Powder {
-
-typedef std::set<DPL::String> StringSet;
-//! Widget description
-struct Description
-{
- //!Content level
- typedef enum
- {
- Level0 = 0,
- Level1,
- Level2,
- Level3,
- Level4,
- Level5,
- LevelUnknown
- } LevelEnum;
- struct LevelEntry
- {
- LevelEnum level; //!< content level
-
- typedef StringSet Context;
-
- //! POWDER context
- //! xa This material appears in an artistic context
- //! xb This material appears in an educational context
- //! xc This material appears in a medical context
- //! xd This material appears in a sports context
- //! xe This material appears in a violent context
- Context context;
- explicit LevelEntry(LevelEnum level = LevelUnknown);
- //! Function checks if context is valid
- //! \param[in] level POWDER content level
- //! \param[in] context POWDER context
- bool isContextValid(LevelEnum level,
- const DPL::OptionalString& context) const;
- };
-
- struct CategoryEntry
- {
- //! Levels entries for POWDER description
- typedef std::vector <LevelEntry> LevelsContainer;
- LevelsContainer levels;
- //! Function checks if context is valid
- //! \param[out] reason set if context invalid
- //! \param[in] level POWDER content level
- //! \param[in] context POWDER context
- bool isCategoryValid(LevelEntry& reason,
- LevelEnum level,
- const DPL::OptionalString& context) const;
- };
-
- //! POWDER Category -> Category entry map for Widget
- //!
- //! nu Nudity
- //! se Sex
- //! vi Violence
- //! la Potentially offensive language
- //! dr Drug use
- //! ga Gambling
- //! ha Hate or harmful activities
- //! ug Use of user-generated content
- typedef std::map<DPL::String, CategoryEntry> CategoryEntries;
-
- CategoryEntries categories;
-
- //! Age rating for widget
- //! If Null not set
- DPL::OptionalInt ageRating;
-};
-} // namespace Powder
-
-namespace ChildProtection {
-
-//! Blacklist with forbidden URLs
-//! It should be stored in WidgetDAO
-typedef std::vector<DPL::String> BlackList;
-
-//! Widget Child protection record
-//! Record should be stored in WingetDAO
-struct Record
-{
- //! Child protection enabled
- bool enabled;
- explicit Record(bool enabled) :
- enabled(enabled)
- {
- }
-};
-
-//! Powder processing
-struct PowderRules
-{
- //! Rule set by parent about forbidden category
- //! Powder category
- //! nu Nudity
- //! se Sex
- //! vi Violence
- //! la Potentially offensive language
- //! dr Drug use
- //! ga Gambling
- //! ha Hate or harmful activities
- //! ug Use of user-generated content
- //! Powder context
- //! xa This material appears in an artistic conteaxt
- //! xb This material appears in an educational context
- //! xc This material appears in a medical context
- //! xd This material appears in a sports context
- //! xe This material appears in a violent context
- struct CategoryRule
- {
- DPL::String category;
- Powder::Description::LevelEnum level;
- DPL::OptionalString context;
- explicit CategoryRule(const DPL::String& category = DPL::String(),
- Powder::Description::LevelEnum level =
- Powder::Description::LevelUnknown,
- const DPL::OptionalString& context = DPL::OptionalString());
- };
-
- struct PowderResult
- {
- //! Reasoning outcome: part of POWDER description used to invalidate
- Powder::Description::LevelEntry invalidDescription;
- //! Reasoning outcome: rule set by parent not full filed by description
- CategoryRule invalidRule;
-
- //! Reasoning outcome: type of invalidity
- enum InvalidReason
- {
- InvalidRule, //!< One of rules was not fulfilled
- InvalidAge, //!< Age is invalid
- AgeRatingNotSet, //!< Age rating for widget is not set
- Valid //!< Description valid
- };
- InvalidReason reason;
- explicit PowderResult(InvalidReason reason = Valid,
- const Powder::Description::LevelEntry& invalidDescription =
- Powder::Description::LevelEntry(),
- const CategoryRule& invalidRule = CategoryRule());
- };
-
- typedef std::pair<bool, PowderResult> ResultPair;
-
- //! Function checks if rule is fulfilled by description
- //! \param[in] rule checked rule
- //! \param[in] description
- //! \retval true rule is valid
- //! \retval false rule is invalid
- ResultPair isRuleValidForDescription(const CategoryRule& rule,
- const Powder::Description& description) const;
- //! Function checks if age limit is fulfilled by description
- //! \param[in] description
- //! \retval true age is valid
- //! \retval false age is invalid
- ResultPair isAgeValidForDescription(
- const Powder::Description& description) const;
-
- //! It is the maximum age rating valid for child
- //! Uniform age is stored in WidgetDAO
- DPL::OptionalInt ageLimit;
-
- //! Set to true if age rating is required
- //! If ageLimit is not set value is ignored
- bool isAgeRatingRequired;
-
- //! Set of rules configured by parent
- //! Rules are stored in WidgetDAO and are uniform for all widgets
- typedef std::vector<CategoryRule> RulesContainer;
- RulesContainer rules;
-
- //! Function check if Widget description is valid for ChildProtection
- //! configuration
- //! \param description widget description
- //! \retval true widget is valid
- //! \retval false widget is invalid
- ResultPair isDescriptionValid(const Powder::Description& description)
- const;
-
- PowderRules() :
- isAgeRatingRequired(false)
- {
- }
-};
-} // namespace ChildProtection