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_
32 #include <dpl/optional_typedefs.h>
33 #include <dpl/shared_ptr.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 DPL::SharedPtr<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 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) :
109 inline bool operator ==(const DbWidgetSize &objA, const DbWidgetSize &objB)
111 if (!objA.height || !objA.width || !objB.width || !objB.height) {
114 return *objA.height == *objB.height && *objA.width == *objB.width;
119 * Widget [G]lobal [U]nique [ID]entifier
120 * Orginated from appstore ID
122 typedef DPL::OptionalString WidgetGUID;
124 struct WidgetAccessInfo
126 DPL::String strIRI; /* origin iri */
127 bool bSubDomains; /* do we want access to subdomains ? */
129 bool operator ==(const WidgetAccessInfo& info) const
131 return info.strIRI == strIRI &&
132 info.bSubDomains == bSubDomains;
136 struct EncryptedFileInfo
138 DPL::String fileName;
141 bool operator==(const EncryptedFileInfo& info) const
143 return fileName == info.fileName;
146 bool operator==(const DPL::String& file) const
148 return fileName == file;
151 bool operator< (const EncryptedFileInfo& info) const
153 return fileName < info.fileName;
157 typedef std::list<WidgetAccessInfo> WidgetAccessInfoList;
159 typedef std::list<DPL::String> WindowModeList;
161 typedef std::set<EncryptedFileInfo> EncryptedFileList;
164 * @brief Widget configuration parameter key
166 typedef DPL::String WidgetParamKey;
169 * @brief Widget configuration parameter value
171 typedef DPL::String WidgetParamValue;
174 * @brief A map of widget configuration parameters.
176 * Widget configuration parameters are read from database and are stored
177 * along with feature that they describe.
179 typedef std::multimap<WidgetParamKey, WidgetParamValue> WidgetParamMap;
182 * @brief Widget feature host information about possible javascript extensions
183 * that widget may use
185 * Widget features are declared in configuration file in widget installation
186 * package. Each declared special feature is contained in some wrt-plugin that
187 * declares to implement it. After widget launch wrt searches for proper plugin
188 * libraries and load needed features.
190 * Widget features can be required or optional. It is possible to start widget
191 * without missing feature. When required feature cannot be loaded widget will
196 INVALID_PLUGIN_HANDLE = -1
198 typedef int DbPluginHandle;
200 struct DbWidgetFeature
202 DPL::String name; /// Feature name
203 bool required; /// Whether feature is required
204 bool rejected; /// Api feature was rejected by ace
205 DbPluginHandle pluginId; /// Plugin id that implement this feature
206 WidgetParamMap params; /// Widget's params
210 pluginId(INVALID_PLUGIN_HANDLE)
215 inline bool operator < (const DbWidgetFeature &objA,
216 const DbWidgetFeature &objB)
218 return objA.name.compare(objB.name) < 0;
221 inline bool operator==(const DbWidgetFeature &featureA,
222 const DbWidgetFeature &featureB)
224 return featureA.name == featureB.name &&
225 featureA.required == featureB.required &&
226 featureA.pluginId == featureB.pluginId;
230 * @brief Default container for features list
232 typedef std::multiset<DbWidgetFeature> DbWidgetFeatureSet;
235 * @brief Default container with DbWidgetHandle's
237 typedef std::list<DbWidgetHandle> DbWidgetHandleList;
239 typedef std::list<DPL::Optional<WidgetPkgName> > WidgetPkgNameList; //TODO: this cannot be null -> appropriate changes in db schema needed
241 class WidgetDAOReadOnly; //forward declaration
242 typedef std::shared_ptr<WidgetDAOReadOnly> WidgetDAOReadOnlyPtr;
244 * @brief Default container with WidgetDAOReadOnly
246 typedef std::list<WidgetDAOReadOnlyPtr> DbWidgetDAOReadOnlyList;
249 * @brief Widget specific type
251 * Widget type describes belowed in WAC, TIZEN WebApp
255 APP_TYPE_UNKNOWN = 0, // unknown
256 APP_TYPE_WAC20, // WAC 2.0
257 APP_TYPE_TIZENWEBAPP // Tizen webapp
264 :appType(APP_TYPE_UNKNOWN)
267 WidgetType(const AppType type)
271 bool operator== (const AppType& other) const
273 return appType == other;
275 bool operator!= (const AppType& other) const
277 return appType != other;
279 std::string getApptypeToString()
282 #define X(x) case x: return #x;
285 X(APP_TYPE_TIZENWEBAPP)
296 * @brief Package specific type
298 * Package type describes belowed in Tizen webapp, C++ service App
302 PKG_TYPE_UNKNOWN = 0, // unknown
303 PKG_TYPE_NOMAL_WEB_APP,
304 PKG_TYPE_HOSTED_WEB_APP, // request from browser
305 PKG_TYPE_HYBRID_WEB_APP, // Tizen webapp with C++ service app
312 :pkgType(PKG_TYPE_UNKNOWN)
315 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_HOSTED_WEB_APP)
334 X(PKG_TYPE_HYBRID_WEB_APP)
348 DPL::String settingName;
349 DPL::String settingValue;
351 bool operator ==(const WidgetSetting& info) const
353 return (info.settingName == settingName &&
354 info.settingValue == settingValue);
356 bool operator !=(const WidgetSetting& info) const
358 return (info.settingName != settingName ||
359 info.settingValue != settingValue);
363 typedef std::list<WidgetSetting> WidgetSettings;
366 * @brief Widget Application Service
368 * Application sercvice describes details of behaviour
369 * when widget receives aul bundle data.
371 struct WidgetApplicationService
374 DPL::String src; /* start uri */
375 DPL::String operation; /* service name */
376 DPL::String scheme; /* scheme type*/
377 DPL::String mime; /* mime type */
379 bool operator== (const WidgetApplicationService& other) const
381 return src == other.src &&
382 operation == other.operation &&
383 scheme == other.scheme &&
388 typedef std::list<WidgetApplicationService> WidgetApplicationServiceList;
390 #endif /* WRT_WIDGET_DAO_COMMON_DAO_TYPES_H_ */