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>
33 #include <dpl/shared_ptr.h>
38 typedef std::set<DPL::String> StringSet;
39 //! Widget description
55 LevelEnum level; //!< content level
57 typedef StringSet Context;
60 //! xa This material appears in an artistic context
61 //! xb This material appears in an educational context
62 //! xc This material appears in a medical context
63 //! xd This material appears in a sports context
64 //! xe This material appears in a violent context
66 explicit LevelEntry(LevelEnum level = LevelUnknown);
67 //! Function checks if context is valid
68 //! \param[in] level POWDER content level
69 //! \param[in] context POWDER context
70 bool isContextValid(LevelEnum level,
71 const DPL::OptionalString& context) const;
76 //! Levels entries for POWDER description
77 typedef std::vector <LevelEntry> LevelsContainer;
78 LevelsContainer levels;
79 //! Function checks if context is valid
80 //! \param[out] reason set if context invalid
81 //! \param[in] level POWDER content level
82 //! \param[in] context POWDER context
83 bool isCategoryValid(LevelEntry& reason,
85 const DPL::OptionalString& context) const;
88 //! POWDER Category -> Category entry map for Widget
93 //! la Potentially offensive language
96 //! ha Hate or harmful activities
97 //! ug Use of user-generated content
98 typedef std::map<DPL::String, CategoryEntry> CategoryEntries;
100 CategoryEntries categories;
102 //! Age rating for widget
104 DPL::OptionalInt ageRating;
106 } // namespace Powder
108 namespace ChildProtection {
110 //! Blacklist with forbidden URLs
111 //! It should be stored in WidgetDAO
112 typedef std::vector<DPL::String> BlackList;
114 //! Widget Child protection record
115 //! Record should be stored in WingetDAO
118 //! Child protection enabled
120 explicit Record(bool enabled) :
126 //! Powder processing
129 //! Rule set by parent about forbidden category
134 //! la Potentially offensive language
137 //! ha Hate or harmful activities
138 //! ug Use of user-generated content
140 //! xa This material appears in an artistic conteaxt
141 //! xb This material appears in an educational context
142 //! xc This material appears in a medical context
143 //! xd This material appears in a sports context
144 //! xe This material appears in a violent context
147 DPL::String category;
148 Powder::Description::LevelEnum level;
149 DPL::OptionalString context;
150 explicit CategoryRule(const DPL::String& category = DPL::String(),
151 Powder::Description::LevelEnum level =
152 Powder::Description::LevelUnknown,
153 const DPL::OptionalString& context = DPL::OptionalString());
158 //! Reasoning outcome: part of POWDER description used to invalidate
159 Powder::Description::LevelEntry invalidDescription;
160 //! Reasoning outcome: rule set by parent not full filed by description
161 CategoryRule invalidRule;
163 //! Reasoning outcome: type of invalidity
166 InvalidRule, //!< One of rules was not fulfilled
167 InvalidAge, //!< Age is invalid
168 AgeRatingNotSet, //!< Age rating for widget is not set
169 Valid //!< Description valid
171 InvalidReason reason;
172 explicit PowderResult(InvalidReason reason = Valid,
173 const Powder::Description::LevelEntry& invalidDescription =
174 Powder::Description::LevelEntry(),
175 const CategoryRule& invalidRule = CategoryRule());
178 typedef std::pair<bool, PowderResult> ResultPair;
180 //! Function checks if rule is fulfilled by description
181 //! \param[in] rule checked rule
182 //! \param[in] description
183 //! \retval true rule is valid
184 //! \retval false rule is invalid
185 ResultPair isRuleValidForDescription(const CategoryRule& rule,
186 const Powder::Description& description) const;
187 //! Function checks if age limit is fulfilled by description
188 //! \param[in] description
189 //! \retval true age is valid
190 //! \retval false age is invalid
191 ResultPair isAgeValidForDescription(
192 const Powder::Description& description) const;
194 //! It is the maximum age rating valid for child
195 //! Uniform age is stored in WidgetDAO
196 DPL::OptionalInt ageLimit;
198 //! Set to true if age rating is required
199 //! If ageLimit is not set value is ignored
200 bool isAgeRatingRequired;
202 //! Set of rules configured by parent
203 //! Rules are stored in WidgetDAO and are uniform for all widgets
204 typedef std::vector<CategoryRule> RulesContainer;
205 RulesContainer rules;
207 //! Function check if Widget description is valid for ChildProtection
209 //! \param description widget description
210 //! \retval true widget is valid
211 //! \retval false widget is invalid
212 ResultPair isDescriptionValid(const Powder::Description& description)
216 isAgeRatingRequired(false)
220 } // namespace ChildProtection
222 class PluginMetafileData
228 std::set<std::string> m_deviceCapabilities;
230 bool operator< (const Feature& obj) const
232 return m_name < obj.m_name;
235 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 DPL::SharedPtr<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) :
291 inline bool operator ==(const DbWidgetSize &objA, const DbWidgetSize &objB)
293 if (!objA.height || !objA.width || !objB.width || !objB.height) {
296 return *objA.height == *objB.height && *objA.width == *objB.width;
301 * Widget [G]lobal [U]nique [ID]entifier
302 * Orginated from appstore ID
304 typedef DPL::OptionalString WidgetGUID;
306 struct WidgetAccessInfo
308 DPL::String strIRI; /* origin iri */
309 bool bSubDomains; /* do we want access to subdomains ? */
311 bool operator ==(const WidgetAccessInfo& info) const
313 return info.strIRI == strIRI &&
314 info.bSubDomains == bSubDomains;
318 typedef std::list<WidgetAccessInfo> WidgetAccessInfoList;
320 typedef std::list<DPL::String> WindowModeList;
323 * @brief Widget configuration parameter key
325 typedef DPL::String WidgetParamKey;
328 * @brief Widget configuration parameter value
330 typedef DPL::String WidgetParamValue;
333 * @brief A map of widget configuration parameters.
335 * Widget configuration parameters are read from database and are stored
336 * along with feature that they describe.
338 typedef std::multimap<WidgetParamKey, WidgetParamValue> WidgetParamMap;
341 * @brief Widget feature host information about possible javascript extensions
342 * that widget may use
344 * Widget features are declared in configuration file in widget installation
345 * package. Each declared special feature is contained in some wrt-plugin that
346 * declares to implement it. After widget launch wrt searches for proper plugin
347 * libraries and load needed features.
349 * Widget features can be required or optional. It is possible to start widget
350 * without missing feature. When required feature cannot be loaded widget will
355 INVALID_PLUGIN_HANDLE = -1
357 typedef int DbPluginHandle;
359 struct DbWidgetFeature
361 DPL::String name; /// Feature name
362 bool required; /// Whether feature is required
363 DbPluginHandle pluginId; /// Plugin id that implement this feature
364 WidgetParamMap params; /// Widget's params
368 pluginId(INVALID_PLUGIN_HANDLE)
373 inline bool operator < (const DbWidgetFeature &objA,
374 const DbWidgetFeature &objB)
376 return objA.name.compare(objB.name) < 0;
379 inline bool operator==(const DbWidgetFeature &featureA,
380 const DbWidgetFeature &featureB)
382 return featureA.name == featureB.name &&
383 featureA.required == featureB.required &&
384 featureA.pluginId == featureB.pluginId;
388 * @brief Default container for features list
390 typedef std::multiset<DbWidgetFeature> DbWidgetFeatureSet;
393 * @brief Default container with DbWidgetHandle's
395 typedef std::list<DbWidgetHandle> DbWidgetHandleList;
398 * @brief Widget specific type
400 * Widget type describes belowed in WAC, TIZEN WebApp
404 APP_TYPE_UNKNOWN = 0, // unknown
405 APP_TYPE_WAC10, // WAC 1.0
406 APP_TYPE_WAC20, // WAC 2.0
407 APP_TYPE_TIZENWEBAPP, // Tizen webapp
414 :appType(APP_TYPE_UNKNOWN)
417 WidgetType(const AppType type)
421 bool operator== (const AppType& other) const
423 return appType == other;
425 std::string getApptypeToString()
428 #define X(x) case x: return #x;
432 X(APP_TYPE_TIZENWEBAPP)
446 DPL::String settingName;
447 DPL::String settingValue;
449 bool operator ==(const WidgetSetting& info) const
451 return (info.settingName == settingName &&
452 info.settingValue == settingValue);
454 bool operator !=(const WidgetSetting& info) const
456 return (info.settingName != settingName ||
457 info.settingValue != settingValue);
461 typedef std::list<WidgetSetting> WidgetSettings;
464 * @brief Widget Application Service
466 * Application sercvice describes details of behaviour
467 * when widget receives aul bundle data.
469 struct WidgetApplicationService
472 DPL::String src; /* start uri */
473 DPL::String operation; /* service name */
474 DPL::String scheme; /* scheme type*/
475 DPL::String mime; /* mime type */
477 bool operator== (const WidgetApplicationService& other) const
479 return src == other.src &&
480 operation == other.operation &&
481 scheme == other.scheme &&
486 typedef std::list<WidgetApplicationService> WidgetApplicationServiceList;
487 #endif /* WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_ */