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>
35 #include <dpl/platform.h>
38 class PluginMetafileData
44 std::set<std::string> m_deviceCapabilities;
46 bool operator< (const Feature& obj) const
48 return m_name < obj.m_name;
51 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;
88 * Value of invalid widget handle
91 INVALID_WIDGET_HANDLE = -1
95 * @brief Structure to hold the information of widget's size
99 DPL::OptionalInt width;
100 DPL::OptionalInt height;
102 DbWidgetSize(DPL::OptionalInt w = DPL::OptionalInt(),
103 DPL::OptionalInt h = DPL::OptionalInt()) :
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;
135 typedef std::list<WidgetAccessInfo> WidgetAccessInfoList;
137 struct WidgetAllowNavigationInfo
142 typedef std::list<WidgetAllowNavigationInfo> WidgetAllowNavigationInfoList;
144 struct EncryptedFileInfo
146 DPL::String fileName;
149 bool operator==(const EncryptedFileInfo& info) const
151 return fileName == info.fileName;
154 bool operator==(const DPL::String& file) const
156 return fileName == file;
159 bool operator< (const EncryptedFileInfo& info) const
161 return fileName < info.fileName;
165 typedef std::list<DPL::String> WindowModeList;
167 typedef std::list<DPL::String> PrivilegeList;
169 typedef std::set<EncryptedFileInfo> EncryptedFileList;
172 * @brief Widget feature host information about possible javascript extensions
173 * that widget may use
175 * Widget features are declared in configuration file in widget installation
176 * package. Each declared special feature is contained in some wrt-plugin that
177 * declares to implement it. After widget launch wrt searches for proper plugin
178 * libraries and load needed features.
180 * Widget features can be required or optional. It is possible to start widget
181 * without missing feature. When required feature cannot be loaded widget will
186 INVALID_PLUGIN_HANDLE = -1
188 typedef int DbPluginHandle;
190 struct DbWidgetFeature
192 DPL::String name; /// Feature name
193 bool rejected; /// Api feature was rejected by ace
194 DbPluginHandle pluginId; /// Plugin id that implement this feature
197 pluginId(INVALID_PLUGIN_HANDLE)
201 inline bool operator < (const DbWidgetFeature &objA,
202 const DbWidgetFeature &objB)
204 return objA.name.compare(objB.name) < 0;
207 inline bool operator==(const DbWidgetFeature &featureA,
208 const DbWidgetFeature &featureB)
210 return featureA.name == featureB.name &&
211 featureA.pluginId == featureB.pluginId;
215 * @brief Default container for features list
217 typedef std::multiset<DbWidgetFeature> DbWidgetFeatureSet;
220 * @brief Default container with DbWidgetHandle's
222 typedef std::list<DbWidgetHandle> DbWidgetHandleList;
223 typedef std::list<TizenAppId> TizenAppIdList;
224 typedef std::list<TizenPkgId> TizenPkgIdList;
226 class WidgetDAOReadOnly; //forward declaration
227 typedef std::shared_ptr<WidgetDAOReadOnly> WidgetDAOReadOnlyPtr;
229 * @brief Default container with WidgetDAOReadOnly
231 typedef std::list<WidgetDAOReadOnlyPtr> DbWidgetDAOReadOnlyList;
234 * @brief Widget specific type
236 * Widget type describes belowed in WAC, TIZEN WebApp
240 APP_TYPE_UNKNOWN = 0, // unknown
241 APP_TYPE_TIZENWEBAPP, // Tizen webapp
242 APP_TYPE_TIZENWEBSERVICE // Tizen web service
249 appType(APP_TYPE_UNKNOWN)
251 WidgetType(const AppType type) :
254 bool operator== (const AppType& other) const
256 return appType == other;
258 bool operator!= (const AppType& other) const
260 return appType != other;
262 std::string getApptypeToString()
265 #define X(x) case x: return #x;
267 X(APP_TYPE_TIZENWEBAPP)
268 X(APP_TYPE_TIZENWEBSERVICE)
280 * @brief Package specific type
282 * Package type describes belowed in Tizen webapp, C++ service App
286 PKG_TYPE_UNKNOWN = 0, // unknown
287 PKG_TYPE_NOMAL_WEB_APP,
288 PKG_TYPE_DIRECTORY_WEB_APP,
289 PKG_TYPE_HOSTED_WEB_APP, // request from browser
290 PKG_TYPE_HYBRID_WEB_APP // Tizen webapp with C++ service app
297 pkgType(PKG_TYPE_UNKNOWN)
299 PackagingType(const PkgType type) :
302 bool operator== (const PkgType& other) const
304 return pkgType == other;
306 bool operator!= (const PkgType& other) const
308 return pkgType != other;
310 std::string getPkgtypeToString()
313 #define X(x) case x: return #x;
315 X(PKG_TYPE_NOMAL_WEB_APP)
316 X(PKG_TYPE_DIRECTORY_WEB_APP)
317 X(PKG_TYPE_HOSTED_WEB_APP)
318 X(PKG_TYPE_HYBRID_WEB_APP)
330 DPL::String settingName;
331 DPL::String settingValue;
333 bool operator ==(const WidgetSetting& info) const
335 return (info.settingName == settingName &&
336 info.settingValue == settingValue);
338 bool operator !=(const WidgetSetting& info) const
340 return (info.settingName != settingName ||
341 info.settingValue != settingValue);
345 typedef std::list<WidgetSetting> WidgetSettings;
348 * @brief Widget AppControl
350 * Application control describes details of behaviour
351 * when widget receives aul bundle data.
353 namespace AppControlPrefix {
354 const char* const PROCESS_PREFIX = "-__CONTROL_PROCESS__";
356 struct WidgetAppControl
358 DPL::String src; /* start uri */
359 DPL::String operation; /* service name */
360 DPL::String uri; /* scheme type*/
361 DPL::String mime; /* mime type */
362 bool reset; /* src reset */
364 bool operator== (const WidgetAppControl& other) const
366 return src == other.src &&
367 operation == other.operation &&
369 mime == other.mime &&
370 reset == other.reset;
374 typedef std::list<WidgetAppControl> WidgetAppControlList;
376 enum class WidgetSecurityModelVersion
378 WIDGET_SECURITY_MODEL_V1 = 0, // WARP
379 WIDGET_SECURITY_MODEL_V2 // CSP, allow-navigation
385 #if ENABLE(WIDGET_INTERFACE_DAO_PERFORMANCE)
386 void clearStatementsMap();
387 std::map<const char* const, sqlite3_stmt*> m_statements;
388 #endif //ENABLE(WIDGET_INTERFACE_DAO_PERFORMANCE)
393 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
394 DECLARE_EXCEPTION_TYPE(Base, DatabaseError)
398 virtual ~SQLiteDAOBase();
400 inline DPL::String sqlite3_column_string(sqlite3_stmt* stmt, int iCol)
402 const char* str = reinterpret_cast<const char*>(sqlite3_column_text(stmt, iCol));
406 return DPL::FromUTF8String(std::string(str));
409 void sqlBind(sqlite3_stmt* stmt, int index, const char* value) const;
410 void sqlBind(sqlite3_stmt* stmt, int index, const std::string& value) const;
411 void sqlBind(sqlite3_stmt* stmt, int index, const DPL::String& value) const;
412 void sqlBind(sqlite3_stmt* stmt, int index, int value) const;
414 sqlite3* m_databaseInterface;
415 sqlite3_stmt* sqlPrepare(const char* const query);
416 #if ENABLE(WIDGET_INTERFACE_DAO_PERFORMANCE)
417 inline void releaseStatement(sqlite3_stmt *)
420 inline void releaseStatement(sqlite3_stmt *statement)
422 sqlite3_finalize(statement);
424 #endif //ENABLE(WIDGET_INTERFACE_DAO_PERFORMANCE)
428 #endif /* WRT_WIDGET_DAO_COMMON_DAO_TYPES_H_ */