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;
109 * A structure to hold widget's information needed to be registered.
110 * @see WidgetConfigurationInfo
112 struct WidgetRegisterInfo
114 struct LocalizedIcon : public ConfigParserData::Icon
116 LocalizedIcon(const ConfigParserData::Icon& icon,
117 const LocaleSet& _availableLocales) :
118 ConfigParserData::Icon(icon),
119 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 type(APP_TYPE_UNKNOWN),
159 signatureType(SIGNATURE_TYPE_UNIDENTIFIED),
163 pType(PKG_TYPE_UNKNOWN)
168 DPL::OptionalString guid;
169 DPL::OptionalString version;
170 DPL::OptionalString minVersion;
171 std::string shareHref;
172 std::string baseFolder;
173 WidgetSignatureType signatureType;
176 ConfigParserData configInfo;
177 LocalizationData localizationData;
178 DPL::OptionalString pkgname;
179 time_t installedTime;
181 EncryptedFileList encryptedFiles;
184 typedef std::list<std::string> CertificateChainList;
188 virtual ~IWacSecurity();
190 virtual const WidgetCertificateDataList& getCertificateList() const = 0;
192 virtual bool isRecognized() const = 0;
194 virtual bool isDistributorSigned() const = 0;
196 virtual bool isWacSigned() const = 0;
198 virtual void getCertificateChainList(CertificateChainList& list,
199 CertificateSource source) const = 0;
204 * Structure to hold the information of widget's author.
206 struct WidgetAuthorInfo
208 DPL::OptionalString name;
209 DPL::OptionalString email;
210 DPL::OptionalString href;
214 * Widget update policy
216 enum WidgetUpdatePolicy
218 WIDGET_UPDATE_MONTHLY = 0, //< monthly update
219 WIDGET_UPDATE_WEEKLY, //< weekly update
220 WIDGET_UPDATE_DAILY, //< daily update
221 WIDGET_UPDATE_STARTUP, //< update when cell phone boots
222 WIDGET_UPDATE_NEVER //< never update
225 typedef std::list <std::string> WidgetCertificateCNList;
226 typedef std::list<DPL::String> LanguageTagList;
227 typedef std::list<std::string> HostList;
228 typedef std::list<std::string> FingerPrintList;
229 typedef std::list<std::string> ResourceAttributeList;
230 typedef std::list<std::string> ExternalLocationList; //TODO: if there will be many files registered std::set is better
232 class WidgetDAOReadOnly
236 * WidgetDAO Exception classes
241 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
242 DECLARE_EXCEPTION_TYPE(Base, DatabaseError)
243 DECLARE_EXCEPTION_TYPE(Base, ReadOnlyProperty)
244 DECLARE_EXCEPTION_TYPE(Base, GUIDisNull)
245 DECLARE_EXCEPTION_TYPE(Base, UnexpectedEmptyResult)
246 DECLARE_EXCEPTION_TYPE(Base, WidgetNotExist)
247 DECLARE_EXCEPTION_TYPE(Base, AlreadyRegistered)
251 DbWidgetHandle m_widgetHandle;
254 struct WidgetLocalizedIconRow
258 DPL::String widgetLocale;
260 typedef std::list<WidgetLocalizedIconRow> WidgetLocalizedIconList;
267 DPL::OptionalInt iconWidth;
268 DPL::OptionalInt iconHeight;
270 typedef std::list<WidgetIconRow> WidgetIconList;
272 struct WidgetStartFileRow
278 typedef std::list<WidgetStartFileRow> WidgetStartFileList;
280 struct WidgetLocalizedStartFileRow
284 DPL::String widgetLocale;
286 DPL::String encoding;
288 typedef std::list<WidgetLocalizedStartFileRow> LocalizedStartFileList;
291 * This is a constructor.
293 * @param[in] widgetHandle application id of widget.
295 WidgetDAOReadOnly(DbWidgetHandle widgetHandle);
296 WidgetDAOReadOnly(DPL::OptionalString widgetGUID);
297 WidgetDAOReadOnly(DPL::String pkgName);
302 virtual ~WidgetDAOReadOnly();
305 * This method returns widget handle(m_widgetHandle).
307 * @return widget handle(m_widgetHandle).
308 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
309 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in DB table.
311 DbWidgetHandle getHandle() const;
312 static DbWidgetHandle getHandle(const WidgetGUID GUID);
313 static DbWidgetHandle getHandle(const DPL::String pkgName);
316 * This method returns the root directory of widget resource.
318 * @return path name of root directory.
319 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
320 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
323 DPL::String getPath() const;
325 DPL::String getFullPath() const;
328 * This method returns the preferred size of the widget,
329 * including width and height.
332 * @return An structure type variable to hold widget's size.
333 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
334 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
337 DbWidgetSize getPreferredSize() const;
340 * This method returns the type of the widget.
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 WidgetType getWidgetType() const;
350 * This method returns the id 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 records in
357 WidgetGUID getGUID() const;
360 * This method returns the Package name 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 DB table.
366 DPL::OptionalString getPkgname() const;
369 * This method returns the defaultlocale for the widget.
371 * @return defaultlocale
372 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
373 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
376 DPL::OptionalString getDefaultlocale() const;
379 * This method returns list of localized icons files;
381 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
382 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
385 WidgetLocalizedIconList getLocalizedIconList() const;
388 * This method returns list of icons files;
390 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
391 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
394 WidgetIconList getIconList() const;
397 * This method returns list of localized start files;
399 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
400 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
403 LocalizedStartFileList getLocalizedStartFileList() const;
406 * This method returns list of start files;
408 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
409 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
412 WidgetStartFileList getStartFileList() const;
415 * @param[out] outAccessInfoList list filled with access info structures
417 void getWidgetAccessInfo(WidgetAccessInfoList& outAccessInfoList) const;
421 * @return recognized status
423 bool isRecognized() const;
429 bool isWacSigned() const;
435 bool isDistributorSigned() const;
439 * @return trusted status
441 bool isTrusted() const;
445 * @return is WAC test widget
447 bool isTestWidget() const;
450 * This method returns window mode of widget.
452 * @return window modes of widget
453 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
454 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
457 WindowModeList getWindowModes() const;
460 * This method returns the version of the widget.
462 * @return version of widget
463 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
464 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
467 DPL::OptionalString getVersion() const;
470 * This method returns list filed with Common Name entries from certificate.
472 * @return Common Name of Distribuotor End Entity certificate.
473 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
474 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
477 WidgetCertificateCNList getKeyCommonNameList(
478 WidgetCertificateData::Owner owner,
479 WidgetCertificateData::Type type) const;
482 * given a certificate owner (author / distributor) and type of certificate
484 * function returns list of matching fingerprints
486 FingerPrintList getKeyFingerprints(
487 WidgetCertificateData::Owner owner,
488 WidgetCertificateData::Type type) const;
491 * This method gets certificate data list for a widget from database.
493 WidgetCertificateDataList getCertificateDataList() const;
496 * This method returns a list of widget features.
499 * @see FreeFeatureList()
500 * @return list of widget features, type of list element is structure
502 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
503 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
506 DbWidgetFeatureSet getFeaturesList() const;
508 static WidgetParamMap getFeatureParams(int widgetFeatureId);
510 * This method checks whether widget has specified feature.
512 * @return true if has, false if has not
513 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
515 bool hasFeature(const std::string& featureName) const;
518 * This method gets host list that widget can connect to.
520 * @return See above comment
521 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
523 HostList getAccessHostList() const;
526 * This method gets widget's access on network: true or false.
528 * @return true: widget can access network; false: widget can not access
530 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
531 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
534 bool getAccessNetworkMode() const;
537 * This method gets if widget needs webkit plugins enabled
539 * @return true: widget needs webkit plugins enabled
540 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
541 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
544 bool getWebkitPluginsRequired() const;
547 * This method returns a list of all the installed widgets' app id.
549 * @return list of installed widgets' app id.
550 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
551 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
554 static DbWidgetHandleList getHandleList();
557 * This method returns a list of all the installed widgets.
559 * @return list of installed widgets.
560 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
561 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
564 static DbWidgetDAOReadOnlyList getWidgetList();
567 * This method removes a widget's information from EmDB.
569 * @see RegisterWidget()
570 * @param[in] widgetHandle widget's app id
571 * @return true if succeed, false if fail.
573 static void unregisterWidget(DbWidgetHandle widgetHandle);
576 * This method gets author's infomation of a widget which is parsed from
577 * configiration document.
579 * @see WidgetAuthorInfo
580 * @param[out] pAuthorInfo
581 * @return true if succeed, false if fail.
583 WidgetAuthorInfo getAuthorInfo() const;
586 * This method gets author's name of a widget which is parsed from
587 * configiration document.
589 * @param[out] pAuthorInfo
590 * @return author's name.
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 DPL::OptionalString getAuthorName() const;
598 * This method gets author's email of a widget which is parsed from
599 * configiration document.
601 * @param[out] pAuthorInfo
602 * @return author's email.
603 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
604 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
607 DPL::OptionalString getAuthorEmail() const;
610 * This method gets author's email of a widget which is parsed from
611 * configiration document.
613 * @param[out] pAuthorInfo
614 * @return author's email.
615 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
616 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
619 DPL::OptionalString getAuthorHref() const;
622 * This method returns minimum version of WAC that WRT has to be compliant
623 * to to run this widget
625 * @return Minimum version
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 getMinimumWacVersion() const;
632 /* This method get widget' share href.
634 * @return widget's share href
636 std::string getShareHref() const;
639 * This method checks whether specified widget is a factory widget.
641 * @param[in] widgetHandle widget's app id
642 * @return true if yes, false if no.
644 bool isFactory() const;
647 * This method get widget installed time
649 * @return time_t : return widget's install time
651 time_t getInstallTime() const;
654 * This method gets widget base folder.
656 * @return widget base folder.
657 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
658 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
661 std::string getBaseFolder() const;
664 * This method gets deletable property of widget.
666 * @return true: can be deleted; false: can not be deleted
667 * @exception WRT_CONF_ERR_GCONF_FAILURE
668 * @exception WRT_CONF_ERR_EMDB_FAILURE
669 * @exception WRT_CONF_ERR_EMDB_NO_RECORD
671 bool isDeletable() const;
673 /* This method gets the parameter list for resource.
675 ResourceAttributeList getResourceAttribute(
676 const std::string &resourceId) const;
678 /* This method checks read only flag for given property
680 DPL::OptionalInt checkPropertyReadFlag(
681 const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
683 /* This method gets widget property key list
685 PropertyDAOReadOnly::WidgetPropertyKeyList getPropertyKeyList() const;
687 /* This method gets widget property list
689 PropertyDAOReadOnly::WidgetPreferenceList getPropertyList() const;
691 /* This method get widget property value
693 PropertyDAOReadOnly::WidgetPropertyValue getPropertyValue(
694 const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
696 LanguageTagList getLanguageTags() const;
697 LanguageTagList getIconLanguageTags() const;
701 WidgetLocalizedInfo getLocalizedInfo(const DPL::String& languageTag) const;
702 std::string getCookieDatabasePath() const;
704 std::string getPrivateLocalStoragePath() const;
706 bool getBackSupported() const;
708 static bool isWidgetInstalled(DbWidgetHandle handle);
709 static bool isWidgetInstalled(DPL::String pkgName);
711 /* This method get path of the splash image.
713 * @return path of the widget's splash image
715 DPL::OptionalString getSplashImgSrc() const;
717 ExternalLocationList getWidgetExternalLocations() const;
720 * Default value is required to keep compatibility with
721 * wrt-installer and wrt.
723 CertificateChainList getWidgetCertificate(
724 CertificateSource source = SIGNATURE_DISTRIBUTOR) const;
726 void getWidgetSettings(WidgetSettings& outWidgetSettings) const;
729 * This method gets application service list that define AUL value
731 * @return See above comment
732 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
734 void getAppServiceList(
735 WidgetApplicationServiceList& outAppServiceList) const;
738 * This method returns the type of the package.
741 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
742 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
745 PkgType getPkgType() const;
747 void getEncryptedFileList(EncryptedFileList& filesList) const;
750 * This method returns widget's background page filename.
752 * @return Name of file containing background page
754 DPL::OptionalString getBackgroundPage() const;
759 #endif // _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_