Tizen 2.1 base
[platform/framework/native/uifw.git] / src / ui / resource / FUi_ResourceConfigParser.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FUi_ResourceConfigParser.cpp
20  * @brief       This is the header file for the ConfigParser.
21  *
22  * This header file contains the declarations of the ConfigParser.
23  */
24
25 #include <FBaseByteBuffer.h>
26 #include <FBaseInteger.h>
27 #include <FBaseString.h>
28 #include <FBaseSysLog.h>
29 #include <FBaseColHashMapT.h>
30 #include <FIoFile.h>
31 #include <FGrpColor.h>
32 #include <FGrpDimension.h>
33 #include <FBase_StringConverter.h>
34 #include "FUi_ResourceMapContainer.h"
35 #include "FUi_ResourceConfigParser.h"
36
37 using namespace Tizen::Base;
38 using namespace Collection;
39 using namespace Tizen::Io;
40 using namespace Tizen::Graphics;
41
42 namespace
43 {
44 class _ColorMatchingMapProvider
45         : public IHashCodeProviderT <String>
46 {
47 public:
48         _ColorMatchingMapProvider(void) {}
49         virtual ~_ColorMatchingMapProvider(void) {}
50
51         virtual int GetHashCode(const String& obj) const
52         {
53                 return obj.GetHashCode();
54         }
55 };
56
57 class _ColorMatchingMapComparer
58         : public IComparerT <String>
59 {
60 public:
61         _ColorMatchingMapComparer(void) {}
62         virtual ~_ColorMatchingMapComparer(void) {}
63         virtual result Compare(const String& obj1, const String& obj2, int& cmp) const
64         {
65                 if (obj1 == obj2)
66                 {
67                         cmp = 0;
68                         return E_SUCCESS;
69                 }
70                 else
71                 {
72                         cmp = -1;
73                         return E_SUCCESS;
74                 }
75         }
76 };
77 }
78
79 namespace
80 {
81 xmlSAXHandler mySaxHandler = {null, null, null, null, null, null, null, null, null, null, null, null, null, null,
82                                                         Tizen::Ui::_Resource::ConfigParser::StartSaxFunc,
83                                                         null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null};
84 }
85
86 namespace Tizen { namespace Ui { namespace _Resource
87 {
88 ConfigParser* pConfigXmlHandler = null;
89 HashMapT<String, String*>* pColorMatchingMap = null;
90
91 ConfigParser::ColorMatchingMap::ColorMatchingMap(void)
92         :HashMapT<String, String*>()
93         , __pProvider(null)
94         , __pComparer(null)
95 {
96         __pProvider = new (std::nothrow) _ColorMatchingMapProvider;
97         SysTryReturnVoidResult(NID_UI, __pProvider, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
98         __pComparer = new (std::nothrow) _ColorMatchingMapComparer;
99         SysTryReturnVoidResult(NID_UI, __pComparer, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
100 }
101 ConfigParser::ColorMatchingMap::~ColorMatchingMap(void)
102 {
103         result r = E_SUCCESS;
104         Collection::IMapEnumeratorT< String, String* >* pMapEnum = null;
105         if (Collection::HashMapT<String, String*>::GetCount() > 0)
106         {
107                 pMapEnum = Collection::HashMapT<String, String*>::GetMapEnumeratorN();
108                 SysTryReturn(NID_UI_ANIM, (pMapEnum != null), , E_SYSTEM, "[E_SYSTEM] System Error.");
109
110                 Collection::MapEntryT< String, String* > value;
111                 while ((pMapEnum->MoveNext() == E_SUCCESS))
112                 {
113                         r = pMapEnum->GetCurrent(value);
114                         SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System Error.");
115
116                         String* pObj = value.GetValue();
117                         delete pObj;
118                 }
119                 Collection::HashMapT<String, String*>::RemoveAll();
120         }
121         //fall through
122         CATCH:
123         delete pMapEnum;
124         delete __pProvider;
125         __pProvider = null;
126         delete __pComparer;
127         __pComparer = null;
128 }
129 bool
130 ConfigParser::ColorMatchingMap::Initialize(const String& version, const String& dVersion)
131 {
132         if (HashMapT<String, String*>::Construct(0,0,*__pProvider, *__pComparer) != E_SUCCESS)
133         {
134                 return false;
135         }
136         /*
137         if(version == L"beta1")
138         {
139                 Add(L"W0612", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_handle_text_disabled"));
140                 Add(L"B0622", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_list_item_divider_01"));
141                 Add(L"B0231", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_item_divider_line_01"));
142                 Add(L"B022", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_divider_line_01"));
143
144                 Add(L"B011", new (std::nothrow) String(L"DEFAULTCOLORTABLE::form_bg"));
145                 Add(L"B012", new (std::nothrow) String(L"DEFAULTCOLORTABLE::form_group_list_bg"));
146                 Add(L"B013", new (std::nothrow) String(L"DEFAULTCOLORTABLE::form_black"));
147                 Add(L"B014", new (std::nothrow) String(L"DEFAULTCOLORTABLE::form_white"));
148                 Add(L"B015", new (std::nothrow) String(L"DEFAULTCOLORTABLE::form_list_reorder_bg"));
149                 Add(L"B0211", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_bg"));
150                 Add(L"B0211D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_bg_disabled"));
151                 Add(L"B0212", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_context_item_bg"));
152                 Add(L"B0213", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_grid_item_bg"));
153                 Add(L"B0214", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_2nd_depth_item_bg"));
154                 Add(L"B0215", new (std::nothrow) String(L"DEFAULTCOLORTABLE::searchbar_bg"));
155                 Add(L"B0216", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_select_all_item_bg"));
156                 Add(L"B0217", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_item_bg"));
157                 Add(L"B0217D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_item_bg_disabled"));
158                 Add(L"B0221", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_divider_line_01"));
159                 Add(L"B0222", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_divider_line_02"));
160                 Add(L"B0231L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_item_divider_line_01"));
161                 Add(L"B0231L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_item_divider_line_02"));
162                 Add(L"B0232", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_item_bar"));
163                 Add(L"B0233", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_item_top_line"));
164                 Add(L"B031", new (std::nothrow) String(L"DEFAULTCOLORTABLE::indicator_bg"));
165                 Add(L"B041", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_bg_pressed"));
166                 Add(L"B042", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_item_bg_pressed"));
167                 Add(L"B043", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_item_bg_pressed"));
168                 Add(L"B044", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_item_bg_pressed"));
169                 Add(L"B0511", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_bg"));
170                 Add(L"B0512", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_optiontray_bg"));
171                 Add(L"B0513", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_tab_bg"));
172                 Add(L"B0514", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_tab_item_bg"));
173                 Add(L"B0514P1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_tab_item_bg_selected"));
174                 Add(L"B0514P2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_tab_item_bg_edit"));
175                 Add(L"B0515", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_toolbar_bg"));
176                 Add(L"B0516", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_toolbar_item_bg_pressed"));
177                 Add(L"B0517", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_tab_item_bg"));
178                 Add(L"B0517P1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_tab_item_selected"));
179                 Add(L"B0517P2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_tab_item_bg_edit"));
180                 Add(L"B0518", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_item_bg"));
181                 Add(L"B0518P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::tabbar_item_bg"));
182                 Add(L"B0520", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_softkey_item_bg_normal"));
183                 Add(L"B0520P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_softkey_item_bg_pressed"));
184                 Add(L"B052L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_item_normal"));
185                 Add(L"B052L1P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_item_selected"));
186                 Add(L"B052L1D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_item_disabled"));
187                 Add(L"B052L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_translucent_item_normal"));
188                 Add(L"B052L2P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_more_icon_pressed"));
189                 Add(L"B052L3", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_segment_font_normal"));
190                 Add(L"B052L4", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_text_normal"));
191                 Add(L"B052L4P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_text_pressed"));
192                 Add(L"B052L4D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_text_disabled"));
193                 Add(L"B052L5", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_title_text_normal"));
194                 Add(L"B052L6", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_tab_text_normal"));
195                 Add(L"B052L6P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_tab_text_pressed"));
196                 Add(L"B052L8", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_footer_text_normal"));
197                 Add(L"B052L8P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_footer_text_pressed"));
198                 Add(L"B052L8D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_footer_text_disabled"));
199                 Add(L"B052L9", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_softkey_item_icon_normal"));
200                 Add(L"B052L9P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_softkey_item_icon_pressed"));
201                 Add(L"B052L9D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_softkey_item_icon_disabled"));
202                 Add(L"B0531", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_segment_item_bg_normal"));
203                 Add(L"B0532", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_segment_item_bg_selected"));
204                 Add(L"B0533", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_segment_item_bg_normal"));
205                 Add(L"B0534", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_segment_item_bg_selected"));
206                 Add(L"B0535", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_translucent_segment_item_bg_normal"));
207                 Add(L"B0536", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_translucent_segment_item_bg_selected"));
208                 Add(L"B0537", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_expandable_line"));
209                 Add(L"B0545", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_button_item_bg_pressed"));
210                 Add(L"B0556", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_translucent_item_bg"));
211                 Add(L"B0557", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_translucent_item_bg_normal"));
212                 Add(L"B0558", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_translucent_item_bg_pressed"));
213                 Add(L"B061L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_bg"));
214                 Add(L"B061L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_title_bg"));
215                 Add(L"B061L3", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_bottom_bg"));
216                 Add(L"B061L4", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_bg"));
217                 Add(L"B0621", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_list_item_divider"));
218                 Add(L"B0622L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_list_item_divider_01"));
219                 Add(L"B0622L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_list_item_divider_02"));
220                 Add(L"B0623L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_grid_item_divider_01"));
221                 Add(L"B0623L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_grid_item_divider_02"));
222                 Add(L"B063L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_text"));
223                 Add(L"B063L1P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_item_text_pressed"));
224                 Add(L"B063L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::ticker_detail_text"));
225                 Add(L"B063L3", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_progress_text"));
226                 Add(L"B063L4", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_title_text"));
227                 Add(L"B063L5", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_item_text_normal"));
228                 Add(L"B063L5D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_item_text_disabled"));
229                 Add(L"B071", new (std::nothrow) String(L"DEFAULTCOLORTABLE::scroll_bar_bg"));
230                 Add(L"B0721", new (std::nothrow) String(L"DEFAULTCOLORTABLE::fastscroll_index_bar_text_normal"));
231                 Add(L"B0722", new (std::nothrow) String(L"DEFAULTCOLORTABLE::fastscroll_index_bar_text_selected"));
232                 Add(L"B0723", new (std::nothrow) String(L"DEFAULTCOLORTABLE::fastscroll_index_bar_bg"));
233                 Add(L"B0724", new (std::nothrow) String(L"DEFAULTCOLORTABLE::fastscroll_index_bar_line_01"));
234                 Add(L"B0725", new (std::nothrow) String(L"DEFAULTCOLORTABLE::fastscroll_index_bar_line_02"));
235                 Add(L"B0731", new (std::nothrow) String(L"DEFAULTCOLORTABLE::fastscroll_popup_bg"));
236                 Add(L"B0732", new (std::nothrow) String(L"DEFAULTCOLORTABLE::fastscroll_popup_text"));
237                 Add(L"B0741", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_fastscroll_index_bar_text_normal"));
238                 Add(L"B0742", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_fastscroll_index_bar_text_selected"));
239                 Add(L"B0743", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_fastscroll_index_bar_bg"));
240                 Add(L"B0744", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_fastscroll_index_bar_line_01"));
241                 Add(L"B0745", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_fastscroll_index_bar_line_02"));
242                 Add(L"B0751", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_fastscroll_popup_bg"));
243                 Add(L"F011L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_text_normal"));
244                 Add(L"F011L1P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_text_pressed"));
245                 Add(L"F011L1D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_text_disabled"));
246                 Add(L"F011L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_sub_text_setting_normal"));
247                 Add(L"F011L2D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_sub_text_setting_disabled"));
248                 Add(L"F011L3", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_sub_text_title_normal"));
249                 Add(L"F011L3D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_sub_text_title_disabled"));
250                 Add(L"F011L4", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_text_read_normal"));
251                 Add(L"F011L4D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_text_read_disabled"));
252                 Add(L"F011L5", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_title_text"));
253                 Add(L"F011L6", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_no_content_text"));
254                 Add(L"F011L7", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_3line_2nd_text_normal"));
255                 Add(L"F011L7D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_3line_2nd_text_disabled"));
256                 Add(L"F011L8", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_text_invalid"));
257                 Add(L"F011L9", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_text_white"));
258                 Add(L"F011L10", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_bubble_text"));
259                 Add(L"F011L11", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_contact_text"));
260                 Add(L"F011L12", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_name_text"));
261                 Add(L"F011L13", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_edit_mode_text_01"));
262                 Add(L"F011L14", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_edit_mode_text_02"));
263                 Add(L"F011L15", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_message_time_failed_text"));
264                 Add(L"F011L16", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_message_time_sent_text"));
265                 Add(L"F011L17", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_message_time_receive_text"));
266                 Add(L"F011L18", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_message_date_text"));
267                 Add(L"F011L19", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_message_group_chat_name_text"));
268                 Add(L"F011L20", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_sweep_text"));
269                 Add(L"F011L21", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_help_text"));
270                 Add(L"F011L22", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_message_help_text"));
271                 Add(L"F021L1i", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_icon_normal"));
272                 Add(L"F021L1iP", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_icon_pressed"));
273                 Add(L"F021L1iD", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_icon_disabled"));
274                 Add(L"F022L1i", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_star_icon_normal"));
275                 Add(L"F022L2i", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_star_icon_selected"));
276                 Add(L"F031L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_text_item_normal"));
277                 Add(L"F031L1P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_text_item_pressed"));
278                 Add(L"F031L1D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_text_item_disabled"));
279                 Add(L"F031L3", new (std::nothrow) String(L"DEFAULTCOLORTABLE::tabbar_item_text_normal"));
280                 Add(L"F031L3P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::tabbar_item_text_pressed"));
281                 Add(L"F031L3D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::tabbar_item_text_disabled"));
282                 Add(L"F032L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_icon_item_normal"));
283                 Add(L"F032L1P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_icon_item_pressed"));
284                 Add(L"F032L1D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_icon_item_disabled"));
285                 Add(L"F032L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::warning_font_icon_normal"));
286                 Add(L"F032L2P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::warning_font_icon_pressed"));
287                 Add(L"F032L2D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::warning_font_icon_disabled"));
288                 Add(L"F041i", new (std::nothrow) String(L"DEFAULTCOLORTABLE::searchbar_icon_normal"));
289                 Add(L"F041iD", new (std::nothrow) String(L"DEFAULTCOLORTABLE::searchbar_icon_disabled"));
290                 Add(L"F051", new (std::nothrow) String(L"DEFAULTCOLORTABLE::editfield_guide_text"));
291                 Add(L"F052", new (std::nothrow) String(L"DEFAULTCOLORTABLE::editfield_cursor"));
292                 Add(L"W011", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_bg"));
293                 Add(L"W012", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_button_bg"));
294                 Add(L"W013", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_context_item_button_bg"));
295                 Add(L"W0141", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_context_delete_button_bg_normal"));
296                 Add(L"W0141P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_context_delete_button_bg_pressed"));
297                 Add(L"W021L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_index_section_title_bg_normal"));
298                 Add(L"W021L1P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_index_section_title_bg_pressed"));
299                 Add(L"W021L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_index_section_title_line_normal"));
300                 Add(L"W021L2P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_index_section_title_line_pressed"));
301                 Add(L"W021L3", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_index_section_title_text_normal"));
302                 Add(L"W021L3P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_index_section_title_text_pressed"));
303                 Add(L"W031", new (std::nothrow) String(L"DEFAULTCOLORTABLE::searchbar_field_bg_normal"));
304                 Add(L"W031D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::searchbar_field_bg_disabled"));
305                 Add(L"W032", new (std::nothrow) String(L"DEFAULTCOLORTABLE::searchbar_text_normal"));
306                 Add(L"W032D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::searchbar_text_disabled"));
307                 Add(L"W041", new (std::nothrow) String(L"DEFAULTCOLORTABLE::editfield_bg"));
308                 Add(L"W0611", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_handle_text"));
309                 Add(L"W0611D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_handle_text_disabled"));
310                 Add(L"W062L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_bar_bg"));
311                 Add(L"W062L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_bar"));
312                 Add(L"W062L3", new (std::nothrow) String(L"DEFAULTCOLORTABLE::progress_circle_bar_bg"));
313                 Add(L"W062L4", new (std::nothrow) String(L"DEFAULTCOLORTABLE::progress_circle_bar"));
314                 Add(L"W063", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_bubble_bg"));
315                 Add(L"W0641", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_handle_bg"));
316                 Add(L"W0641P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_handle_bg_pressed"));
317                 Add(L"W0641D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_handle_bg_disabled"));
318                 Add(L"W0711", new (std::nothrow) String(L"DEFAULTCOLORTABLE::token_edit_item_bg_normal"));
319                 Add(L"W0712", new (std::nothrow) String(L"DEFAULTCOLORTABLE::token_edit_item_outline_normal"));
320                 Add(L"W0713", new (std::nothrow) String(L"DEFAULTCOLORTABLE::token_edit_item_bg_pressed"));
321                 Add(L"W0714", new (std::nothrow) String(L"DEFAULTCOLORTABLE::token_edit_item_outline_pressed"));
322                 Add(L"W0721", new (std::nothrow) String(L"DEFAULTCOLORTABLE::token_edit_expansion_button_bg"));
323                 Add(L"W0811", new (std::nothrow) String(L"DEFAULTCOLORTABLE::picker_detail_bar_bg"));
324                 Add(L"W0812", new (std::nothrow) String(L"DEFAULTCOLORTABLE::picker_button_bg"));
325                 Add(L"W082", new (std::nothrow) String(L"DEFAULTCOLORTABLE::picker_detail_bar_bg"));
326                 Add(L"W083", new (std::nothrow) String(L"DEFAULTCOLORTABLE::picker_keypad_button_bg"));
327                 Add(L"W084", new (std::nothrow) String(L"DEFAULTCOLORTABLE::picker_detail_bar_text_normal"));
328                 Add(L"W084P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::picker_detail_bar_text_pressed"));
329                 Add(L"W101", new (std::nothrow) String(L"DEFAULTCOLORTABLE::tabbar_item_bg_pressed"));
330                 Add(L"W111", new (std::nothrow) String(L"DEFAULTCOLORTABLE::optionmenu_bg"));
331                 Add(L"W1121", new (std::nothrow) String(L"DEFAULTCOLORTABLE::optionmenu_item_normal"));
332                 Add(L"W1122", new (std::nothrow) String(L"DEFAULTCOLORTABLE::optionmenu_item_pressed"));
333                 Add(L"W1123", new (std::nothrow) String(L"DEFAULTCOLORTABLE::optionmenu_item_disabled"));
334                 Add(L"W1211", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_table_item_bg"));
335                 Add(L"W1212", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_table_item_inputmode_bg"));
336                 Add(L"W1221", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_table_item_text"));
337                 Add(L"W1222", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_table_item_text_inputmode"));
338                 Add(L"W1223", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_table_item_text_pressed"));
339                 Add(L"W131", new (std::nothrow) String(L"DEFAULTCOLORTABLE::splitpanel_divider_bg"));
340                 Add(L"W132", new (std::nothrow) String(L"DEFAULTCOLORTABLE::splitpanel_divider_bg_pressed"));
341                 Add(L"W141", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_no_content_icon"));
342                 Add(L"W151", new (std::nothrow) String(L"DEFAULTCOLORTABLE::iconlist_item_border_normal"));
343                 Add(L"W152", new (std::nothrow) String(L"DEFAULTCOLORTABLE::iconlist_item_border_loading"));
344                 Add(L"W153", new (std::nothrow) String(L"DEFAULTCOLORTABLE::iconlist_item_border_selected"));
345         }
346         */
347         return true;
348 }
349 HashMapT<String, String*>*
350 ConfigParser::GetMatchingTable(void)
351 {
352         return pColorMatchingMap;
353 }
354
355 ConfigParser::ConfigParser(void)
356         : __pMapContainer(null)
357         , __currentAttribute(L"")
358 {
359 }
360 ConfigParser::~ConfigParser(void)
361 {
362         delete pColorMatchingMap;
363         pColorMatchingMap = null;
364 }
365 bool
366 ConfigParser::Parse(const String& filename, MapContainer & table)
367 {
368         File file;
369         ByteBuffer buffer;
370         FileAttributes attrib;
371         int readCount = 0;
372         byte* pXmlContents = null;
373         result r = E_SUCCESS;
374         int size = 0;
375
376         if (!File::IsFileExist(filename))
377         {
378                 return false;
379         }
380         r = file.Construct(filename, L"r");
381         if (IsFailed(r))
382         {
383                 SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Parse Failed -- XML file Construct.");
384                 return false;
385         }
386
387         r = Tizen::Io::File::GetAttributes(filename, attrib);
388         if (IsFailed(r))
389         {
390                 SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Parse Failed -- XML file GetAttributes.");
391                 return false;
392         }
393         size = (int) attrib.GetFileSize();
394
395         r = buffer.Construct(size);
396         if (IsFailed(r))
397         {
398                 SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Parse Failed - Buffer Construct Failed.");
399                 return false;
400         }
401
402         r = file.Read(buffer);
403         if (IsFailed(r))
404         {
405                 SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Parse Failed -- can't read the file.");
406                 return false;
407         }
408
409         readCount = buffer.GetPosition();
410         pXmlContents = new (std::nothrow) byte[readCount];
411         SysTryReturn(NID_UI, pXmlContents != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create XmlContents.");
412         buffer.Flip();
413
414         r = buffer.GetArray(pXmlContents, 0, readCount);
415         if (IsFailed(r))
416         {
417                 SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Parse Failed -- buffer.GetArray is Failed.");
418                 delete[] pXmlContents;
419                 return false;
420         }
421         char* pXmlBuffer = (char*) pXmlContents;
422
423         __pMapContainer = &table;
424         pConfigXmlHandler = this;
425         xmlSAXHandlerPtr pMySaxhandler = &mySaxHandler;
426         xmlSubstituteEntitiesDefault(1);
427         xmlSAXUserParseMemory(pMySaxhandler, null, pXmlBuffer, readCount);
428         pConfigXmlHandler = null;
429         delete [] pXmlContents;
430         return true;
431 }
432 void
433 ConfigParser::StartSaxFunc(void* pXmlParserCtxt, const xmlChar* pName, const xmlChar** pAttributes)
434 {
435         if (xmlStrcasecmp(pName, (xmlChar*) "Image") == 0)
436         {
437                 pConfigXmlHandler->AddImage(pAttributes);
438         }
439         else if (xmlStrcasecmp(pName, (xmlChar*) "Color") == 0)
440         {
441                 pConfigXmlHandler->AddColor(pAttributes);
442         }
443         else if (xmlStrcasecmp(pName, (xmlChar*) "Resource") == 0)
444         {
445                 pConfigXmlHandler->SetInformation(pAttributes);
446         }
447         else if (xmlStrcasecmp(pName, (xmlChar*) "Palette") == 0)
448         {
449                 pConfigXmlHandler->StartAttribute(pAttributes);
450         }
451         else if (xmlStrcasecmp(pName, (xmlChar*) "Control") == 0)
452         {
453                 pConfigXmlHandler->StartAttribute(pAttributes);
454         }
455         else
456         {
457                 ;//nothing to do
458         }
459 }
460
461 void
462 ConfigParser::SetInformation(const xmlChar** pAttributes)
463 {
464         if (pAttributes != null)
465         {
466                 for (int i = 0; (pAttributes[i] != null); i++)
467                 {
468                         if (xmlStrcasecmp(pAttributes[i], (xmlChar*) "Version") == 0)
469                         {
470                                 String version = (char*) pAttributes[++i];
471                                 __pMapContainer->SetVersion(version);
472 //                              ColorMatchingMap* matchingMap = new ColorMatchingMap;
473 //                              if (!matchingMap->Initialize(version))
474 //                              {
475 //                                      delete matchingMap;
476 //                              }
477 //                              else
478 //                              {
479 //                                      pColorMatchingMap = matchingMap;
480 //                              }
481                         }
482                 }
483         }
484 }
485
486 void
487 ConfigParser::StartAttribute(const xmlChar** pAttributes)
488 {
489         if (pAttributes != null)
490         {
491                 for (int i = 0; (pAttributes[i] != null); i++)
492                 {
493                         if (xmlStrcasecmp(pAttributes[i], (xmlChar*) "Name") == 0)
494                         {
495                                 __currentAttribute = (char*) pAttributes[++i];
496                         }
497                 }
498         }
499 }
500
501 void
502 ConfigParser::AddColor(const xmlChar** pAttributes)
503 {
504         if (pAttributes != null)
505         {
506                 for (int i = 0; (pAttributes[i] != null); i++)
507                 {
508                         if (pAttributes[++i] != null)
509                         {
510                                 bool exist = false;
511                                 String key = __currentAttribute + L"::" + (char*) pAttributes[i - 1];
512                                 if(__pMapContainer->GetColorMap()->ContainsKey(key, exist) == E_SUCCESS)
513                                 {
514                                         if(exist)
515                                         {
516                                                 Color color;
517                                                 GetValue((char*) pAttributes[i], color);
518                                                 SysLog(NID_UI,"The resource config parser changes resource color value, key %s, color %s", pAttributes[i - 1], pAttributes[i]);
519                                                 __pMapContainer->GetColorMap()->SetValue(key,&color);
520                                         }
521                                         else
522                                         {
523                                                 Color* pColor = new (std::nothrow) Color();
524                                                 SysTryReturnVoidResult(NID_UI, pColor, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
525                                                 SysLog(NID_UI,"The resource config parser adds resource color, key %s, color %s", pAttributes[i - 1], pAttributes[i]);
526                                                 GetValue((char*) pAttributes[i], *pColor);
527                                                 result r = __pMapContainer->GetColorMap()->Add(key, pColor);
528                                                 if(r != E_SUCCESS)
529                                                 {
530                                                         SysAssert(0);
531                                                 }
532                                         }
533                                 }
534                         }
535                 }
536         }
537 }
538
539 void
540 ConfigParser::AddImage(const xmlChar** pAttributes)
541 {
542         if (pAttributes != null)
543         {
544                 for (int i = 0; (pAttributes[i] != null); i++)
545                 {
546                         if (pAttributes[++i] != null)
547                         {
548                                 bool exist = false;
549                                 String key = __currentAttribute + L"::" + (char*) pAttributes[i - 1];
550                                 if(__pMapContainer->GetImageMap()->ContainsKey(key, exist) == E_SUCCESS)
551                                 {
552                                         if(exist)
553                                         {
554                                                 String value((char*) pAttributes[i]);
555                                                 value.SubString(1, value);
556                                                 __pMapContainer->GetImageMap()->SetValue(key,&value);
557                                         }
558                                         else
559                                         {
560                                                 String* pString = new (std::nothrow) String((char*) pAttributes[i]);
561                                                 SysTryReturnVoidResult(NID_UI, pString, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
562                                                 pString->SubString(1,*pString);
563                                                 result r = __pMapContainer->GetImageMap()->Add(key, pString);
564                                                 if(r != E_SUCCESS)
565                                                 {
566                                                         SysAssert(0);
567                                                 }
568                                         }
569                                 }
570                         }
571                 }
572         }
573 }
574
575 void
576 ConfigParser::ConvertStringToColor32(const char* pString, Color& color)
577 {
578         int index = 0;
579         int len = 0;
580         int gap = 0;
581         char ch;
582         unsigned int temp = 0;
583
584         len = strlen(pString);
585
586         if (len < 1)
587         {
588                 SysLog(NID_UI, "String is empty");
589                 return;
590         }
591
592         for (index = 1; index < len + 1; index++)
593         {
594                 ch = pString[index];
595                 if ((ch >= '0') && (ch <= '9'))
596                 {
597                         temp = temp << 4;
598                         gap = ch - '0';
599                         temp |= gap;
600
601                 }
602                 else if ((ch >= 'A') && (ch <= 'F'))
603                 {
604                         temp = temp << 4;
605                         gap = ch - 'A' + 10;
606                         temp |= gap;
607
608                 }
609                 else if ((ch >= 'a') && (ch <= 'f'))
610                 {
611                         temp = temp << 4;
612                         gap = ch - 'a' + 10;
613                         temp |= gap;
614                 }
615         }
616         color.SetRGB32(temp, true);
617 }
618
619 void
620 ConfigParser::GetValue(const String& value, String& out)
621 {
622         if (value.StartsWith(L"#", 0))
623         {
624                 value.SubString(1, out);
625         }
626         else if (value.StartsWith(L"$", 0))
627         {
628                 String* pString = null;
629                 if(__pMapContainer->GetImageMap()->GetValue(value, pString) != E_SUCCESS)
630                 {
631                         SysAssert(0);
632                 }
633                 out = *pString;
634         }
635         else
636         {
637                 //nothing to do
638         }
639 }
640 void
641 ConfigParser::GetValue(const String& value, Color& out)
642 {
643         if (value.StartsWith(L"#", 0))
644         {
645                 char* pString = _StringConverter::CopyToCharArrayN(value);
646                 ConvertStringToColor32(pString, out);
647                 delete [] pString;
648         }
649         else if (value.StartsWith(L"$", 0))
650         {
651                 Color* pColor = null;
652                 String key(L"");
653                 value.SubString(1, key);
654                 if(__pMapContainer->GetColorMap()->GetValue(key, pColor) != E_SUCCESS)
655                 {
656                         SysAssert(0);
657                 }
658                 out = *pColor;
659         }
660         else
661         {
662                 //nothing to do
663         }
664 }
665
666 }}}//Tizen::Ui