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>
37 class PluginMetafileData
43 std::set<std::string> m_deviceCapabilities;
45 bool operator< (const Feature& obj) const
47 return m_name < obj.m_name;
50 typedef std::set<Feature> FeatureContainer;
58 std::string m_libraryName;
59 FeatureContainer m_featureContainer;
62 class PluginObjectsDAO
65 typedef std::set<std::string> Objects;
66 typedef std::shared_ptr<Objects> ObjectsPtr;
69 explicit PluginObjectsDAO() {}
72 ObjectsPtr m_implemented;
73 ObjectsPtr m_dependent;
77 * @brief Widget id describes web-runtime global widget identifier.
79 * Notice that only up to one widget can exist at the same time.
80 * DbWidgetHandle can be translated into corresponding WidgetModel by invoking
81 * FindWidgetModel routine.
83 typedef int DbWidgetHandle;
84 typedef DPL::String TizenPkgId;
85 typedef DPL::String TizenAppId;
86 typedef DPL::String WidgetPkgName;
89 * Value of invalid widget handle
92 INVALID_WIDGET_HANDLE = -1
96 * @brief Structure to hold the information of widget's size
100 DPL::OptionalInt width;
101 DPL::OptionalInt height;
103 DbWidgetSize(DPL::OptionalInt w = DPL::OptionalInt::Null,
104 DPL::OptionalInt h = DPL::OptionalInt::Null) :
111 inline bool operator ==(const DbWidgetSize &objA, const DbWidgetSize &objB)
113 if (!objA.height || !objA.width || !objB.width || !objB.height) {
116 return *objA.height == *objB.height && *objA.width == *objB.width;
121 * Widget [G]lobal [U]nique [ID]entifier
122 * Orginated from appstore ID
124 typedef DPL::OptionalString WidgetGUID;
126 struct WidgetAccessInfo
128 DPL::String strIRI; /* origin iri */
129 bool bSubDomains; /* do we want access to subdomains ? */
131 bool operator ==(const WidgetAccessInfo& info) const
133 return info.strIRI == strIRI &&
134 info.bSubDomains == bSubDomains;
138 struct EncryptedFileInfo
140 DPL::String fileName;
143 bool operator==(const EncryptedFileInfo& info) const
145 return fileName == info.fileName;
148 bool operator==(const DPL::String& file) const
150 return fileName == file;
153 bool operator< (const EncryptedFileInfo& info) const
155 return fileName < info.fileName;
159 typedef std::list<WidgetAccessInfo> WidgetAccessInfoList;
161 typedef std::list<DPL::String> WindowModeList;
163 typedef std::set<EncryptedFileInfo> EncryptedFileList;
166 * @brief Widget configuration parameter key
168 typedef DPL::String WidgetParamKey;
171 * @brief Widget configuration parameter value
173 typedef DPL::String WidgetParamValue;
176 * @brief A map of widget configuration parameters.
178 * Widget configuration parameters are read from database and are stored
179 * along with feature that they describe.
181 typedef std::multimap<WidgetParamKey, WidgetParamValue> WidgetParamMap;
184 * @brief Widget feature host information about possible javascript extensions
185 * that widget may use
187 * Widget features are declared in configuration file in widget installation
188 * package. Each declared special feature is contained in some wrt-plugin that
189 * declares to implement it. After widget launch wrt searches for proper plugin
190 * libraries and load needed features.
192 * Widget features can be required or optional. It is possible to start widget
193 * without missing feature. When required feature cannot be loaded widget will
198 INVALID_PLUGIN_HANDLE = -1
200 typedef int DbPluginHandle;
202 struct DbWidgetFeature
204 DPL::String name; /// Feature name
205 bool required; /// Whether feature is required
206 bool rejected; /// Api feature was rejected by ace
207 DbPluginHandle pluginId; /// Plugin id that implement this feature
208 WidgetParamMap params; /// Widget's params
212 pluginId(INVALID_PLUGIN_HANDLE)
217 inline bool operator < (const DbWidgetFeature &objA,
218 const DbWidgetFeature &objB)
220 return objA.name.compare(objB.name) < 0;
223 inline bool operator==(const DbWidgetFeature &featureA,
224 const DbWidgetFeature &featureB)
226 return featureA.name == featureB.name &&
227 featureA.required == featureB.required &&
228 featureA.pluginId == featureB.pluginId;
232 * @brief Default container for features list
234 typedef std::multiset<DbWidgetFeature> DbWidgetFeatureSet;
237 * @brief Default container with DbWidgetHandle's
239 typedef std::list<DbWidgetHandle> DbWidgetHandleList;
241 typedef std::list<WidgetPkgName> WidgetPkgNameList; //TODO: this cannot be null -> appropriate changes in db schema needed
242 typedef std::list<TizenAppId> TizenAppIdList; //TODO: this cannot be null -> appropriate changes in db schema needed
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)
270 WidgetType(const AppType type)
274 bool operator== (const AppType& other) const
276 return appType == other;
278 bool operator!= (const AppType& other) const
280 return appType != other;
282 std::string getApptypeToString()
285 #define X(x) case x: return #x;
288 X(APP_TYPE_TIZENWEBAPP)
299 * @brief Package specific type
301 * Package type describes belowed in Tizen webapp, C++ service App
305 PKG_TYPE_UNKNOWN = 0, // unknown
306 PKG_TYPE_NOMAL_WEB_APP,
307 PKG_TYPE_DIRECTORY_WEB_APP,
308 PKG_TYPE_HOSTED_WEB_APP, // request from browser
309 PKG_TYPE_HYBRID_WEB_APP // Tizen webapp with C++ service app
316 :pkgType(PKG_TYPE_UNKNOWN)
319 PackagingType(const PkgType type)
323 bool operator== (const PkgType& other) const
325 return pkgType == other;
327 bool operator!= (const PkgType& other) const
329 return pkgType != other;
331 std::string getPkgtypeToString()
334 #define X(x) case x: return #x;
336 X(PKG_TYPE_NOMAL_WEB_APP)
337 X(PKG_TYPE_DIRECTORY_WEB_APP)
338 X(PKG_TYPE_HOSTED_WEB_APP)
339 X(PKG_TYPE_HYBRID_WEB_APP)
351 SETTINGS_TYPE_UNKNOWN = 0,
353 SETTINGS_TYPE_ALWAYS_ASK,
360 DPL::String settingName;
361 DPL::String settingValue;
363 bool operator ==(const WidgetSetting& info) const
365 return (info.settingName == settingName &&
366 info.settingValue == settingValue);
368 bool operator !=(const WidgetSetting& info) const
370 return (info.settingName != settingName ||
371 info.settingValue != settingValue);
375 typedef std::list<WidgetSetting> WidgetSettings;
378 * @brief Widget Application Service
380 * Application sercvice describes details of behaviour
381 * when widget receives aul bundle data.
383 struct WidgetApplicationService
386 DPL::String src; /* start uri */
387 DPL::String operation; /* service name */
388 DPL::String scheme; /* scheme type*/
389 DPL::String mime; /* mime type */
391 bool operator== (const WidgetApplicationService& other) const
393 return src == other.src &&
394 operation == other.operation &&
395 scheme == other.scheme &&
400 typedef std::list<WidgetApplicationService> WidgetApplicationServiceList;
402 #endif /* WRT_WIDGET_DAO_COMMON_DAO_TYPES_H_ */