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 type(APP_TYPE_UNKNOWN),
160 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;
175 ConfigParserData configInfo;
176 LocalizationData localizationData;
177 DPL::OptionalString pkgname;
178 time_t installedTime;
180 EncryptedFileList encryptedFiles;
181 ExternalLocationList externalLocations;
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;
231 class WidgetDAOReadOnly
235 * WidgetDAO Exception classes
240 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
241 DECLARE_EXCEPTION_TYPE(Base, DatabaseError)
242 DECLARE_EXCEPTION_TYPE(Base, ReadOnlyProperty)
243 DECLARE_EXCEPTION_TYPE(Base, GUIDisNull)
244 DECLARE_EXCEPTION_TYPE(Base, UnexpectedEmptyResult)
245 DECLARE_EXCEPTION_TYPE(Base, WidgetNotExist)
246 DECLARE_EXCEPTION_TYPE(Base, AlreadyRegistered)
250 DbWidgetHandle m_widgetHandle;
253 struct WidgetLocalizedIconRow
257 DPL::String widgetLocale;
259 typedef std::list<WidgetLocalizedIconRow> WidgetLocalizedIconList;
266 DPL::OptionalInt iconWidth;
267 DPL::OptionalInt iconHeight;
269 typedef std::list<WidgetIconRow> WidgetIconList;
271 struct WidgetStartFileRow
277 typedef std::list<WidgetStartFileRow> WidgetStartFileList;
279 struct WidgetLocalizedStartFileRow
283 DPL::String widgetLocale;
285 DPL::String encoding;
287 typedef std::list<WidgetLocalizedStartFileRow> LocalizedStartFileList;
290 * This is a constructor.
292 * @param[in] widgetHandle application id of widget.
294 WidgetDAOReadOnly(DbWidgetHandle widgetHandle);
295 WidgetDAOReadOnly(DPL::OptionalString widgetGUID);
296 WidgetDAOReadOnly(DPL::String pkgName);
301 virtual ~WidgetDAOReadOnly();
304 * This method returns widget handle(m_widgetHandle).
306 * @return widget handle(m_widgetHandle).
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 DB table.
310 DbWidgetHandle getHandle() const;
311 static DbWidgetHandle getHandle(const WidgetGUID GUID);
312 static DbWidgetHandle getHandle(const DPL::String pkgName);
315 * This method returns the root directory of widget resource.
317 * @return path name of root directory.
318 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
319 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
322 DPL::String getPath() const;
324 DPL::String getFullPath() const;
327 * This method returns the preferred size of the widget,
328 * including width and height.
331 * @return An structure type variable to hold widget's size.
332 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
333 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
336 DbWidgetSize getPreferredSize() const;
339 * This method returns the type of the widget.
342 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
343 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
346 WidgetType getWidgetType() const;
349 * This method returns the id of the widget.
352 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
353 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
356 WidgetGUID getGUID() const;
359 * This method returns the Package name of the widget.
362 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
363 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in DB table.
365 DPL::OptionalString getPkgname() const;
368 * This method returns the defaultlocale for the widget.
370 * @return defaultlocale
371 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
372 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
375 DPL::OptionalString getDefaultlocale() const;
378 * This method returns list of localized icons files;
380 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
381 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
384 WidgetLocalizedIconList getLocalizedIconList() const;
387 * This method returns list of icons files;
389 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
390 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
393 WidgetIconList getIconList() const;
396 * This method returns list of localized start files;
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 LocalizedStartFileList getLocalizedStartFileList() const;
405 * This method returns list of start 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 WidgetStartFileList getStartFileList() const;
414 * @param[out] outAccessInfoList list filled with access info structures
416 void getWidgetAccessInfo(WidgetAccessInfoList& outAccessInfoList) const;
420 * @return recognized status
422 bool isRecognized() const;
428 bool isWacSigned() const;
434 bool isDistributorSigned() const;
438 * @return trusted status
440 bool isTrusted() const;
444 * @return is WAC test widget
446 bool isTestWidget() const;
449 * This method returns window mode of widget.
451 * @return window modes of widget
452 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
453 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
456 WindowModeList getWindowModes() const;
459 * This method returns the version of the widget.
461 * @return version of widget
462 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
463 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
466 DPL::OptionalString getVersion() const;
469 * This method returns list filed with Common Name entries from certificate.
471 * @return Common Name of Distribuotor End Entity certificate.
472 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
473 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
476 WidgetCertificateCNList getKeyCommonNameList(
477 WidgetCertificateData::Owner owner,
478 WidgetCertificateData::Type type) const;
481 * given a certificate owner (author / distributor) and type of certificate
483 * function returns list of matching fingerprints
485 FingerPrintList getKeyFingerprints(
486 WidgetCertificateData::Owner owner,
487 WidgetCertificateData::Type type) const;
490 * This method gets certificate data list for a widget from database.
492 WidgetCertificateDataList getCertificateDataList() const;
495 * This method returns a list of widget features.
498 * @see FreeFeatureList()
499 * @return list of widget features, type of list element is structure
501 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
502 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
505 DbWidgetFeatureSet getFeaturesList() const;
507 static WidgetParamMap getFeatureParams(int widgetFeatureId);
509 * This method checks whether widget has specified feature.
511 * @return true if has, false if has not
512 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
514 bool hasFeature(const std::string& featureName) const;
517 * This method gets host list that widget can connect to.
519 * @return See above comment
520 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
522 HostList getAccessHostList() const;
525 * This method gets widget's access on network: true or false.
527 * @return true: widget can access network; false: widget can not access
529 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
530 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
533 bool getAccessNetworkMode() const;
536 * This method gets if widget needs webkit plugins enabled
538 * @return true: widget needs webkit plugins enabled
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 bool getWebkitPluginsRequired() const;
546 * This method returns a list of all the installed widgets' app id.
548 * @return list of installed widgets' app id.
549 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
550 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
553 static DbWidgetHandleList getHandleList();
556 * This method returns a list of all the installed widgets.
558 * @return list of installed widgets.
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 static DbWidgetDAOReadOnlyList getWidgetList();
566 * This method removes a widget's information from EmDB.
568 * @see RegisterWidget()
569 * @param[in] widgetHandle widget's app id
570 * @return true if succeed, false if fail.
572 static void unregisterWidget(DbWidgetHandle widgetHandle);
575 * This method gets author's infomation of a widget which is parsed from
576 * configiration document.
578 * @see WidgetAuthorInfo
579 * @param[out] pAuthorInfo
580 * @return true if succeed, false if fail.
582 WidgetAuthorInfo getAuthorInfo() const;
585 * This method gets author's name of a widget which is parsed from
586 * configiration document.
588 * @param[out] pAuthorInfo
589 * @return author's name.
590 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
591 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
594 DPL::OptionalString getAuthorName() const;
597 * This method gets author's email of a widget which is parsed from
598 * configiration document.
600 * @param[out] pAuthorInfo
601 * @return author's email.
602 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
603 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
606 DPL::OptionalString getAuthorEmail() const;
609 * This method gets author's email of a widget which is parsed from
610 * configiration document.
612 * @param[out] pAuthorInfo
613 * @return author's email.
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 getAuthorHref() const;
621 * This method returns minimum version of WAC that WRT has to be compliant
622 * to to run this widget
624 * @return Minimum version
625 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
626 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
629 DPL::OptionalString getMinimumWacVersion() const;
631 /* This method get widget' share href.
633 * @return widget's share href
635 std::string getShareHref() const;
638 * This method get widget installed time
640 * @return time_t : return widget's install time
642 time_t getInstallTime() const;
645 * This method gets widget base folder.
647 * @return widget base folder.
648 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
649 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
652 std::string getBaseFolder() const;
654 /* This method gets the parameter list for resource.
656 ResourceAttributeList getResourceAttribute(
657 const std::string &resourceId) const;
659 /* This method checks read only flag for given property
661 DPL::OptionalInt checkPropertyReadFlag(
662 const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
664 /* This method gets widget property key list
666 PropertyDAOReadOnly::WidgetPropertyKeyList getPropertyKeyList() const;
668 /* This method gets widget property list
670 PropertyDAOReadOnly::WidgetPreferenceList getPropertyList() const;
672 /* This method get widget property value
674 PropertyDAOReadOnly::WidgetPropertyValue getPropertyValue(
675 const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
677 LanguageTagList getLanguageTags() const;
678 LanguageTagList getIconLanguageTags() const;
682 WidgetLocalizedInfo getLocalizedInfo(const DPL::String& languageTag) const;
683 std::string getCookieDatabasePath() const;
685 std::string getPrivateLocalStoragePath() const;
687 bool getBackSupported() const;
689 static bool isWidgetInstalled(DbWidgetHandle handle);
690 static bool isWidgetInstalled(DPL::String pkgName);
692 /* This method get path of the splash image.
694 * @return path of the widget's splash image
696 DPL::OptionalString getSplashImgSrc() const;
698 ExternalLocationList getWidgetExternalLocations() const;
701 * Default value is required to keep compatibility with
702 * wrt-installer and wrt.
704 CertificateChainList getWidgetCertificate(
705 CertificateSource source = SIGNATURE_DISTRIBUTOR) const;
707 void getWidgetSettings(WidgetSettings& outWidgetSettings) const;
710 * This method gets application service list that define AUL value
712 * @return See above comment
713 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
715 void getAppServiceList(
716 WidgetApplicationServiceList& outAppServiceList) const;
719 * This method returns the type of the package.
722 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
723 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
726 PkgType getPkgType() const;
728 void getEncryptedFileList(EncryptedFileList& filesList) const;
731 * This method returns widget's background page filename.
733 * @return Name of file containing background page
735 DPL::OptionalString getBackgroundPage() const;
740 #endif // _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_