[Release] wrt_0.8.181
[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      *  ex> "TizenIDabc.appname"
53      *
54      *  - TizenId / AppId : "TizenIDabc.appname"
55      *  - TzPkgId         : "TizenIDabc"
56      *  - App name        : "appname"
57      *
58      */
59     DPL::String TizenId;
60     DPL::Event::Property<WrtDB::TizenPkgId,
61                          DPL::Event::PropertyReadOnly,
62                          DPL::Event::PropertyStorageDynamicCached> TzPkgId;
63
64     /**
65      * @brief Widget type
66      *
67      * Note: This is a readonly property
68      */
69     DPL::Event::Property<WrtDB::WidgetType,
70                          DPL::Event::PropertyReadOnly,
71                          DPL::Event::PropertyStorageDynamicCached> Type;
72
73     /**
74      * @brief Config file based csp policy
75      */
76     DPL::Event::Property<DPL::OptionalString,
77                          DPL::Event::PropertyReadOnly,
78                          DPL::Event::PropertyStorageDynamicCached> CspPolicy;
79
80     /**
81      * @brief Config file based csp policy - report only
82      */
83     DPL::Event::Property<DPL::OptionalString,
84                          DPL::Event::PropertyReadOnly,
85                          DPL::Event::PropertyStorageDynamicCached>
86     CspReportOnlyPolicy;
87
88     /**
89      * @brief Current widget actual size
90      */
91     DPL::Event::Property<WidgetSize> ActualSize;
92
93     /**
94      * @brief Current widget preferred size
95      */
96     DPL::Event::Property<WidgetSize,
97                          DPL::Event::PropertyReadOnly,
98                          DPL::Event::PropertyStorageDynamicCached>
99     PreferredSize;
100
101     /**
102      * @brief Start URL for widget
103      */
104     DPL::Event::Property<DPL::OptionalString> StartURL;
105
106     /**
107      * @brief Start URL information for widget
108      */
109     DPL::Event::Property<OptionalWidgetStartFileInfo> StartFileInfo;
110
111     /**
112      * @brief Prefix URL for widget
113      *
114      * This is a prefix address of html file that widget is displaying.
115      * The whole address is PrefixURL + StartURL.
116      */
117     DPL::Event::Property<DPL::String, DPL::Event::PropertyReadOnly> PrefixURL;
118
119     /**
120      * @brief Install path for widget
121      *
122      * Gets path in which files of widget are being kept
123      */
124     DPL::Event::Property<DPL::String,
125                          DPL::Event::PropertyReadOnly,
126                          DPL::Event::PropertyStorageDynamicCached> InstallPath;
127
128     /**
129      * @brief Path to widget's persistent storage.
130      *
131      * Gets path in which widget may store its persistent private data.
132      */
133     DPL::Event::Property<DPL::String,
134                          DPL::Event::PropertyReadOnly> PersistentStoragePath;
135
136     /**
137      * @brief Path to widget's temporary storage.
138      *
139      * Gets path in which widget may store its temporary private data.
140      */
141     DPL::Event::Property<DPL::String,
142                          DPL::Event::PropertyReadOnly> TemporaryStoragePath;
143
144     /**
145      * @brief Widget defaultlocale
146      */
147     DPL::Event::Property<DPL::OptionalString,
148                          DPL::Event::PropertyReadOnly,
149                          DPL::Event::PropertyStorageDynamicCached>
150     defaultlocale;
151
152     /**
153      * @brief Widget name
154      */
155     DPL::Event::Property<DPL::OptionalString> Name;
156
157     /**
158      * @brief Widget short name
159      */
160     DPL::Event::Property<DPL::OptionalString> ShortName;
161
162     /**
163      * @brief Widget description
164      */
165     DPL::Event::Property<DPL::OptionalString> Description;
166
167     /**
168      * @brief Widget license
169      */
170     DPL::Event::Property<DPL::OptionalString> License;
171
172     /**
173      * @brief Widget license href
174      */
175     DPL::Event::Property<DPL::OptionalString> LicenseHref;
176
177     /**
178      * @brief Widget icon
179      */
180     DPL::Event::Property<OptionalWidgetIcon> Icon;
181
182     /**
183      * @brief Widget splash image src
184      */
185     DPL::Event::Property<DPL::OptionalString,
186                          DPL::Event::PropertyReadOnly,
187                          DPL::Event::PropertyStorageDynamicCached> SplashImg;
188
189     /**
190      * @brief window mode
191      */
192     DPL::Event::Property<WrtDB::WindowModeList,
193                          DPL::Event::PropertyReadOnly,
194                          DPL::Event::PropertyStorageDynamic> WindowModes;
195
196     //    /**
197     //     * @brief Value of network element.
198     //     */
199     //    DPL::Event::Property<bool,
200     //                  DPL::Event::PropertyReadOnly> AccessNetwork;
201
202     //    /**
203     //     * @brief Does widget contain WARP definitions.
204     //     */
205     //    DPL::Event::Property<bool> WarpDefinitionEmpty;
206
207     /**
208      * @brief Is back supported
209      */
210     DPL::Event::Property<bool,
211                          DPL::Event::PropertyReadOnly,
212                          DPL::Event::PropertyStorageDynamicCached>
213     BackSupported;
214
215     /**
216      * @brief Widget access list
217      */
218     DPL::Event::Property<WidgetAccessList> AccessList;
219
220     /**
221      * @brief Is this DeveloperWidget
222      */
223     DPL::Event::Property<bool,
224                          DPL::Event::PropertyReadOnly,
225                          DPL::Event::PropertyStorageDynamicCached> IsTestWidget;
226
227     DPL::Event::Property<WidgetSettingList> SettingList;
228
229     /**
230      * @brief Widget Application Service list
231      */
232     DPL::Event::Property<WidgetApplicationServiceList> AppServiceList;
233 #ifdef MULTIPROCESS_SERVICE_SUPPORT
234     DPL::Event::Property<DPL::Optional<unsigned> > AppServiceIndex;
235 #endif
236     WidgetModel(const std::string &tizenId);
237
238   private:
239     // Custom read write delegates
240     static DPL::String           getTimestamp();
241
242     DPL::String getTizenId() const;
243 };
244
245 #endif // SRC_DOMAIN_WIDGET_MODEL_H