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_WIDGET_DAO_COMMON_DAO_TYPES_H_
25 #define WRT_WIDGET_DAO_COMMON_DAO_TYPES_H_
33 #include <dpl/optional_typedefs.h>
36 class PluginMetafileData
42 std::set<std::string> m_deviceCapabilities;
44 bool operator< (const Feature& obj) const
46 return m_name < obj.m_name;
49 typedef std::set<Feature> FeatureContainer;
56 std::string m_libraryName;
57 FeatureContainer m_featureContainer;
60 class PluginObjectsDAO
63 typedef std::set<std::string> Objects;
64 typedef std::shared_ptr<Objects> ObjectsPtr;
67 explicit PluginObjectsDAO() {}
70 ObjectsPtr m_implemented;
71 ObjectsPtr m_dependent;
75 * @brief Widget id describes web-runtime global widget identifier.
77 * Notice that only up to one widget can exist at the same time.
78 * DbWidgetHandle can be translated into corresponding WidgetModel by invoking
79 * FindWidgetModel routine.
81 typedef int DbWidgetHandle;
82 typedef DPL::String TizenPkgId;
83 typedef DPL::String TizenAppId;
84 typedef DPL::String WidgetPkgName;
87 * Value of invalid widget handle
90 INVALID_WIDGET_HANDLE = -1
94 * @brief Structure to hold the information of widget's size
98 DPL::OptionalInt width;
99 DPL::OptionalInt height;
101 DbWidgetSize(DPL::OptionalInt w = DPL::OptionalInt::Null,
102 DPL::OptionalInt h = DPL::OptionalInt::Null) :
108 inline bool operator ==(const DbWidgetSize &objA, const DbWidgetSize &objB)
110 if (!objA.height || !objA.width || !objB.width || !objB.height) {
113 return *objA.height == *objB.height && *objA.width == *objB.width;
118 * Widget [G]lobal [U]nique [ID]entifier
119 * Orginated from appstore ID
121 typedef DPL::OptionalString WidgetGUID;
123 struct WidgetAccessInfo
125 DPL::String strIRI; /* origin iri */
126 bool bSubDomains; /* do we want access to subdomains ? */
128 bool operator ==(const WidgetAccessInfo& info) const
130 return info.strIRI == strIRI &&
131 info.bSubDomains == bSubDomains;
135 struct EncryptedFileInfo
137 DPL::String fileName;
140 bool operator==(const EncryptedFileInfo& info) const
142 return fileName == info.fileName;
145 bool operator==(const DPL::String& file) const
147 return fileName == file;
150 bool operator< (const EncryptedFileInfo& info) const
152 return fileName < info.fileName;
156 typedef std::list<WidgetAccessInfo> WidgetAccessInfoList;
158 typedef std::list<DPL::String> WindowModeList;
160 typedef std::set<EncryptedFileInfo> EncryptedFileList;
163 * @brief Widget configuration parameter key
165 typedef DPL::String WidgetParamKey;
168 * @brief Widget configuration parameter value
170 typedef DPL::String WidgetParamValue;
173 * @brief A map of widget configuration parameters.
175 * Widget configuration parameters are read from database and are stored
176 * along with feature that they describe.
178 typedef std::multimap<WidgetParamKey, WidgetParamValue> WidgetParamMap;
181 * @brief Widget feature host information about possible javascript extensions
182 * that widget may use
184 * Widget features are declared in configuration file in widget installation
185 * package. Each declared special feature is contained in some wrt-plugin that
186 * declares to implement it. After widget launch wrt searches for proper plugin
187 * libraries and load needed features.
189 * Widget features can be required or optional. It is possible to start widget
190 * without missing feature. When required feature cannot be loaded widget will
195 INVALID_PLUGIN_HANDLE = -1
197 typedef int DbPluginHandle;
199 struct DbWidgetFeature
201 DPL::String name; /// Feature name
202 bool required; /// Whether feature is required
203 bool rejected; /// Api feature was rejected by ace
204 DbPluginHandle pluginId; /// Plugin id that implement this feature
205 WidgetParamMap params; /// Widget's params
209 pluginId(INVALID_PLUGIN_HANDLE)
213 inline bool operator < (const DbWidgetFeature &objA,
214 const DbWidgetFeature &objB)
216 return objA.name.compare(objB.name) < 0;
219 inline bool operator==(const DbWidgetFeature &featureA,
220 const DbWidgetFeature &featureB)
222 return featureA.name == featureB.name &&
223 featureA.required == featureB.required &&
224 featureA.pluginId == featureB.pluginId;
228 * @brief Default container for features list
230 typedef std::multiset<DbWidgetFeature> DbWidgetFeatureSet;
233 * @brief Default container with DbWidgetHandle's
235 typedef std::list<DbWidgetHandle> DbWidgetHandleList;
237 typedef std::list<WidgetPkgName> WidgetPkgNameList; //TODO: this cannot be null
238 // -> appropriate changes in
240 typedef std::list<TizenAppId> TizenAppIdList; //TODO: this cannot be null ->
241 // appropriate changes in db
244 class WidgetDAOReadOnly; //forward declaration
245 typedef std::shared_ptr<WidgetDAOReadOnly> WidgetDAOReadOnlyPtr;
247 * @brief Default container with WidgetDAOReadOnly
249 typedef std::list<WidgetDAOReadOnlyPtr> DbWidgetDAOReadOnlyList;
252 * @brief Widget specific type
254 * Widget type describes belowed in WAC, TIZEN WebApp
258 APP_TYPE_UNKNOWN = 0, // unknown
259 APP_TYPE_WAC20, // WAC 2.0
260 APP_TYPE_TIZENWEBAPP // Tizen webapp
267 appType(APP_TYPE_UNKNOWN)
269 WidgetType(const AppType type) :
272 bool operator== (const AppType& other) const
274 return appType == other;
276 bool operator!= (const AppType& other) const
278 return appType != other;
280 std::string getApptypeToString()
283 #define X(x) case x: return #x;
286 X(APP_TYPE_TIZENWEBAPP)
297 * @brief Package specific type
299 * Package type describes belowed in Tizen webapp, C++ service App
303 PKG_TYPE_UNKNOWN = 0, // unknown
304 PKG_TYPE_NOMAL_WEB_APP,
305 PKG_TYPE_DIRECTORY_WEB_APP,
306 PKG_TYPE_HOSTED_WEB_APP, // request from browser
307 PKG_TYPE_HYBRID_WEB_APP // Tizen webapp with C++ service app
314 pkgType(PKG_TYPE_UNKNOWN)
316 PackagingType(const PkgType type) :
319 bool operator== (const PkgType& other) const
321 return pkgType == other;
323 bool operator!= (const PkgType& other) const
325 return pkgType != other;
327 std::string getPkgtypeToString()
330 #define X(x) case x: return #x;
332 X(PKG_TYPE_NOMAL_WEB_APP)
333 X(PKG_TYPE_DIRECTORY_WEB_APP)
334 X(PKG_TYPE_HOSTED_WEB_APP)
335 X(PKG_TYPE_HYBRID_WEB_APP)
347 SETTINGS_TYPE_UNKNOWN = 0,
349 SETTINGS_TYPE_ALWAYS_ASK,
356 DPL::String settingName;
357 DPL::String settingValue;
359 bool operator ==(const WidgetSetting& info) const
361 return (info.settingName == settingName &&
362 info.settingValue == settingValue);
364 bool operator !=(const WidgetSetting& info) const
366 return (info.settingName != settingName ||
367 info.settingValue != settingValue);
371 typedef std::list<WidgetSetting> WidgetSettings;
374 * @brief Widget Application Service
376 * Application sercvice describes details of behaviour
377 * when widget receives aul bundle data.
379 struct WidgetApplicationService
381 enum class Disposition {
386 DPL::String src; /* start uri */
387 DPL::String operation; /* service name */
388 DPL::String scheme; /* scheme type*/
389 DPL::String mime; /* mime type */
390 Disposition disposition;
392 bool operator== (const WidgetApplicationService& other) const
394 return src == other.src &&
395 operation == other.operation &&
396 scheme == other.scheme &&
397 mime == other.mime &&
398 disposition == other.disposition;
402 typedef std::list<WidgetApplicationService> WidgetApplicationServiceList;
404 #endif /* WRT_WIDGET_DAO_COMMON_DAO_TYPES_H_ */