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