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/string.h>
34 #include <dpl/exception.h>
35 #include <dpl/db/orm.h>
36 #include <dpl/optional_typedefs.h>
37 #include <dpl/wrt-dao-ro/config_parser_data.h>
38 #include <dpl/wrt-dao-ro/property_dao_read_only.h>
39 #include <dpl/wrt-dao-ro/common_dao_types.h>
43 * Widget's signature enum.
44 * This enumerates signature type of widget.
46 enum WidgetSignatureType
48 SIGNATURE_TYPE_CARRIER = 0,
49 SIGNATURE_TYPE_IDENTIFIED,
50 SIGNATURE_TYPE_UNIDENTIFIED
53 enum CertificateSource {
54 SIGNATURE_DISTRIBUTOR = 0,
58 typedef std::list<DPL::String> StringList;
60 struct WidgetLocalizedInfo
62 DPL::OptionalString name;
63 DPL::OptionalString shortName;
64 DPL::OptionalString description;
65 DPL::OptionalString license;
66 DPL::OptionalString licenseHref;
71 * A structure to hold certificate fingerprints.
73 struct WidgetCertificateData
75 enum Owner { AUTHOR, DISTRIBUTOR, UNKNOWN };
76 enum Type { ROOT, ENDENTITY };
78 // type of signature: author/distributor
80 // indicates whether this is ca certificate
83 // chain id number: relative BASE, where BASE is signatureBASE.xml
85 // certificate fingerprint digested by md5
86 std::string strMD5Fingerprint;
87 // certificate fingerprint digestef by sha1
88 std::string strSHA1Fingerprint;
89 // Common name field in certificate
90 DPL::String strCommonName;
92 bool operator== (const WidgetCertificateData& certData) const
94 return certData.chainId == chainId &&
95 certData.owner == owner &&
96 certData.strCommonName == strCommonName &&
97 certData.strMD5Fingerprint == strMD5Fingerprint &&
98 certData.strSHA1Fingerprint == strSHA1Fingerprint;
102 typedef std::list<WidgetCertificateData> WidgetCertificateDataList;
104 typedef DPL::String Locale;
105 typedef std::set<Locale> LocaleSet;
106 typedef std::list<std::string> ExternalLocationList;
110 * A structure to hold widget's information needed to be registered.
111 * @see WidgetConfigurationInfo
113 struct WidgetRegisterInfo
115 struct LocalizedIcon : public ConfigParserData::Icon
117 LocalizedIcon(const ConfigParserData::Icon& icon,
118 const LocaleSet& _availableLocales) :
119 ConfigParserData::Icon(icon),
120 availableLocales(_availableLocales)
123 LocaleSet availableLocales;
126 struct StartFileProperties
128 DPL::String encoding;
132 typedef std::map<Locale,
133 StartFileProperties> StartFilePropertiesForLocalesMap;
134 struct LocalizedStartFile
137 StartFilePropertiesForLocalesMap propertiesForLocales;
140 typedef std::list<LocalizedIcon> LocalizedIconList;
141 typedef std::list<LocalizedStartFile> LocalizedStartFileList;
142 struct LocalizationData
144 LocalizedIconList icons;
145 LocalizedStartFileList startFiles;
157 WidgetRegisterInfo() :
158 webAppType(APP_TYPE_UNKNOWN),
159 signatureType(SIGNATURE_TYPE_UNIDENTIFIED),
161 packagingType(PKG_TYPE_UNKNOWN)
164 WidgetType webAppType;
165 DPL::OptionalString guid;
166 DPL::OptionalString version;
167 DPL::OptionalString minVersion;
168 std::string shareHref;
169 std::string baseFolder;
170 WidgetSignatureType signatureType;
171 ConfigParserData configInfo;
172 LocalizationData localizationData;
177 time_t installedTime;
178 PackagingType packagingType;
179 EncryptedFileList encryptedFiles;
180 ExternalLocationList externalLocations;
181 DPL::OptionalString widgetInstalledPath;
184 typedef std::list<std::string> CertificateChainList;
185 class IWidgetSecurity
188 virtual ~IWidgetSecurity();
190 virtual const WidgetCertificateDataList& getCertificateList() const = 0;
192 virtual bool isRecognized() const = 0;
194 virtual bool isDistributorSigned() const = 0;
196 virtual void getCertificateChainList(CertificateChainList& list,
197 CertificateSource source) const = 0;
202 * Structure to hold the information of widget's author.
204 struct WidgetAuthorInfo
206 DPL::OptionalString name;
207 DPL::OptionalString email;
208 DPL::OptionalString href;
212 * Widget update policy
214 enum WidgetUpdatePolicy
216 WIDGET_UPDATE_MONTHLY = 0, //< monthly update
217 WIDGET_UPDATE_WEEKLY, //< weekly update
218 WIDGET_UPDATE_DAILY, //< daily update
219 WIDGET_UPDATE_STARTUP, //< update when cell phone boots
220 WIDGET_UPDATE_NEVER //< never update
223 typedef std::list <std::string> WidgetCertificateCNList;
224 typedef std::list<DPL::String> LanguageTagList;
225 typedef std::list<std::string> HostList;
226 typedef std::list<std::string> FingerPrintList;
227 typedef std::list<std::string> ResourceAttributeList;
229 class WidgetDAOReadOnly
233 * WidgetDAO Exception classes
238 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
239 DECLARE_EXCEPTION_TYPE(Base, DatabaseError)
240 DECLARE_EXCEPTION_TYPE(Base, ReadOnlyProperty)
241 DECLARE_EXCEPTION_TYPE(Base, GUIDisNull)
242 DECLARE_EXCEPTION_TYPE(Base, UnexpectedEmptyResult)
243 DECLARE_EXCEPTION_TYPE(Base, WidgetNotExist)
244 DECLARE_EXCEPTION_TYPE(Base, AlreadyRegistered)
248 DbWidgetHandle m_widgetHandle;
251 struct WidgetLocalizedIconRow
255 DPL::String widgetLocale;
257 typedef std::list<WidgetLocalizedIconRow> WidgetLocalizedIconList;
264 DPL::OptionalInt iconWidth;
265 DPL::OptionalInt iconHeight;
267 typedef std::list<WidgetIconRow> WidgetIconList;
269 struct WidgetStartFileRow
275 typedef std::list<WidgetStartFileRow> WidgetStartFileList;
277 struct WidgetLocalizedStartFileRow
281 DPL::String widgetLocale;
283 DPL::String encoding;
285 typedef std::list<WidgetLocalizedStartFileRow> LocalizedStartFileList;
288 * This is a constructor.
290 * @param[in] widgetHandle application id of widget.
292 WidgetDAOReadOnly(DbWidgetHandle widgetHandle);
293 WidgetDAOReadOnly(DPL::OptionalString widgetGUID);
294 WidgetDAOReadOnly(WrtDB::TizenAppId tzAppid);
299 virtual ~WidgetDAOReadOnly();
302 * This method returns widget handle(m_widgetHandle).
304 * @return widget handle(m_widgetHandle).
305 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
306 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
309 DbWidgetHandle getHandle() const;
310 static DbWidgetHandle getHandle(const WidgetGUID GUID);
311 static DbWidgetHandle getHandle(const DPL::String pkgName);
314 * Returns tizenAppId for the specified widget
317 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
318 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
322 TizenAppId getTzAppId() const;
323 static TizenAppId getTzAppId(const WidgetGUID GUID);
324 static TizenAppId getTzAppId(const DbWidgetHandle handle);
325 static TizenAppId getTzAppId(const TizenPkgId tzPkgid);
328 * Returns TizenPkgId for the specified widget
330 * @return TizenPkgId;
331 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
332 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
336 TizenPkgId getTzPkgId() const;
337 static TizenPkgId getTzPkgId(const DbWidgetHandle handle);
338 static TizenPkgId getTzPkgId(const TizenAppId tzAppid);
341 * This method returns the root directory of widget resource.
343 * @return path name of root directory.
344 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
345 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
348 virtual DPL::String getPath() const;
350 DPL::String getFullPath() const;
353 * This method returns the preferred size of the widget,
354 * including width and height.
357 * @return An structure type variable to hold widget's size.
358 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
359 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
362 DbWidgetSize getPreferredSize() const;
365 * This method returns the type of the widget.
368 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
369 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
370 * records in DB table.
372 WidgetType getWidgetType() const;
375 * This method returns the id of the widget.
378 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
379 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
382 WidgetGUID getGUID() const;
385 * This method returns the App id of the widget.
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 getTizenAppId() const;
395 * This method returns the defaultlocale for the widget.
397 * @return defaultlocale
398 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
399 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
402 DPL::OptionalString getDefaultlocale() const;
405 * This method returns list of localized icons files;
407 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
408 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
411 WidgetLocalizedIconList getLocalizedIconList() const;
414 * This method returns list of icons files;
416 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
417 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
420 WidgetIconList getIconList() const;
423 * This method returns list of localized start files;
425 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
426 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
429 LocalizedStartFileList getLocalizedStartFileList() const;
432 * This method returns list of start files;
434 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
435 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
438 WidgetStartFileList getStartFileList() const;
441 * @param[out] outAccessInfoList list filled with access info structures
443 void getWidgetAccessInfo(WidgetAccessInfoList& outAccessInfoList) const;
444 void getWidgetAllowNavigationInfo(
445 WidgetAllowNavigationInfoList& allowNavigationInfoList) const;
449 * @return recognized status
451 bool isRecognized() const;
457 bool isDistributorSigned() const;
461 * @return trusted status
463 bool isTrusted() const;
466 * This method returns window mode of widget.
468 * @return window modes of widget
469 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
470 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
473 WindowModeList getWindowModes() const;
476 * This method returns the version of the widget.
478 * @return version of widget
479 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
480 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
483 DPL::OptionalString getVersion() const;
486 * This method is used as a getter for csp policy of widget. It should be
487 * provided in configuration file.
488 * @return global csp policy for widget
490 DPL::OptionalString getCspPolicy() const;
493 * This method is used as a getter for report only csp policy of widget.
494 * It may be provided in configuration file.
495 * @return global csp report only policy for widget
497 DPL::OptionalString getCspPolicyReportOnly() const;
500 * This method returns list filed with Common Name entries from certificate.
502 * @return Common Name of Distribuotor End Entity certificate.
503 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
504 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
507 WidgetCertificateCNList getKeyCommonNameList(
508 WidgetCertificateData::Owner owner,
509 WidgetCertificateData::Type type) const;
512 * given a certificate owner (author / distributor) and type of certificate
514 * function returns list of matching fingerprints
516 FingerPrintList getKeyFingerprints(
517 WidgetCertificateData::Owner owner,
518 WidgetCertificateData::Type type) const;
521 * This method gets certificate data list for a widget from database.
523 WidgetCertificateDataList getCertificateDataList() const;
526 * This method returns a list of widget features.
529 * @see FreeFeatureList()
530 * @return list of widget features, type of list element is structure
532 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
533 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
536 DbWidgetFeatureSet getFeaturesList() const;
539 * This method checks whether widget has specified feature.
541 * @return true if has, false if has not
542 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
544 bool hasFeature(const std::string& featureName) const;
547 * This method gets host list that widget can connect to.
549 * @return See above comment
550 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
552 HostList getAccessHostList() const;
555 * This method gets widget's access on network: true or false.
557 * @return true: widget can access network; false: widget can not access
559 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
560 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
563 bool getAccessNetworkMode() const;
566 * This method gets if widget needs webkit plugins enabled
568 * @return true: widget needs webkit plugins enabled
569 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
570 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
573 bool getWebkitPluginsRequired() const;
576 * This method returns a list of all the installed widgets' app id.
578 * @return list of installed widgets' app id.
579 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
580 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
583 static DbWidgetHandleList getHandleList();
586 * This method returns list of tizen application list of installed packages
587 * @return list of TizenAppIdList of installed packages
589 static TizenAppIdList getTizenAppidList();
592 * This method returns list of tizen package list of installed packages
593 * @return list of TizenPkgIdList of installed packages
595 static TizenPkgIdList getTizenPkgidList();
598 * This method returns a list of all the installed widgets.
600 * @return list of installed widgets.
601 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
602 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
605 static DbWidgetDAOReadOnlyList getWidgetList();
608 * This method gets author's infomation of a widget which is parsed from
609 * configiration document.
611 * @see WidgetAuthorInfo
612 * @param[out] pAuthorInfo
613 * @return true if succeed, false if fail.
615 WidgetAuthorInfo getAuthorInfo() const;
618 * This method gets author's name of a widget which is parsed from
619 * configiration document.
621 * @param[out] pAuthorInfo
622 * @return author's name.
623 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
624 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
627 DPL::OptionalString getAuthorName() const;
630 * This method gets author's email of a widget which is parsed from
631 * configiration document.
633 * @param[out] pAuthorInfo
634 * @return author's email.
635 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
636 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
639 DPL::OptionalString getAuthorEmail() const;
642 * This method gets author's email of a widget which is parsed from
643 * configiration document.
645 * @param[out] pAuthorInfo
646 * @return author's email.
647 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
648 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
651 DPL::OptionalString getAuthorHref() const;
654 * This method returns minimum version of WAC that WRT has to be compliant
655 * to to run this widget
657 * @return Minimum version
658 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
659 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
662 DPL::OptionalString getMinimumWacVersion() const;
664 /* This method get widget' share href.
666 * @return widget's share href
668 std::string getShareHref() const;
671 * This method get widget installed time
673 * @return time_t : return widget's install time
675 time_t getInstallTime() const;
678 * This method gets widget base folder.
680 * @return widget base folder.
681 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
682 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
685 std::string getBaseFolder() const;
687 /* This method checks read only flag for given property
689 DPL::OptionalInt checkPropertyReadFlag(
690 const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
692 /* This method gets widget property key list
694 PropertyDAOReadOnly::WidgetPropertyKeyList getPropertyKeyList() const;
696 /* This method gets widget property list
698 PropertyDAOReadOnly::WidgetPreferenceList getPropertyList() const;
700 /* This method get widget property value
702 PropertyDAOReadOnly::WidgetPropertyValue getPropertyValue(
703 const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
705 LanguageTagList getLanguageTags() const;
706 LanguageTagList getIconLanguageTags() const;
708 WidgetLocalizedInfo getLocalizedInfo(const DPL::String& languageTag) const;
709 std::string getCookieDatabasePath() const;
711 std::string getPrivateLocalStoragePath() const;
713 bool getBackSupported() const;
715 static bool isWidgetInstalled(DbWidgetHandle handle);
716 static bool isWidgetInstalled(const TizenAppId & tzAppId);
718 /* This method get path of the splash image.
720 * @return path of the widget's splash image
722 DPL::OptionalString getSplashImgSrc() const;
724 ExternalLocationList getWidgetExternalLocations() const;
727 * Default value is required to keep compatibility with
728 * wrt-installer and wrt.
730 CertificateChainList getWidgetCertificate(
731 CertificateSource source = SIGNATURE_DISTRIBUTOR) const;
733 void getWidgetSettings(WidgetSettings& outWidgetSettings) const;
736 * This method gets application control list that define AUL value
738 * @return See above comment
739 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
741 void getAppControlList(
742 WidgetAppControlList& outAppControlList) const;
745 * This method returns the type of the package.
747 * @return PackagingType
748 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
749 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
750 * records in DB table.
752 PackagingType getPackagingType() const;
754 void getEncryptedFileList(EncryptedFileList& filesList) const;
757 * This method returns widget's background page filename.
759 * @return Name of file containing background page
761 DPL::OptionalString getBackgroundPage() const;
764 * @brief generateTizenId generates new package id
766 * If widget do not supplies it's own tizen package id, this method can be
768 * although it should be removed in future.
770 * @return new tizen package id
772 static TizenPkgId generatePkgId();
773 static TizenPkgId generateTizenId()
775 return generatePkgId();
779 * @brief This method return each value for security setting
781 * @return SettingsType
782 * SETTINGS_TYPE_UNKNOWN : unknow value
783 * SETTINGS_TYPE_ON : enable
784 * SETTINGS_TYPE_ALWAYS_ASK : ask by popup
785 * SETTINGS_TYPE_OFF : disable
787 SettingsType getSecurityPopupUsage() const;
788 SettingsType getGeolocationUsage() const;
789 SettingsType getWebNotificationUsage() const;
790 SettingsType getWebDatabaseUsage() const;
793 * This method returns widget's installed path
795 * @return path of widget installed
797 DPL::OptionalString getWidgetInstalledPath() const;
800 * This method returns tizen package id
802 * @return tizen package id
804 TizenPkgId getTizenPkgId() const;
805 PrivilegeList getWidgetPrivilege() const;
806 WidgetSecurityModelVersion getSecurityModelVersion() const;
811 #endif // _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_