[Release] wrt-commons_0.2.145
[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] widgetSecurity   Widget's security certificates.
65      */
66     static void registerWidget(
67         const TizenAppId& tzAppId,
68         const WidgetRegisterInfo &widgetRegInfo,
69         const IWidgetSecurity &widgetSecurity);
70
71     static DbWidgetHandle registerWidget(
72         const WidgetRegisterInfo &pWidgetRegisterInfo,
73         const IWidgetSecurity &widgetSecurity) __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 widgetSecurity Widget's security certificates.
84      * @return tzAppId generated
85      */
86     static TizenAppId registerWidgetGeneratePkgId(
87         const WidgetRegisterInfo &pWidgetRegisterInfo,
88         const IWidgetSecurity &widgetSecurity);
89
90     static void updateTizenAppId(const TizenAppId & fromAppId,
91                                  const TizenAppId & toAppId);
92     /**
93      * This method removes a widget's information from EmDB.
94      *
95      * @see RegisterWidget()
96      * @param[in] tzAppId widgets name to be unregistered
97      */
98     static void unregisterWidget(const TizenAppId & tzAppId);
99
100     /* This method removes widget property
101      */
102     void removeProperty(const PropertyDAOReadOnly::WidgetPropertyKey &key);
103
104     /**
105      * @brief registerExternalLocations Removes rows from
106      * WidgetExternalLocations
107      */
108     void unregisterAllExternalLocations();
109
110     /* This method sets widget property
111      */
112     void setProperty(const PropertyDAOReadOnly::WidgetPropertyKey &key,
113                      const PropertyDAOReadOnly::WidgetPropertyValue &value,
114                      bool readOnly = false);
115
116     /* set tzAppId
117      */
118     void setTizenAppId(const DPL::OptionalString& tzAppId);
119
120     /* This function will update of api-feature status.
121      * If status is true (feature rejected) plugin connected with this
122      * api feature mustn't be loaded durign widget launch.
123      */
124     void updateFeatureRejectStatus(const DbWidgetFeature &widgetFeature);
125
126     /*
127      * This method change security settings value
128      */
129     void setSecurityPopupUsage(const SettingsType value);
130     void setGeolocationUsage(const SettingsType value);
131     void setWebNotificationUsage(const SettingsType value);
132     void setWebDatabaseUsage(const SettingsType value);
133
134   private:
135     //Methods used during widget registering
136     static DbWidgetHandle registerWidgetInfo(
137         const TizenAppId & widgetName,
138         const WidgetRegisterInfo &regInfo,
139         const IWidgetSecurity &widgetSecurity,
140         const DPL::Optional<DbWidgetHandle> handle =
141             DPL::Optional<DbWidgetHandle>());
142     static void registerWidgetExtendedInfo(
143         DbWidgetHandle widgetHandle,
144         const WidgetRegisterInfo &regInfo);
145     static void registerWidgetLocalizedInfo(
146         DbWidgetHandle widgetHandle,
147         const WidgetRegisterInfo &regInfo);
148     static void registerWidgetIcons(
149         DbWidgetHandle widgetHandle,
150         const WidgetRegisterInfo &regInfo);
151     static void registerWidgetStartFile(
152         DbWidgetHandle widgetHandle,
153         const WidgetRegisterInfo &regInfo);
154     static void registerWidgetPreferences(
155         DbWidgetHandle widgetHandle,
156         const WidgetRegisterInfo &regInfo);
157     static void registerWidgetFeatures(
158         DbWidgetHandle widgetHandle,
159         const WidgetRegisterInfo &regInfo);
160     static void registerWidgetPrivilege(
161         DbWidgetHandle widgetHandle,
162         const WidgetRegisterInfo &regInfo);
163     static void registerWidgetWindowModes(
164         DbWidgetHandle widgetHandle,
165         const WidgetRegisterInfo &regInfo);
166     static void registerWidgetWarpInfo(
167         DbWidgetHandle widgetHandle,
168         const WidgetRegisterInfo &regInfo);
169     static void registerWidgetAllowNavigationInfo(
170         DbWidgetHandle widgetHandle,
171         const WidgetRegisterInfo &regInfo);
172     static void registerWidgetCertificates(
173         DbWidgetHandle widgetHandle,
174         const IWidgetSecurity &widgetSecurity);
175     static void registerCertificatesChains(
176         DbWidgetHandle widgetHandle,
177         CertificateSource certificateSource,
178         const CertificateChainList &list);
179     static void registerWidgetSettings(
180         DbWidgetHandle widgetHandle,
181         const WidgetRegisterInfo &regInfo);
182     static void registerAppControl(
183         DbWidgetHandle widgetHandle,
184         const WidgetRegisterInfo &regInfo);
185     static void registerEncryptedResouceInfo(
186         DbWidgetHandle widgetHandle,
187         const WidgetRegisterInfo &regInfo);
188     /**
189      * @brief registerExternalLocations Inserts new rows to
190      * WidgetExternalLocations
191      * @param externals list of files
192      */
193     static void registerExternalLocations(
194         DbWidgetHandle widgetHandle,
195         const ExternalLocationList &
196         externals);
197     static void registerWidgetSecuritySettings(DbWidgetHandle widgetHandle);
198
199     static void registerWidgetInternal(
200         const TizenAppId & tzAppId,
201         const WidgetRegisterInfo &widgetRegInfo,
202         const IWidgetSecurity &widgetSecurity,
203         const DPL::Optional<DbWidgetHandle> handle =
204             DPL::Optional<DbWidgetHandle>());
205     static void unregisterWidgetInternal(const TizenAppId & tzAppId);
206     static void insertAppControlInfo(DbWidgetHandle handle,
207                                      DPL::String src,
208                                      DPL::String operation,
209                                      DPL::String uri,
210                                      DPL::String mime,
211                                      unsigned index,
212                                      unsigned disposition);
213 };
214 } // namespace WrtDB
215
216 #endif // WIDGET_DAO_H