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