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);
287 WidgetDAOReadOnly(DPL::OptionalString widgetGUID);
292 virtual ~WidgetDAOReadOnly();
295 * This method returns widget handle(m_widgetHandle).
297 * @return widget handle(m_widgetHandle).
298 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
299 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in DB table.
301 DbWidgetHandle getHandle() const;
302 static DbWidgetHandle getHandle(const WidgetGUID GUID);
303 static DbWidgetHandle getHandle(const DPL::String pkgName);
306 * This method returns the root directory of widget resource.
308 * @return path name of root directory.
309 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
310 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
313 DPL::String getPath() const;
315 DPL::String getFullPath() const;
318 * This method returns the preferred size of the widget,
319 * including width and height.
322 * @return An structure type variable to hold widget's size.
323 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
324 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
327 DbWidgetSize getPreferredSize() const;
330 * This method returns the type of the widget.
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 WidgetType getWidgetType() const;
340 * This method returns the id 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 records in
347 WidgetGUID getGUID() const;
350 * This method returns the Package name 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 DB table.
356 DPL::OptionalString getPkgname() const;
359 * This method returns the defaultlocale for the widget.
361 * @return defaultlocale
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
366 DPL::OptionalString getDefaultlocale() const;
369 * This method returns list of localized icons files;
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 WidgetLocalizedIconList getLocalizedIconList() const;
378 * This method returns list of 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 WidgetIconList getIconList() const;
387 * This method returns list of localized start 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 LocalizedStartFileList getLocalizedStartFileList() const;
396 * This method returns list of 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 WidgetStartFileList getStartFileList() const;
405 * @param[out] outAccessInfoList list filled with access info structures
407 void getWidgetAccessInfo(WidgetAccessInfoList& outAccessInfoList) const;
411 * @return recognized status
413 bool isRecognized() const;
419 bool isWacSigned() const;
425 bool isDistributorSigned() const;
429 * @return trusted status
431 bool isTrusted() const;
435 * @return is WAC test widget
437 bool isTestWidget() const;
440 * This method returns window mode of widget.
442 * @return window modes of widget
443 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
444 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
447 WindowModeList getWindowModes() const;
450 * This method returns the version of the widget.
452 * @return version 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 DPL::OptionalString getVersion() const;
460 * This method returns list filed with Common Name entries from certificate.
462 * @return Common Name of Distribuotor End Entity certificate.
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 WidgetCertificateCNList getKeyCommonNameList(
468 WidgetCertificateData::Owner owner,
469 WidgetCertificateData::Type type) const;
472 * given a certificate owner (author / distributor) and type of certificate
474 * function returns list of matching fingerprints
476 FingerPrintList getKeyFingerprints(
477 WidgetCertificateData::Owner owner,
478 WidgetCertificateData::Type type) const;
481 * This method gets certificate data list for a widget from database.
483 WidgetCertificateDataList getCertificateDataList() const;
486 * This method returns a list of widget features.
489 * @see FreeFeatureList()
490 * @return list of widget features, type of list element is structure
492 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
493 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
496 DbWidgetFeatureSet getFeaturesList() const;
498 static WidgetParamMap getFeatureParams(int widgetFeatureId);
500 * This method checks whether widget has specified feature.
502 * @return true if has, false if has not
503 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
505 bool hasFeature(const std::string& featureName) const;
508 * This method gets host list that widget can connect to.
510 * @return See above comment
511 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
513 HostList getAccessHostList() const;
516 * This method gets widget's access on network: true or false.
518 * @return true: widget can access network; false: widget can not access
520 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
521 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
524 bool getAccessNetworkMode() const;
527 * This method gets if widget needs webkit plugins enabled
529 * @return true: widget needs webkit plugins enabled
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 getWebkitPluginsRequired() const;
537 * This method returns a list of all the installed widgets.
539 * @return list of installed widgets' app id.
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 static DbWidgetHandleList getHandleList();
547 * This method removes a widget's information from EmDB.
549 * @see RegisterWidget()
550 * @param[in] widgetHandle widget's app id
551 * @return true if succeed, false if fail.
553 static void unregisterWidget(DbWidgetHandle widgetHandle);
556 * This method gets author's infomation of a widget which is parsed from
557 * configiration document.
559 * @see WidgetAuthorInfo
560 * @param[out] pAuthorInfo
561 * @return true if succeed, false if fail.
563 WidgetAuthorInfo getAuthorInfo() const;
566 * This method gets author's name of a widget which is parsed from
567 * configiration document.
569 * @param[out] pAuthorInfo
570 * @return author's name.
571 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
572 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
575 DPL::OptionalString getAuthorName() const;
578 * This method gets author's email of a widget which is parsed from
579 * configiration document.
581 * @param[out] pAuthorInfo
582 * @return author's email.
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 DPL::OptionalString getAuthorEmail() const;
590 * This method gets author's email of a widget which is parsed from
591 * configiration document.
593 * @param[out] pAuthorInfo
594 * @return author's email.
595 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
596 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
599 DPL::OptionalString getAuthorHref() const;
602 * This method returns minimum version of WAC that WRT has to be compliant
603 * to to run this widget
605 * @return Minimum version
606 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
607 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
610 DPL::OptionalString getMinimumWacVersion() const;
612 /* This method get widget' share href.
614 * @return widget's share href
616 std::string getShareHref() const;
619 * This method checks whether specified widget is a factory widget.
621 * @param[in] widgetHandle widget's app id
622 * @return true if yes, false if no.
624 bool isFactory() const;
627 * This method get widget installed time
629 * @return time_t : return widget's install time
631 time_t getInstallTime() const;
634 * This method gets widget base folder.
636 * @return widget base folder.
637 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
638 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
641 std::string getBaseFolder() const;
644 * This method gets deletable property of widget.
646 * @return true: can be deleted; false: can not be deleted
647 * @exception WRT_CONF_ERR_GCONF_FAILURE
648 * @exception WRT_CONF_ERR_EMDB_FAILURE
649 * @exception WRT_CONF_ERR_EMDB_NO_RECORD
651 bool isDeletable() const;
653 /* This method gets the parameter list for resource.
655 ResourceAttributeList getResourceAttribute(
656 const std::string &resourceId) const;
658 /* This method checks read only flag for given property
660 DPL::OptionalInt checkPropertyReadFlag(
661 const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
663 /* This method gets widget property key list
665 PropertyDAOReadOnly::WidgetPropertyKeyList getPropertyKeyList() const;
667 /* This method gets widget property list
669 PropertyDAOReadOnly::WidgetPreferenceList getPropertyList() const;
671 /* This method get widget property value
673 PropertyDAOReadOnly::WidgetPropertyValue getPropertyValue(
674 const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
676 LanguageTagList getLanguageTags() const;
677 LanguageTagList getIconLanguageTags() const;
679 WidgetLocalizedInfo getLocalizedInfo(const DPL::String& languageTag) const;
680 std::string getCookieDatabasePath() const;
682 std::string getPrivateLocalStoragePath() const;
684 bool getBackSupported() const;
686 static bool isWidgetInstalled(DbWidgetHandle handle);
687 static bool isWidgetInstalled(DPL::String pkgName);
689 CertificateChainList getWidgetCertificate() const;
691 void getWidgetSettings(WidgetSettings& outWidgetSettings) const;
694 * This method gets application service list that define AUL value
696 * @return See above comment
697 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
699 void getAppServiceList(
700 WidgetApplicationServiceList& outAppServiceList) const;
705 #endif // _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_