Fixed buildrequires dukgenerator to dukgenerator-devel
[framework/web/wrt-commons.git] / tests / files_localization / mockup_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_read_only.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
27 #ifndef _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_
28 #define _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_
29
30 #include <time.h>
31
32 #include <list>
33 #include <map>
34 #include <set>
35 #include <string>
36
37 #include <dpl/string.h>
38 #include <dpl/exception.h>
39 #include <dpl/optional_typedefs.h>
40
41 #include <dpl/wrt-dao-ro/common_dao_types.h>
42 //#include "../wrt-dao-ro/common_dao_types.h"
43
44 typedef DPL::OptionalString WidgetGUID;
45
46 namespace ConfigParserData {
47 struct Icon
48 {
49     Icon(const DPL::String& src) : src(src)
50     {}
51     DPL::String src;
52     DPL::OptionalInt width;
53     DPL::OptionalInt height;
54     bool operator==(const Icon&) const;
55     bool operator!=(const Icon&) const;
56     bool operator >(const Icon&) const;
57     bool operator>=(const Icon&) const;
58     bool operator <(const Icon&) const;
59     bool operator<=(const Icon&) const;
60 };
61 } // namespace ConfigParserData
62 namespace WrtDB {
63 typedef std::list<DPL::String> StringList;
64
65 struct WidgetLocalizedInfo
66 {
67     DPL::OptionalString name;
68     DPL::OptionalString shortName;
69     DPL::OptionalString description;
70     DPL::OptionalString license;
71     DPL::OptionalString licenseHref;
72 };
73
74 typedef std::list<DPL::String> LanguageTagList;
75
76 class WidgetDAO
77 {
78   public:
79     /**
80      * WidgetDAO Exception classes
81      */
82     class Exception
83     {
84       public:
85         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
86         DECLARE_EXCEPTION_TYPE(Base, DatabaseError)
87         DECLARE_EXCEPTION_TYPE(Base, ReadOnlyProperty)
88         DECLARE_EXCEPTION_TYPE(Base, GUIDisNull)
89         DECLARE_EXCEPTION_TYPE(Base, UnexpectedEmptyResult)
90         DECLARE_EXCEPTION_TYPE(Base, WidgetNotExist)
91         DECLARE_EXCEPTION_TYPE(Base, AlreadyRegistered)
92     };
93
94   protected:
95     DbWidgetHandle m_widgetHandle;
96
97   public:
98     struct WidgetLocalizedIconRow
99     {
100         int appId;
101         int iconId;
102         DPL::String widgetLocale;
103     };
104     typedef std::list<WidgetLocalizedIconRow> WidgetLocalizedIconList;
105
106     struct WidgetIconRow
107     {
108         int iconId;
109         int appId;
110         DPL::String iconSrc;
111         DPL::OptionalInt iconWidth;
112         DPL::OptionalInt iconHeight;
113     };
114     typedef std::list<WidgetIconRow> WidgetIconList;
115
116     struct WidgetStartFileRow
117     {
118         int startFileId;
119         int appId;
120         DPL::String src;
121     };
122     typedef std::list<WidgetStartFileRow> WidgetStartFileList;
123
124     struct WidgetLocalizedStartFileRow
125     {
126         int startFileId;
127         int appId;
128         DPL::String widgetLocale;
129         DPL::String type;
130         DPL::String encoding;
131     };
132     typedef std::list<WidgetLocalizedStartFileRow> LocalizedStartFileList;
133
134     /**
135      * This is a constructor.
136      *
137      * @param[in] widgetHandle application id of widget.
138      */
139     WidgetDAO(DbWidgetHandle widgetHandle) :
140         m_widgetHandle(widgetHandle)
141     {}
142
143     /**
144      * Destructor
145      */
146     virtual ~WidgetDAO(){}
147
148     /**
149      * This method returns widget handle(m_widgetHandle).
150      *
151      * @return widget handle(m_widgetHandle).
152      * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
153      * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
154      * DB table.
155      */
156     DbWidgetHandle getHandle() const
157     {
158         return m_widgetHandle;
159     }
160     DbWidgetHandle getHandle(const WidgetGUID GUID) const;
161     static DbWidgetHandle getHandle(const DPL::String tizenAppId);
162
163     /**
164      * This method returns the root directory of widget resource.
165      *
166      * @return path name of root directory.
167      * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
168      * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
169      * DB table.
170      */
171     DPL::String getPath() const;
172     void setPath(const DPL::String &path) const;
173
174     /**
175      * This method returns the defaultlocale for the widget.
176      *
177      * @return defaultlocale
178      * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
179      * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
180      *  DB table.
181      */
182     DPL::OptionalString getDefaultlocale() const;
183
184     /**
185      * This method returns list of localized icons files;
186      *
187      * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
188      * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
189      *  DB table.
190      */
191     WidgetLocalizedIconList getLocalizedIconList() const;
192
193     /**
194      * This method returns list of icons files;
195      *
196      * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
197      * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
198      *  DB table.
199      */
200     WidgetIconList getIconList() const;
201
202     /**
203      * This method returns list of localized start files;
204      *
205      * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
206      * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
207      *  DB table.
208      */
209     LocalizedStartFileList getLocalizedStartFileList() const;
210     void setLocalizedStartFileList(const LocalizedStartFileList &list) const;
211     /**
212      * This method returns list of start files;
213      *
214      * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
215      * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
216      *  DB table.
217      */
218     WidgetStartFileList getStartFileList() const;
219     void setStartFileList(const WidgetStartFileList &list) const;
220
221     WidgetLocalizedInfo getLocalizedInfo(const DPL::String& languageTag) const;
222
223   protected:
224     static std::map<DbWidgetHandle, WidgetStartFileList> s_startFileMap;
225     static std::map<DbWidgetHandle,
226                     LocalizedStartFileList> s_localizedStartFileMap;
227     static std::map<DbWidgetHandle, DPL::String> s_pathMap;
228 };
229 } // namespace WrtDB
230
231 #endif // _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_
232