b3c276a14de497d4fb95227c72e1c9c6d8355e95
[platform/framework/web/wrt-commons.git] / modules / widget_dao / include / dpl / wrt-dao-rw / widget_dao.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  * This file contains the declaration of widget dao class.
18  *
19  * @file    widget_dao.h
20  * @author  Yang Jie (jie2.yang@samsung.com)
21  * @author  Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
22  * @author  Pawel Sikorski (p.sikorski@samsung.com)
23  * @version 1.0
24  * @brief   This file contains the declaration of widget dao
25  */
26 #ifndef WIDGET_DAO_H
27 #define WIDGET_DAO_H
28
29 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
30 #include <list>
31 #include <string>
32 #include <sys/time.h>
33 #include <ctime>
34 #include <cstdlib>
35 #include <dpl/exception.h>
36 #include <dpl/db/orm.h>
37 #include <dpl/wrt-dao-ro/config_parser_data.h>
38 #include <dpl/wrt-dao-rw/property_dao.h>
39
40 namespace WrtDB {
41 class WidgetDAO : public WidgetDAOReadOnly
42 {
43   public:
44     typedef std::list<DPL::String> LanguageTagsList;
45
46     WidgetDAO(DbWidgetHandle handle);
47     WidgetDAO(DPL::OptionalString widgetGUID);
48     WidgetDAO(DPL::String tzAppId);
49
50     /**
51      * Destructor
52      */
53     virtual ~WidgetDAO();
54
55     /**
56      * This method registers the widget information in the DB when it is
57      * installed.
58      *
59      * @see WidgetRegisterInfo
60      * @see UnRegisterWidget()
61      * @param[in] TizenAppId Widget app id that will be registered.
62      * @param[in] pWidgetRegisterInfo    Specified the widget's information
63      * needed to be registered.
64      * @param[in] wacSecurity   Widget's security certificates.
65      */
66     static void registerWidget(
67         const TizenAppId& tzAppId,
68         const WidgetRegisterInfo &widgetRegInfo,
69         const IWacSecurity &wacSecurity);
70
71     static DbWidgetHandle registerWidget(
72         const WidgetRegisterInfo &pWidgetRegisterInfo,
73         const IWacSecurity &wacSecurity) __attribute__((deprecated));
74
75     /**
76      * @brief registerWidgetGenerateTizenId Registers widget with auto-generated
77      * tizen id
78      *
79      * This function is disadviced and should be used only in tests.
80      * Function is not thread-safe.
81      *
82      * @param pWidgetRegisterInfo registeration information
83      * @param wacSecurity Widget's security certificates.
84      * @return tzAppId generated
85      */
86     static TizenAppId registerWidgetGeneratePkgId(
87         const WidgetRegisterInfo &pWidgetRegisterInfo,
88         const IWacSecurity &wacSecurity);
89
90     /**
91      * This method re-registers the widget information to the DB when it is
92      * installed.
93      *
94      * It performs unregistration and new registration of widget in db in one
95      * transaction.
96      *
97      * @see WidgetRegisterInfo
98      * @param[in] tzAppId  Widget tizen app id that will be registered.
99      * @param[in] pWidgetRegisterInfo    Specified the widget's information
100      * needed to be registered.
101      * @param[in] wacSecurity   Widget's security certificates.
102      */
103     static void registerOrUpdateWidget(
104         const TizenAppId & tzAppId,
105         const WidgetRegisterInfo &widgetRegInfo,
106         const IWacSecurity &wacSecurity);
107
108     /**
109      * This method removes a widget's information from EmDB.
110      *
111      * @see RegisterWidget()
112      * @param[in] tzAppId widgets name to be unregistered
113      */
114     static void unregisterWidget(const TizenAppId & tzAppId);
115
116     static void unregisterWidget(WrtDB::DbWidgetHandle handle) __attribute__((
117                                                                                  deprecated));
118
119     /* This method removes widget property
120      */
121     void removeProperty(const PropertyDAOReadOnly::WidgetPropertyKey &key);
122
123     /**
124      * @brief registerExternalLocations Removes rows from
125      * WidgetExternalLocations
126      */
127     void unregisterAllExternalLocations();
128
129     /* This method sets widget property
130      */
131     void setProperty(const PropertyDAOReadOnly::WidgetPropertyKey &key,
132                      const PropertyDAOReadOnly::WidgetPropertyValue &value,
133                      bool readOnly = false);
134
135     /* set tzAppId
136      */
137     void setTizenAppId(const DPL::OptionalString& tzAppId);
138
139     /* This function will update of api-feature status.
140      * If status is true (feature rejected) plugin connected with this
141      * api feature mustn't be loaded durign widget launch.
142      */
143     void updateFeatureRejectStatus(const DbWidgetFeature &widgetFeature);
144
145     /*
146      * This method change security settings value
147      */
148     void setSecurityPopupUsage(const SettingsType value);
149     void setGeolocationUsage(const SettingsType value);
150     void setWebNotificationUsage(const SettingsType value);
151     void setWebDatabaseUsage(const SettingsType value);
152     void setFileSystemUsage(const SettingsType value);
153
154   private:
155     //Methods used during widget registering
156     static DbWidgetHandle registerWidgetInfo(
157         const TizenAppId & widgetName,
158         const WidgetRegisterInfo &regInfo,
159         const IWacSecurity &wacSecurity,
160         const DPL::Optional<DbWidgetHandle> handle =
161             DPL::Optional<DbWidgetHandle>());
162     static void registerWidgetExtendedInfo(
163         DbWidgetHandle widgetHandle,
164         const WidgetRegisterInfo &regInfo);
165     static void registerWidgetLocalizedInfo(
166         DbWidgetHandle widgetHandle,
167         const WidgetRegisterInfo &regInfo);
168     static void registerWidgetIcons(
169         DbWidgetHandle widgetHandle,
170         const WidgetRegisterInfo &regInfo);
171     static void registerWidgetStartFile(
172         DbWidgetHandle widgetHandle,
173         const WidgetRegisterInfo &regInfo);
174     static void registerWidgetPreferences(
175         DbWidgetHandle widgetHandle,
176         const WidgetRegisterInfo &regInfo);
177     static void registerWidgetFeatures(
178         DbWidgetHandle widgetHandle,
179         const WidgetRegisterInfo &regInfo);
180     static void registerWidgetPrivilege(
181         DbWidgetHandle widgetHandle,
182         const WidgetRegisterInfo &regInfo);
183     static void registerWidgetWindowModes(
184         DbWidgetHandle widgetHandle,
185         const WidgetRegisterInfo &regInfo);
186     static void registerWidgetWarpInfo(
187         DbWidgetHandle widgetHandle,
188         const WidgetRegisterInfo &regInfo);
189     static void registerWidgetCertificates(
190         DbWidgetHandle widgetHandle,
191         const IWacSecurity &wacSecurity);
192     static void registerCertificatesChains(
193         DbWidgetHandle widgetHandle,
194         CertificateSource certificateSource,
195         const CertificateChainList &list);
196     static void registerWidgetSettings(
197         DbWidgetHandle widgetHandle,
198         const WidgetRegisterInfo &regInfo);
199     static void registerAppControl(
200         DbWidgetHandle widgetHandle,
201         const WidgetRegisterInfo &regInfo);
202     static void registerEncryptedResouceInfo(
203         DbWidgetHandle widgetHandle,
204         const WidgetRegisterInfo &regInfo);
205     /**
206      * @brief registerExternalLocations Inserts new rows to
207      * WidgetExternalLocations
208      * @param externals list of files
209      */
210     static void registerExternalLocations(
211         DbWidgetHandle widgetHandle,
212         const ExternalLocationList &
213         externals);
214     static void registerWidgetSecuritySettings(DbWidgetHandle widgetHandle);
215
216     static void registerWidgetInternal(
217         const TizenAppId & tzAppId,
218         const WidgetRegisterInfo &widgetRegInfo,
219         const IWacSecurity &wacSecurity,
220         const DPL::Optional<DbWidgetHandle> handle =
221             DPL::Optional<DbWidgetHandle>());
222     static void unregisterWidgetInternal(
223         const TizenAppId & tzAppId);
224
225     static void insertAppControlInfo(DbWidgetHandle handle,
226                                              DPL::String src,
227                                              DPL::String operation,
228                                              DPL::String uri,
229                                              DPL::String mime,
230                                              unsigned index,
231                                              unsigned disposition);
232 };
233 } // namespace WrtDB
234
235 #endif // WIDGET_DAO_H