[Engine] Replace widget handle with tizen id in widgetModel
[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 Tizen id
51      */
52     DPL::String TizenId;
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 splash image src
176      */
177     DPL::Event::Property<DPL::OptionalString,
178                   DPL::Event::PropertyReadOnly,
179                   DPL::Event::PropertyStorageDynamicCached> SplashImg;
180
181     /**
182      * @brief window mode
183      */
184     DPL::Event::Property<WrtDB::WindowModeList,
185                   DPL::Event::PropertyReadOnly,
186                   DPL::Event::PropertyStorageDynamic> WindowModes;
187
188     /**
189      * @brief Minimum of the WAC Engine Standard required to run widget.
190      */
191     DPL::Event::Property<WidgetStandard,
192                   DPL::Event::PropertyReadOnly,
193                   DPL::Event::PropertyStorageDynamicCached> Standard;
194
195     /**
196      * @brief How much space application and its storage takes.
197      */
198     DPL::Event::Property<WidgetStorageSize,
199                   DPL::Event::PropertyReadOnly,
200                   DPL::Event::PropertyStorageDynamicCached> ApplicationStorage;
201     //    /**
202     //     * @brief Value of network element.
203     //     */
204     //    DPL::Event::Property<bool,
205     //                  DPL::Event::PropertyReadOnly> AccessNetwork;
206
207     //    /**
208     //     * @brief Does widget contain WARP definitions.
209     //     */
210     //    DPL::Event::Property<bool> WarpDefinitionEmpty;
211
212     /**
213      * @brief Is back supported
214      */
215     DPL::Event::Property<bool,
216                   DPL::Event::PropertyReadOnly,
217                   DPL::Event::PropertyStorageDynamicCached> BackSupported;
218
219     /**
220      * @brief Widget access list
221      */
222     DPL::Event::Property<WidgetAccessList> AccessList;
223
224     /**
225      * @brief Is this DeveloperWidget
226      */
227     DPL::Event::Property<bool,
228                   DPL::Event::PropertyReadOnly,
229                   DPL::Event::PropertyStorageDynamicCached> IsTestWidget;
230
231
232     DPL::Event::Property<WidgetSettingList> SettingList;
233
234     /**
235      * @brief Widget Application Service list
236      */
237     DPL::Event::Property<WidgetApplicationServiceList> AppServiceList;
238
239     WidgetModel(const std::string &tizenId);
240
241   private:
242     // Custom read write delegates
243     static WidgetStandard        readStandard(DPL::Event::Model *model);
244     static OptionalWidgetVersion readVersion(DPL::Event::Model *model);
245     static WidgetStorageSize     getApplicationStorage(DPL::Event::Model *model);
246     static DPL::String           getTimestamp();
247
248     DPL::String getTizenId() const;
249 };
250
251 #endif // SRC_DOMAIN_WIDGET_MODEL_H