356facfb3f3d28df3dac8e12f4ee2870eaa217a5
[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 <dpl/exception.h>
33 #include <dpl/db/orm.h>
34 #include <dpl/wrt-dao-ro/config_parser_data.h>
35 #include <dpl/wrt-dao-rw/property_dao.h>
36
37 namespace WrtDB {
38
39 class WidgetDAO : public WidgetDAOReadOnly
40 {
41   public:
42     typedef std::list<DPL::String> LanguageTagsList;
43
44     /**
45      * This is a constructor.
46      *
47      * @param[in] widgetHandle application id of widget.
48      * @param[in] widgetGUID application guid of widget.
49      */
50     WidgetDAO(DbWidgetHandle widgetHandle);
51     WidgetDAO(DPL::OptionalString widgetGUID);
52
53     /**
54      * Destructor
55      */
56     virtual ~WidgetDAO();
57
58     /**
59      * This method registers the widget information to the DB when it is installed.
60      *
61      * @see WidgetRegisterInfo
62      * @see UnRegisterWidget()
63      * @param[in] pWidgetRegisterInfo    Specified the widget's information needed to be registered.
64      * @return widget's app id issued by app manager; 0 represents a failure during register.
65      */
66     static DbWidgetHandle registerWidget(
67             const WidgetRegisterInfo &pWidgetRegisterInfo,
68             const IWacSecurity &wacSecurity,
69             const LanguageTagsList& languageTags);
70
71     /**
72      * This method removes a widget's information from EmDB.
73      *
74      * @see RegisterWidget()
75      * @param[in] widgetHandle    widget's app id
76      * @return true if succeed, false if fail.
77      */
78     static void unregisterWidget(DbWidgetHandle widgetHandle);
79
80     /* This method removes widget property
81      */
82     void removeProperty(const PropertyDAOReadOnly::WidgetPropertyKey &key);
83
84     /* This method sets widget property
85      */
86     void setProperty(const PropertyDAOReadOnly::WidgetPropertyKey &key,
87             const PropertyDAOReadOnly::WidgetPropertyValue &value,
88             bool readOnly = false);
89
90     /* set PkgName
91      */
92     void setPkgName(const DPL::OptionalString& pkgName);
93
94     /* This function will update of api-feature status.
95      * If status is true (feature rejected) plugin connected with this
96      * api feature mustn't be loaded durign widget launch.
97      */
98     void updateFeatureRejectStatus(const DbWidgetFeature &widgetFeature);
99
100   private:
101     //Methods used during widget registering
102     static DbWidgetHandle registerWidgetInfo(
103             const WidgetRegisterInfo &regInfo,
104             const IWacSecurity &wacSecurity);
105     static void registerWidgetExtendedInfo(
106             DbWidgetHandle widgetHandle,
107             const WidgetRegisterInfo &regInfo);
108     static void registerWidgetLocalizedInfo(
109             DbWidgetHandle widgetHandle,
110             const WidgetRegisterInfo &regInfo);
111     static void registerWidgetUserAgentLocales(
112             DbWidgetHandle widgetHandle,
113             const WidgetRegisterInfo &rInf,
114             const LanguageTagsList& languageTags);
115     static void registerWidgetIcons(
116             DbWidgetHandle widgetHandle,
117             const WidgetRegisterInfo &regInfo);
118     static void registerWidgetStartFile(
119             DbWidgetHandle widgetHandle,
120             const WidgetRegisterInfo &regInfo);
121     static void registerWidgetPreferences(
122             DbWidgetHandle widgetHandle,
123             const WidgetRegisterInfo &regInfo);
124     static void registerWidgetFeatures(
125             DbWidgetHandle widgetHandle,
126             const WidgetRegisterInfo &regInfo);
127     static void registerWidgetWindowModes(
128             DbWidgetHandle widgetHandle,
129             const WidgetRegisterInfo &regInfo);
130     static void registerWidgetWarpInfo(
131             DbWidgetHandle widgetHandle,
132             const WidgetRegisterInfo &regInfo);
133     static void registerWidgetCertificates(
134             DbWidgetHandle widgetHandle,
135             const IWacSecurity &wacSecurity);
136     static void registerLaunchCertificates(
137             DbWidgetHandle widgetHandle,
138             const CertificateChainList &list);
139     static void registerWidgetSettings(
140             DbWidgetHandle widgetHandle,
141             const WidgetRegisterInfo &regInfo);
142     static void registerAppService(
143             DbWidgetHandle widgetHandle,
144             const WidgetRegisterInfo &regInfo);
145 };
146
147 } // namespace WrtDB
148
149 #endif // WIDGET_DAO_H