tizen 2.4 release
[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/availability.h>
36 #include <dpl/exception.h>
37 #include <dpl/platform.h>
38 #include <dpl/db/orm.h>
39 #include <dpl/wrt-dao-ro/config_parser_data.h>
40 #include <dpl/wrt-dao-rw/property_dao.h>
41
42 namespace WrtDB {
43 class WidgetDAO : public WidgetDAOReadOnly
44 {
45   public:
46     typedef std::list<DPL::String> LanguageTagsList;
47
48     WidgetDAO(DPL::OptionalString widgetGUID);
49     WidgetDAO(DPL::String tzAppId);
50
51     /**
52      * Destructor
53      */
54     virtual ~WidgetDAO();
55
56     /**
57      * This method registers the widget information in the DB when it is
58      * installed.
59      *
60      * @see WidgetRegisterInfo
61      * @see UnRegisterWidget()
62      * @param[in] TizenAppId Widget app id that will be registered.
63      * @param[in] pWidgetRegisterInfo    Specified the widget's information
64      * needed to be registered.
65      * @param[in] widgetSecurity   Widget's security certificates.
66      */
67     static void registerWidget(
68         const TizenAppId& tzAppId,
69         const WidgetRegisterInfo &widgetRegInfo,
70         const IWidgetSecurity &widgetSecurity);
71
72     static void registerService(
73         const ConfigParserData::ServiceAppInfo &serviceAppInfo,
74         const WidgetRegisterInfo &widgetRegInfo,
75         const IWidgetSecurity &widgetSecurity);
76
77     /**
78      * @brief registerWidgetGenerateTizenId Registers widget with auto-generated
79      * tizen id
80      *
81      * This function is disadviced and should be used only in tests.
82      * Function is not thread-safe.
83      *
84      * @param pWidgetRegisterInfo registeration information
85      * @param widgetSecurity Widget's security certificates.
86      * @return tzAppId generated
87      */
88     static TizenAppId registerWidgetGeneratePkgId(
89         const WidgetRegisterInfo &pWidgetRegisterInfo,
90         const IWidgetSecurity &widgetSecurity);
91
92     static void updateTizenAppId(const TizenAppId & fromAppId,
93                                  const TizenAppId & toAppId);
94     /**
95      * This method removes a widget's information from EmDB.
96      *
97      * @see RegisterWidget()
98      * @param[in] tzAppId widgets name to be unregistered
99      */
100     static void unregisterWidget(const TizenAppId & tzAppId);
101
102     /* This method removes widget property
103      */
104     void removeProperty(const PropertyDAOReadOnly::WidgetPropertyKey &key);
105
106     /**
107      * @brief registerExternalLocations Removes rows from
108      * WidgetExternalLocations
109      */
110     void unregisterAllExternalLocations();
111
112     /* This method sets widget property
113      */
114     void setProperty(const PropertyDAOReadOnly::WidgetPropertyKey &key,
115                      const PropertyDAOReadOnly::WidgetPropertyValue &value,
116                      bool readOnly = false);
117
118     /* set tzAppId
119      */
120     void setTizenAppId(const DPL::OptionalString& tzAppId);
121
122     /* This function will update of api-feature status.
123      * If status is true (feature rejected) plugin connected with this
124      * api feature mustn't be loaded durign widget launch.
125      */
126     void updateFeatureRejectStatus(const DbWidgetFeature &widgetFeature);
127
128   private:
129     //Methods used during widget registering
130     static DbWidgetHandle registerWidgetInfo(
131         const TizenAppId & tzAppId,
132         const TizenPkgId & tzPkgId,
133         const std::string & baseFolder,
134         AppType appType,
135         PkgType pkgType,
136         const ConfigParserData &widgetConfigurationInfo,
137         const IWidgetSecurity &widgetSecurity,
138         const boost::optional<DbWidgetHandle> handle =
139             boost::optional<DbWidgetHandle>());
140     static void registerWidgetExtendedInfo(
141         DbWidgetHandle widgetHandle,
142         time_t installedTime,
143         const DPL::OptionalString & splashImgSrc,
144         const DPL::OptionalString & backgroundPage,
145         const DPL::OptionalString & widgetInstalledPath);
146     static void registerWidgetLocalizedInfo(
147         DbWidgetHandle widgetHandle,
148         const ConfigParserData::LocalizedDataSet &localizedDataSet);
149     static void registerWidgetIcons(
150         DbWidgetHandle widgetHandle,
151         const WidgetRegisterInfo::LocalizedIconList &icons);
152     static void registerWidgetStartFile(
153         DbWidgetHandle widgetHandle,
154         const WidgetRegisterInfo::LocalizedStartFileList &startFiles);
155     static void registerWidgetPreferences(
156         DbWidgetHandle widgetHandle,
157         const WidgetRegisterInfo &regInfo);
158     static void registerWidgetFeatures(
159         DbWidgetHandle widgetHandle,
160         const ConfigParserData::FeaturesList &featuresList);
161     static void registerWidgetPrivilege(
162         DbWidgetHandle widgetHandle,
163         const ConfigParserData::PrivilegeList &privilegeList);
164     static void registerWidgetWindowModes(
165         DbWidgetHandle widgetHandle,
166         const ConfigParserData::StringsList &windowModes);
167     static void registerWidgetWarpInfo(
168         DbWidgetHandle widgetHandle,
169         const ConfigParserData::AccessInfoSet &accessInfoSet);
170     static void registerWidgetAllowNavigationInfo(
171         DbWidgetHandle widgetHandle,
172         const ConfigParserData::AllowNavigationInfoList &allowNavigationInfoList);
173     static void registerWidgetCertificates(
174         DbWidgetHandle widgetHandle,
175         const IWidgetSecurity &widgetSecurity);
176     static void registerCertificatesChains(
177         DbWidgetHandle widgetHandle,
178         CertificateSource certificateSource,
179         const CertificateChainList &list);
180     static void registerWidgetSettings(
181         DbWidgetHandle widgetHandle,
182          const  ConfigParserData::SettingsList &settingsList);
183     static void registerAppControl(
184         DbWidgetHandle widgetHandle,
185         const ConfigParserData::AppControlInfoList &appControlList);
186     static void registerEncryptedResouceInfo(
187         DbWidgetHandle widgetHandle,
188         const EncryptedFileList &encryptedFiles);
189
190     /**
191      * @brief registerExternalLocations Inserts new rows to
192      * WidgetExternalLocations
193      * @param externals list of files
194      */
195     static void registerExternalLocations(
196         DbWidgetHandle widgetHandle,
197         const ExternalLocationList &
198         externals);
199
200     static void registerServiceInternal(
201         const ConfigParserData::ServiceAppInfo &serviceAppInfo,
202         const WidgetRegisterInfo &widgetRegInfo,
203         const IWidgetSecurity &widgetSecurity);
204
205 #if USE(WEB_PROVIDER)
206     static void registerLiveBoxInfo(
207         DbWidgetHandle widgetHandle,
208         const WidgetRegisterInfo &regInfo);
209 #endif
210     static void registerWidgetInternal(
211         const TizenAppId & tzAppId,
212         const WidgetRegisterInfo &widgetRegInfo,
213         const IWidgetSecurity &widgetSecurity,
214         const boost::optional<DbWidgetHandle> handle =
215             boost::optional<DbWidgetHandle>());
216     static void unregisterWidgetInternal(const TizenAppId & tzAppId);
217     static void insertAppControlInfo(DbWidgetHandle handle,
218                                      DPL::String src,
219                                      DPL::String operation,
220                                      DPL::String uri,
221                                      DPL::String mime,
222                                      bool reload);
223 };
224 } // namespace WrtDB
225
226 #endif // WIDGET_DAO_H