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>
44 * Widget's signature enum.
45 * This enumerates signature type of widget.
47 enum WidgetSignatureType
49 SIGNATURE_TYPE_CARRIER = 0,
50 SIGNATURE_TYPE_IDENTIFIED,
51 SIGNATURE_TYPE_UNIDENTIFIED
54 enum CertificateSource {
55 SIGNATURE_DISTRIBUTOR = 0,
59 typedef std::list<DPL::String> StringList;
61 struct WidgetLocalizedInfo
63 DPL::OptionalString name;
64 DPL::OptionalString shortName;
65 DPL::OptionalString description;
66 DPL::OptionalString license;
67 DPL::OptionalString licenseHref;
72 * A structure to hold certificate fingerprints.
74 struct WidgetCertificateData
76 enum Owner { AUTHOR, DISTRIBUTOR, UNKNOWN };
77 enum Type { ROOT, ENDENTITY };
79 // type of signature: author/distributor
81 // indicates whether this is ca certificate
84 // chain id number: relative BASE, where BASE is signatureBASE.xml
86 // certificate fingerprint digested by md5
87 std::string strMD5Fingerprint;
88 // certificate fingerprint digestef by sha1
89 std::string strSHA1Fingerprint;
90 // Common name field in certificate
91 DPL::String strCommonName;
93 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)
124 LocaleSet availableLocales;
127 struct StartFileProperties
129 DPL::String encoding;
133 typedef std::map<Locale,
134 StartFileProperties> StartFilePropertiesForLocalesMap;
135 struct LocalizedStartFile
138 StartFilePropertiesForLocalesMap propertiesForLocales;
141 typedef std::list<LocalizedIcon> LocalizedIconList;
142 typedef std::list<LocalizedStartFile> LocalizedStartFileList;
143 struct LocalizationData
145 LocalizedIconList icons;
146 LocalizedStartFileList startFiles;
158 WidgetRegisterInfo() :
159 webAppType(APP_TYPE_UNKNOWN),
160 signatureType(SIGNATURE_TYPE_UNIDENTIFIED),
163 packagingType(PKG_TYPE_UNKNOWN)
167 WidgetType webAppType;
168 WidgetType type; // TODO : This type will be removed.
169 DPL::OptionalString guid;
170 DPL::OptionalString version;
171 DPL::OptionalString minVersion;
172 std::string shareHref;
173 std::string baseFolder;
174 WidgetSignatureType signatureType;
176 ConfigParserData configInfo;
177 LocalizationData localizationData;
179 DPL::OptionalString pkgname;
180 WidgetPkgName pkgname_TEMPORARY_API;
182 time_t installedTime;
183 PackagingType packagingType;
184 EncryptedFileList encryptedFiles;
185 ExternalLocationList externalLocations;
186 DPL::OptionalString widgetInstalledPath;
189 typedef std::list<std::string> CertificateChainList;
193 virtual ~IWacSecurity();
195 virtual const WidgetCertificateDataList& getCertificateList() const = 0;
197 virtual bool isRecognized() const = 0;
199 virtual bool isDistributorSigned() const = 0;
201 virtual bool isWacSigned() const = 0;
203 virtual void getCertificateChainList(CertificateChainList& list,
204 CertificateSource source) const = 0;
209 * Structure to hold the information of widget's author.
211 struct WidgetAuthorInfo
213 DPL::OptionalString name;
214 DPL::OptionalString email;
215 DPL::OptionalString href;
219 * Widget update policy
221 enum WidgetUpdatePolicy
223 WIDGET_UPDATE_MONTHLY = 0, //< monthly update
224 WIDGET_UPDATE_WEEKLY, //< weekly update
225 WIDGET_UPDATE_DAILY, //< daily update
226 WIDGET_UPDATE_STARTUP, //< update when cell phone boots
227 WIDGET_UPDATE_NEVER //< never update
230 typedef std::list <std::string> WidgetCertificateCNList;
231 typedef std::list<DPL::String> LanguageTagList;
232 typedef std::list<std::string> HostList;
233 typedef std::list<std::string> FingerPrintList;
234 typedef std::list<std::string> ResourceAttributeList;
236 class WidgetDAOReadOnly
240 * WidgetDAO Exception classes
245 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
246 DECLARE_EXCEPTION_TYPE(Base, DatabaseError)
247 DECLARE_EXCEPTION_TYPE(Base, ReadOnlyProperty)
248 DECLARE_EXCEPTION_TYPE(Base, GUIDisNull)
249 DECLARE_EXCEPTION_TYPE(Base, UnexpectedEmptyResult)
250 DECLARE_EXCEPTION_TYPE(Base, WidgetNotExist)
251 DECLARE_EXCEPTION_TYPE(Base, AlreadyRegistered)
255 DbWidgetHandle m_widgetHandle;
258 struct WidgetLocalizedIconRow
262 DPL::String widgetLocale;
264 typedef std::list<WidgetLocalizedIconRow> WidgetLocalizedIconList;
271 DPL::OptionalInt iconWidth;
272 DPL::OptionalInt iconHeight;
274 typedef std::list<WidgetIconRow> WidgetIconList;
276 struct WidgetStartFileRow
282 typedef std::list<WidgetStartFileRow> WidgetStartFileList;
284 struct WidgetLocalizedStartFileRow
288 DPL::String widgetLocale;
290 DPL::String encoding;
292 typedef std::list<WidgetLocalizedStartFileRow> LocalizedStartFileList;
295 * This is a constructor.
297 * @param[in] widgetHandle application id of widget.
299 WidgetDAOReadOnly(DbWidgetHandle widgetHandle);
300 WidgetDAOReadOnly(DPL::OptionalString widgetGUID);
301 WidgetDAOReadOnly(DPL::String pkgName);
306 virtual ~WidgetDAOReadOnly();
309 * This method returns widget handle(m_widgetHandle).
311 * @return widget handle(m_widgetHandle).
312 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
313 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in DB table.
315 DbWidgetHandle getHandle() const;
316 static DbWidgetHandle getHandle(const WidgetGUID GUID);
317 static DbWidgetHandle getHandle(const DPL::String pkgName);
320 * Returns pkgname for the specified widget
323 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
324 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in DB table.
326 WidgetPkgName getPkgName() const;
327 static WidgetPkgName getPkgName(const WidgetGUID GUID);
328 static WidgetPkgName getPkgName(const DbWidgetHandle handle);
331 * This method returns the root directory of widget resource.
333 * @return path name of root directory.
334 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
335 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
338 DPL::String getPath() const;
340 DPL::String getFullPath() const;
343 * This method returns the preferred size of the widget,
344 * including width and height.
347 * @return An structure type variable to hold widget's size.
348 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
349 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
352 DbWidgetSize getPreferredSize() const;
355 * This method returns the type of the widget.
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 WidgetType getWidgetType() const;
365 * This method returns the id 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 records in
372 WidgetGUID getGUID() const;
375 * This method returns the Package name 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 DB table.
381 DPL::OptionalString getPkgname() const;
382 WidgetPkgName getPkgname_TEMPORARY_API() const;
385 * This method returns the defaultlocale for the widget.
387 * @return defaultlocale
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 getDefaultlocale() const;
395 * This method returns list of localized icons files;
397 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
398 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
401 WidgetLocalizedIconList getLocalizedIconList() const;
404 * This method returns list of icons files;
406 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
407 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
410 WidgetIconList getIconList() const;
413 * This method returns list of localized start files;
415 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
416 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
419 LocalizedStartFileList getLocalizedStartFileList() const;
422 * This method returns list of start files;
424 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
425 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
428 WidgetStartFileList getStartFileList() const;
431 * @param[out] outAccessInfoList list filled with access info structures
433 void getWidgetAccessInfo(WidgetAccessInfoList& outAccessInfoList) const;
437 * @return recognized status
439 bool isRecognized() const;
445 bool isWacSigned() const;
451 bool isDistributorSigned() const;
455 * @return trusted status
457 bool isTrusted() const;
461 * @return is WAC test widget
463 bool isTestWidget() 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 returns list filed with Common Name entries from certificate.
488 * @return Common Name of Distribuotor End Entity certificate.
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 WidgetCertificateCNList getKeyCommonNameList(
494 WidgetCertificateData::Owner owner,
495 WidgetCertificateData::Type type) const;
498 * given a certificate owner (author / distributor) and type of certificate
500 * function returns list of matching fingerprints
502 FingerPrintList getKeyFingerprints(
503 WidgetCertificateData::Owner owner,
504 WidgetCertificateData::Type type) const;
507 * This method gets certificate data list for a widget from database.
509 WidgetCertificateDataList getCertificateDataList() const;
512 * This method returns a list of widget features.
515 * @see FreeFeatureList()
516 * @return list of widget features, type of list element is structure
518 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
519 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
522 DbWidgetFeatureSet getFeaturesList() const;
524 static WidgetParamMap getFeatureParams(int widgetFeatureId);
526 * This method checks whether widget has specified feature.
528 * @return true if has, false if has not
529 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
531 bool hasFeature(const std::string& featureName) const;
534 * This method gets host list that widget can connect to.
536 * @return See above comment
537 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
539 HostList getAccessHostList() const;
542 * This method gets widget's access on network: true or false.
544 * @return true: widget can access network; false: widget can not access
546 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
547 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
550 bool getAccessNetworkMode() const;
553 * This method gets if widget needs webkit plugins enabled
555 * @return true: widget needs webkit plugins enabled
556 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
557 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
560 bool getWebkitPluginsRequired() const;
563 * This method returns a list of all the installed widgets' app id.
565 * @return list of installed widgets' app id.
566 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
567 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
570 static DbWidgetHandleList getHandleList();
573 * This method returns list of pkgname of installed packages
574 * @return list of pkgname of installed packages
576 static WidgetPkgNameList getPkgnameList();
577 static WidgetPkgNameList_TEMPORARY_API getPkgnameList_TEMPORARY_API();
580 * This method returns a list of all the installed widgets.
582 * @return list of installed widgets.
583 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
584 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
587 static DbWidgetDAOReadOnlyList getWidgetList();
590 * This method removes a widget's information from EmDB.
592 * @see RegisterWidget()
593 * @param[in] widgetHandle widget's app id
594 * @return true if succeed, false if fail.
596 static void unregisterWidget(DbWidgetHandle widgetHandle);
599 * This method gets author's infomation of a widget which is parsed from
600 * configiration document.
602 * @see WidgetAuthorInfo
603 * @param[out] pAuthorInfo
604 * @return true if succeed, false if fail.
606 WidgetAuthorInfo getAuthorInfo() const;
609 * This method gets author's name of a widget which is parsed from
610 * configiration document.
612 * @param[out] pAuthorInfo
613 * @return author's name.
614 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
615 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
618 DPL::OptionalString getAuthorName() const;
621 * This method gets author's email of a widget which is parsed from
622 * configiration document.
624 * @param[out] pAuthorInfo
625 * @return author's email.
626 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
627 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
630 DPL::OptionalString getAuthorEmail() const;
633 * This method gets author's email of a widget which is parsed from
634 * configiration document.
636 * @param[out] pAuthorInfo
637 * @return author's email.
638 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
639 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
642 DPL::OptionalString getAuthorHref() const;
645 * This method returns minimum version of WAC that WRT has to be compliant
646 * to to run this widget
648 * @return Minimum version
649 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
650 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
653 DPL::OptionalString getMinimumWacVersion() const;
655 /* This method get widget' share href.
657 * @return widget's share href
659 std::string getShareHref() const;
662 * This method get widget installed time
664 * @return time_t : return widget's install time
666 time_t getInstallTime() const;
669 * This method gets widget base folder.
671 * @return widget base folder.
672 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
673 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
676 std::string getBaseFolder() const;
678 /* This method gets the parameter list for resource.
680 ResourceAttributeList getResourceAttribute(
681 const std::string &resourceId) const;
683 /* This method checks read only flag for given property
685 DPL::OptionalInt checkPropertyReadFlag(
686 const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
688 /* This method gets widget property key list
690 PropertyDAOReadOnly::WidgetPropertyKeyList getPropertyKeyList() const;
692 /* This method gets widget property list
694 PropertyDAOReadOnly::WidgetPreferenceList getPropertyList() const;
696 /* This method get widget property value
698 PropertyDAOReadOnly::WidgetPropertyValue getPropertyValue(
699 const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
701 LanguageTagList getLanguageTags() const;
702 LanguageTagList getIconLanguageTags() const;
706 WidgetLocalizedInfo getLocalizedInfo(const DPL::String& languageTag) const;
707 std::string getCookieDatabasePath() const;
709 std::string getPrivateLocalStoragePath() const;
711 bool getBackSupported() const;
713 static bool isWidgetInstalled(DbWidgetHandle handle);
714 static bool isWidgetInstalled(const WidgetPkgName & pkgName);
716 /* This method get path of the splash image.
718 * @return path of the widget's splash image
720 DPL::OptionalString getSplashImgSrc() const;
722 ExternalLocationList getWidgetExternalLocations() const;
725 * Default value is required to keep compatibility with
726 * wrt-installer and wrt.
728 CertificateChainList getWidgetCertificate(
729 CertificateSource source = SIGNATURE_DISTRIBUTOR) const;
731 void getWidgetSettings(WidgetSettings& outWidgetSettings) const;
734 * This method gets application service list that define AUL value
736 * @return See above comment
737 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
739 void getAppServiceList(
740 WidgetApplicationServiceList& outAppServiceList) const;
743 * This method returns the type of the package.
745 * @return PackagingType
746 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
747 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
750 PackagingType getPackagingType() const;
752 void getEncryptedFileList(EncryptedFileList& filesList) const;
755 * This method returns widget's background page filename.
757 * @return Name of file containing background page
759 DPL::OptionalString getBackgroundPage() const;
762 * @brief generateTizenId generates new tizen id
764 * If widget do not supplies it's own tizen id, this method can be used,
765 * although it should be removed in future.
767 * @return new tizen id
769 static WidgetPkgName generateTizenId();
772 * @brief This method return each value for security setting
774 * @return SettingsType
775 * SETTINGS_TYPE_UNKNOWN : unknow value
776 * SETTINGS_TYPE_ON : enable
777 * SETTINGS_TYPE_ALWAYS_ASK : ask by popup
778 * SETTINGS_TYPE_OFF : disable
780 SettingsType getSecurityPopupUsage() const;
781 SettingsType getGeolocationUsage() const;
782 SettingsType getWebNotificationUsage() const;
783 SettingsType getWebDatabaseUsage() const;
784 SettingsType getFileSystemUsage() const;
787 * This method returns widget's installed path
789 * @return path of widget installed
791 DPL::OptionalString getWidgetInstalledPath() const;
796 #endif // _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_