Fixed Nabi Issues 49466,55718,55225,52332
[apps/osp/Internet.git] / src / IntSettingForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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 //!Internet SettingForm class
18 /*@file:        IntSettingForm.cpp
19  *@brief:       The SettingForm
20  */
21
22 #include <FApp.h>
23 #include <FGraphics.h>
24 #include <FUi.h>
25
26 #include "IntCommonLib.h"
27 #include "IntConfirmationPopup.h"
28 #include "IntDefaultCustomItem.h"
29 #include "IntDropDownCustomItem.h"
30 #include "IntHistoryPresentationModel.h"
31 #include "IntInternetApp.h"
32 #include "IntMultipleWindowPresentationModel.h"
33 #include "IntNotificationPanel.h"
34 #include "IntRadioCustomItem.h"
35 #include "IntSceneRegister.h"
36 #include "IntSettingForm.h"
37 #include "IntSettingPresentationModel.h"
38 #include "IntSettingToggleCustomItem.h"
39
40
41 using namespace Tizen::App;
42 using namespace Tizen::Base;
43 using namespace Tizen::Base::Collection;
44 using namespace Tizen::Graphics;
45 using namespace Tizen::System;
46 using namespace Tizen::Ui;
47 using namespace Tizen::Ui::Controls;
48 using namespace Tizen::Ui::Scenes;
49
50
51
52 SettingForm::SettingForm(void)
53 : __fontValue(0),__pResetPopup(null),__pWindowInfo(null) , __pConfirmationPopup(null),__pNotification(null)
54 {
55         __currentURL = L"";
56         __pList = null;
57         InitializeSettingValues();
58         __fontSize = 44;
59 }
60
61 SettingForm::~SettingForm(void)
62 {
63         if (pGroupItemCount)
64         {
65                 delete[] pGroupItemCount;
66                 pGroupItemCount = null;
67         }
68 }
69
70 void
71 SettingForm::InitializeSettingValues(void)
72 {
73         AppLog("SettingForm::InitializeSettingValues homepage %ls",SettingPresentationModel::GetInstance()->GetHomepage().GetPointer());
74         groupCount = 5;
75         pGroupItemCount = new(std::nothrow) int[5];
76         pGroupItemCount[0] = 5;  //Homepage
77         pGroupItemCount[1] = 6;  //Page content settings
78         pGroupItemCount[2] = 9;  //Private and Security
79         pGroupItemCount[3] = 4;  //Search
80         pGroupItemCount[4] = 1;  //Website settings and Reset
81
82         for (int iter = (int) SETTING_INVALID + 1; iter < (int) SETTING_MAX; iter++)
83         {
84                 settingInfo[iter].isSelected = false;
85         }
86
87         AppLogDebug("image display %d", (int) SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
88         settingInfo[SETTING_HOMEPAGE_TITLE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_HOMEPAGE");
89         settingInfo[SETTING_HOMEPAGE_TITLE].subText = SettingPresentationModel::GetInstance()->GetHomepage();
90         settingInfo[SETTING_HOMEPAGE_TITLE].itemType = ITEM_TYPE_DROPDOWN;
91
92         settingInfo[SETTING_CURRENT_PAGE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_CURRENT_PAGE");
93         settingInfo[SETTING_CURRENT_PAGE].subText = L"";
94         settingInfo[SETTING_CURRENT_PAGE].itemType = ITEM_TYPE_RADIO;
95
96         settingInfo[SETTING_BLANK_PAGE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_BLANK_PAGE");
97         settingInfo[SETTING_BLANK_PAGE].subText = L"";
98         settingInfo[SETTING_BLANK_PAGE].itemType = ITEM_TYPE_RADIO;
99         if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
100         {
101                 settingInfo[SETTING_BLANK_PAGE].isSelected = true;
102         }
103
104         settingInfo[SETTING_MOST_VISITED_SITE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_MOST_VISITED_SITES");
105         settingInfo[SETTING_MOST_VISITED_SITE].subText = L"";
106         settingInfo[SETTING_MOST_VISITED_SITE].itemType = ITEM_TYPE_RADIO;
107         if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
108         {
109                 settingInfo[SETTING_MOST_VISITED_SITE].isSelected = true;
110         }
111         WindowInfo* pWindowInfo = null;
112         String curUrl = SettingPresentationModel::GetInstance()->GetFavoriteUrl();
113         AppLog("SettingForm::OnSceneActivatedN check1");
114
115         settingInfo[SETTING_FAVORITE_URL].titleText = L"http://www.tizen.org";
116         if (SettingPresentationModel::GetInstance()->GetFavoriteUrl().CompareTo(L"") == 0)
117         {
118                 SettingPresentationModel::GetInstance()->SetFavoriteValue(L"http://www.tizen.org");
119         }
120         settingInfo[SETTING_FAVORITE_URL].subText = L"";
121         settingInfo[SETTING_FAVORITE_URL].itemType = ITEM_TYPE_RADIO;
122
123         String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
124         if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
125         {
126                 settingInfo[SETTING_MOST_VISITED_SITE].isSelected = true;
127                 settingInfo[SETTING_BLANK_PAGE].isSelected = false;
128                 settingInfo[SETTING_CURRENT_PAGE].isSelected = false;
129                 settingInfo[SETTING_FAVORITE_URL].isSelected = false;
130                 SettingPresentationModel::GetInstance()->SetHomepage(L"IDS_BR_BODY_MOST_VISITED_SITES");
131         }
132         else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
133         {
134                 settingInfo[SETTING_MOST_VISITED_SITE].isSelected = false;
135                 settingInfo[SETTING_BLANK_PAGE].isSelected = true;
136                 settingInfo[SETTING_CURRENT_PAGE].isSelected = false;
137                 settingInfo[SETTING_FAVORITE_URL].isSelected = false;
138                 SettingPresentationModel::GetInstance()->SetHomepage(L"IDS_BR_BODY_BLANK_PAGE");
139         }
140         else
141         {
142                 settingInfo[SETTING_MOST_VISITED_SITE].isSelected = false;
143                 settingInfo[SETTING_BLANK_PAGE].isSelected = false;
144                 settingInfo[SETTING_CURRENT_PAGE].isSelected = false;
145                 settingInfo[SETTING_FAVORITE_URL].isSelected = true;
146         }
147
148         settingInfo[SETTING_DEFAULT_VIEW_TITLE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_DEFAULT_VIEW");
149         settingInfo[SETTING_DEFAULT_VIEW_TITLE].subText = CommonUtil::GetString(SettingPresentationModel::GetInstance()->GetDefaultView());
150         settingInfo[SETTING_DEFAULT_VIEW_TITLE].itemType = ITEM_TYPE_DROPDOWN;
151
152         settingInfo[SETTING_FIT_TO_WIDTH].titleText = CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH");
153         settingInfo[SETTING_FIT_TO_WIDTH].subText = L"";
154         settingInfo[SETTING_FIT_TO_WIDTH].itemType = ITEM_TYPE_RADIO;
155         settingInfo[SETTING_FIT_TO_WIDTH].isSelected = !(String::Compare(settingInfo[SETTING_FIT_TO_WIDTH].titleText, settingInfo[SETTING_DEFAULT_VIEW_TITLE].subText));
156
157         settingInfo[SETTING_READABLE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_READABLE");
158         settingInfo[SETTING_READABLE].subText = L"";
159         settingInfo[SETTING_READABLE].itemType = ITEM_TYPE_RADIO;
160         settingInfo[SETTING_READABLE].isSelected = !(String::Compare(settingInfo[SETTING_READABLE].titleText, settingInfo[SETTING_DEFAULT_VIEW_TITLE].subText));
161
162         settingInfo[SETTING_RUN_JAVASCRIPT].titleText = CommonUtil::GetString(L"IDS_BR_BODY_RUN_JAVASCRIPT");
163         settingInfo[SETTING_RUN_JAVASCRIPT].subText = L"";
164         settingInfo[SETTING_RUN_JAVASCRIPT].itemType = ITEM_TYPE_TOGGLE;
165         settingInfo[SETTING_RUN_JAVASCRIPT].isSelected = SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled();
166
167         settingInfo[SETTING_DISPLAY_IMAGES].titleText = CommonUtil::GetString(L"IDS_BR_OPT_LOAD_IMAGES");
168         settingInfo[SETTING_DISPLAY_IMAGES].subText = L"";
169         settingInfo[SETTING_DISPLAY_IMAGES].itemType = ITEM_TYPE_TOGGLE;
170         settingInfo[SETTING_DISPLAY_IMAGES].isSelected = SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled();
171
172         settingInfo[SETTING_BLOCK_POPUP].titleText = CommonUtil::GetString(L"IDS_BR_BODY_BLOCK_POP_UPS_ABB");
173         settingInfo[SETTING_BLOCK_POPUP].subText = L"";
174         settingInfo[SETTING_BLOCK_POPUP].itemType = ITEM_TYPE_TOGGLE;
175         settingInfo[SETTING_BLOCK_POPUP].isSelected = !SettingPresentationModel::GetInstance()->IsBlockPopUp();
176
177         settingInfo[SETTING_CLEAR_CACHE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_CLEAR_CACHE");
178         settingInfo[SETTING_CLEAR_CACHE].subText = L"";
179         settingInfo[SETTING_CLEAR_CACHE].itemType = ITEM_TYPE_NORMAL;
180
181         settingInfo[SETTING_CLEAR_HISTORY].titleText = CommonUtil::GetString(L"IDS_BR_BODY_CLEAR_HISTORY");
182         settingInfo[SETTING_CLEAR_HISTORY].subText = L"";
183         settingInfo[SETTING_CLEAR_HISTORY].itemType = ITEM_TYPE_NORMAL;
184
185         settingInfo[SETTING_SHOW_SECURITY_WARNINGS].titleText = CommonUtil::GetString(L"IDS_BR_BODY_SHOW_SECURITY_WARNINGS");
186         settingInfo[SETTING_SHOW_SECURITY_WARNINGS].subText = L"";
187         settingInfo[SETTING_SHOW_SECURITY_WARNINGS].itemType = ITEM_TYPE_TOGGLE;
188         settingInfo[SETTING_SHOW_SECURITY_WARNINGS].isSelected = SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled();
189
190         settingInfo[SETTING_ACCEPT_COOKIES].titleText = CommonUtil::GetString(L"IDS_BR_BODY_ACCEPT_COOKIES");
191         settingInfo[SETTING_ACCEPT_COOKIES].subText = L"";
192         settingInfo[SETTING_ACCEPT_COOKIES].itemType = ITEM_TYPE_TOGGLE;
193         settingInfo[SETTING_ACCEPT_COOKIES].isSelected = SettingPresentationModel::GetInstance()->IsCookiesEnabled();
194
195         settingInfo[SETTING_CLEAR_COOKIE_DATA].titleText = CommonUtil::GetString(L"IDS_BR_BODY_CLEAR_ALL_COOKIE_DATA");
196         settingInfo[SETTING_CLEAR_COOKIE_DATA].subText = CommonUtil::GetString(L"IDS_BR_BODY_COOKIES");
197         settingInfo[SETTING_CLEAR_COOKIE_DATA].itemType = ITEM_TYPE_NORMAL;
198
199         settingInfo[SETTING_REMEMBER_FORM_DATA].titleText = CommonUtil::GetString(L"IDS_BR_BODY_REMEMBER_FORM_DATA");
200         settingInfo[SETTING_REMEMBER_FORM_DATA].subText = L"";
201         settingInfo[SETTING_REMEMBER_FORM_DATA].itemType = ITEM_TYPE_TOGGLE;
202         settingInfo[SETTING_REMEMBER_FORM_DATA].isSelected = SettingPresentationModel::GetInstance()->IsRememberFormData();
203
204         settingInfo[SETTING_CLEAR_FORM_DATA].titleText = CommonUtil::GetString(L"IDS_BR_BODY_CLEAR_FORM_DATA");
205         settingInfo[SETTING_CLEAR_FORM_DATA].subText = CommonUtil::GetString(L"IDS_BR_HEADER_FORM_DATA");
206         settingInfo[SETTING_CLEAR_FORM_DATA].itemType = ITEM_TYPE_NORMAL;
207
208         settingInfo[SETTING_REMEMBER_PASSWORD].titleText = CommonUtil::GetString(L"IDS_BR_BODY_REMEMBER_PASSWORDS");
209         settingInfo[SETTING_REMEMBER_PASSWORD].subText = L"";
210         settingInfo[SETTING_REMEMBER_PASSWORD].itemType = ITEM_TYPE_TOGGLE;
211         settingInfo[SETTING_REMEMBER_PASSWORD].isSelected = SettingPresentationModel::GetInstance()->IsRememberPassword();
212
213
214         settingInfo[SETTING_CLEAR_PASSWORDS].titleText = CommonUtil::GetString(L"IDS_BR_BODY_CLEAR_PASSWORDS");
215         settingInfo[SETTING_CLEAR_PASSWORDS].subText = L"";
216         settingInfo[SETTING_CLEAR_PASSWORDS].itemType = ITEM_TYPE_NORMAL;
217
218         settingInfo[SETTING_SEARCH_ENGINE_TITLE].titleText = CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_ENGINE");
219         settingInfo[SETTING_SEARCH_ENGINE_TITLE].subText = SettingPresentationModel::GetInstance()->GetSearchEngine();
220         settingInfo[SETTING_SEARCH_ENGINE_TITLE].itemType = ITEM_TYPE_DROPDOWN;
221
222         settingInfo[SETTING_SEARCH_ENGINE_YAHOO].titleText = L"Yahoo";  //CommonUtil::GetString(L"IDS_BR_BODY_YAHOO");
223         settingInfo[SETTING_SEARCH_ENGINE_YAHOO].subText = L"";
224         settingInfo[SETTING_SEARCH_ENGINE_YAHOO].itemType = ITEM_TYPE_RADIO;
225         settingInfo[SETTING_SEARCH_ENGINE_YAHOO].isSelected = !(String::Compare(settingInfo[SETTING_SEARCH_ENGINE_YAHOO].titleText, settingInfo[SETTING_SEARCH_ENGINE_TITLE].subText));
226
227         settingInfo[SETTING_SEARCH_ENGINE_NAVER].titleText = L"Naver";          //CommonUtil::GetString(L"IDS_BR_BODY_NAVER");
228         settingInfo[SETTING_SEARCH_ENGINE_NAVER].subText = L"";
229         settingInfo[SETTING_SEARCH_ENGINE_NAVER].itemType = ITEM_TYPE_RADIO;
230         settingInfo[SETTING_SEARCH_ENGINE_NAVER].isSelected = !(String::Compare(settingInfo[SETTING_SEARCH_ENGINE_NAVER].titleText, settingInfo[SETTING_SEARCH_ENGINE_TITLE].subText));
231
232         settingInfo[SETTING_SEARCH_ENGINE_GOOGLE].titleText = L"Google";//CommonUtil::GetString(L"IDS_COM_BODY_GOOGLE");
233         settingInfo[SETTING_SEARCH_ENGINE_GOOGLE].subText = L"";
234         settingInfo[SETTING_SEARCH_ENGINE_GOOGLE].itemType = ITEM_TYPE_RADIO;
235         settingInfo[SETTING_SEARCH_ENGINE_GOOGLE].isSelected = !(String::Compare(settingInfo[SETTING_SEARCH_ENGINE_GOOGLE].titleText, settingInfo[SETTING_SEARCH_ENGINE_TITLE].subText));
236
237         settingInfo[SETTING_RESET_TO_DEFAULT].titleText = CommonUtil::GetString(L"IDS_BR_BODY_RESET_TO_DEFAULT");
238         settingInfo[SETTING_RESET_TO_DEFAULT].subText = L"";
239         settingInfo[SETTING_RESET_TO_DEFAULT].itemType = ITEM_TYPE_NORMAL;
240 }
241
242 bool
243 SettingForm::Initialize(void)
244 {
245         result r = E_FAILURE;
246
247         r = Construct(L"IDL_SETTING_FORM");
248         if (IsFailed(r))
249         {
250                 return false;
251         }
252         return true;
253 }
254
255 result
256 SettingForm::OnInitializing(void)
257 {
258         result r = E_FAILURE;
259         Footer* pFooter = NULL;
260         SceneManager* pSceneManager = NULL;
261
262         __fontSize = CommonUtil::GetFontSize();
263
264         bool isHwKeySupported = false;
265
266         //SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR);
267         __pList = static_cast< GroupedListView* >(GetControl(L"IDC_SETTING_LIST"));
268         if ( __pList != NULL )
269         {
270
271                 r = __pList->SetItemProvider(*this);
272                 TryCatch(!IsFailed(r),,"setItemProvider failed with error %s",GetErrorMessage(r));
273                 __pList->AddGroupedListViewItemEventListener(*this);
274         }
275
276 //      pFooter = GetFooter();
277 //      if (pFooter)
278 //      {
279 //              AppLogDebug("setting back button");
280 //              pFooter->SetBackButtonEnabled(true);
281 //      }
282         SetFormBackEventListener(this);
283         AppLog("SetFormBackEventListener result %s",GetErrorMessage(GetLastResult()));
284         pSceneManager = SceneManager::GetInstance();
285         if (pSceneManager != null)
286         {
287                 r = pSceneManager->AddSceneEventListener(IDSCN_SETTINGS, *this);
288                 TryCatch(!IsFailed(r),,"AddSceneEventListener failed with error %s",GetErrorMessage(r));
289         }
290         AddOrientationEventListener(*this);
291
292         CATCH:
293         return r;
294 }
295
296 void
297 SettingForm::OnGroupedListViewContextItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListContextItemStatus status)
298 {
299
300 }
301
302 void
303 SettingForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListItemStatus status)
304 {
305         int effectiveIndex = 0;
306         SettingPresentationModel* pSettingMgr = SettingPresentationModel::GetInstance();
307
308         if (pSettingMgr == null)
309                 return;
310
311         for (int i = 0; i < groupIndex; i++)
312                 effectiveIndex = effectiveIndex + pGroupItemCount[i];
313         effectiveIndex = effectiveIndex + itemIndex;
314
315         if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_DROPDOWN)
316         {
317                 AppLogDebug("refreshing data child count is %d", settingInfo[effectiveIndex].childCount);
318                 if (settingInfo[effectiveIndex].isOpen == false)
319                 {
320                         settingInfo[effectiveIndex].isOpen = true;
321                         settingInfo[effectiveIndex].childCount = 0;
322                         for (int iter = effectiveIndex + 1; iter < SETTING_MAX; iter++)
323                         {
324                                 if (settingInfo[iter].itemType == ITEM_TYPE_RADIO)
325                                         settingInfo[effectiveIndex].childCount++;
326                                 else
327                                         break;
328                         }
329 /*
330                         listView.RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
331                         for(int iter = 0; iter < settingInfo[effectiveIndex].childCount; iter++)
332                         {
333                                 listView.RefreshList(groupIndex, itemIndex + iter + 1, LIST_REFRESH_TYPE_ITEM_MODIFY);
334                         }
335 */
336                         listView.UpdateList();
337                 }
338                 else
339                 {
340                         settingInfo[effectiveIndex].isOpen = false;
341 /*
342                         listView.RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
343                         for(int iter = 0; iter < settingInfo[effectiveIndex].childCount; iter++)
344                         {
345                                 listView.RefreshList(groupIndex, itemIndex + iter + 1, LIST_REFRESH_TYPE_ITEM_MODIFY);
346                         }
347 */
348                         listView.UpdateList();
349                 }
350         }
351         else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_RADIO)
352         {
353                 int parentIndex = 0;
354                 for (parentIndex = effectiveIndex; parentIndex > SETTING_INVALID; parentIndex--)
355                 {
356                         if (settingInfo[parentIndex].itemType == ITEM_TYPE_DROPDOWN)
357                                 break;
358                 }
359                 settingInfo[parentIndex].subText = settingInfo[effectiveIndex].titleText;
360
361                 listView.RefreshList(groupIndex, itemIndex - (effectiveIndex - parentIndex), LIST_REFRESH_TYPE_ITEM_MODIFY);
362                 listView.RefreshList(groupIndex, parentIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
363                 for (int iter = 0; iter < settingInfo[parentIndex].childCount; iter++)
364                 {
365                         if (parentIndex + iter + 1 != effectiveIndex)
366                         {
367                                 AppLogDebug("long effectiveIndex %d set to false", itemIndex - (effectiveIndex - parentIndex) + iter + 1);
368                                 settingInfo[parentIndex + iter + 1].isSelected = false;
369                         }
370                         else
371                         {
372                                 AppLogDebug("effectiveIndex %d set to true", effectiveIndex);
373                                 settingInfo[effectiveIndex].isSelected = true;
374                         }
375                         if (effectiveIndex == SETTING_CURRENT_PAGE)
376                         {
377                                 settingInfo[SETTING_CURRENT_PAGE].isSelected = false;
378                                 settingInfo[SETTING_FAVORITE_URL].isSelected = true;
379                         }
380                         listView.RefreshList(groupIndex, itemIndex - (effectiveIndex - parentIndex) + iter + 1, LIST_REFRESH_TYPE_ITEM_MODIFY);
381                 }
382 //              listView.UpdateList();
383                 //listView.ScrollToItem(groupIndex, itemIndex, LIST_SCROLL_ITEM_ALIGNMENT_TOP);
384                 Invalidate(true);
385         }
386         else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_TOGGLE)
387         {
388                 if (settingInfo[effectiveIndex].isSelected == true)
389                 {
390                         settingInfo[effectiveIndex].isSelected = false;
391                 }
392                 else
393                 {
394                         settingInfo[effectiveIndex].isSelected = true;
395                 }
396 //              listView.RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
397                 if(__pList != null)
398                 {
399                         __pList->SetItemChecked(groupIndex, itemIndex, settingInfo[effectiveIndex].isSelected);
400                 }
401         }
402
403         switch (effectiveIndex)
404         {
405         case SETTING_CURRENT_PAGE:
406                 //SettingPresentationModel::GetInstance()->SetHomepage(settingInfo[SETTING_FAVORITE_URL].titleText);
407                 AppLog("setting current page currentURL is =%ls",__currentURL.GetPointer());
408                 if (__currentURL.CompareTo(L"") != 0)
409                 {
410                         AppLog("setting current page currentURL is =%ls",__currentURL.GetPointer());
411                         SettingPresentationModel::GetInstance()->SetHomepage(CommonUtil::GetString(L"IDS_BR_BODY_USER_HOMEPAGE"));
412                         SettingPresentationModel::GetInstance()->SetFavoriteValue(__currentURL);
413                         settingInfo[SETTING_FAVORITE_URL].titleText = __currentURL;
414 //                      listView.RefreshList(groupIndex, effectiveIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
415 //                      listView.RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
416 //                      listView.UpdateList();
417                 }
418                 break;
419         case SETTING_BLANK_PAGE:
420                 //SettingPresentationModel::GetInstance()->SetHomepage(settingInfo[SETTING_BLANK_PAGE].titleText);
421                 SettingPresentationModel::GetInstance()->SetHomepage((L"IDS_BR_BODY_BLANK_PAGE"));
422                 AppLog("GetHomepage() %ls",SettingPresentationModel::GetInstance()->GetHomepage().GetPointer());
423 //              listView.RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
424 //              listView.UpdateList();
425
426                 break;
427         case SETTING_MOST_VISITED_SITE:
428                 SettingPresentationModel::GetInstance()->SetHomepage(L"IDS_BR_BODY_MOST_VISITED_SITES");
429 //              listView.RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
430 //              listView.UpdateList();
431                 break;
432
433         case SETTING_FAVORITE_URL:
434                 //SettingPresentationModel::GetInstance()->SetHomepage(settingInfo[SETTING_FAVORITE_URL].titleText);
435                 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_EDIT_HOMEPAGE_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
436                 break;
437
438         case SETTING_FIT_TO_WIDTH:
439                 SettingPresentationModel::GetInstance()->SetDefaultView(L"IDS_BR_BODY_FIT_TO_WIDTH");
440 //              listView.RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
441 //              listView.UpdateList();
442                 break;
443
444         case SETTING_READABLE:
445                 SettingPresentationModel::GetInstance()->SetDefaultView(L"IDS_BR_BODY_READABLE");
446 //              listView.RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
447 //              listView.UpdateList();
448                 break;
449
450         case SETTING_RUN_JAVASCRIPT:
451                 SettingPresentationModel::GetInstance()->SetRunJavascriptEnabled(settingInfo[SETTING_RUN_JAVASCRIPT].isSelected);
452                 break;
453
454         case SETTING_DISPLAY_IMAGES:
455                 SettingPresentationModel::GetInstance()->SetDisplayImagesEnabled(settingInfo[SETTING_DISPLAY_IMAGES].isSelected);
456                 break;
457
458         case SETTING_BLOCK_POPUP:
459                 SettingPresentationModel::GetInstance()->SetBlockPopUp(!settingInfo[SETTING_BLOCK_POPUP].isSelected);
460                 break;
461
462         case SETTING_CLEAR_CACHE:
463                 ClearCache();
464                 break;
465
466         case SETTING_CLEAR_HISTORY:
467                 ClearHistory();
468                 break;
469
470         case SETTING_SHOW_SECURITY_WARNINGS:
471                 SettingPresentationModel::GetInstance()->SetSecurityWarningsEnabled(settingInfo[SETTING_SHOW_SECURITY_WARNINGS].isSelected);
472                 break;
473
474         case SETTING_ACCEPT_COOKIES:
475                 SettingPresentationModel::GetInstance()->SetCookiesEnabled(settingInfo[SETTING_ACCEPT_COOKIES].isSelected);
476                 break;
477
478         case SETTING_CLEAR_COOKIE_DATA:
479                 ClearCookie();
480                 break;
481
482         case SETTING_REMEMBER_FORM_DATA:
483                 SettingPresentationModel::GetInstance()->SetRememberFormData(settingInfo[SETTING_REMEMBER_FORM_DATA].isSelected);
484                 break;
485
486         case SETTING_CLEAR_FORM_DATA:
487                 ClearFormData();
488                 break;
489
490         case SETTING_CLEAR_PASSWORDS:
491                 ClearPasswords();
492                 break;
493
494         case SETTING_REMEMBER_PASSWORD:
495                 SettingPresentationModel::GetInstance()->SetRememberPassword(settingInfo[SETTING_REMEMBER_PASSWORD].isSelected);
496                 break;
497
498         case SETTING_SEARCH_ENGINE_YAHOO:
499                 SettingPresentationModel::GetInstance()->SetSearchEngine(settingInfo[SETTING_SEARCH_ENGINE_YAHOO].titleText);
500 //              listView.RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
501 //              listView.UpdateList();
502                 break;
503
504         case SETTING_SEARCH_ENGINE_NAVER:
505                 SettingPresentationModel::GetInstance()->SetSearchEngine(settingInfo[SETTING_SEARCH_ENGINE_NAVER].titleText);
506 //              listView.RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
507 //              listView.UpdateList();
508                 break;
509
510         case SETTING_SEARCH_ENGINE_GOOGLE:
511                 SettingPresentationModel::GetInstance()->SetSearchEngine(settingInfo[SETTING_SEARCH_ENGINE_GOOGLE].titleText);
512 //              listView.RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
513 //              listView.UpdateList();
514                 break;
515
516         case SETTING_RESET_TO_DEFAULT:
517                 //OpenResetPopup();
518                 ResetToDefault();
519                 break;
520
521         default:
522                 break;
523         }
524 }
525
526 void
527 SettingForm::OnGroupedListViewItemSwept(GroupedListView& listView, int groupIndex, int itemIndex, SweepDirection direction)
528 {
529
530 }
531
532 GroupItem*
533 SettingForm::CreateGroupItem(int groupIndex, int itemWidth)
534 {
535         result r = E_FAILURE;
536         String text(L"");
537         GroupItem* pItem = null;
538         const Color ITEM_TEXT_COLOR = CUSTOM_COLOR_SETTINGS_GROUPTITLE;
539
540         pItem = new(std::nothrow) GroupItem();
541         if (pItem == null)
542         {
543                 return null;
544         }
545         r = pItem->Construct(Dimension(itemWidth, 76));
546         if (IsFailed(r))
547         {
548                 delete pItem;
549                 return null;
550         }
551
552         switch (groupIndex)
553         {
554         case 0:
555                 text = CommonUtil::GetString(L"IDS_BR_BODY_HOMEPAGE"); // IDS_HOMEPAGE
556                 settingInfo[SETTING_HOMEPAGE_TITLE].subText = SettingPresentationModel::GetInstance()->GetHomepage();
557                 break;
558
559         case 1:
560                 text = CommonUtil::GetString(L"IDS_BR_MBODY_PAGE_CONTENT_SETTINGS"); // IDS_BR_MBODY_PAGE_CONTENT_SETTINGS
561                 break;
562
563         case 2:
564                 text = CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB");  // IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB
565                 break;
566
567         case 3:
568                 text = CommonUtil::GetString(L"IDS_BR_BODY_SEARCH");    // IDS_BR_BODY_SEARCH
569                 break;
570
571         case 4:
572                 text = L" ";
573                 __pList->SetItemEnabled(groupIndex,-1,false);
574                 break;
575
576         default:
577                 break;
578         }
579
580         pItem->SetElement(text, null);
581
582         AppLogDebug("background color set result %s", GetErrorMessage(r));
583
584         pItem->SetTextColor(ITEM_TEXT_COLOR);
585         return pItem;
586 }
587
588 ListItemBase*
589 SettingForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
590 {
591         AppLog("SettingForm::CreateItem --> groupIndex : %d, itemIndex: %d itemWidth: %d ", groupIndex, itemIndex, itemWidth);
592
593         result r = E_SUCCESS;
594         int effectiveIndex = 0;
595         const Color ITEM_BACKGROUND_COLOR = CUSTOM_COLOR_SETTINGS_LISTITEM_BACKGROUND;
596         const Color ITEM_RADIO_ITEM_BACKGROUND_COLOR = CUSTOM_COLOR_SETTINGS_LISTITEM_RADIO_BACKGROUND;
597         const Color ITEM_BACKGROUND_COLOR_HIGHLIGHTED = CUSTOM_BACKGROUND_COLOR_LISTVIEW_PRESSED_HIGHLIGHTED;
598
599         for (int i = 0; i < groupIndex; i++)
600                 effectiveIndex = effectiveIndex + pGroupItemCount[i];
601         effectiveIndex = effectiveIndex + itemIndex;
602         AppLogDebug("SettingForm::CreateItem --> groupIndex : %d, itemIndex: %d itemWidth: %d effectiveIndex %d", groupIndex, itemIndex, itemWidth, effectiveIndex);
603
604         if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_TOGGLE)
605         {
606                 SettingToggleCustomItem* pItem = new(std::nothrow) SettingToggleCustomItem();
607                 r = pItem->Construct(itemWidth, 112 + (__fontSize - 44));
608                 if (IsFailed(r))
609                 {
610                         delete pItem;
611                         return null;
612                 }
613
614                 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL,ITEM_BACKGROUND_COLOR);
615                 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,ITEM_BACKGROUND_COLOR_HIGHLIGHTED);
616 //              if(__pList != null)
617 //              {
618 //                      __pList->SetItemChecked(groupIndex, itemIndex, settingInfo[effectiveIndex].isSelected);
619 //              }
620
621                 ArrayList *pList = new(std::nothrow) ArrayList();
622                 pList->Construct();
623                 Integer *pGroupIndex = new Integer(groupIndex);
624                 Integer *pItemIndex = new Integer(itemIndex);
625                 pList->Add(pGroupIndex);
626                 pList->Add(pItemIndex);
627                 AppLog("sending event UPDATE_LIST_COMPLETE");
628                 SendUserEvent(UPDATE_LIST_COMPLETE,pList);
629
630                 pItem->SetText(settingInfo[effectiveIndex].titleText);
631                 pItem->Make();
632
633                 return pItem;
634
635         }
636         else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_DROPDOWN)
637         {
638                 DropDownCustomItem* pItem = new(std::nothrow) DropDownCustomItem();
639                 r = pItem->Construct(itemWidth);
640                 if (IsFailed(r))
641                 {
642                         delete pItem;
643                         return null;
644                 }
645
646 /*              Bitmap* pNormalBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG9,itemWidth,128);
647                 Bitmap* pPressedBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG_PRESS9,itemWidth,112);
648
649                 if (pNormalBackgroundBitmap != NULL)
650                 {
651                         pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_NORMAL,pNormalBackgroundBitmap);
652                         delete pNormalBackgroundBitmap;
653                 }
654
655                 if (pPressedBackgroundBitmap != NULL)
656                 {
657                         pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_PRESSED,pPressedBackgroundBitmap);
658                         delete pPressedBackgroundBitmap;
659                 }*/
660
661                 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL,ITEM_BACKGROUND_COLOR);
662                 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,ITEM_BACKGROUND_COLOR_HIGHLIGHTED);
663
664                 pItem->SetMainText(settingInfo[effectiveIndex].titleText);
665                 if(settingInfo[effectiveIndex].subText.CompareTo(L"IDS_BR_BODY_BLANK_PAGE") == 0 || settingInfo[effectiveIndex].subText.CompareTo(L"IDS_BR_BODY_MOST_VISITED_SITES") == 0  || settingInfo[effectiveIndex].subText.CompareTo(L"IDS_BR_BODY_FIT_TO_WIDTH") == 0 || settingInfo[effectiveIndex].subText.CompareTo(L"IDS_BR_BODY_READABLE") == 0)
666                 {
667                         pItem->SetSubText(CommonUtil::GetString(settingInfo[effectiveIndex].subText));
668                 }
669                 else
670                 {
671                         pItem->SetSubText(settingInfo[effectiveIndex].subText);
672                 }
673                 if (settingInfo[effectiveIndex].isOpen)
674                 {
675                         pItem->SetCurState(DROP_DOWN_ITEM_STATE_OPENED);
676                 }
677                 else
678                 {
679                         pItem->SetCurState(DROP_DOWN__ITEM_STATE_CLOSED);
680                 }
681                 r = pItem->Make();
682                 //      if (pBitmap != null)
683                 //              pItem->AddElement(Rectangle(0, 0, 10, 128), IDA_LIST_LEFT_SIDE_MARGIN_DROPDOWN, *pBitmap, null);
684
685                 if (IsFailed(r))
686                 {
687                         delete pItem;
688                         return null;
689                 }
690
691                 return pItem;
692         }
693         else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_RADIO)
694         {
695                 RadioCustomItem* pItem = new(std::nothrow) RadioCustomItem();
696                 int parentIndex = 0;
697                 for (parentIndex = effectiveIndex; parentIndex > SETTING_INVALID; parentIndex--)
698                 {
699                         if (settingInfo[parentIndex].itemType == ITEM_TYPE_DROPDOWN)
700                                 break;
701                 }
702                 if (settingInfo[parentIndex].isOpen == false || (__isCurrentPageDisable == true && groupIndex == 0 && itemIndex == 1))
703                 {
704                         r = pItem->Construct(itemWidth, 0);
705                         __pList->SetItemEnabled(groupIndex,itemIndex,false);
706                         AppLogDebug("construct with height 0 %s", GetErrorMessage(r));
707                         return pItem;
708                 }
709                 else
710                 {
711                         __pList->SetItemEnabled(groupIndex,itemIndex,true);
712                         pItem->Construct(itemWidth, 112 +  (__fontSize - 44));
713                 }
714 /*
715                 Bitmap* pNormalBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG9,itemWidth,112);
716                 Bitmap* pPressedBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG_PRESS9,itemWidth,112);
717
718                 if (pNormalBackgroundBitmap != NULL)
719                 {
720                         pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_NORMAL,pNormalBackgroundBitmap);
721                         delete pNormalBackgroundBitmap;
722                 }
723
724                 if (pPressedBackgroundBitmap != NULL)
725                 {
726                         pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_PRESSED,pPressedBackgroundBitmap);
727                         delete pPressedBackgroundBitmap;
728                 }*/
729
730                 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL,ITEM_RADIO_ITEM_BACKGROUND_COLOR);
731                 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,ITEM_BACKGROUND_COLOR_HIGHLIGHTED);
732
733
734                 pItem->SetText(settingInfo[effectiveIndex].titleText);
735                 AppLogDebug("effectiveIndex %d SettingInfo[effectiveIndex].isSelected %d", effectiveIndex, settingInfo[effectiveIndex].isSelected);
736
737                 //if (pBitmap != null)
738                 //      pItem->AddElement(Rectangle(0, 0, 10, 112), IDA_LIST_LEFT_SIDE_MARGIN, *pBitmap, null);
739
740 //              pItem->SetSelected(settingInfo[effectiveIndex].isSelected);
741 //              __pList->SetItemChecked(groupIndex,itemIndex,settingInfo[effectiveIndex].isSelected);
742                 ArrayList *pList = new(std::nothrow) ArrayList();
743                 pList->Construct();
744                 Integer *pGroupIndex = new Integer(groupIndex);
745                 Integer *pItemIndex = new Integer(itemIndex);
746                 pList->Add(pGroupIndex);
747                 pList->Add(pItemIndex);
748                 AppLog("sending event UPDATE_LIST_COMPLETE");
749                 SendUserEvent(UPDATE_LIST_COMPLETE,pList);
750                 pItem->Make();
751
752                 return pItem;
753         }
754         else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_NORMAL)
755         {
756                 DefaultCustomItem* pItem = new(std::nothrow) DefaultCustomItem();
757
758                 r = pItem->Construct(itemWidth, 112 + (__fontSize - 44));
759                 if (IsFailed(r))
760                 {
761                         delete pItem;
762                         return null;
763                 }
764
765
766 //              Bitmap* pNormalBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG9,itemWidth,112);
767 //              Bitmap* pPressedBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG_PRESS9,itemWidth,112);
768 //
769 //              if (pNormalBackgroundBitmap != NULL)
770 //              {
771 //                      pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_NORMAL,pNormalBackgroundBitmap);
772 //                      delete pNormalBackgroundBitmap;
773 //              }
774 //
775 //              if (pPressedBackgroundBitmap != NULL)
776 //              {
777 //                      pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_PRESSED,pPressedBackgroundBitmap);
778 //                      delete pPressedBackgroundBitmap;
779 //              }
780
781                 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL,ITEM_BACKGROUND_COLOR);
782                 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,ITEM_BACKGROUND_COLOR_HIGHLIGHTED);
783
784
785                 pItem->SetText(settingInfo[effectiveIndex].titleText);
786
787                 //if (pBitmap != null)
788                 //      pItem->AddElement(Rectangle(0, 0, 10, 112), IDA_LIST_LEFT_SIDE_MARGIN, *pBitmap, null);
789
790                 r = pItem->Make();
791                 if (IsFailed(r))
792                 {
793                         delete pItem;
794                         return null;
795                 }
796                 return pItem;
797         }
798         else
799         {
800                 return null;
801         }
802 }
803
804 bool
805 SettingForm::DeleteGroupItem(int groupIndex, GroupItem* pItem, int itemWidth)
806 {
807         delete pItem;
808         pItem = null;
809         return true;
810 }
811
812 bool
813 SettingForm::DeleteItem(int groupIndex, int itemIndex, ListItemBase* pItem, int itemWidth)
814 {
815         delete pItem;
816         pItem = null;
817         return true;
818 }
819
820 int
821 SettingForm::GetGroupCount(void)
822 {
823         return groupCount;
824 }
825
826 int
827 SettingForm::GetItemCount(int groupIndex)
828 {
829         AppLog(" SettingForm::GetItemCount --> groupIndex : %d,", groupIndex);
830         return pGroupItemCount[groupIndex];
831 }
832
833 void
834 SettingForm::OnFormBackRequested(Form& source)
835 {
836         AppLog("SettingForm::OnFormBackRequested entered");
837         String* pSelectedScene = NULL;
838         Object* value = NULL;
839         MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &value);
840         pSelectedScene = (String*) value;
841         if (pSelectedScene)
842         {
843                 SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(*pSelectedScene, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
844 //              delete pSelectedScene;
845 //              pSelectedScene = null;
846         }
847 }
848
849 void
850 SettingForm::OnActionPerformed(const Control& source, int actionId)
851 {
852         switch (actionId)
853         {
854         case IDA_BUTTON_NO:
855                 if(__pConfirmationPopup)
856                 {
857                         __pConfirmationPopup->SetShowState(false);
858                         __pConfirmationPopup->Show();
859                         delete __pConfirmationPopup;
860                         __pConfirmationPopup = null;
861                 }
862                 break;
863
864         case IDA_BUTTON_YES:
865                 if(__pConfirmationPopup)
866                 {
867                         String message = L"";
868                         __pConfirmationPopup->SetShowState(false);
869                         __pConfirmationPopup->Show();
870                         if (__pConfirmationPopup->GetMessage() == CommonUtil::GetString(L"IDS_BR_POP_EMPTY_COOKIE_POPUP_BNO"))
871                         {
872                                 message = CommonUtil::GetString(L"IDS_BR_POP_DELETED");
873                                 SettingPresentationModel::GetInstance()->ClearCookie();
874                         }
875                         else if (__pConfirmationPopup->GetMessage() == CommonUtil::GetString(L"IDS_BR_POP_DELETE_ALL_SAVED_FORM_DATA_Q"))
876                         {
877                                 message = CommonUtil::GetString(L"IDS_BR_POP_DELETED");
878                                 SettingPresentationModel::GetInstance()->ClearFormData();
879                         }
880                         else if (__pConfirmationPopup->GetMessage() == CommonUtil::GetString(L"IDS_BR_POP_DELETE_ALL_SAVED_PASSWORDS_Q"))
881                         {
882                                 message = CommonUtil::GetString(L"IDS_BR_POP_DELETED");
883                                 SettingPresentationModel::GetInstance()->ClearPasswords();
884                         }
885                         else if (__pConfirmationPopup->GetMessage() == CommonUtil::GetString(L"IDS_BR_POP_DELETE_LOCALLY_CACHED_CONTENT_AND_DATABASES_Q"))
886                         {
887                                 message = CommonUtil::GetString(L"IDS_BR_POP_DELETED");
888                                 SettingPresentationModel::GetInstance()->ClearCache();
889                         }
890                         else if (__pConfirmationPopup->GetMessage() == CommonUtil::GetString(L"IDS_BR_BODY_DELETE_BROWSER_HISTORY_Q"))
891                         {
892                                 message = CommonUtil::GetString(L"IDS_BR_POP_DELETED");
893                                 HistoryPresentationModel::GetInstance()->ClearHistory();
894                         }
895                         else if (__pConfirmationPopup->GetMessage() == CommonUtil::GetString(L"IDS_BR_POP_ALL_SETTINGS_TO_DEFAULT_CONTINUE_Q"))
896                         {
897                                 message = CommonUtil::GetString(L"IDS_BR_SK_DONE");
898                                 SettingPresentationModel::GetInstance()->ResetRegistry();
899                                 InitializeSettingValues();
900                                 if(__pList != null)
901                                 {
902                                         __pList->UpdateList();
903                                 }
904                         }
905                         delete __pConfirmationPopup;
906                         __pConfirmationPopup = null;
907
908                         if (__pNotification != null)
909                         {
910                                 RemoveControl(__pNotification);
911                                 __pNotification = null;
912                         }
913                         __pNotification = new (std::nothrow) NotificationPanel(*this);
914
915                         //NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
916                         __pNotification->SetText(message);
917                         __pNotification->SetPositionDiff(0);
918                         __pNotification->ShowNotification();
919                 }
920                 break;
921
922         default:
923                 break;
924         }
925 }
926
927 void
928 SettingForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
929 {
930         Rectangle rect = GetClientAreaBounds();
931
932         if (__pNotification != null && __pNotification->GetShowState() == true)
933         {
934                 __pNotification->OrientationChanged();
935         }
936
937         if (__pList == null)
938         {
939                 return;
940         }
941         __pList->SetBounds(rect.x,rect.y,rect.width-16,rect.height);
942 //      __pList->UpdateList();//removed for issue 53768
943 }
944
945 SettingForm::SettingItemInfo::SettingItemInfo(void)
946 {
947         titleText = L"";
948         subText = L"";
949         childCount = 0;
950         isOpen = false;
951         isSelected = false ;
952 }
953 void
954 SettingForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
955 {
956         WindowInfo* pWindowInfo = null;
957         String curUrl = SettingPresentationModel::GetInstance()->GetFavoriteUrl();
958
959         pWindowInfo = MultipleWindowPresentationModel::GetInstance()->GetActiveWindowInfo();
960
961         if (previousSceneId == IDSCN_EDIT_HOMEPAGE_VIEW)
962         {
963                 if (pArgs != null)
964                 {
965                         String* pValue = NULL;
966                         pValue = dynamic_cast<String*>(pArgs->GetAt(0));
967                         if( pValue != NULL )
968                         {
969                                 if (pValue->CompareTo(L"Done") == 0)
970                                 {
971                                 //      SettingPresentationModel::GetInstance()->SetHomepage(CommonUtil::GetString(L"IDS_BR_BODY_USER_HOMEPAGE"));
972                                 }
973                                 else if (pValue->CompareTo(L"Cancel") == 0)
974                                 {
975                                         String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
976                                         if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
977                                         {
978                                                 settingInfo[SETTING_MOST_VISITED_SITE].isSelected = true;
979                                                 settingInfo[SETTING_BLANK_PAGE].isSelected = false;
980                                                 settingInfo[SETTING_CURRENT_PAGE].isSelected = false;
981                                                 settingInfo[SETTING_FAVORITE_URL].isSelected = false;
982                                                 SettingPresentationModel::GetInstance()->SetHomepage(L"IDS_BR_BODY_MOST_VISITED_SITES");
983
984                                         }
985                                         else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
986                                         {
987                                                 settingInfo[SETTING_MOST_VISITED_SITE].isSelected = false;
988                                                 settingInfo[SETTING_BLANK_PAGE].isSelected = true;
989                                                 settingInfo[SETTING_CURRENT_PAGE].isSelected = false;
990                                                 settingInfo[SETTING_FAVORITE_URL].isSelected = false;
991                                                 SettingPresentationModel::GetInstance()->SetHomepage(L"IDS_BR_BODY_BLANK_PAGE");
992                                         }
993                                         else
994                                         {
995                                                 settingInfo[SETTING_MOST_VISITED_SITE].isSelected = false;
996                                                 settingInfo[SETTING_BLANK_PAGE].isSelected = false;
997                                                 settingInfo[SETTING_CURRENT_PAGE].isSelected = false;
998                                                 settingInfo[SETTING_FAVORITE_URL].isSelected = true;
999                                         }
1000
1001                                 }
1002                         }
1003                 }
1004         }
1005
1006         if (pWindowInfo != null)
1007         {
1008                 __currentURL.Clear();
1009                 __currentURL.Append(pWindowInfo->pageUrl);
1010                 AppLog("current url is %ls",__currentURL.GetPointer());
1011
1012                 if (SettingPresentationModel::GetInstance()->GetFavoriteUrl().CompareTo(L"") == 0)
1013                 {
1014                         if (pWindowInfo->pageUrl.CompareTo(L"") == 0)
1015                         {
1016                                 //settingInfo[SETTING_FAVORITE_URL].titleText = CommonUtil::GetString(L"IDS_SET_HOMEPAGE");
1017                                 settingInfo[SETTING_FAVORITE_URL].titleText = L"http://www.tizen.org";
1018                         }
1019                         else
1020                         {
1021                                 settingInfo[SETTING_FAVORITE_URL].titleText = pWindowInfo->pageUrl;
1022                         }
1023                 }
1024                 else
1025                 {
1026                         settingInfo[SETTING_FAVORITE_URL].titleText = SettingPresentationModel::GetInstance()->GetFavoriteUrl();
1027                 }
1028         }
1029
1030         if (__pList != null)
1031         {
1032                 __pList->UpdateList();
1033                 if (pWindowInfo && pWindowInfo->pageUrl.CompareTo(L"") == 0)
1034                 {
1035                         __isCurrentPageDisable = true;
1036                         AppLog("set item enabled is false");
1037                         __pList->SetItemEnabled(0, 1, false);
1038                 }
1039                 else
1040                 {
1041                         __isCurrentPageDisable = false;
1042                         AppLog("set item enabled is true");
1043                         if (settingInfo[0].isOpen == false)
1044                         {
1045                                 __pList->SetItemEnabled(0,1,false);
1046                         }
1047                         else
1048                         {
1049                                 __pList->SetItemEnabled(0,1,true);
1050                         }
1051                 }
1052                 for(int grpindex = 0; grpindex < groupCount; grpindex++)
1053                 {
1054                         for(int index = 0; index < *(pGroupItemCount+groupCount); index++)
1055                         {
1056                                 int effectiveIndex = 0;
1057                                 for (int i = 0; i < grpindex; i++)
1058                                                 effectiveIndex = effectiveIndex + pGroupItemCount[i];
1059                                         effectiveIndex = effectiveIndex + index;
1060
1061                                         if(effectiveIndex >= SETTING_MAX)
1062                                         {
1063                                                 continue;
1064                                         }
1065                                 if(settingInfo[effectiveIndex].itemType == ITEM_TYPE_TOGGLE || settingInfo[effectiveIndex].itemType == ITEM_TYPE_RADIO )
1066                                 {
1067                                         __pList->SetItemChecked(grpindex, index, settingInfo[effectiveIndex].isSelected);
1068                                 }
1069                         }
1070                 }
1071         }
1072         return;
1073 }
1074
1075 void
1076 SettingForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
1077 {
1078         return;
1079 }
1080
1081 void
1082 SettingForm::ClearHistory(void)
1083 {
1084         if(__pConfirmationPopup)
1085         {
1086                 __pConfirmationPopup->SetShowState(false);
1087                 __pConfirmationPopup->Show();
1088                 delete __pConfirmationPopup;
1089                 __pConfirmationPopup = null;
1090         }
1091         String message = CommonUtil::GetString(L"IDS_BR_BODY_DELETE_BROWSER_HISTORY_Q");
1092         if(!__pConfirmationPopup)
1093         {
1094                 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
1095                 __pConfirmationPopup->Initialize();
1096                 __pConfirmationPopup->RemoveActionListener(*this);
1097                 __pConfirmationPopup->AddActionListener(*this);
1098                 __pConfirmationPopup->setMessage(message);
1099                 __pConfirmationPopup->Show();
1100         }
1101 }
1102
1103 void
1104 SettingForm::ClearCache(void)
1105 {
1106         if(__pConfirmationPopup)
1107         {
1108                 __pConfirmationPopup->SetShowState(false);
1109                 __pConfirmationPopup->Show();
1110                 delete __pConfirmationPopup;
1111                 __pConfirmationPopup = null;
1112         }
1113         String message = CommonUtil::GetString(L"IDS_BR_POP_DELETE_LOCALLY_CACHED_CONTENT_AND_DATABASES_Q");
1114         if(!__pConfirmationPopup)
1115         {
1116                 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
1117                 __pConfirmationPopup->Initialize();
1118                 __pConfirmationPopup->RemoveActionListener(*this);
1119                 __pConfirmationPopup->AddActionListener(*this);
1120                 __pConfirmationPopup->setMessage(message);
1121                 __pConfirmationPopup->Show();
1122         }
1123 }
1124
1125 void
1126 SettingForm::ClearCookie(void)
1127 {
1128         if(__pConfirmationPopup)
1129         {
1130                 __pConfirmationPopup->SetShowState(false);
1131                 __pConfirmationPopup->Show();
1132                 delete __pConfirmationPopup;
1133                 __pConfirmationPopup = null;
1134         }
1135         String message = CommonUtil::GetString(L"IDS_BR_POP_EMPTY_COOKIE_POPUP_BNO");
1136         if(!__pConfirmationPopup)
1137         {
1138                 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
1139                 __pConfirmationPopup->Initialize();
1140                 __pConfirmationPopup->RemoveActionListener(*this);
1141                 __pConfirmationPopup->AddActionListener(*this);
1142                 __pConfirmationPopup->setMessage(message);
1143                 __pConfirmationPopup->Show();
1144         }
1145 }
1146
1147 void
1148 SettingForm::ClearFormData(void)
1149 {
1150         if(__pConfirmationPopup)
1151         {
1152                 __pConfirmationPopup->SetShowState(false);
1153                 __pConfirmationPopup->Show();
1154                 delete __pConfirmationPopup;
1155                 __pConfirmationPopup = null;
1156         }
1157         String message = CommonUtil::GetString(L"IDS_BR_POP_DELETE_ALL_SAVED_FORM_DATA_Q");
1158         if(!__pConfirmationPopup)
1159         {
1160                 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
1161                 __pConfirmationPopup->Initialize();
1162                 __pConfirmationPopup->RemoveActionListener(*this);
1163                 __pConfirmationPopup->AddActionListener(*this);
1164                 __pConfirmationPopup->setMessage(message);
1165                 __pConfirmationPopup->Show();
1166         }
1167 }
1168
1169 void
1170 SettingForm::ClearPasswords(void)
1171 {
1172         if(__pConfirmationPopup)
1173         {
1174                 __pConfirmationPopup->SetShowState(false);
1175                 __pConfirmationPopup->Show();
1176                 delete __pConfirmationPopup;
1177                 __pConfirmationPopup = null;
1178         }
1179         String message = CommonUtil::GetString(L"IDS_BR_POP_DELETE_ALL_SAVED_PASSWORDS_Q");
1180         if(!__pConfirmationPopup)
1181         {
1182                 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
1183                 __pConfirmationPopup->Initialize();
1184                 __pConfirmationPopup->RemoveActionListener(*this);
1185                 __pConfirmationPopup->AddActionListener(*this);
1186                 __pConfirmationPopup->setMessage(message);
1187                 __pConfirmationPopup->Show();
1188         }
1189 }
1190
1191
1192 void
1193 SettingForm::ResetToDefault()
1194 {
1195         if(__pConfirmationPopup)
1196         {
1197                 __pConfirmationPopup->SetShowState(false);
1198                 __pConfirmationPopup->Show();
1199                 delete __pConfirmationPopup;
1200                 __pConfirmationPopup = null;
1201         }
1202         String message = CommonUtil::GetString(L"IDS_BR_POP_ALL_SETTINGS_TO_DEFAULT_CONTINUE_Q");
1203         if(!__pConfirmationPopup)
1204         {
1205                 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
1206                 __pConfirmationPopup->Initialize();
1207                 __pConfirmationPopup->RemoveActionListener(*this);
1208                 __pConfirmationPopup->AddActionListener(*this);
1209                 __pConfirmationPopup->setMessage(message);
1210                 __pConfirmationPopup->Show();
1211         }
1212 }
1213
1214 void
1215 SettingForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
1216 {
1217         AppLog("receiving userevent for appcontrol %d",requestId);
1218         if (requestId == APPCONTROL_LAUNCH_MAX_LIMIT_REACHED)
1219         {
1220                 AppLog("receiving userevent for appcontrol %d ",requestId);
1221                 if(__pConfirmationPopup)
1222                 {
1223                         __pConfirmationPopup->SetShowState(false);
1224                         delete __pConfirmationPopup;
1225                         __pConfirmationPopup = null;
1226                 }
1227         }
1228         else if (requestId == UPDATE_LIST_COMPLETE)
1229         {
1230                 AppLog("receiving event UPDATE_LIST_COMPLETE");
1231                 Integer *pGroupIndex = static_cast<Integer*>(pArgs->GetAt(0));
1232                 Integer *pItemIndex = static_cast<Integer*>(pArgs->GetAt(1));
1233                 int groupIndex = pGroupIndex->ToInt();
1234                 int itemIndex = pItemIndex->ToInt();
1235
1236                 int effectiveIndex = 0;
1237                 for (int i = 0; i < groupIndex; i++)
1238                         effectiveIndex = effectiveIndex + pGroupItemCount[i];
1239                 effectiveIndex = effectiveIndex + itemIndex;
1240
1241
1242                 if(settingInfo[effectiveIndex].itemType == ITEM_TYPE_TOGGLE || settingInfo[effectiveIndex].itemType == ITEM_TYPE_RADIO )
1243                 {
1244                         AppLog("UPDATE_LIST_COMPLETE SetItemChecked %d, %d, %d",groupIndex, itemIndex, settingInfo[effectiveIndex].isSelected);
1245                         __pList->SetItemChecked(groupIndex, itemIndex, settingInfo[effectiveIndex].isSelected);
1246                         __pList->Invalidate(true);
1247                 }
1248
1249         }
1250 }
1251