tizen beta 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 <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   private:
95     //Methods used during widget registering
96     static DbWidgetHandle registerWidgetInfo(
97             const WidgetRegisterInfo &regInfo,
98             const IWacSecurity &wacSecurity);
99     static void registerWidgetExtendedInfo(
100             DbWidgetHandle widgetHandle,
101             const WidgetRegisterInfo &regInfo);
102     static void registerWidgetLocalizedInfo(
103             DbWidgetHandle widgetHandle,
104             const WidgetRegisterInfo &regInfo);
105     static void registerWidgetUserAgentLocales(
106             DbWidgetHandle widgetHandle,
107             const WidgetRegisterInfo &rInf,
108             const LanguageTagsList& languageTags);
109     static void registerWidgetIcons(
110             DbWidgetHandle widgetHandle,
111             const WidgetRegisterInfo &regInfo);
112     static void registerWidgetStartFile(
113             DbWidgetHandle widgetHandle,
114             const WidgetRegisterInfo &regInfo);
115     static void registerWidgetPreferences(
116             DbWidgetHandle widgetHandle,
117             const WidgetRegisterInfo &regInfo);
118     static void registerWidgetFeatures(
119             DbWidgetHandle widgetHandle,
120             const WidgetRegisterInfo &regInfo);
121     static void registerWidgetWindowModes(
122             DbWidgetHandle widgetHandle,
123             const WidgetRegisterInfo &regInfo);
124     static void registerWidgetWarpInfo(
125             DbWidgetHandle widgetHandle,
126             const WidgetRegisterInfo &regInfo);
127     static void registerWidgetCertificates(
128             DbWidgetHandle widgetHandle,
129             const IWacSecurity &wacSecurity);
130     static void registerWidgetPowderData(
131             DbWidgetHandle widgetHandle,
132             const WidgetRegisterInfo &regInfo);
133     static void registerLaunchCertificates(
134             DbWidgetHandle widgetHandle,
135             const CertificateChainList &list);
136     static void registerWidgetSettings(
137             DbWidgetHandle widgetHandle,
138             const WidgetRegisterInfo &regInfo);
139     static void registerAppService(
140             DbWidgetHandle widgetHandle,
141             const WidgetRegisterInfo &regInfo);
142 };
143
144 } // namespace WrtDB
145
146 #endif // WIDGET_DAO_H