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;
176 EncryptedFileList encryptedFiles;
179 typedef std::list<std::string> CertificateChainList;
183 virtual ~IWacSecurity();
185 virtual const WidgetCertificateDataList& getCertificateList() const = 0;
187 virtual bool isRecognized() const = 0;
189 virtual bool isDistributorSigned() const = 0;
191 virtual bool isWacSigned() const = 0;
193 virtual void getCertificateChainList(CertificateChainList& list) const = 0;
198 * Structure to hold the information of widget's author.
200 struct WidgetAuthorInfo
202 DPL::OptionalString name;
203 DPL::OptionalString email;
204 DPL::OptionalString href;
208 * Widget update policy
210 enum WidgetUpdatePolicy
212 WIDGET_UPDATE_MONTHLY = 0, //< monthly update
213 WIDGET_UPDATE_WEEKLY, //< weekly update
214 WIDGET_UPDATE_DAILY, //< daily update
215 WIDGET_UPDATE_STARTUP, //< update when cell phone boots
216 WIDGET_UPDATE_NEVER //< never update
219 typedef std::list <std::string> WidgetCertificateCNList;
220 typedef std::list<DPL::String> LanguageTagList;
221 typedef std::list<std::string> HostList;
222 typedef std::list<std::string> FingerPrintList;
223 typedef std::list<std::string> ResourceAttributeList;
225 class WidgetDAOReadOnly
229 * WidgetDAO Exception classes
234 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
235 DECLARE_EXCEPTION_TYPE(Base, DatabaseError)
236 DECLARE_EXCEPTION_TYPE(Base, ReadOnlyProperty)
237 DECLARE_EXCEPTION_TYPE(Base, GUIDisNull)
238 DECLARE_EXCEPTION_TYPE(Base, UnexpectedEmptyResult)
239 DECLARE_EXCEPTION_TYPE(Base, WidgetNotExist)
240 DECLARE_EXCEPTION_TYPE(Base, AlreadyRegistered)
244 DbWidgetHandle m_widgetHandle;
247 struct WidgetLocalizedIconRow
251 DPL::String widgetLocale;
253 typedef std::list<WidgetLocalizedIconRow> WidgetLocalizedIconList;
260 DPL::OptionalInt iconWidth;
261 DPL::OptionalInt iconHeight;
263 typedef std::list<WidgetIconRow> WidgetIconList;
265 struct WidgetStartFileRow
271 typedef std::list<WidgetStartFileRow> WidgetStartFileList;
273 struct WidgetLocalizedStartFileRow
277 DPL::String widgetLocale;
279 DPL::String encoding;
281 typedef std::list<WidgetLocalizedStartFileRow> LocalizedStartFileList;
285 * This is a constructor.
287 * @param[in] widgetHandle application id of widget.
289 WidgetDAOReadOnly(DbWidgetHandle widgetHandle);
290 WidgetDAOReadOnly(DPL::OptionalString widgetGUID);
295 virtual ~WidgetDAOReadOnly();
298 * This method returns widget handle(m_widgetHandle).
300 * @return widget handle(m_widgetHandle).
301 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
302 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in DB table.
304 DbWidgetHandle getHandle() const;
305 static DbWidgetHandle getHandle(const WidgetGUID GUID);
306 static DbWidgetHandle getHandle(const DPL::String pkgName);
309 * This method returns the root directory of widget resource.
311 * @return path name of root directory.
312 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
313 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
316 DPL::String getPath() const;
318 DPL::String getFullPath() const;
321 * This method returns the preferred size of the widget,
322 * including width and height.
325 * @return An structure type variable to hold widget's size.
326 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
327 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
330 DbWidgetSize getPreferredSize() const;
333 * This method returns the type of the widget.
336 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
337 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
340 WidgetType getWidgetType() const;
343 * This method returns the id of the widget.
346 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
347 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
350 WidgetGUID getGUID() const;
353 * This method returns the Package name of the widget.
356 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
357 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in DB table.
359 DPL::OptionalString getPkgname() const;
362 * This method returns the defaultlocale for the widget.
364 * @return defaultlocale
365 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
366 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
369 DPL::OptionalString getDefaultlocale() const;
372 * This method returns list of localized icons files;
374 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
375 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
378 WidgetLocalizedIconList getLocalizedIconList() const;
381 * This method returns list of icons files;
383 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
384 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
387 WidgetIconList getIconList() const;
390 * This method returns list of localized start files;
392 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
393 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
396 LocalizedStartFileList getLocalizedStartFileList() const;
399 * This method returns list of start files;
401 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
402 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
405 WidgetStartFileList getStartFileList() const;
408 * @param[out] outAccessInfoList list filled with access info structures
410 void getWidgetAccessInfo(WidgetAccessInfoList& outAccessInfoList) const;
414 * @return recognized status
416 bool isRecognized() const;
422 bool isWacSigned() const;
428 bool isDistributorSigned() const;
432 * @return trusted status
434 bool isTrusted() const;
438 * @return is WAC test widget
440 bool isTestWidget() const;
443 * This method returns window mode of widget.
445 * @return window modes of widget
446 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
447 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
450 WindowModeList getWindowModes() const;
453 * This method returns the version of the widget.
455 * @return version of widget
456 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
457 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
460 DPL::OptionalString getVersion() const;
463 * This method returns list filed with Common Name entries from certificate.
465 * @return Common Name of Distribuotor End Entity certificate.
466 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
467 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
470 WidgetCertificateCNList getKeyCommonNameList(
471 WidgetCertificateData::Owner owner,
472 WidgetCertificateData::Type type) const;
475 * given a certificate owner (author / distributor) and type of certificate
477 * function returns list of matching fingerprints
479 FingerPrintList getKeyFingerprints(
480 WidgetCertificateData::Owner owner,
481 WidgetCertificateData::Type type) const;
484 * This method gets certificate data list for a widget from database.
486 WidgetCertificateDataList getCertificateDataList() const;
489 * This method returns a list of widget features.
492 * @see FreeFeatureList()
493 * @return list of widget features, type of list element is structure
495 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
496 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
499 DbWidgetFeatureSet getFeaturesList() const;
501 static WidgetParamMap getFeatureParams(int widgetFeatureId);
503 * This method checks whether widget has specified feature.
505 * @return true if has, false if has not
506 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
508 bool hasFeature(const std::string& featureName) const;
511 * This method gets host list that widget can connect to.
513 * @return See above comment
514 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
516 HostList getAccessHostList() const;
519 * This method gets widget's access on network: true or false.
521 * @return true: widget can access network; false: widget can not access
523 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
524 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
527 bool getAccessNetworkMode() const;
530 * This method gets if widget needs webkit plugins enabled
532 * @return true: widget needs webkit plugins enabled
533 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
534 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
537 bool getWebkitPluginsRequired() const;
540 * This method returns a list of all the installed widgets.
542 * @return list of installed widgets' app id.
543 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
544 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
547 static DbWidgetHandleList getHandleList();
550 * This method removes a widget's information from EmDB.
552 * @see RegisterWidget()
553 * @param[in] widgetHandle widget's app id
554 * @return true if succeed, false if fail.
556 static void unregisterWidget(DbWidgetHandle widgetHandle);
559 * This method gets author's infomation of a widget which is parsed from
560 * configiration document.
562 * @see WidgetAuthorInfo
563 * @param[out] pAuthorInfo
564 * @return true if succeed, false if fail.
566 WidgetAuthorInfo getAuthorInfo() const;
569 * This method gets author's name of a widget which is parsed from
570 * configiration document.
572 * @param[out] pAuthorInfo
573 * @return author's name.
574 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
575 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
578 DPL::OptionalString getAuthorName() const;
581 * This method gets author's email of a widget which is parsed from
582 * configiration document.
584 * @param[out] pAuthorInfo
585 * @return author's email.
586 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
587 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
590 DPL::OptionalString getAuthorEmail() const;
593 * This method gets author's email of a widget which is parsed from
594 * configiration document.
596 * @param[out] pAuthorInfo
597 * @return author's email.
598 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
599 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
602 DPL::OptionalString getAuthorHref() const;
605 * This method returns minimum version of WAC that WRT has to be compliant
606 * to to run this widget
608 * @return Minimum version
609 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
610 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
613 DPL::OptionalString getMinimumWacVersion() const;
615 /* This method get widget' share href.
617 * @return widget's share href
619 std::string getShareHref() const;
622 * This method checks whether specified widget is a factory widget.
624 * @param[in] widgetHandle widget's app id
625 * @return true if yes, false if no.
627 bool isFactory() const;
630 * This method get widget installed time
632 * @return time_t : return widget's install time
634 time_t getInstallTime() const;
637 * This method gets widget base folder.
639 * @return widget base folder.
640 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
641 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
644 std::string getBaseFolder() const;
647 * This method gets deletable property of widget.
649 * @return true: can be deleted; false: can not be deleted
650 * @exception WRT_CONF_ERR_GCONF_FAILURE
651 * @exception WRT_CONF_ERR_EMDB_FAILURE
652 * @exception WRT_CONF_ERR_EMDB_NO_RECORD
654 bool isDeletable() const;
656 /* This method gets the parameter list for resource.
658 ResourceAttributeList getResourceAttribute(
659 const std::string &resourceId) const;
661 /* This method checks read only flag for given property
663 DPL::OptionalInt checkPropertyReadFlag(
664 const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
666 /* This method gets widget property key list
668 PropertyDAOReadOnly::WidgetPropertyKeyList getPropertyKeyList() const;
670 /* This method gets widget property list
672 PropertyDAOReadOnly::WidgetPreferenceList getPropertyList() const;
674 /* This method get widget property value
676 PropertyDAOReadOnly::WidgetPropertyValue getPropertyValue(
677 const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
679 LanguageTagList getLanguageTags() const;
680 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 CertificateChainList getWidgetCertificate() const;
700 void getWidgetSettings(WidgetSettings& outWidgetSettings) const;
703 * This method gets application service list that define AUL value
705 * @return See above comment
706 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
708 void getAppServiceList(
709 WidgetApplicationServiceList& outAppServiceList) const;
712 * This method returns the type of the package.
715 * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
716 * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
719 PkgType getPkgType() const;
721 void getEncryptedFileList(EncryptedFileList& filesList) const;
726 #endif // _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_