tizen beta release
[platform/framework/web/wrt.git] / src / domain / widget_model.h
1 /*
2  * Copyright (c) 2011 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_model.h
18  * @author  Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
19  * @version 1.0
20  * @brief   Header file for widget model
21  */
22 #ifndef SRC_DOMAIN_WIDGET_MODEL_H
23 #define SRC_DOMAIN_WIDGET_MODEL_H
24
25 #include <dpl/event/model.h>
26 #include <dpl/event/property.h>
27 #include <dpl/optional.h>
28 #include <dpl/event/nested_loop.h>
29 #include <vcore/CertificateCollection.h>
30
31 #include "widget_data_types.h"
32
33 /**
34  * @brief Widget model
35  *
36  * Widget model is the core object that hold information about state and
37  * properties of widget. After wrt launch each widget contained in database is
38  * mapped to WidgetModel.
39  *
40  * Widget model is a type of MVC model, so it is possible to listen for it's
41  * changes. If widget model is in running state @see WidgetState it has some
42  * corresponding view. A widget model view is displaying contents of widget
43  * model with webkit.
44  *
45  */
46 class WidgetModel : public DPL::Event::Model
47 {
48   public:
49     /**
50      * @brief Current widget model state
51      */
52     DPL::Event::Property<WidgetState> State;
53
54     /**
55      * @brief Widget handle
56      *
57      * Note: This is a readonly property
58      */
59     DPL::Event::Property<WidgetHandle, DPL::Event::PropertyReadOnly> Handle;
60
61     /**
62      * @brief Widget type
63      *
64      * Note: This is a readonly property
65      */
66     DPL::Event::Property<WrtDB::WidgetType,
67     DPL::Event::PropertyReadOnly,
68     DPL::Event::PropertyStorageDynamicCached> Type;
69
70     /**
71      * @brief Current widget actual size
72      */
73     DPL::Event::Property<WidgetSize> ActualSize;
74
75     /**
76      * @brief Current widget preferred size
77      */
78     DPL::Event::Property<WidgetSize,
79                   DPL::Event::PropertyReadOnly,
80                   DPL::Event::PropertyStorageDynamicCached> PreferredSize;
81
82     /**
83      * @brief Start URL for widget
84      */
85     DPL::Event::Property<DPL::OptionalString> StartURL;
86
87     /**
88      * @brief Start URL information for widget
89      */
90     DPL::Event::Property<OptionalWidgetStartFileInfo> StartFileInfo;
91
92     /**
93      * @brief Prefix URL for widget
94      *
95      * This is a prefix address of html file that widget is displaying.
96      * The whole address is PrefixURL + StartURL.
97      */
98     DPL::Event::Property<DPL::String, DPL::Event::PropertyReadOnly> PrefixURL;
99
100     /**
101      * @brief Install path for widget
102      *
103      * Gets path in which files of widget are being kept
104      */
105     DPL::Event::Property<DPL::String,
106                   DPL::Event::PropertyReadOnly,
107                   DPL::Event::PropertyStorageDynamicCached> InstallPath;
108
109     /**
110      * @brief Path to widget's persistent storage.
111      *
112      * Gets path in which widget may store its persistent private data.
113      */
114     DPL::Event::Property<DPL::String, DPL::Event::PropertyReadOnly> PersistentStoragePath;
115
116     /**
117      * @brief Path to widget's temporary storage.
118      *
119      * Gets path in which widget may store its temporary private data.
120      */
121     DPL::Event::Property<DPL::String, DPL::Event::PropertyReadOnly> TemporaryStoragePath;
122
123     /**
124      * @brief Widget GUID
125      */
126     DPL::Event::Property<WrtDB::WidgetGUID,
127                   DPL::Event::PropertyReadOnly,
128                   DPL::Event::PropertyStorageDynamicCached> GUID;
129
130     /**
131      * @brief Widget defaultlocale
132      */
133     DPL::Event::Property<DPL::OptionalString,
134                   DPL::Event::PropertyReadOnly,
135                   DPL::Event::PropertyStorageDynamicCached> defaultlocale;
136
137     /**
138      * @brief Widget version
139      */
140     DPL::Event::Property<OptionalWidgetVersion,
141                   DPL::Event::PropertyReadOnly,
142                   DPL::Event::PropertyStorageDynamicCached> Version;
143
144     /**
145      * @brief Widget name
146      */
147     DPL::Event::Property<DPL::OptionalString> Name;
148
149     /**
150      * @brief Widget short name
151      */
152     DPL::Event::Property<DPL::OptionalString> ShortName;
153
154     /**
155      * @brief Widget description
156      */
157     DPL::Event::Property<DPL::OptionalString> Description;
158
159     /**
160      * @brief Widget license
161      */
162     DPL::Event::Property<DPL::OptionalString> License;
163
164     /**
165      * @brief Widget license href
166      */
167     DPL::Event::Property<DPL::OptionalString> LicenseHref;
168
169     /**
170      * @brief Widget icon
171      */
172     DPL::Event::Property<OptionalWidgetIcon> Icon;
173
174     /**
175      * @brief Widget name if running
176      */
177     DPL::Event::Property<DPL::OptionalString> RunningName;
178
179     /**
180      * @brief Widget icon if running
181      */
182     DPL::Event::Property<OptionalWidgetIcon> RunningIcon;
183
184     /**
185      * @brief Start URL for widget if running
186      */
187     DPL::Event::Property<DPL::OptionalString> RunningStartURL;
188
189     /**
190      * @brief Widget short name  for widget if running
191      */
192     DPL::Event::Property<DPL::OptionalString> RunningShortName;
193
194     /**
195      * @brief Widget description for widget if running
196      */
197     DPL::Event::Property<DPL::OptionalString> RunningDescription;
198
199     /**
200      * @brief Widget license
201      */
202     DPL::Event::Property<DPL::OptionalString> RunningLicense;
203
204     /**
205      * @brief Widget license href
206      */
207     DPL::Event::Property<DPL::OptionalString> RunningLicenseHref;
208
209     /**
210      * @brief Start URL information for widget
211      */
212     DPL::Event::Property<OptionalWidgetStartFileInfo> RunningStartFileInfo;
213
214     /**
215      * @brief window mode
216      */
217     DPL::Event::Property<WrtDB::WindowModeList,
218                   DPL::Event::PropertyReadOnly,
219                   DPL::Event::PropertyStorageDynamic> WindowModes;
220
221     /**
222      * @brief Package name
223      */
224     DPL::Event::Property<DPL::String,
225                   DPL::Event::PropertyReadOnly,
226                   DPL::Event::PropertyStorageDynamicCached> PkgName;
227
228     /**
229      * @brief Current widget language tags
230      */
231     DPL::Event::Property<LanguageTagsList> LanguageTags;
232
233     /**
234      * @brief Minimum of the WAC Engine Standard required to run widget.
235      */
236     DPL::Event::Property<WidgetStandard,
237                   DPL::Event::PropertyReadOnly,
238                   DPL::Event::PropertyStorageDynamicCached> Standard;
239
240     /**
241      * @brief How much space application and its storage takes.
242      */
243     DPL::Event::Property<WidgetStorageSize,
244                   DPL::Event::PropertyReadOnly,
245                   DPL::Event::PropertyStorageDynamicCached> ApplicationStorage;
246     //    /**
247     //     * @brief Value of network element.
248     //     */
249     //    DPL::Event::Property<bool,
250     //                  DPL::Event::PropertyReadOnly> AccessNetwork;
251
252     //    /**
253     //     * @brief Does widget contain WARP definitions.
254     //     */
255     //    DPL::Event::Property<bool> WarpDefinitionEmpty;
256
257     /**
258      * @brief Certificates required OCSP check.
259      */
260     DPL::Event::Property<ValidationCore::CertificateCollectionList,
261                   DPL::Event::PropertyReadOnly,
262                   DPL::Event::PropertyStorageDynamic> OCSPCertificateChainList;
263
264     /**
265      * @brief Is back supported
266      */
267     DPL::Event::Property<bool,
268                   DPL::Event::PropertyReadOnly,
269                   DPL::Event::PropertyStorageDynamicCached> BackSupported;
270
271     /**
272      * @brief Widget access list
273      */
274     DPL::Event::Property<WidgetAccessList> AccessList;
275
276     /**
277      * @brief Is this DeveloperWidget
278      */
279     DPL::Event::Property<bool,
280                   DPL::Event::PropertyReadOnly,
281                   DPL::Event::PropertyStorageDynamicCached> IsTestWidget;
282
283     DPL::Event::Property<bool,
284                   DPL::Event::PropertyReadOnly,
285                   DPL::Event::PropertyStorageDynamicCached> IsDeletable;
286
287     DPL::Event::Property<WidgetSettingList> SettingList;
288
289     /**
290      * @brief Widget Application Service list
291      */
292     DPL::Event::Property<WidgetApplicationServiceList> AppServiceList;
293
294     WidgetModel(const WidgetHandle &handle);
295
296   private:
297     // Custom read write delegates
298     static DPL::String           readPkgName(DPL::Event::Model *model);
299     static WidgetStandard        readStandard(DPL::Event::Model *model);
300     static OptionalWidgetVersion readVersion(DPL::Event::Model *model);
301     static WidgetStorageSize     getApplicationStorage(DPL::Event::Model *model);
302     static ValidationCore::CertificateCollectionList
303                                  readWidgetCertificate(DPL::Event::Model *model);
304
305     WidgetHandle getHandle() const;
306 };
307
308 #endif // SRC_DOMAIN_WIDGET_MODEL_H