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/db/orm.h>
37 #include <dpl/optional_typedefs.h>
38 #include <dpl/wrt-dao-ro/config_parser_data.h>
39 #include <dpl/wrt-dao-ro/property_dao_read_only.h>
40 #include <dpl/wrt-dao-ro/common_dao_types.h>
43 enum CertificateSource {
45 SIGNATURE_DISTRIBUTOR = 1,
46 SIGNATURE_DISTRIBUTOR2 = 2,
50 struct WidgetLocalizedInfo
52 DPL::OptionalString name;
53 DPL::OptionalString shortName;
54 DPL::OptionalString description;
55 DPL::OptionalString license;
56 DPL::OptionalString licenseHref;
61 * A structure to hold certificate fingerprints.
63 struct WidgetCertificateData
65 enum Owner { AUTHOR, DISTRIBUTOR, DISTRIBUTOR2, UNKNOWN };
66 enum Type { ROOT, ENDENTITY };
68 // type of signature: author/distributor
70 // indicates whether this is ca certificate
73 // chain id number: relative BASE, where BASE is signatureBASE.xml
75 // certificate fingerprint digested by md5
76 std::string strMD5Fingerprint;
77 // certificate fingerprint digestef by sha1
78 std::string strSHA1Fingerprint;
79 // Common name field in certificate
80 DPL::String strCommonName;
82 bool operator== (const WidgetCertificateData& certData) const
84 return certData.chainId == chainId &&
85 certData.owner == owner &&
86 certData.strCommonName == strCommonName &&
87 certData.strMD5Fingerprint == strMD5Fingerprint &&
88 certData.strSHA1Fingerprint == strSHA1Fingerprint;
92 typedef std::list<WidgetCertificateData> WidgetCertificateDataList;
94 typedef DPL::String Locale;
95 typedef std::set<Locale> LocaleSet;
96 typedef std::list<std::string> ExternalLocationList;
100 * A structure to hold widget's information needed to be registered.
101 * @see WidgetConfigurationInfo
103 struct WidgetRegisterInfo
105 struct LocalizedIcon : public ConfigParserData::Icon
107 LocalizedIcon(const ConfigParserData::Icon& icon,
108 const LocaleSet& _availableLocales) :
109 ConfigParserData::Icon(icon),
110 availableLocales(_availableLocales)
113 LocaleSet availableLocales;
116 struct StartFileProperties
118 DPL::String encoding;
122 typedef std::map<Locale,
123 StartFileProperties> StartFilePropertiesForLocalesMap;
124 struct LocalizedStartFile
127 StartFilePropertiesForLocalesMap propertiesForLocales;
130 typedef std::list<LocalizedIcon> LocalizedIconList;
131 typedef std::list<LocalizedStartFile> LocalizedStartFileList;
132 struct LocalizationData
134 LocalizedIconList icons;
135 LocalizedStartFileList startFiles;
139 WidgetRegisterInfo() :
140 webAppType(APP_TYPE_UNKNOWN),
142 packagingType(PKG_TYPE_UNKNOWN)
145 WidgetType webAppType;
146 DPL::OptionalString guid;
147 DPL::OptionalString version;
148 DPL::OptionalString minVersion;
149 std::string baseFolder;
150 ConfigParserData configInfo;
151 LocalizationData localizationData;
155 TizenAppId tzBackupAppid;
157 time_t installedTime;
158 PackagingType packagingType;
159 EncryptedFileList encryptedFiles;
160 ExternalLocationList externalLocations;
161 DPL::OptionalString widgetInstalledPath;
164 typedef std::list<std::string> CertificateChainList;
165 class IWidgetSecurity
168 virtual ~IWidgetSecurity();
170 virtual const WidgetCertificateDataList& getCertificateList() const = 0;
172 virtual bool isRecognized() const = 0;
174 virtual bool isDistributorSigned() const = 0;
176 virtual void getCertificateChainList(CertificateChainList& list,
177 CertificateSource source) const = 0;
182 * Structure to hold the information of widget's author.
184 struct WidgetAuthorInfo
186 DPL::OptionalString name;
187 DPL::OptionalString email;
188 DPL::OptionalString href;
191 typedef std::list <std::string> WidgetCertificateCNList;
192 typedef std::list<DPL::String> LanguageTagList;
193 typedef std::list<std::string> HostList;
194 typedef std::list<std::string> FingerPrintList;
196 class WidgetDAOReadOnly
200 * WidgetDAO Exception classes
205 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
206 DECLARE_EXCEPTION_TYPE(Base, DatabaseError)
207 DECLARE_EXCEPTION_TYPE(Base, ReadOnlyProperty)
208 DECLARE_EXCEPTION_TYPE(Base, GUIDisNull)
209 DECLARE_EXCEPTION_TYPE(Base, UnexpectedEmptyResult)
210 DECLARE_EXCEPTION_TYPE(Base, WidgetNotExist)
211 DECLARE_EXCEPTION_TYPE(Base, AlreadyRegistered)
215 DbWidgetHandle m_widgetHandle;
218 struct WidgetLocalizedIconRow
222 DPL::String widgetLocale;
224 typedef std::list<WidgetLocalizedIconRow> WidgetLocalizedIconList;
231 DPL::OptionalInt iconWidth;
232 DPL::OptionalInt iconHeight;
234 typedef std::list<WidgetIconRow> WidgetIconList;
236 struct WidgetStartFileRow
242 typedef std::list<WidgetStartFileRow> WidgetStartFileList;
244 struct WidgetLocalizedStartFileRow
248 DPL::String widgetLocale;
250 DPL::String encoding;
252 typedef std::list<WidgetLocalizedStartFileRow> LocalizedStartFileList;
255 * This is a constructor.
257 * @param[in] widgetHandle application id of widget.
259 WidgetDAOReadOnly(DbWidgetHandle widgetHandle);
260 WidgetDAOReadOnly(DPL::OptionalString widgetGUID);
261 WidgetDAOReadOnly(WrtDB::TizenAppId tzAppid);
266 virtual ~WidgetDAOReadOnly();
269 * This method returns widget handle(m_widgetHandle).
271 * @return widget handle(m_widgetHandle).
272 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
273 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
276 DbWidgetHandle getHandle() const;
277 static DbWidgetHandle getHandle(const WidgetGUID GUID);
278 static DbWidgetHandle getHandle(const DPL::String tzAppId);
279 static DbWidgetHandle getHandleByPkgId(const DPL::String pkgId);
282 * This method Returns tizen application id for the specified web application
285 TizenAppId getTzAppId() const DPL_DEPRECATED_WITH_MESSAGE("Use getTizenAppId");
286 static TizenAppId getTzAppId(const WidgetGUID GUID) DPL_DEPRECATED_WITH_MESSAGE("Use getTizenAppId");
287 static TizenAppId getTzAppId(const DbWidgetHandle handle) DPL_DEPRECATED_WITH_MESSAGE("Use getTizenAppId");
288 static TizenAppId getTzAppId(const TizenPkgId tizenPkgId) DPL_DEPRECATED_WITH_MESSAGE("Use getTizenAppId");
289 TizenAppId getTizenAppId() const;
290 static TizenAppId getTizenAppId(const WidgetGUID GUID);
291 static TizenAppId getTizenAppId(const DbWidgetHandle handle);
292 static TizenAppId getTizenAppId(const TizenPkgId tizenPkgId);
295 * This method returns list of installed tizen application id
296 * @return TizenAppIdList
298 static TizenAppIdList getTizenAppidList() DPL_DEPRECATED_WITH_MESSAGE("Use getTizenAppIdList");
299 static TizenAppIdList getTizenAppIdList();
300 static std::list<TizenAppId> getTzAppIdList(const TizenPkgId tzPkgid);
303 * Returns TizenPkgId for the specified widget
305 * @return TizenPkgId;
306 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
307 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
311 TizenPkgId getTzPkgId() const DPL_DEPRECATED_WITH_MESSAGE("Use getTizenPkgId");
312 static TizenPkgId getTzPkgId(const DbWidgetHandle handle) DPL_DEPRECATED_WITH_MESSAGE("Use getTizenPkgId");
313 static TizenPkgId getTzPkgId(const TizenAppId tzAppid) DPL_DEPRECATED_WITH_MESSAGE("Use getTizenPkgId");
314 TizenPkgId getTizenPkgId() const;
315 static TizenPkgId getTizenPkgId(const DbWidgetHandle handle);
316 static TizenPkgId getTizenPkgId(const TizenAppId tzAppid);
319 * This method returns list of tizen package list of installed packages
320 * @return list of TizenPkgIdList of installed packages
322 static TizenPkgIdList getTizenPkgidList() DPL_DEPRECATED_WITH_MESSAGE("Use getTizenPkgIdList");
323 static TizenPkgIdList getTizenPkgIdList();
326 * This method returns the root directory of widget resource.
328 * @return path name of root directory.
329 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
330 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
333 virtual DPL::String getPath() const;
335 DPL::String getFullPath() const;
338 * This method returns the preferred size of the widget,
339 * including width and height.
342 * @return An structure type variable to hold widget's size.
343 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
344 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
347 DbWidgetSize getPreferredSize() const;
350 * This method returns the type of the widget.
353 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
354 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
355 * records in DB table.
357 WidgetType getWidgetType() const;
360 * This method returns the id of the widget.
363 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
364 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
367 WidgetGUID getGUID() const;
370 * This method returns the defaultlocale for the widget.
372 * @return defaultlocale
373 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
374 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
377 DPL::OptionalString getDefaultlocale() const;
380 * This method returns list of localized icons files;
382 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
383 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
386 WidgetLocalizedIconList getLocalizedIconList() const;
389 * This method returns list of icons files;
391 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
392 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
395 WidgetIconList getIconList() const;
398 * This method returns list of localized start files;
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 LocalizedStartFileList getLocalizedStartFileList() const;
407 * This method returns list of start files;
409 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
410 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
413 WidgetStartFileList getStartFileList() const;
416 * @param[out] outAccessInfoList list filled with access info structures
418 void getWidgetAccessInfo(WidgetAccessInfoList& outAccessInfoList) const;
419 void getWidgetAllowNavigationInfo(
420 WidgetAllowNavigationInfoList& allowNavigationInfoList) const;
423 * This method returns window mode of widget.
425 * @return window modes of widget
426 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
427 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
430 WindowModeList getWindowModes() const;
433 * This method returns the version of the widget.
435 * @return version of widget
436 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
437 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
440 DPL::OptionalString getVersion() const;
443 * This method is used as a getter for csp policy of widget. It should be
444 * provided in configuration file.
445 * @return global csp policy for widget
447 DPL::OptionalString getCspPolicy() const;
450 * This method is used as a getter for report only csp policy of widget.
451 * It may be provided in configuration file.
452 * @return global csp report only policy for widget
454 DPL::OptionalString getCspPolicyReportOnly() const;
457 * This method returns list filed with Common Name entries from certificate.
459 * @return Common Name of Distribuotor End Entity certificate.
460 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
461 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
464 WidgetCertificateCNList getKeyCommonNameList(
465 WidgetCertificateData::Owner owner,
466 WidgetCertificateData::Type type) const;
469 * given a certificate owner (author / distributor) and type of certificate
471 * function returns list of matching fingerprints
473 FingerPrintList getKeyFingerprints(
474 WidgetCertificateData::Owner owner,
475 WidgetCertificateData::Type type) const;
478 * This method gets certificate data list for a widget from database.
480 WidgetCertificateDataList getCertificateDataList() const;
483 * This method returns a list of widget features.
486 * @see FreeFeatureList()
487 * @return list of widget features, type of list element is structure
489 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
490 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
493 DbWidgetFeatureSet getFeaturesList() const;
496 * This method checks whether widget has specified feature.
498 * @return true if has, false if has not
499 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
501 bool hasFeature(const std::string& featureName) const;
504 * This method gets if widget needs webkit plugins enabled
506 * @return true: widget needs webkit plugins enabled
507 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
508 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
511 bool getWebkitPluginsRequired() const;
514 * This method returns a list of all the installed widgets.
516 * @return list of installed widgets.
517 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
518 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
521 static DbWidgetDAOReadOnlyList getWidgetList();
524 * This method gets author's infomation of a widget which is parsed from
525 * configiration document.
527 * @see WidgetAuthorInfo
528 * @param[out] pAuthorInfo
529 * @return true if succeed, false if fail.
531 WidgetAuthorInfo getAuthorInfo() const;
534 * This method gets author's name of a widget which is parsed from
535 * configiration document.
537 * @param[out] pAuthorInfo
538 * @return author's name.
539 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
540 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
543 DPL::OptionalString getAuthorName() const;
546 * This method gets author's email of a widget which is parsed from
547 * configiration document.
549 * @param[out] pAuthorInfo
550 * @return author's email.
551 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
552 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
555 DPL::OptionalString getAuthorEmail() const;
558 * This method gets author's email of a widget which is parsed from
559 * configiration document.
561 * @param[out] pAuthorInfo
562 * @return author's email.
563 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
564 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
567 DPL::OptionalString getAuthorHref() const;
570 * This method returns minimum version of WAC that WRT has to be compliant
571 * to to run this widget
573 * @return Minimum version
574 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
575 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
578 DPL::OptionalString getMinimumWacVersion() const;
581 * This method get widget installed time
583 * @return time_t : return widget's install time
585 time_t getInstallTime() const;
588 * This method gets widget base folder.
590 * @return widget base folder.
591 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
592 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
595 std::string getBaseFolder() const;
597 /* This method checks read only flag for given property
599 DPL::OptionalInt checkPropertyReadFlag(
600 const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
602 /* This method gets widget property key list
604 PropertyDAOReadOnly::WidgetPropertyKeyList getPropertyKeyList() const;
606 /* This method gets widget property list
608 PropertyDAOReadOnly::WidgetPreferenceList getPropertyList() const;
610 /* This method get widget property value
612 PropertyDAOReadOnly::WidgetPropertyValue getPropertyValue(
613 const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
615 LanguageTagList getLanguageTags() const;
616 LanguageTagList getIconLanguageTags() const;
618 WidgetLocalizedInfo getLocalizedInfo(const DPL::String& languageTag) const;
620 bool getBackSupported() const;
622 static bool isWidgetInstalled(DbWidgetHandle handle);
623 static bool isWidgetInstalled(const TizenAppId & tzAppId);
625 /* This method get path of the splash image.
627 * @return path of the widget's splash image
629 DPL::OptionalString getSplashImgSrc() const;
631 ExternalLocationList getWidgetExternalLocations() const;
634 * Default value is required to keep compatibility with
635 * wrt-installer and wrt.
637 CertificateChainList getWidgetCertificate(
638 CertificateSource source = SIGNATURE_DISTRIBUTOR) const;
640 void getWidgetSettings(WidgetSettings& outWidgetSettings) const;
643 * This method gets application control list that define AUL value
645 * @return See above comment
646 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
648 void getAppControlList(
649 WidgetAppControlList& outAppControlList) const;
652 * This method returns the type of the package.
654 * @return PackagingType
655 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
656 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
657 * records in DB table.
659 PackagingType getPackagingType() const;
661 void getEncryptedFileList(EncryptedFileList& filesList) const;
664 * This method returns widget's background page filename.
666 * @return Name of file containing background page
668 DPL::OptionalString getBackgroundPage() const;
671 * @brief generateTizenId generates new package id
673 * If widget do not supplies it's own tizen package id, this method can be
675 * although it should be removed in future.
677 * @return new tizen package id
679 static TizenPkgId generatePkgId();
680 static TizenPkgId generateTizenId()
682 return generatePkgId();
686 * This method returns widget's installed path
688 * @return path of widget installed
690 DPL::OptionalString getWidgetInstalledPath() const;
691 PrivilegeList getWidgetPrivilege() const;
692 WidgetSecurityModelVersion getSecurityModelVersion() const;
697 #endif // _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_