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