2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @file common_dao_types.h
19 * @author Michal Ciepielski (m.ciepielski@samsung.com)
21 * @brief This file contains the declaration of common data types for wrtdb
24 #ifndef WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_
25 #define WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_
32 #include <dpl/optional_typedefs.h>
37 typedef std::set<DPL::String> StringSet;
38 //! Widget description
54 LevelEnum level; //!< content level
56 typedef StringSet Context;
59 //! xa This material appears in an artistic context
60 //! xb This material appears in an educational context
61 //! xc This material appears in a medical context
62 //! xd This material appears in a sports context
63 //! xe This material appears in a violent context
65 explicit LevelEntry(LevelEnum level = LevelUnknown);
66 //! Function checks if context is valid
67 //! \param[in] level POWDER content level
68 //! \param[in] context POWDER context
69 bool isContextValid(LevelEnum level,
70 const DPL::OptionalString& context) const;
75 //! Levels entries for POWDER description
76 typedef std::vector <LevelEntry> LevelsContainer;
77 LevelsContainer levels;
78 //! Function checks if context is valid
79 //! \param[out] reason set if context invalid
80 //! \param[in] level POWDER content level
81 //! \param[in] context POWDER context
82 bool isCategoryValid(LevelEntry& reason,
84 const DPL::OptionalString& context) const;
87 //! POWDER Category -> Category entry map for Widget
92 //! la Potentially offensive language
95 //! ha Hate or harmful activities
96 //! ug Use of user-generated content
97 typedef std::map<DPL::String, CategoryEntry> CategoryEntries;
99 CategoryEntries categories;
101 //! Age rating for widget
103 DPL::OptionalInt ageRating;
105 } // namespace Powder
107 namespace ChildProtection {
108 //! Blacklist with forbidden URLs
109 //! It should be stored in WidgetDAO
110 typedef std::vector<DPL::String> BlackList;
112 //! Widget Child protection record
113 //! Record should be stored in WingetDAO
116 //! Child protection enabled
118 explicit Record(bool enabled) :
123 //! Powder processing
126 //! Rule set by parent about forbidden category
131 //! la Potentially offensive language
134 //! ha Hate or harmful activities
135 //! ug Use of user-generated content
137 //! xa This material appears in an artistic conteaxt
138 //! xb This material appears in an educational context
139 //! xc This material appears in a medical context
140 //! xd This material appears in a sports context
141 //! xe This material appears in a violent context
144 DPL::String category;
145 Powder::Description::LevelEnum level;
146 DPL::OptionalString context;
147 explicit CategoryRule(
148 const DPL::String& category = DPL::String(),
149 Powder::Description::LevelEnum level =
150 Powder::Description::LevelUnknown,
151 const DPL::OptionalString& context =
152 DPL::OptionalString());
157 //! Reasoning outcome: part of POWDER description used to invalidate
158 Powder::Description::LevelEntry invalidDescription;
159 //! Reasoning outcome: rule set by parent not full filed by description
160 CategoryRule invalidRule;
162 //! Reasoning outcome: type of invalidity
165 InvalidRule, //!< One of rules was not fulfilled
166 InvalidAge, //!< Age is invalid
167 AgeRatingNotSet, //!< Age rating for widget is not set
168 Valid //!< Description valid
170 InvalidReason reason;
171 explicit PowderResult(
172 InvalidReason reason = Valid,
173 const Powder::Description::LevelEntry&
175 Powder::Description::LevelEntry(),
176 const CategoryRule& invalidRule = CategoryRule());
179 typedef std::pair<bool, PowderResult> ResultPair;
181 //! Function checks if rule is fulfilled by description
182 //! \param[in] rule checked rule
183 //! \param[in] description
184 //! \retval true rule is valid
185 //! \retval false rule is invalid
186 ResultPair isRuleValidForDescription(const CategoryRule& rule,
187 const Powder::Description& description)
189 //! Function checks if age limit is fulfilled by description
190 //! \param[in] description
191 //! \retval true age is valid
192 //! \retval false age is invalid
193 ResultPair isAgeValidForDescription(
194 const Powder::Description& description) const;
196 //! It is the maximum age rating valid for child
197 //! Uniform age is stored in WidgetDAO
198 DPL::OptionalInt ageLimit;
200 //! Set to true if age rating is required
201 //! If ageLimit is not set value is ignored
202 bool isAgeRatingRequired;
204 //! Set of rules configured by parent
205 //! Rules are stored in WidgetDAO and are uniform for all widgets
206 typedef std::vector<CategoryRule> RulesContainer;
207 RulesContainer rules;
209 //! Function check if Widget description is valid for ChildProtection
211 //! \param description widget description
212 //! \retval true widget is valid
213 //! \retval false widget is invalid
214 ResultPair isDescriptionValid(const Powder::Description& description)
218 isAgeRatingRequired(false)
221 } // namespace ChildProtection
223 class PluginMetafileData
229 std::set<std::string> m_deviceCapabilities;
231 bool operator< (const Feature& obj) const
233 return m_name < obj.m_name;
236 typedef std::set<Feature> FeatureContainer;
243 std::string m_libraryName;
244 std::string m_featuresInstallURI;
245 std::string m_featuresKeyCN;
246 std::string m_featuresRootCN;
247 std::string m_featuresRootFingerprint;
249 FeatureContainer m_featureContainer;
252 class PluginObjectsDAO
255 typedef std::set<std::string> Objects;
256 typedef std::shared_ptr<Objects> ObjectsPtr;
259 explicit PluginObjectsDAO() {}
262 ObjectsPtr m_implemented;
263 ObjectsPtr m_dependent;
267 * @brief Widget id describes web-runtime global widget identifier.
269 * Notice that only up to one widget can exist at the same time.
270 * DbWidgetHandle can be translated into corresponding WidgetModel by invoking
271 * FindWidgetModel routine.
273 typedef int DbWidgetHandle;
276 * @brief Structure to hold the information of widget's size
280 DPL::OptionalInt width;
281 DPL::OptionalInt height;
283 DbWidgetSize(DPL::OptionalInt w = DPL::OptionalInt::Null,
284 DPL::OptionalInt h = DPL::OptionalInt::Null) :
290 inline bool operator ==(const DbWidgetSize &objA, const DbWidgetSize &objB)
292 if (!objA.height || !objA.width || !objB.width || !objB.height) {
295 return *objA.height == *objB.height && *objA.width == *objB.width;
300 * Widget [G]lobal [U]nique [ID]entifier
301 * Orginated from appstore ID
303 typedef DPL::OptionalString WidgetGUID;
305 struct WidgetAccessInfo
307 DPL::String strIRI; /* origin iri */
308 bool bSubDomains; /* do we want access to subdomains ? */
310 bool operator ==(const WidgetAccessInfo& info) const
312 return info.strIRI == strIRI &&
313 info.bSubDomains == bSubDomains;
317 typedef std::list<WidgetAccessInfo> WidgetAccessInfoList;
319 typedef std::list<DPL::String> WindowModeList;
322 * @brief Widget configuration parameter key
324 typedef DPL::String WidgetParamKey;
327 * @brief Widget configuration parameter value
329 typedef DPL::String WidgetParamValue;
332 * @brief A map of widget configuration parameters.
334 * Widget configuration parameters are read from database and are stored
335 * along with feature that they describe.
337 typedef std::multimap<WidgetParamKey, WidgetParamValue> WidgetParamMap;
340 * @brief Widget feature host information about possible javascript extensions
341 * that widget may use
343 * Widget features are declared in configuration file in widget installation
344 * package. Each declared special feature is contained in some wrt-plugin that
345 * declares to implement it. After widget launch wrt searches for proper plugin
346 * libraries and load needed features.
348 * Widget features can be required or optional. It is possible to start widget
349 * without missing feature. When required feature cannot be loaded widget will
354 INVALID_PLUGIN_HANDLE = -1
356 typedef int DbPluginHandle;
358 struct DbWidgetFeature
360 DPL::String name; /// Feature name
361 bool required; /// Whether feature is required
362 DbPluginHandle pluginId; /// Plugin id that implement this
364 WidgetParamMap params; /// Widget's params
368 pluginId(INVALID_PLUGIN_HANDLE)
372 inline bool operator < (const DbWidgetFeature &objA,
373 const DbWidgetFeature &objB)
375 return objA.name.compare(objB.name) < 0;
378 inline bool operator==(const DbWidgetFeature &featureA,
379 const DbWidgetFeature &featureB)
381 return featureA.name == featureB.name &&
382 featureA.required == featureB.required &&
383 featureA.pluginId == featureB.pluginId;
387 * @brief Default container for features list
389 typedef std::multiset<DbWidgetFeature> DbWidgetFeatureSet;
392 * @brief Default container with DbWidgetHandle's
394 typedef std::list<DbWidgetHandle> DbWidgetHandleList;
397 * @brief Widget specific type
399 * Widget type describes belowed in WAC, TIZEN WebApp
403 APP_TYPE_UNKNOWN = 0, // unknown
404 APP_TYPE_WAC20, // WAC 2.0
405 APP_TYPE_TIZENWEBAPP, // slp webapp
412 appType(APP_TYPE_UNKNOWN)
414 WidgetType(const AppType type) :
417 bool operator== (const AppType& other) const
419 return appType == other;
421 std::string getApptypeToString()
424 #define X(x) case x: return #x;
427 X(APP_TYPE_TIZENWEBAPP)
440 DPL::String settingName;
441 DPL::String settingValue;
443 bool operator ==(const WidgetSetting& info) const
445 return (info.settingName == settingName &&
446 info.settingValue == settingValue);
448 bool operator !=(const WidgetSetting& info) const
450 return (info.settingName != settingName ||
451 info.settingValue != settingValue);
455 typedef std::list<WidgetSetting> WidgetSettings;
458 * @brief Widget Application Service
460 * Application sercvice describes details of behaviour
461 * when widget receives aul bundle data.
463 struct WidgetApplicationService
466 DPL::String src; /* start uri */
467 DPL::String operation; /* service name */
468 DPL::String scheme; /* scheme type*/
469 DPL::String mime; /* mime type */
471 bool operator== (const WidgetApplicationService& other) const
473 return src == other.src &&
474 operation == other.operation &&
475 scheme == other.scheme &&
480 typedef std::list<WidgetApplicationService> WidgetApplicationServiceList;
481 #endif /* WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_ */