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.
17 * This file contains the declaration of widget dao class.
19 * @file widget_dao_read_only.h
20 * @author Yang Jie (jie2.yang@samsung.com)
21 * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
22 * @author Pawel Sikorski (p.sikorski@samsung.com)
24 * @brief This file contains the declaration of widget dao
27 #ifndef _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_
28 #define _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_
33 #include <dpl/availability.h>
34 #include <dpl/string.h>
35 #include <dpl/exception.h>
36 #include <dpl/optional_typedefs.h>
37 #include <dpl/platform.h>
38 #include <dpl/wrt-dao-ro/property_dao_read_only.h>
39 #include <dpl/wrt-dao-ro/common_dao_types.h>
40 #include <dpl/wrt-dao-ro/widget_register_types.h>
44 class WidgetDAOReadOnly
48 * WidgetDAO Exception classes
53 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
54 DECLARE_EXCEPTION_TYPE(Base, DatabaseError)
55 DECLARE_EXCEPTION_TYPE(Base, ReadOnlyProperty)
56 DECLARE_EXCEPTION_TYPE(Base, GUIDisNull)
57 DECLARE_EXCEPTION_TYPE(Base, UnexpectedEmptyResult)
58 DECLARE_EXCEPTION_TYPE(Base, WidgetNotExist)
59 DECLARE_EXCEPTION_TYPE(Base, AlreadyRegistered)
63 DbWidgetHandle m_widgetHandle;
66 struct WidgetLocalizedIconRow
70 DPL::String widgetLocale;
72 typedef std::list<WidgetLocalizedIconRow> WidgetLocalizedIconList;
79 DPL::OptionalInt iconWidth;
80 DPL::OptionalInt iconHeight;
82 typedef std::list<WidgetIconRow> WidgetIconList;
84 struct WidgetStartFileRow
90 typedef std::list<WidgetStartFileRow> WidgetStartFileList;
92 struct WidgetLocalizedStartFileRow
96 DPL::String widgetLocale;
100 typedef std::list<WidgetLocalizedStartFileRow> LocalizedStartFileList;
102 #if USE(WEB_PROVIDER)
104 * This List is to retrive liveBox(es)ID from wrt.db. List is required as
105 * there might be multiple app-widget tag in config.xml for one widget.
107 typedef std::list<DPL::OptionalString> LiveBoxIdList;
111 * This is a constructor.
113 * @param[in] widgetHandle application id of widget.
115 WidgetDAOReadOnly(DbWidgetHandle widgetHandle);
116 WidgetDAOReadOnly(DPL::OptionalString widgetGUID);
117 WidgetDAOReadOnly(WrtDB::TizenAppId tzAppid);
122 virtual ~WidgetDAOReadOnly();
125 * This method returns widget handle(m_widgetHandle).
127 * @return widget handle(m_widgetHandle).
128 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
129 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
132 DbWidgetHandle getHandle() const;
133 static DbWidgetHandle getHandle(const WidgetGUID GUID);
134 static DbWidgetHandle getHandle(const DPL::String tzAppId);
135 static DbWidgetHandle getHandleByPkgId(const DPL::String pkgId);
138 * This method Returns tizen application id for the specified web application
141 TizenAppId getTzAppId() const DPL_DEPRECATED_WITH_MESSAGE("Use getTizenAppId");
142 static TizenAppId getTzAppId(const WidgetGUID GUID) DPL_DEPRECATED_WITH_MESSAGE("Use getTizenAppId");
143 static TizenAppId getTzAppId(const DbWidgetHandle handle) DPL_DEPRECATED_WITH_MESSAGE("Use getTizenAppId");
144 static TizenAppId getTzAppId(const TizenPkgId tizenPkgId) DPL_DEPRECATED_WITH_MESSAGE("Use getTizenAppId");
145 TizenAppId getTizenAppId() const;
146 static TizenAppId getTizenAppId(const WidgetGUID GUID);
147 static TizenAppId getTizenAppId(const DbWidgetHandle handle);
148 static TizenAppId getTizenAppId(const TizenPkgId tizenPkgId);
151 * This method returns list of installed tizen application id
152 * @return TizenAppIdList
154 static TizenAppIdList getTizenAppidList() DPL_DEPRECATED_WITH_MESSAGE("Use getTizenAppIdList");
155 static TizenAppIdList getTizenAppIdList();
156 static std::list<TizenAppId> getTzAppIdList(const TizenPkgId tzPkgid);
159 * Returns tizen package id for the specified web application
162 TizenPkgId getTizenPkgId() const;
163 static TizenPkgId getTizenPkgId(const DbWidgetHandle handle);
164 static TizenPkgId getTizenPkgId(const TizenAppId tzAppid);
167 * This method returns list of tizen package list of installed web applications
168 * @return TizenPkgIdList
170 static TizenPkgIdList getTizenPkgIdList();
173 * This method returns the root directory of widget resource.
175 * @return path name of root directory.
176 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
177 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
180 virtual DPL::String getPath() const;
182 DPL::String getFullPath() const;
185 * This method returns the preferred size of the widget,
186 * including width and height.
189 * @return An structure type variable to hold widget's size.
190 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
191 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
194 DbWidgetSize getPreferredSize() const;
197 * This method returns the type of the widget.
200 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
201 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
202 * records in DB table.
204 WidgetType getWidgetType() const;
207 * This method returns the id of the widget.
210 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
211 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
214 WidgetGUID getGUID() const;
217 * This method returns the defaultlocale for the widget.
219 * @return defaultlocale
220 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
221 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
224 DPL::OptionalString getDefaultlocale() const;
227 * This method returns list of localized icons files;
229 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
230 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
233 WidgetLocalizedIconList getLocalizedIconList() const;
236 * This method returns list of icons files;
238 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
239 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
242 WidgetIconList getIconList() const;
245 * This method returns list of localized start files;
247 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
248 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
251 LocalizedStartFileList getLocalizedStartFileList() const;
254 * This method returns list of start files;
256 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
257 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
260 WidgetStartFileList getStartFileList() const;
263 * @param[out] outAccessInfoList list filled with access info structures
265 void getWidgetAccessInfo(WidgetAccessInfoList& outAccessInfoList) const;
266 void getWidgetAllowNavigationInfo(
267 WidgetAllowNavigationInfoList& allowNavigationInfoList) const;
270 * This method returns window mode of widget.
272 * @return window modes of widget
273 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
274 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
277 WindowModeList getWindowModes() const;
280 * This method returns the version of the widget.
282 * @return version of widget
283 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
284 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
287 DPL::OptionalString getVersion() const;
290 * This method is used as a getter for csp policy of widget. It should be
291 * provided in configuration file.
292 * @return global csp policy for widget
294 DPL::OptionalString getCspPolicy() const;
297 * This method is used as a getter for report only csp policy of widget.
298 * It may be provided in configuration file.
299 * @return global csp report only policy for widget
301 DPL::OptionalString getCspPolicyReportOnly() const;
304 * This method returns list filed with Common Name entries from certificate.
306 * @return Common Name of Distribuotor End Entity certificate.
307 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
308 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
311 WidgetCertificateCNList getKeyCommonNameList(
312 WidgetCertificateData::Owner owner,
313 WidgetCertificateData::Type type) const;
316 * given a certificate owner (author / distributor) and type of certificate
318 * function returns list of matching fingerprints
320 FingerPrintList getKeyFingerprints(
321 WidgetCertificateData::Owner owner,
322 WidgetCertificateData::Type type) const;
325 * This method gets certificate data list for a widget from database.
327 WidgetCertificateDataList getCertificateDataList() const;
330 * This method returns a list of widget features.
333 * @see FreeFeatureList()
334 * @return list of widget features, type of list element is structure
336 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
337 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
340 DbWidgetFeatureSet getFeaturesList() const;
343 * This method checks whether widget has specified feature.
345 * @return true if has, false if has not
346 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
348 bool hasFeature(const std::string& featureName) const;
351 * This method returns a list of all the installed widgets.
353 * @return list of installed widgets.
354 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
355 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
358 static DbWidgetDAOReadOnlyList getWidgetList();
361 * This method gets author's infomation of a widget which is parsed from
362 * configiration document.
364 * @see WidgetAuthorInfo
365 * @param[out] pAuthorInfo
366 * @return true if succeed, false if fail.
368 WidgetAuthorInfo getAuthorInfo() const;
371 * This method gets author's name of a widget which is parsed from
372 * configiration document.
374 * @param[out] pAuthorInfo
375 * @return author's name.
376 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
377 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
380 DPL::OptionalString getAuthorName() const;
383 * This method gets author's email of a widget which is parsed from
384 * configiration document.
386 * @param[out] pAuthorInfo
387 * @return author's email.
388 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
389 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
392 DPL::OptionalString getAuthorEmail() const;
395 * This method gets author's email of a widget which is parsed from
396 * configiration document.
398 * @param[out] pAuthorInfo
399 * @return author's email.
400 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
401 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
404 DPL::OptionalString getAuthorHref() const;
407 * This method returns minimum version of WAC that WRT has to be compliant
408 * to to run this widget
410 * @return Minimum version
411 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
412 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
415 DPL::OptionalString getMinimumWacVersion() const;
418 * This method get widget installed time
420 * @return time_t : return widget's install time
422 time_t getInstallTime() const;
424 /* This method checks read only flag for given property
426 DPL::OptionalInt checkPropertyReadFlag(
427 const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
429 /* This method gets widget property key list
431 PropertyDAOReadOnly::WidgetPropertyKeyList getPropertyKeyList() const;
433 /* This method gets widget property list
435 PropertyDAOReadOnly::WidgetPreferenceList getPropertyList() const;
437 /* This method get widget property value
439 PropertyDAOReadOnly::WidgetPropertyValue getPropertyValue(
440 const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
442 LanguageTagList getLanguageTags() const;
443 LanguageTagList getIconLanguageTags() const;
445 WidgetLocalizedInfo getLocalizedInfo(const DPL::String& languageTag) const;
447 bool getBackSupported() const;
449 static bool isWidgetInstalled(DbWidgetHandle handle);
450 static bool isWidgetInstalled(const TizenAppId & tzAppId);
452 /* This method get path of the splash image.
454 * @return path of the widget's splash image
456 DPL::OptionalString getSplashImgSrc() const;
458 ExternalLocationList getWidgetExternalLocations() const;
461 * Default value is required to keep compatibility with
462 * wrt-installer and wrt.
464 CertificateChainList getWidgetCertificate(
465 CertificateSource source = SIGNATURE_DISTRIBUTOR) const;
467 void getWidgetSettings(WidgetSettings& outWidgetSettings) const;
470 * This method gets application control list that define AUL value
472 * @return See above comment
473 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
475 void getAppControlList(
476 WidgetAppControlList& outAppControlList) const;
479 * This method returns the type of the package.
481 * @return PackagingType
482 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
483 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
484 * records in DB table.
486 PackagingType getPackagingType() const;
488 void getEncryptedFileList(EncryptedFileList& filesList) const;
491 * This method returns widget's background page filename.
493 * @return Name of file containing background page
495 DPL::OptionalString getBackgroundPage() const;
498 * @brief generateTizenId generates new package id
500 * If widget do not supplies it's own tizen package id, this method can be
502 * although it should be removed in future.
504 * @return new tizen package id
506 static TizenPkgId generatePkgId();
507 static TizenPkgId generateTizenId()
509 return generatePkgId();
513 * This method returns widget's installed path
515 * @return path of widget installed
517 DPL::OptionalString getWidgetInstalledPath() const;
518 PrivilegeList getWidgetPrivilege() const;
519 WidgetSecurityModelVersion getSecurityModelVersion() const;
521 #if USE(WEB_PROVIDER)
523 * @brief Gets list of liveBox(es) ID(s) for a particular widget.
524 * @param[out] out param to retrive livebox(es) ID(s) as a list of String
526 void getLiveBoxInfoList(LiveBoxIdList& outLiveBoxIdList) const;
531 #endif // _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_