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),
162 DPL::OptionalString guid;
163 DPL::OptionalString version;
164 DPL::OptionalString minVersion;
165 std::string shareHref;
166 std::string baseFolder;
167 WidgetSignatureType signatureType;
170 ConfigParserData configInfo;
171 LocalizationData localizationData;
172 DPL::OptionalString pkgname;
173 time_t installedTime;
176 typedef std::list<std::string> CertificateChainList;
180 virtual ~IWacSecurity();
182 virtual const WidgetCertificateDataList& getCertificateList() const = 0;
184 virtual bool isRecognized() const = 0;
186 virtual bool isDistributorSigned() const = 0;
188 virtual bool isWacSigned() const = 0;
190 virtual void getCertificateChainList(CertificateChainList& list) const = 0;
195 * Structure to hold the information of widget's author.
197 struct WidgetAuthorInfo
199 DPL::OptionalString name;
200 DPL::OptionalString email;
201 DPL::OptionalString href;
205 * Widget update policy
207 enum WidgetUpdatePolicy
209 WIDGET_UPDATE_MONTHLY = 0, //< monthly update
210 WIDGET_UPDATE_WEEKLY, //< weekly update
211 WIDGET_UPDATE_DAILY, //< daily update
212 WIDGET_UPDATE_STARTUP, //< update when cell phone boots
213 WIDGET_UPDATE_NEVER //< never update
216 typedef std::list <std::string> WidgetCertificateCNList;
217 typedef std::list<DPL::String> LanguageTagList;
218 typedef std::list<std::string> HostList;
219 typedef std::list<std::string> FingerPrintList;
220 typedef std::list<std::string> ResourceAttributeList;
222 class WidgetDAOReadOnly
226 * WidgetDAO Exception classes
231 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
232 DECLARE_EXCEPTION_TYPE(Base, DatabaseError)
233 DECLARE_EXCEPTION_TYPE(Base, ReadOnlyProperty)
234 DECLARE_EXCEPTION_TYPE(Base, GUIDisNull)
235 DECLARE_EXCEPTION_TYPE(Base, UnexpectedEmptyResult)
236 DECLARE_EXCEPTION_TYPE(Base, WidgetNotExist)
237 DECLARE_EXCEPTION_TYPE(Base, AlreadyRegistered)
241 DbWidgetHandle m_widgetHandle;
244 struct WidgetLocalizedIconRow
248 DPL::String widgetLocale;
250 typedef std::list<WidgetLocalizedIconRow> WidgetLocalizedIconList;
257 DPL::OptionalInt iconWidth;
258 DPL::OptionalInt iconHeight;
260 typedef std::list<WidgetIconRow> WidgetIconList;
262 struct WidgetStartFileRow
268 typedef std::list<WidgetStartFileRow> WidgetStartFileList;
270 struct WidgetLocalizedStartFileRow
274 DPL::String widgetLocale;
276 DPL::String encoding;
278 typedef std::list<WidgetLocalizedStartFileRow> LocalizedStartFileList;
282 * This is a constructor.
284 * @param[in] widgetHandle application id of widget.
286 WidgetDAOReadOnly(DbWidgetHandle widgetHandle);
291 virtual ~WidgetDAOReadOnly();
294 * This method returns widget handle(m_widgetHandle).
296 * @return widget handle(m_widgetHandle).
297 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
298 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in DB table.
300 DbWidgetHandle getHandle() const;
301 static DbWidgetHandle getHandle(const WidgetGUID GUID);
302 static DbWidgetHandle getHandle(const DPL::String pkgName);
305 * This method returns the root directory of widget resource.
307 * @return path name of root directory.
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
312 DPL::String getPath() const;
314 DPL::String getFullPath() const;
317 * This method returns the preferred size of the widget,
318 * including width and height.
321 * @return An structure type variable to hold widget's size.
322 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
323 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
326 DbWidgetSize getPreferredSize() const;
329 * This method returns the type of the widget.
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 WidgetType getWidgetType() const;
339 * This method returns the id 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 records in
346 WidgetGUID getGUID() const;
349 * This method returns the Package name 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 DB table.
355 DPL::OptionalString getPkgname() const;
358 * This method returns the defaultlocale for the widget.
360 * @return defaultlocale
361 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
362 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
365 DPL::OptionalString getDefaultlocale() const;
368 * This method returns list of localized icons files;
370 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
371 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
374 WidgetLocalizedIconList getLocalizedIconList() const;
377 * This method returns list of icons files;
379 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
380 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
383 WidgetIconList getIconList() const;
386 * This method returns list of localized start files;
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 LocalizedStartFileList getLocalizedStartFileList() const;
395 * This method returns list of start 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 WidgetStartFileList getStartFileList() const;
404 * @param[out] outAccessInfoList list filled with access info structures
406 void getWidgetAccessInfo(WidgetAccessInfoList& outAccessInfoList) const;
410 * @return recognized status
412 bool isRecognized() const;
418 bool isWacSigned() const;
424 bool isDistributorSigned() const;
428 * @return trusted status
430 bool isTrusted() const;
434 * @return is WAC test widget
436 bool isTestWidget() const;
439 * This method returns window mode of widget.
441 * @return window modes of widget
442 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
443 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
446 WindowModeList getWindowModes() const;
449 * This method returns the version of the widget.
451 * @return version 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 DPL::OptionalString getVersion() const;
459 * This method returns list filed with Common Name entries from certificate.
461 * @return Common Name of Distribuotor End Entity certificate.
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 WidgetCertificateCNList getKeyCommonNameList(
467 WidgetCertificateData::Owner owner,
468 WidgetCertificateData::Type type) const;
471 * given a certificate owner (author / distributor) and type of certificate
473 * function returns list of matching fingerprints
475 FingerPrintList getKeyFingerprints(
476 WidgetCertificateData::Owner owner,
477 WidgetCertificateData::Type type) const;
480 * This method gets certificate data list for a widget from database.
482 WidgetCertificateDataList getCertificateDataList() const;
485 * This method returns a list of widget features.
488 * @see FreeFeatureList()
489 * @return list of widget features, type of list element is structure
491 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
492 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
495 DbWidgetFeatureSet getFeaturesList() const;
497 static WidgetParamMap getFeatureParams(int widgetFeatureId);
499 * This method checks whether widget has specified feature.
501 * @return true if has, false if has not
502 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
504 bool hasFeature(const std::string& featureName) const;
507 * This method gets host list that widget can connect to.
509 * @return See above comment
510 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
512 HostList getAccessHostList() const;
515 * This method gets widget's access on network: true or false.
517 * @return true: widget can access network; false: widget can not access
519 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
520 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
523 bool getAccessNetworkMode() const;
526 * This method gets if widget needs webkit plugins enabled
528 * @return true: widget needs webkit plugins enabled
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 getWebkitPluginsRequired() const;
536 * This method returns a list of all the installed widgets.
538 * @return list of installed widgets' app id.
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 static DbWidgetHandleList getHandleList();
546 * This method removes a widget's information from EmDB.
548 * @see RegisterWidget()
549 * @param[in] widgetHandle widget's app id
550 * @return true if succeed, false if fail.
552 static void unregisterWidget(DbWidgetHandle widgetHandle);
555 * This method gets author's infomation of a widget which is parsed from
556 * configiration document.
558 * @see WidgetAuthorInfo
559 * @param[out] pAuthorInfo
560 * @return true if succeed, false if fail.
562 WidgetAuthorInfo getAuthorInfo() const;
565 * This method gets author's name of a widget which is parsed from
566 * configiration document.
568 * @param[out] pAuthorInfo
569 * @return author's name.
570 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
571 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
574 DPL::OptionalString getAuthorName() const;
577 * This method gets author's email of a widget which is parsed from
578 * configiration document.
580 * @param[out] pAuthorInfo
581 * @return author's email.
582 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
583 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
586 DPL::OptionalString getAuthorEmail() const;
589 * This method gets author's email of a widget which is parsed from
590 * configiration document.
592 * @param[out] pAuthorInfo
593 * @return author's email.
594 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
595 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
598 DPL::OptionalString getAuthorHref() const;
601 * This method returns minimum version of WAC that WRT has to be compliant
602 * to to run this widget
604 * @return Minimum version
605 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
606 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
609 DPL::OptionalString getMinimumWacVersion() const;
611 /* This method get widget' share href.
613 * @return widget's share href
615 std::string getShareHref() const;
618 * This method checks whether specified widget is a factory widget.
620 * @param[in] widgetHandle widget's app id
621 * @return true if yes, false if no.
623 bool isFactory() const;
626 * This method get widget installed time
628 * @return time_t : return widget's install time
630 time_t getInstallTime() const;
633 * This method gets widget base folder.
635 * @return widget base folder.
636 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
637 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
640 std::string getBaseFolder() const;
643 * This method gets deletable property of widget.
645 * @return true: can be deleted; false: can not be deleted
646 * @exception WRT_CONF_ERR_GCONF_FAILURE
647 * @exception WRT_CONF_ERR_EMDB_FAILURE
648 * @exception WRT_CONF_ERR_EMDB_NO_RECORD
650 bool isDeletable() const;
652 /* This method gets the parameter list for resource.
654 ResourceAttributeList getResourceAttribute(
655 const std::string &resourceId) const;
657 /* This method checks read only flag for given property
659 DPL::OptionalInt checkPropertyReadFlag(
660 const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
662 /* This method gets widget property key list
664 PropertyDAOReadOnly::WidgetPropertyKeyList getPropertyKeyList() const;
666 /* This method gets widget property list
668 PropertyDAOReadOnly::WidgetPreferenceList getPropertyList() const;
670 /* This method get widget property value
672 PropertyDAOReadOnly::WidgetPropertyValue getPropertyValue(
673 const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
675 LanguageTagList getLanguageTags() const;
676 LanguageTagList getIconLanguageTags() const;
678 WidgetLocalizedInfo getLocalizedInfo(const DPL::String& languageTag) const;
679 std::string getCookieDatabasePath() const;
681 std::string getPrivateLocalStoragePath() const;
683 bool getBackSupported() const;
685 static bool isWidgetInstalled(DbWidgetHandle handle);
686 static bool isWidgetInstalled(DPL::String pkgName);
688 CertificateChainList getWidgetCertificate() const;
690 void getWidgetSettings(WidgetSettings& outWidgetSettings) const;
693 * This method gets application service list that define AUL value
695 * @return See above comment
696 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
698 void getAppServiceList(
699 WidgetApplicationServiceList& outAppServiceList) const;
704 #endif // _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_