3f7b819acec3596528c131f77fd268a18db1f7b9
[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
42 class WidgetDAO : public WidgetDAOReadOnly
43 {
44   public:
45     typedef std::list<DPL::String> LanguageTagsList;
46
47     WidgetDAO(DbWidgetHandle handle);
48     WidgetDAO(DPL::OptionalString widgetGUID);
49     WidgetDAO(DPL::String pkgName);
50
51     /**
52      * Destructor
53      */
54     virtual ~WidgetDAO();
55
56     /**
57      * This method registers the widget information in the DB when it is installed.
58      *
59      * @see WidgetRegisterInfo
60      * @see UnRegisterWidget()
61      * @param[in] widgetPkgname Widget Pkgname that will be registered.
62      * @param[in] pWidgetRegisterInfo    Specified the widget's information needed to be registered.
63      * @param[in] wacSecurity   Widget's security certificates.
64      */
65     static void registerWidget(
66             const WidgetPkgName & widgetPkgname,
67             const WidgetRegisterInfo &widgetRegInfo,
68             const IWacSecurity &wacSecurity);
69
70     static DbWidgetHandle registerWidget(
71                 const WidgetRegisterInfo &pWidgetRegisterInfo,
72                 const IWacSecurity &wacSecurity) __attribute__((deprecated));
73
74     /**
75      * @brief registerWidgetGenerateTizenId Registers widget with auto-generated tizen id
76      *
77      * This function is disadviced and should be used only in tests.
78      * Function is not thread-safe.
79      *
80      * @param pWidgetRegisterInfo registeration information
81      * @param wacSecurity Widget's security certificates.
82      * @return pkgname generated
83      */
84     static WidgetPkgName registerWidgetGenerateTizenId(
85                 const WidgetRegisterInfo &pWidgetRegisterInfo,
86                 const IWacSecurity &wacSecurity);
87
88     /**
89      * This method re-registers the widget information to the DB when it is installed.
90      *
91      * It performs unregistration and new registration of widget in db in one transaction.
92      *
93      * @see WidgetRegisterInfo
94      * @param[in] widgetName  Widget pkgname that will be registered.
95      * @param[in] pWidgetRegisterInfo    Specified the widget's information needed to be registered.
96      * @param[in] wacSecurity   Widget's security certificates.
97      */
98     static void registerOrUpdateWidget(
99             const WidgetPkgName & widgetName,
100             const WidgetRegisterInfo &widgetRegInfo,
101             const IWacSecurity &wacSecurity);
102
103     static void registerWidget(
104             WrtDB::DbWidgetHandle handle,
105             const WidgetRegisterInfo &widgetRegInfo,
106             const IWacSecurity &wacSecurity) __attribute__((deprecated));
107
108     /**
109      * This method removes a widget's information from EmDB.
110      *
111      * @see RegisterWidget()
112      * @param[in] pkgName widgets name to be unregistered
113      */
114     static void unregisterWidget(const WidgetPkgName & pkgName);
115
116     static void unregisterWidget(WrtDB::DbWidgetHandle handle) __attribute__((deprecated));
117
118     /* This method removes widget property
119      */
120     void removeProperty(const PropertyDAOReadOnly::WidgetPropertyKey &key);
121
122     /**
123      * @brief registerExternalLocations Removes rows from WidgetExternalLocations
124      */
125     void unregisterAllExternalLocations();
126
127     /* This method sets widget property
128      */
129     void setProperty(const PropertyDAOReadOnly::WidgetPropertyKey &key,
130             const PropertyDAOReadOnly::WidgetPropertyValue &value,
131             bool readOnly = false);
132
133     /* set PkgName
134      */
135     void setPkgName(const DPL::OptionalString& pkgName);
136     void setPkgName_TEMPORARY_API(const WidgetPkgName& pkgName);
137
138     /* This function will update of api-feature status.
139      * If status is true (feature rejected) plugin connected with this
140      * api feature mustn't be loaded durign widget launch.
141      */
142     void updateFeatureRejectStatus(const DbWidgetFeature &widgetFeature);
143
144      /*
145       * This method change security settings value
146       */
147     void setSecurityPopupUsage(const SettingsType value);
148     void setGeolocationUsage(const SettingsType value);
149     void setWebNotificationUsage(const SettingsType value);
150     void setWebDatabaseUsage(const SettingsType value);
151     void setFileSystemUsage(const SettingsType value);
152
153   private:
154     //Methods used during widget registering
155     static DbWidgetHandle registerWidgetInfo(
156             const WidgetPkgName & widgetName,
157             const WidgetRegisterInfo &regInfo,
158             const IWacSecurity &wacSecurity,
159             const DPL::Optional<DbWidgetHandle> handle = DPL::Optional<DbWidgetHandle>());
160     static void registerWidgetExtendedInfo(
161             DbWidgetHandle widgetHandle,
162             const WidgetRegisterInfo &regInfo);
163     static void registerWidgetLocalizedInfo(
164             DbWidgetHandle widgetHandle,
165             const WidgetRegisterInfo &regInfo);
166     static void registerWidgetIcons(
167             DbWidgetHandle widgetHandle,
168             const WidgetRegisterInfo &regInfo);
169     static void registerWidgetStartFile(
170             DbWidgetHandle widgetHandle,
171             const WidgetRegisterInfo &regInfo);
172     static void registerWidgetPreferences(
173             DbWidgetHandle widgetHandle,
174             const WidgetRegisterInfo &regInfo);
175     static void registerWidgetFeatures(
176             DbWidgetHandle widgetHandle,
177             const WidgetRegisterInfo &regInfo);
178     static void registerWidgetPrivilege(
179             DbWidgetHandle widgetHandle,
180             const WidgetRegisterInfo &regInfo);
181     static void registerWidgetWindowModes(
182             DbWidgetHandle widgetHandle,
183             const WidgetRegisterInfo &regInfo);
184     static void registerWidgetWarpInfo(
185             DbWidgetHandle widgetHandle,
186             const WidgetRegisterInfo &regInfo);
187     static void registerWidgetCertificates(
188             DbWidgetHandle widgetHandle,
189             const IWacSecurity &wacSecurity);
190     static void registerCertificatesChains(
191             DbWidgetHandle widgetHandle,
192             CertificateSource certificateSource,
193             const CertificateChainList &list);
194     static void registerWidgetSettings(
195             DbWidgetHandle widgetHandle,
196             const WidgetRegisterInfo &regInfo);
197     static void registerAppService(
198             DbWidgetHandle widgetHandle,
199             const WidgetRegisterInfo &regInfo);
200     static void registerEncryptedResouceInfo(
201             DbWidgetHandle widgetHandle,
202             const WidgetRegisterInfo &regInfo);
203     /**
204      * @brief registerExternalLocations Inserts new rows to WidgetExternalLocations
205      * @param externals list of files
206      */
207     static void registerExternalLocations(DbWidgetHandle widgetHandle,
208                                 const ExternalLocationList & externals);
209     static void registerWidgetSecuritySettings(DbWidgetHandle widgetHandle);
210
211
212     static void registerWidgetInternal(
213             const WidgetPkgName & widgetName,
214             const WidgetRegisterInfo &widgetRegInfo,
215             const IWacSecurity &wacSecurity,
216             const DPL::Optional<DbWidgetHandle> handle = DPL::Optional<DbWidgetHandle>());
217     static void unregisterWidgetInternal(
218             const WidgetPkgName & pkgName);
219 };
220
221 } // namespace WrtDB
222
223 #endif // WIDGET_DAO_H