tizen 2.4 release
[framework/web/wrt-commons.git] / modules / widget_dao / include / dpl / wrt-dao-ro / widget_register_types.h
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 /**
17  * @file    widget_register_types.h
18  * @author  Tomasz Iwanek (t.iwanek@samsung.com)
19  * @version 1.0
20  */
21
22 #ifndef WIDGET_REGISTER_TYPES_H
23 #define WIDGET_REGISTER_TYPES_H
24
25 #include <time.h>
26 #include <list>
27 #include <set>
28 #include <string>
29 #include <dpl/string.h>
30 #include <dpl/optional_typedefs.h>
31 #include <dpl/wrt-dao-ro/config_parser_data.h>
32 #include <dpl/wrt-dao-ro/property_dao_read_only.h>
33 #include <dpl/wrt-dao-ro/common_dao_types.h>
34
35 namespace WrtDB {
36 enum CertificateSource {
37     SIGNATURE_AUTHOR = 0,
38     SIGNATURE_DISTRIBUTOR = 1,
39     SIGNATURE_DISTRIBUTOR2 = 2,
40     SIGNATURE_UNKNOWN = 3
41 };
42
43 struct WidgetLocalizedInfo
44 {
45     DPL::OptionalString name;
46     DPL::OptionalString shortName;
47     DPL::OptionalString description;
48     DPL::OptionalString license;
49     DPL::OptionalString licenseHref;
50 };
51
52 /**
53  * CertificateData
54  * A structure to hold certificate fingerprints.
55  */
56 struct WidgetCertificateData
57 {
58     enum Owner { AUTHOR, DISTRIBUTOR, DISTRIBUTOR2, UNKNOWN };
59     enum Type { ROOT, ENDENTITY };
60
61     // type of signature: author/distributor
62     Owner owner;
63     // indicates whether this is ca certificate
64     Type type;
65
66     // chain id number: relative BASE, where BASE is signatureBASE.xml
67     int chainId;
68     // certificate fingerprint digested by md5
69     std::string strMD5Fingerprint;
70     // certificate fingerprint digestef by sha1
71     std::string strSHA1Fingerprint;
72     // Common name field in certificate
73     DPL::String strCommonName;
74
75     bool operator== (const WidgetCertificateData& certData) const
76     {
77         return certData.chainId == chainId &&
78                certData.owner == owner &&
79                certData.strCommonName == strCommonName &&
80                certData.strMD5Fingerprint == strMD5Fingerprint &&
81                certData.strSHA1Fingerprint == strSHA1Fingerprint;
82     }
83 };
84
85 typedef std::list<WidgetCertificateData> WidgetCertificateDataList;
86
87 typedef DPL::String Locale;
88 typedef std::set<Locale> LocaleSet;
89 typedef std::list<std::string> ExternalLocationList;
90
91 /**
92  * WidgetRegisterInfo
93  * A structure to hold widget's information needed to be registered.
94  * @see WidgetConfigurationInfo
95  */
96 struct WidgetRegisterInfo
97 {
98     struct LocalizedIcon : public ConfigParserData::Icon
99     {
100         LocalizedIcon(const ConfigParserData::Icon& icon,
101                       const LocaleSet& _availableLocales) :
102             ConfigParserData::Icon(icon),
103             availableLocales(_availableLocales)
104         {}
105
106         LocaleSet availableLocales;
107     };
108
109     struct StartFileProperties
110     {
111         DPL::String encoding;
112         DPL::String type;
113     };
114
115     typedef std::map<Locale,
116                      StartFileProperties> StartFilePropertiesForLocalesMap;
117     struct LocalizedStartFile
118     {
119         DPL::String path;
120         StartFilePropertiesForLocalesMap propertiesForLocales;
121     };
122
123     typedef std::list<LocalizedIcon> LocalizedIconList;
124     typedef std::list<LocalizedStartFile> LocalizedStartFileList;
125     struct LocalizationData
126     {
127         LocalizedIconList icons;
128         LocalizedStartFileList startFiles;
129     };
130
131     //Constructor
132     WidgetRegisterInfo() :
133         webAppType(APP_TYPE_UNKNOWN),
134         configInfo(),
135         packagingType(PKG_TYPE_UNKNOWN)
136     {}
137
138     WidgetType webAppType;
139     DPL::OptionalString guid;
140     DPL::OptionalString version;
141     DPL::OptionalString minVersion;
142     std::string baseFolder;
143     ConfigParserData configInfo;
144     LocalizationData localizationData;
145
146     TizenPkgId tzPkgid;
147     TizenAppId tzAppid;
148
149     time_t installedTime;
150     PackagingType packagingType;
151     EncryptedFileList encryptedFiles;
152     ExternalLocationList externalLocations;
153     DPL::OptionalString widgetInstalledPath;
154 };
155
156 typedef std::list<std::string> CertificateChainList;
157 class IWidgetSecurity
158 {
159   public:
160     virtual ~IWidgetSecurity();
161
162     virtual const WidgetCertificateDataList& getCertificateList() const = 0;
163
164     virtual bool isRecognized() const = 0;
165
166     virtual bool isDistributorSigned() const = 0;
167
168     virtual void getCertificateChainList(CertificateChainList& list,
169                                          CertificateSource source) const = 0;
170 };
171
172 /**
173  * WidgetAuthorInfo.
174  * Structure to hold the information of widget's author.
175  */
176 struct WidgetAuthorInfo
177 {
178     DPL::OptionalString name;
179     DPL::OptionalString email;
180     DPL::OptionalString href;
181 };
182
183 typedef std::list <std::string> WidgetCertificateCNList;
184 typedef std::list<DPL::String> LanguageTagList;
185 typedef std::list<std::string> HostList;
186 typedef std::list<std::string> FingerPrintList;
187
188 }
189
190 #endif // WIDGET_REGISTER_TYPES_H