Crash Fix when Creating SecurityOrigin DB.
[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 Current widget actual size
75      */
76     DPL::Event::Property<WidgetSize> ActualSize;
77
78     /**
79      * @brief Current widget preferred size
80      */
81     DPL::Event::Property<WidgetSize,
82                   DPL::Event::PropertyReadOnly,
83                   DPL::Event::PropertyStorageDynamicCached> PreferredSize;
84
85     /**
86      * @brief Start URL for widget
87      */
88     DPL::Event::Property<DPL::OptionalString> StartURL;
89
90     /**
91      * @brief Start URL information for widget
92      */
93     DPL::Event::Property<OptionalWidgetStartFileInfo> StartFileInfo;
94
95     /**
96      * @brief Prefix URL for widget
97      *
98      * This is a prefix address of html file that widget is displaying.
99      * The whole address is PrefixURL + StartURL.
100      */
101     DPL::Event::Property<DPL::String, DPL::Event::PropertyReadOnly> PrefixURL;
102
103     /**
104      * @brief Install path for widget
105      *
106      * Gets path in which files of widget are being kept
107      */
108     DPL::Event::Property<DPL::String,
109                   DPL::Event::PropertyReadOnly,
110                   DPL::Event::PropertyStorageDynamicCached> InstallPath;
111
112     /**
113      * @brief Path to widget's persistent storage.
114      *
115      * Gets path in which widget may store its persistent private data.
116      */
117     DPL::Event::Property<DPL::String, DPL::Event::PropertyReadOnly> PersistentStoragePath;
118
119     /**
120      * @brief Path to widget's temporary storage.
121      *
122      * Gets path in which widget may store its temporary private data.
123      */
124     DPL::Event::Property<DPL::String, DPL::Event::PropertyReadOnly> TemporaryStoragePath;
125
126     /**
127      * @brief Widget defaultlocale
128      */
129     DPL::Event::Property<DPL::OptionalString,
130                   DPL::Event::PropertyReadOnly,
131                   DPL::Event::PropertyStorageDynamicCached> defaultlocale;
132
133     /**
134      * @brief Widget name
135      */
136     DPL::Event::Property<DPL::OptionalString> Name;
137
138     /**
139      * @brief Widget short name
140      */
141     DPL::Event::Property<DPL::OptionalString> ShortName;
142
143     /**
144      * @brief Widget description
145      */
146     DPL::Event::Property<DPL::OptionalString> Description;
147
148     /**
149      * @brief Widget license
150      */
151     DPL::Event::Property<DPL::OptionalString> License;
152
153     /**
154      * @brief Widget license href
155      */
156     DPL::Event::Property<DPL::OptionalString> LicenseHref;
157
158     /**
159      * @brief Widget icon
160      */
161     DPL::Event::Property<OptionalWidgetIcon> Icon;
162
163     /**
164      * @brief Widget splash image src
165      */
166     DPL::Event::Property<DPL::OptionalString,
167                   DPL::Event::PropertyReadOnly,
168                   DPL::Event::PropertyStorageDynamicCached> SplashImg;
169
170     /**
171      * @brief window mode
172      */
173     DPL::Event::Property<WrtDB::WindowModeList,
174                   DPL::Event::PropertyReadOnly,
175                   DPL::Event::PropertyStorageDynamic> WindowModes;
176
177     //    /**
178     //     * @brief Value of network element.
179     //     */
180     //    DPL::Event::Property<bool,
181     //                  DPL::Event::PropertyReadOnly> AccessNetwork;
182
183     //    /**
184     //     * @brief Does widget contain WARP definitions.
185     //     */
186     //    DPL::Event::Property<bool> WarpDefinitionEmpty;
187
188     /**
189      * @brief Is back supported
190      */
191     DPL::Event::Property<bool,
192                   DPL::Event::PropertyReadOnly,
193                   DPL::Event::PropertyStorageDynamicCached> BackSupported;
194
195     /**
196      * @brief Widget access list
197      */
198     DPL::Event::Property<WidgetAccessList> AccessList;
199
200     /**
201      * @brief Is this DeveloperWidget
202      */
203     DPL::Event::Property<bool,
204                   DPL::Event::PropertyReadOnly,
205                   DPL::Event::PropertyStorageDynamicCached> IsTestWidget;
206
207
208     DPL::Event::Property<WidgetSettingList> SettingList;
209
210     /**
211      * @brief Widget Application Service list
212      */
213     DPL::Event::Property<WidgetApplicationServiceList> AppServiceList;
214
215     WidgetModel(const std::string &tizenId);
216
217   private:
218     // Custom read write delegates
219     static DPL::String           getTimestamp();
220
221     DPL::String getTizenId() const;
222 };
223
224 #endif // SRC_DOMAIN_WIDGET_MODEL_H