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 typedef std::list<DPL::String> StringList;
56 struct WidgetLocalizedInfo
58 DPL::OptionalString name;
59 DPL::OptionalString shortName;
60 DPL::OptionalString description;
61 DPL::OptionalString license;
62 DPL::OptionalString licenseHref;
67 * A structure to hold certificate fingerprints.
69 struct WidgetCertificateData
71 enum Owner { AUTHOR, DISTRIBUTOR, UNKNOWN };
72 enum Type { ROOT, ENDENTITY };
74 // type of signature: author/distributor
76 // indicates whether this is ca certificate
79 // chain id number: relative BASE, where BASE is signatureBASE.xml
81 // certificate fingerprint digested by md5
82 std::string strMD5Fingerprint;
83 // certificate fingerprint digestef by sha1
84 std::string strSHA1Fingerprint;
85 // Common name field in certificate
86 DPL::String strCommonName;
88 bool operator== (const WidgetCertificateData& certData) const {
89 return certData.chainId == chainId &&
90 certData.owner == owner &&
91 certData.strCommonName == strCommonName &&
92 certData.strMD5Fingerprint == strMD5Fingerprint &&
93 certData.strSHA1Fingerprint == strSHA1Fingerprint;
97 typedef std::list<WidgetCertificateData> WidgetCertificateDataList;
99 typedef DPL::String Locale;
100 typedef std::set<Locale> LocaleSet;
104 * A structure to hold widget's information needed to be registered.
105 * @see WidgetConfigurationInfo
107 struct WidgetRegisterInfo
109 struct LocalizedIcon : public ConfigParserData::Icon
111 LocalizedIcon(const ConfigParserData::Icon& icon,
112 const LocaleSet& _availableLocales) :
113 ConfigParserData::Icon(icon),
114 availableLocales(_availableLocales)
118 LocaleSet availableLocales;
121 struct StartFileProperties
123 DPL::String encoding;
127 typedef std::map<Locale,
128 StartFileProperties> StartFilePropertiesForLocalesMap;
129 struct LocalizedStartFile
132 StartFilePropertiesForLocalesMap propertiesForLocales;
135 typedef std::list<LocalizedIcon> LocalizedIconList;
136 typedef std::list<LocalizedStartFile> LocalizedStartFileList;
137 struct LocalizationData
139 LocalizedIconList icons;
140 LocalizedStartFileList startFiles;
152 WidgetRegisterInfo() :
153 type(APP_TYPE_UNKNOWN),
154 signatureType(SIGNATURE_TYPE_UNIDENTIFIED),
158 pType(PKG_TYPE_UNKNOWN)
163 DPL::OptionalString guid;
164 DPL::OptionalString version;
165 DPL::OptionalString minVersion;
166 std::string shareHref;
167 std::string baseFolder;
168 WidgetSignatureType signatureType;
171 ConfigParserData configInfo;
172 LocalizationData localizationData;
173 DPL::OptionalString pkgname;
174 time_t installedTime;
178 typedef std::list<std::string> CertificateChainList;
182 virtual ~IWacSecurity();
184 virtual const WidgetCertificateDataList& getCertificateList() const = 0;
186 virtual bool isRecognized() const = 0;
188 virtual bool isDistributorSigned() const = 0;
190 virtual bool isWacSigned() const = 0;
192 virtual void getCertificateChainList(CertificateChainList& list) const = 0;
197 * Structure to hold the information of widget's author.
199 struct WidgetAuthorInfo
201 DPL::OptionalString name;
202 DPL::OptionalString email;
203 DPL::OptionalString href;
207 * Widget update policy
209 enum WidgetUpdatePolicy
211 WIDGET_UPDATE_MONTHLY = 0, //< monthly update
212 WIDGET_UPDATE_WEEKLY, //< weekly update
213 WIDGET_UPDATE_DAILY, //< daily update
214 WIDGET_UPDATE_STARTUP, //< update when cell phone boots
215 WIDGET_UPDATE_NEVER //< never update
218 typedef std::list <std::string> WidgetCertificateCNList;
219 typedef std::list<DPL::String> LanguageTagList;
220 typedef std::list<std::string> HostList;
221 typedef std::list<std::string> FingerPrintList;
222 typedef std::list<std::string> ResourceAttributeList;
224 class WidgetDAOReadOnly
228 * WidgetDAO Exception classes
233 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
234 DECLARE_EXCEPTION_TYPE(Base, DatabaseError)
235 DECLARE_EXCEPTION_TYPE(Base, ReadOnlyProperty)
236 DECLARE_EXCEPTION_TYPE(Base, GUIDisNull)
237 DECLARE_EXCEPTION_TYPE(Base, UnexpectedEmptyResult)
238 DECLARE_EXCEPTION_TYPE(Base, WidgetNotExist)
239 DECLARE_EXCEPTION_TYPE(Base, AlreadyRegistered)
243 DbWidgetHandle m_widgetHandle;
246 struct WidgetLocalizedIconRow
250 DPL::String widgetLocale;
252 typedef std::list<WidgetLocalizedIconRow> WidgetLocalizedIconList;
259 DPL::OptionalInt iconWidth;
260 DPL::OptionalInt iconHeight;
262 typedef std::list<WidgetIconRow> WidgetIconList;
264 struct WidgetStartFileRow
270 typedef std::list<WidgetStartFileRow> WidgetStartFileList;
272 struct WidgetLocalizedStartFileRow
276 DPL::String widgetLocale;
278 DPL::String encoding;
280 typedef std::list<WidgetLocalizedStartFileRow> LocalizedStartFileList;
284 * This is a constructor.
286 * @param[in] widgetHandle application id of widget.
288 WidgetDAOReadOnly(DbWidgetHandle widgetHandle);
289 WidgetDAOReadOnly(DPL::OptionalString widgetGUID);
294 virtual ~WidgetDAOReadOnly();
297 * This method returns widget handle(m_widgetHandle).
299 * @return widget handle(m_widgetHandle).
300 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
301 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in DB table.
303 DbWidgetHandle getHandle() const;
304 static DbWidgetHandle getHandle(const WidgetGUID GUID);
305 static DbWidgetHandle getHandle(const DPL::String pkgName);
308 * This method returns the root directory of widget resource.
310 * @return path name of root directory.
311 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
312 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
315 DPL::String getPath() const;
317 DPL::String getFullPath() const;
320 * This method returns the preferred size of the widget,
321 * including width and height.
324 * @return An structure type variable to hold widget's size.
325 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
326 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
329 DbWidgetSize getPreferredSize() const;
332 * This method returns the type of the widget.
335 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
336 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
339 WidgetType getWidgetType() const;
342 * This method returns the id of the widget.
345 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
346 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
349 WidgetGUID getGUID() const;
352 * This method returns the Package name of the widget.
355 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
356 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in DB table.
358 DPL::OptionalString getPkgname() const;
361 * This method returns the defaultlocale for the widget.
363 * @return defaultlocale
364 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
365 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
368 DPL::OptionalString getDefaultlocale() const;
371 * This method returns list of localized icons files;
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 WidgetLocalizedIconList getLocalizedIconList() const;
380 * This method returns list of 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 WidgetIconList getIconList() const;
389 * This method returns list of localized start 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 LocalizedStartFileList getLocalizedStartFileList() const;
398 * This method returns list of 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 WidgetStartFileList getStartFileList() const;
407 * @param[out] outAccessInfoList list filled with access info structures
409 void getWidgetAccessInfo(WidgetAccessInfoList& outAccessInfoList) const;
413 * @return recognized status
415 bool isRecognized() const;
421 bool isWacSigned() const;
427 bool isDistributorSigned() const;
431 * @return trusted status
433 bool isTrusted() const;
437 * @return is WAC test widget
439 bool isTestWidget() const;
442 * This method returns window mode of widget.
444 * @return window modes of widget
445 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
446 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
449 WindowModeList getWindowModes() const;
452 * This method returns the version of the widget.
454 * @return version of widget
455 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
456 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
459 DPL::OptionalString getVersion() const;
462 * This method returns list filed with Common Name entries from certificate.
464 * @return Common Name of Distribuotor End Entity certificate.
465 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
466 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
469 WidgetCertificateCNList getKeyCommonNameList(
470 WidgetCertificateData::Owner owner,
471 WidgetCertificateData::Type type) const;
474 * given a certificate owner (author / distributor) and type of certificate
476 * function returns list of matching fingerprints
478 FingerPrintList getKeyFingerprints(
479 WidgetCertificateData::Owner owner,
480 WidgetCertificateData::Type type) const;
483 * This method gets certificate data list for a widget from database.
485 WidgetCertificateDataList getCertificateDataList() const;
488 * This method returns a list of widget features.
491 * @see FreeFeatureList()
492 * @return list of widget features, type of list element is structure
494 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
495 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
498 DbWidgetFeatureSet getFeaturesList() const;
500 static WidgetParamMap getFeatureParams(int widgetFeatureId);
502 * This method checks whether widget has specified feature.
504 * @return true if has, false if has not
505 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
507 bool hasFeature(const std::string& featureName) const;
510 * This method gets host list that widget can connect to.
512 * @return See above comment
513 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
515 HostList getAccessHostList() const;
518 * This method gets widget's access on network: true or false.
520 * @return true: widget can access network; false: widget can not access
522 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
523 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
526 bool getAccessNetworkMode() const;
529 * This method gets if widget needs webkit plugins enabled
531 * @return true: widget needs webkit plugins enabled
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 bool getWebkitPluginsRequired() const;
539 * This method returns a list of all the installed widgets.
541 * @return list of installed widgets' app id.
542 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
543 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
546 static DbWidgetHandleList getHandleList();
549 * This method removes a widget's information from EmDB.
551 * @see RegisterWidget()
552 * @param[in] widgetHandle widget's app id
553 * @return true if succeed, false if fail.
555 static void unregisterWidget(DbWidgetHandle widgetHandle);
558 * This method gets author's infomation of a widget which is parsed from
559 * configiration document.
561 * @see WidgetAuthorInfo
562 * @param[out] pAuthorInfo
563 * @return true if succeed, false if fail.
565 WidgetAuthorInfo getAuthorInfo() const;
568 * This method gets author's name of a widget which is parsed from
569 * configiration document.
571 * @param[out] pAuthorInfo
572 * @return author's name.
573 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
574 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
577 DPL::OptionalString getAuthorName() const;
580 * This method gets author's email of a widget which is parsed from
581 * configiration document.
583 * @param[out] pAuthorInfo
584 * @return author's email.
585 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
586 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
589 DPL::OptionalString getAuthorEmail() const;
592 * This method gets author's email of a widget which is parsed from
593 * configiration document.
595 * @param[out] pAuthorInfo
596 * @return author's email.
597 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
598 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
601 DPL::OptionalString getAuthorHref() const;
604 * This method returns minimum version of WAC that WRT has to be compliant
605 * to to run this widget
607 * @return Minimum version
608 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
609 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
612 DPL::OptionalString getMinimumWacVersion() const;
614 /* This method get widget' share href.
616 * @return widget's share href
618 std::string getShareHref() const;
621 * This method checks whether specified widget is a factory widget.
623 * @param[in] widgetHandle widget's app id
624 * @return true if yes, false if no.
626 bool isFactory() const;
629 * This method get widget installed time
631 * @return time_t : return widget's install time
633 time_t getInstallTime() const;
636 * This method gets widget base folder.
638 * @return widget base folder.
639 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
640 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
643 std::string getBaseFolder() const;
646 * This method gets deletable property of widget.
648 * @return true: can be deleted; false: can not be deleted
649 * @exception WRT_CONF_ERR_GCONF_FAILURE
650 * @exception WRT_CONF_ERR_EMDB_FAILURE
651 * @exception WRT_CONF_ERR_EMDB_NO_RECORD
653 bool isDeletable() const;
655 /* This method gets the parameter list for resource.
657 ResourceAttributeList getResourceAttribute(
658 const std::string &resourceId) const;
660 /* This method checks read only flag for given property
662 DPL::OptionalInt checkPropertyReadFlag(
663 const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
665 /* This method gets widget property key list
667 PropertyDAOReadOnly::WidgetPropertyKeyList getPropertyKeyList() const;
669 /* This method gets widget property list
671 PropertyDAOReadOnly::WidgetPreferenceList getPropertyList() const;
673 /* This method get widget property value
675 PropertyDAOReadOnly::WidgetPropertyValue getPropertyValue(
676 const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
678 LanguageTagList getLanguageTags() const;
679 LanguageTagList getIconLanguageTags() const;
681 WidgetLocalizedInfo getLocalizedInfo(const DPL::String& languageTag) const;
682 std::string getCookieDatabasePath() const;
684 std::string getPrivateLocalStoragePath() const;
686 bool getBackSupported() const;
688 static bool isWidgetInstalled(DbWidgetHandle handle);
689 static bool isWidgetInstalled(DPL::String pkgName);
691 /* This method get path of the splash image.
693 * @return path of the widget's splash image
695 DPL::OptionalString getSplashImgSrc() const;
697 CertificateChainList getWidgetCertificate() const;
699 void getWidgetSettings(WidgetSettings& outWidgetSettings) const;
702 * This method gets application service list that define AUL value
704 * @return See above comment
705 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
707 void getAppServiceList(
708 WidgetApplicationServiceList& outAppServiceList) const;
711 * This method returns the type of the package.
714 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
715 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
718 PkgType getPkgType() const;
723 #endif // _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_