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