Initialize Tizen 2.3
[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
354                 switch (effectiveIndex)
355                 {
356                 case SETTING_CURRENT_PAGE:
357                         //SettingPresentationModel::GetInstance()->SetHomepage(settingInfo[SETTING_FAVORITE_URL].titleText);
358                         AppLog("setting current page currentURL is =%ls",__currentURL.GetPointer());
359                         if (__currentURL.CompareTo(L"") != 0)
360                         {
361                                 AppLog("setting current page currentURL is =%ls",__currentURL.GetPointer());
362                                 SettingPresentationModel::GetInstance()->SetHomepage(CommonUtil::GetString(L"IDS_BR_BODY_USER_HOMEPAGE"));
363                                 SettingPresentationModel::GetInstance()->SetFavoriteValue(__currentURL);
364                                 settingInfo[SETTING_FAVORITE_URL].titleText = __currentURL;
365         //                      listView.RefreshList(groupIndex, effectiveIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
366         //                      listView.RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
367         //                      listView.UpdateList();
368                         }
369                         break;
370                 case SETTING_BLANK_PAGE:
371                         //SettingPresentationModel::GetInstance()->SetHomepage(settingInfo[SETTING_BLANK_PAGE].titleText);
372                         SettingPresentationModel::GetInstance()->SetHomepage((L"IDS_BR_BODY_BLANK_PAGE"));
373                         AppLog("GetHomepage() %ls",SettingPresentationModel::GetInstance()->GetHomepage().GetPointer());
374         //              listView.RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
375         //              listView.UpdateList();
376
377                         break;
378                 case SETTING_MOST_VISITED_SITE:
379                         SettingPresentationModel::GetInstance()->SetHomepage(L"IDS_BR_BODY_MOST_VISITED_SITES");
380         //              listView.RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
381         //              listView.UpdateList();
382                         break;
383
384                 case SETTING_FAVORITE_URL:
385                         //SettingPresentationModel::GetInstance()->SetHomepage(settingInfo[SETTING_FAVORITE_URL].titleText);
386                         SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_EDIT_HOMEPAGE_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
387                         break;
388
389                 case SETTING_FIT_TO_WIDTH:
390                         SettingPresentationModel::GetInstance()->SetDefaultView(L"IDS_BR_BODY_FIT_TO_WIDTH");
391         //              listView.RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
392         //              listView.UpdateList();
393                         break;
394
395                 case SETTING_READABLE:
396                         SettingPresentationModel::GetInstance()->SetDefaultView(L"IDS_BR_BODY_READABLE");
397         //              listView.RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
398         //              listView.UpdateList();
399                         break;
400
401                 case SETTING_SEARCH_ENGINE_YAHOO:
402                         SettingPresentationModel::GetInstance()->SetSearchEngine(settingInfo[SETTING_SEARCH_ENGINE_YAHOO].titleText);
403         //              listView.RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
404         //              listView.UpdateList();
405                         break;
406
407                 case SETTING_SEARCH_ENGINE_NAVER:
408                         SettingPresentationModel::GetInstance()->SetSearchEngine(settingInfo[SETTING_SEARCH_ENGINE_NAVER].titleText);
409         //              listView.RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
410         //              listView.UpdateList();
411                         break;
412
413                 case SETTING_SEARCH_ENGINE_GOOGLE:
414                         SettingPresentationModel::GetInstance()->SetSearchEngine(settingInfo[SETTING_SEARCH_ENGINE_GOOGLE].titleText);
415         //              listView.RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
416         //              listView.UpdateList();
417                         break;
418
419
420                 }
421
422                 int parentIndex = 0;
423                 for (parentIndex = effectiveIndex; parentIndex > SETTING_INVALID; parentIndex--)
424                 {
425                         if (settingInfo[parentIndex].itemType == ITEM_TYPE_DROPDOWN)
426                                 break;
427                 }
428                 settingInfo[parentIndex].subText = settingInfo[effectiveIndex].titleText;
429
430                 listView.RefreshList(groupIndex, itemIndex - (effectiveIndex - parentIndex), LIST_REFRESH_TYPE_ITEM_MODIFY);
431                 listView.RefreshList(groupIndex, parentIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
432                 for (int iter = 0; iter < settingInfo[parentIndex].childCount; iter++)
433                 {
434                         if (parentIndex + iter + 1 != effectiveIndex)
435                         {
436                                 AppLogDebug("long effectiveIndex %d set to false", itemIndex - (effectiveIndex - parentIndex) + iter + 1);
437                                 settingInfo[parentIndex + iter + 1].isSelected = false;
438                         }
439                         else
440                         {
441                                 AppLogDebug("effectiveIndex %d set to true", effectiveIndex);
442                                 settingInfo[effectiveIndex].isSelected = true;
443                         }
444                         if (effectiveIndex == SETTING_CURRENT_PAGE)
445                         {
446                                 settingInfo[SETTING_CURRENT_PAGE].isSelected = false;
447                                 settingInfo[SETTING_FAVORITE_URL].isSelected = true;
448                         }
449                         listView.RefreshList(groupIndex, itemIndex - (effectiveIndex - parentIndex) + iter + 1, LIST_REFRESH_TYPE_ITEM_MODIFY);
450                 }
451 //              listView.UpdateList();
452                 //listView.ScrollToItem(groupIndex, itemIndex, LIST_SCROLL_ITEM_ALIGNMENT_TOP);
453                 Invalidate(true);
454         }
455         else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_TOGGLE)
456         {
457                 if (settingInfo[effectiveIndex].isSelected == true)
458                 {
459                         settingInfo[effectiveIndex].isSelected = false;
460                 }
461                 else
462                 {
463                         settingInfo[effectiveIndex].isSelected = true;
464                 }
465 //              listView.RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
466                 if(__pList != null)
467                 {
468                         __pList->SetItemChecked(groupIndex, itemIndex, settingInfo[effectiveIndex].isSelected);
469                 }
470         }
471
472         switch (effectiveIndex)
473         {
474
475         case SETTING_RUN_JAVASCRIPT:
476                 SettingPresentationModel::GetInstance()->SetRunJavascriptEnabled(settingInfo[SETTING_RUN_JAVASCRIPT].isSelected);
477                 break;
478
479         case SETTING_DISPLAY_IMAGES:
480                 SettingPresentationModel::GetInstance()->SetDisplayImagesEnabled(settingInfo[SETTING_DISPLAY_IMAGES].isSelected);
481                 break;
482
483         case SETTING_BLOCK_POPUP:
484                 SettingPresentationModel::GetInstance()->SetBlockPopUp(!settingInfo[SETTING_BLOCK_POPUP].isSelected);
485                 break;
486
487         case SETTING_CLEAR_CACHE:
488                 ClearCache();
489                 break;
490
491         case SETTING_CLEAR_HISTORY:
492                 ClearHistory();
493                 break;
494
495         case SETTING_SHOW_SECURITY_WARNINGS:
496                 SettingPresentationModel::GetInstance()->SetSecurityWarningsEnabled(settingInfo[SETTING_SHOW_SECURITY_WARNINGS].isSelected);
497                 break;
498
499         case SETTING_ACCEPT_COOKIES:
500                 SettingPresentationModel::GetInstance()->SetCookiesEnabled(settingInfo[SETTING_ACCEPT_COOKIES].isSelected);
501                 break;
502
503         case SETTING_CLEAR_COOKIE_DATA:
504                 ClearCookie();
505                 break;
506
507         case SETTING_REMEMBER_FORM_DATA:
508                 SettingPresentationModel::GetInstance()->SetRememberFormData(settingInfo[SETTING_REMEMBER_FORM_DATA].isSelected);
509                 break;
510
511         case SETTING_CLEAR_FORM_DATA:
512                 ClearFormData();
513                 break;
514
515         case SETTING_CLEAR_PASSWORDS:
516                 ClearPasswords();
517                 break;
518
519         case SETTING_REMEMBER_PASSWORD:
520                 SettingPresentationModel::GetInstance()->SetRememberPassword(settingInfo[SETTING_REMEMBER_PASSWORD].isSelected);
521                 break;
522
523
524         case SETTING_RESET_TO_DEFAULT:
525                 //OpenResetPopup();
526                 ResetToDefault();
527                 break;
528
529         default:
530                 break;
531         }
532 }
533
534 void
535 SettingForm::OnGroupedListViewItemSwept(GroupedListView& listView, int groupIndex, int itemIndex, SweepDirection direction)
536 {
537
538 }
539
540 GroupItem*
541 SettingForm::CreateGroupItem(int groupIndex, int itemWidth)
542 {
543         result r = E_FAILURE;
544         String text(L"");
545         GroupItem* pItem = null;
546         const Color ITEM_TEXT_COLOR = CUSTOM_COLOR_SETTINGS_GROUPTITLE;
547
548         pItem = new(std::nothrow) GroupItem();
549         if (pItem == null)
550         {
551                 return null;
552         }
553         r = pItem->Construct(Dimension(itemWidth, 76));
554         if (IsFailed(r))
555         {
556                 delete pItem;
557                 return null;
558         }
559
560         switch (groupIndex)
561         {
562         case 0:
563                 text = CommonUtil::GetString(L"IDS_BR_BODY_HOMEPAGE"); // IDS_HOMEPAGE
564                 settingInfo[SETTING_HOMEPAGE_TITLE].subText = SettingPresentationModel::GetInstance()->GetHomepage();
565                 break;
566
567         case 1:
568                 text = CommonUtil::GetString(L"IDS_BR_MBODY_PAGE_CONTENT_SETTINGS"); // IDS_BR_MBODY_PAGE_CONTENT_SETTINGS
569                 break;
570
571         case 2:
572                 text = CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB");  // IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB
573                 break;
574
575         case 3:
576                 text = CommonUtil::GetString(L"IDS_BR_BODY_SEARCH");    // IDS_BR_BODY_SEARCH
577                 break;
578
579         case 4:
580                 text = L" ";
581                 __pList->SetItemEnabled(groupIndex,-1,false);
582                 break;
583
584         default:
585                 break;
586         }
587
588         pItem->SetElement(text, null);
589
590         AppLogDebug("background color set result %s", GetErrorMessage(r));
591
592         pItem->SetTextColor(ITEM_TEXT_COLOR);
593         return pItem;
594 }
595
596 ListItemBase*
597 SettingForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
598 {
599         AppLog("SettingForm::CreateItem --> groupIndex : %d, itemIndex: %d itemWidth: %d ", groupIndex, itemIndex, itemWidth);
600
601         result r = E_SUCCESS;
602         int effectiveIndex = 0;
603         const Color ITEM_BACKGROUND_COLOR = CUSTOM_COLOR_SETTINGS_LISTITEM_BACKGROUND;
604         const Color ITEM_RADIO_ITEM_BACKGROUND_COLOR = CUSTOM_COLOR_SETTINGS_LISTITEM_RADIO_BACKGROUND;
605         const Color ITEM_BACKGROUND_COLOR_HIGHLIGHTED = CUSTOM_BACKGROUND_COLOR_LISTVIEW_PRESSED_HIGHLIGHTED;
606
607         for (int i = 0; i < groupIndex; i++)
608                 effectiveIndex = effectiveIndex + pGroupItemCount[i];
609         effectiveIndex = effectiveIndex + itemIndex;
610         AppLogDebug("SettingForm::CreateItem --> groupIndex : %d, itemIndex: %d itemWidth: %d effectiveIndex %d", groupIndex, itemIndex, itemWidth, effectiveIndex);
611
612         if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_TOGGLE)
613         {
614                 SettingToggleCustomItem* pItem = new(std::nothrow) SettingToggleCustomItem();
615                 r = pItem->Construct(itemWidth, 112 + (__fontSize - 44));
616                 if (IsFailed(r))
617                 {
618                         delete pItem;
619                         return null;
620                 }
621
622                 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL,ITEM_BACKGROUND_COLOR);
623                 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,ITEM_BACKGROUND_COLOR_HIGHLIGHTED);
624 //              if(__pList != null)
625 //              {
626 //                      __pList->SetItemChecked(groupIndex, itemIndex, settingInfo[effectiveIndex].isSelected);
627 //              }
628
629                 ArrayList *pList = new(std::nothrow) ArrayList();
630                 pList->Construct();
631                 Integer *pGroupIndex = new Integer(groupIndex);
632                 Integer *pItemIndex = new Integer(itemIndex);
633                 pList->Add(pGroupIndex);
634                 pList->Add(pItemIndex);
635                 AppLog("sending event UPDATE_LIST_COMPLETE");
636                 SendUserEvent(UPDATE_LIST_COMPLETE,pList);
637
638                 pItem->SetText(settingInfo[effectiveIndex].titleText);
639                 pItem->Make();
640
641                 return pItem;
642
643         }
644         else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_DROPDOWN)
645         {
646                 DropDownCustomItem* pItem = new(std::nothrow) DropDownCustomItem();
647                 r = pItem->Construct(itemWidth);
648                 if (IsFailed(r))
649                 {
650                         delete pItem;
651                         return null;
652                 }
653
654 /*              Bitmap* pNormalBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG9,itemWidth,128);
655                 Bitmap* pPressedBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG_PRESS9,itemWidth,112);
656
657                 if (pNormalBackgroundBitmap != NULL)
658                 {
659                         pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_NORMAL,pNormalBackgroundBitmap);
660                         delete pNormalBackgroundBitmap;
661                 }
662
663                 if (pPressedBackgroundBitmap != NULL)
664                 {
665                         pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_PRESSED,pPressedBackgroundBitmap);
666                         delete pPressedBackgroundBitmap;
667                 }*/
668
669                 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL,ITEM_BACKGROUND_COLOR);
670                 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,ITEM_BACKGROUND_COLOR_HIGHLIGHTED);
671
672                 pItem->SetMainText(settingInfo[effectiveIndex].titleText);
673                 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)
674                 {
675                         pItem->SetSubText(CommonUtil::GetString(settingInfo[effectiveIndex].subText));
676                 }
677                 else
678                 {
679                         pItem->SetSubText(settingInfo[effectiveIndex].subText);
680                 }
681                 if (settingInfo[effectiveIndex].isOpen)
682                 {
683                         pItem->SetCurState(DROP_DOWN_ITEM_STATE_OPENED);
684                 }
685                 else
686                 {
687                         pItem->SetCurState(DROP_DOWN__ITEM_STATE_CLOSED);
688                 }
689                 r = pItem->Make();
690                 //      if (pBitmap != null)
691                 //              pItem->AddElement(Rectangle(0, 0, 10, 128), IDA_LIST_LEFT_SIDE_MARGIN_DROPDOWN, *pBitmap, null);
692
693                 if (IsFailed(r))
694                 {
695                         delete pItem;
696                         return null;
697                 }
698
699                 return pItem;
700         }
701         else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_RADIO)
702         {
703                 RadioCustomItem* pItem = new(std::nothrow) RadioCustomItem();
704                 int parentIndex = 0;
705                 for (parentIndex = effectiveIndex; parentIndex > SETTING_INVALID; parentIndex--)
706                 {
707                         if (settingInfo[parentIndex].itemType == ITEM_TYPE_DROPDOWN)
708                                 break;
709                 }
710                 if (settingInfo[parentIndex].isOpen == false || (__isCurrentPageDisable == true && groupIndex == 0 && itemIndex == 1))
711                 {
712                         r = pItem->Construct(itemWidth, 0);
713                         __pList->SetItemEnabled(groupIndex,itemIndex,false);
714                         AppLogDebug("construct with height 0 %s", GetErrorMessage(r));
715                         return pItem;
716                 }
717                 else
718                 {
719                         __pList->SetItemEnabled(groupIndex,itemIndex,true);
720                         pItem->Construct(itemWidth, 112 +  (__fontSize - 44));
721                 }
722 /*
723                 Bitmap* pNormalBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG9,itemWidth,112);
724                 Bitmap* pPressedBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG_PRESS9,itemWidth,112);
725
726                 if (pNormalBackgroundBitmap != NULL)
727                 {
728                         pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_NORMAL,pNormalBackgroundBitmap);
729                         delete pNormalBackgroundBitmap;
730                 }
731
732                 if (pPressedBackgroundBitmap != NULL)
733                 {
734                         pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_PRESSED,pPressedBackgroundBitmap);
735                         delete pPressedBackgroundBitmap;
736                 }*/
737
738                 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL,ITEM_RADIO_ITEM_BACKGROUND_COLOR);
739                 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,ITEM_BACKGROUND_COLOR_HIGHLIGHTED);
740
741
742                 pItem->SetText(settingInfo[effectiveIndex].titleText);
743                 AppLogDebug("effectiveIndex %d SettingInfo[effectiveIndex].isSelected %d", effectiveIndex, settingInfo[effectiveIndex].isSelected);
744
745                 //if (pBitmap != null)
746                 //      pItem->AddElement(Rectangle(0, 0, 10, 112), IDA_LIST_LEFT_SIDE_MARGIN, *pBitmap, null);
747
748 //              pItem->SetSelected(settingInfo[effectiveIndex].isSelected);
749 //              __pList->SetItemChecked(groupIndex,itemIndex,settingInfo[effectiveIndex].isSelected);
750                 ArrayList *pList = new(std::nothrow) ArrayList();
751                 pList->Construct();
752                 Integer *pGroupIndex = new Integer(groupIndex);
753                 Integer *pItemIndex = new Integer(itemIndex);
754                 pList->Add(pGroupIndex);
755                 pList->Add(pItemIndex);
756                 AppLog("sending event UPDATE_LIST_COMPLETE");
757                 SendUserEvent(UPDATE_LIST_COMPLETE,pList);
758                 pItem->Make();
759
760                 return pItem;
761         }
762         else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_NORMAL)
763         {
764                 DefaultCustomItem* pItem = new(std::nothrow) DefaultCustomItem();
765
766                 r = pItem->Construct(itemWidth, 112 + (__fontSize - 44));
767                 if (IsFailed(r))
768                 {
769                         delete pItem;
770                         return null;
771                 }
772
773
774 //              Bitmap* pNormalBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG9,itemWidth,112);
775 //              Bitmap* pPressedBackgroundBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_LIST_GROUP_BG_PRESS9,itemWidth,112);
776 //
777 //              if (pNormalBackgroundBitmap != NULL)
778 //              {
779 //                      pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_NORMAL,pNormalBackgroundBitmap);
780 //                      delete pNormalBackgroundBitmap;
781 //              }
782 //
783 //              if (pPressedBackgroundBitmap != NULL)
784 //              {
785 //                      pItem->SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_PRESSED,pPressedBackgroundBitmap);
786 //                      delete pPressedBackgroundBitmap;
787 //              }
788
789                 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL,ITEM_BACKGROUND_COLOR);
790                 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,ITEM_BACKGROUND_COLOR_HIGHLIGHTED);
791
792
793                 pItem->SetText(settingInfo[effectiveIndex].titleText);
794
795                 //if (pBitmap != null)
796                 //      pItem->AddElement(Rectangle(0, 0, 10, 112), IDA_LIST_LEFT_SIDE_MARGIN, *pBitmap, null);
797
798                 r = pItem->Make();
799                 if (IsFailed(r))
800                 {
801                         delete pItem;
802                         return null;
803                 }
804                 return pItem;
805         }
806         else
807         {
808                 return null;
809         }
810 }
811
812 bool
813 SettingForm::DeleteGroupItem(int groupIndex, GroupItem* pItem, int itemWidth)
814 {
815         delete pItem;
816         pItem = null;
817         return true;
818 }
819
820 bool
821 SettingForm::DeleteItem(int groupIndex, int itemIndex, ListItemBase* pItem, int itemWidth)
822 {
823         delete pItem;
824         pItem = null;
825         return true;
826 }
827
828 int
829 SettingForm::GetGroupCount(void)
830 {
831         return groupCount;
832 }
833
834 int
835 SettingForm::GetItemCount(int groupIndex)
836 {
837         AppLog(" SettingForm::GetItemCount --> groupIndex : %d,", groupIndex);
838         return pGroupItemCount[groupIndex];
839 }
840
841 void
842 SettingForm::OnFormBackRequested(Form& source)
843 {
844         AppLog("SettingForm::OnFormBackRequested entered");
845         String* pSelectedScene = NULL;
846         Object* value = NULL;
847         MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &value);
848         pSelectedScene = (String*) value;
849         if (pSelectedScene)
850         {
851                 SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(*pSelectedScene, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
852 //              delete pSelectedScene;
853 //              pSelectedScene = null;
854         }
855 }
856
857 void
858 SettingForm::OnActionPerformed(const Control& source, int actionId)
859 {
860         switch (actionId)
861         {
862         case IDA_BUTTON_NO:
863                 if(__pConfirmationPopup)
864                 {
865                         __pConfirmationPopup->SetShowState(false);
866                         __pConfirmationPopup->Show();
867                         delete __pConfirmationPopup;
868                         __pConfirmationPopup = null;
869                 }
870                 break;
871
872         case IDA_BUTTON_YES:
873                 if(__pConfirmationPopup)
874                 {
875                         String message = L"";
876                         __pConfirmationPopup->SetShowState(false);
877                         __pConfirmationPopup->Show();
878                         if (__pConfirmationPopup->GetMessage() == CommonUtil::GetString(L"IDS_BR_POP_EMPTY_COOKIE_POPUP_BNO"))
879                         {
880                                 message = CommonUtil::GetString(L"IDS_BR_POP_DELETED");
881                                 SettingPresentationModel::GetInstance()->ClearCookie();
882                         }
883                         else if (__pConfirmationPopup->GetMessage() == CommonUtil::GetString(L"IDS_BR_POP_DELETE_ALL_SAVED_FORM_DATA_Q"))
884                         {
885                                 message = CommonUtil::GetString(L"IDS_BR_POP_DELETED");
886                                 SettingPresentationModel::GetInstance()->ClearFormData();
887                         }
888                         else if (__pConfirmationPopup->GetMessage() == CommonUtil::GetString(L"IDS_BR_POP_DELETE_ALL_SAVED_PASSWORDS_Q"))
889                         {
890                                 message = CommonUtil::GetString(L"IDS_BR_POP_DELETED");
891                                 SettingPresentationModel::GetInstance()->ClearPasswords();
892                         }
893                         else if (__pConfirmationPopup->GetMessage() == CommonUtil::GetString(L"IDS_BR_POP_DELETE_LOCALLY_CACHED_CONTENT_AND_DATABASES_Q"))
894                         {
895                                 message = CommonUtil::GetString(L"IDS_BR_POP_DELETED");
896                                 SettingPresentationModel::GetInstance()->ClearCache();
897                         }
898                         else if (__pConfirmationPopup->GetMessage() == CommonUtil::GetString(L"IDS_BR_BODY_DELETE_BROWSER_HISTORY_Q"))
899                         {
900                                 message = CommonUtil::GetString(L"IDS_BR_POP_DELETED");
901                                 HistoryPresentationModel::GetInstance()->ClearHistory();
902                         }
903                         else if (__pConfirmationPopup->GetMessage() == CommonUtil::GetString(L"IDS_BR_POP_ALL_SETTINGS_TO_DEFAULT_CONTINUE_Q"))
904                         {
905                                 message = CommonUtil::GetString(L"IDS_BR_SK_DONE");
906                                 SettingPresentationModel::GetInstance()->ResetRegistry();
907                                 InitializeSettingValues();
908                                 if(__pList != null)
909                                 {
910                                         __pList->UpdateList();
911                                 }
912                         }
913                         delete __pConfirmationPopup;
914                         __pConfirmationPopup = null;
915
916                         if (__pNotification != null)
917                         {
918                                 RemoveControl(__pNotification);
919                                 __pNotification = null;
920                         }
921                         __pNotification = new (std::nothrow) NotificationPanel(*this);
922
923                         //NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
924                         __pNotification->SetText(message);
925                         __pNotification->SetPositionDiff(0);
926                         __pNotification->ShowNotification();
927                 }
928                 break;
929
930         default:
931                 break;
932         }
933 }
934
935 void
936 SettingForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
937 {
938         Rectangle rect = GetClientAreaBounds();
939
940         if (__pNotification != null && __pNotification->GetShowState() == true)
941         {
942                 __pNotification->OrientationChanged();
943         }
944
945         if (__pList == null)
946         {
947                 return;
948         }
949         __pList->SetBounds(rect.x,rect.y,rect.width-16,rect.height);
950 //      __pList->UpdateList();//removed for issue 53768
951 }
952
953 SettingForm::SettingItemInfo::SettingItemInfo(void)
954 {
955         titleText = L"";
956         subText = L"";
957         childCount = 0;
958         isOpen = false;
959         isSelected = false ;
960 }
961 void
962 SettingForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
963 {
964         WindowInfo* pWindowInfo = null;
965         String curUrl = SettingPresentationModel::GetInstance()->GetFavoriteUrl();
966
967         pWindowInfo = MultipleWindowPresentationModel::GetInstance()->GetActiveWindowInfo();
968
969         if (previousSceneId == IDSCN_EDIT_HOMEPAGE_VIEW)
970         {
971                 if (pArgs != null)
972                 {
973                         String* pValue = NULL;
974                         pValue = dynamic_cast<String*>(pArgs->GetAt(0));
975                         if( pValue != NULL )
976                         {
977                                 if (pValue->CompareTo(L"Done") == 0)
978                                 {
979                                 //      SettingPresentationModel::GetInstance()->SetHomepage(CommonUtil::GetString(L"IDS_BR_BODY_USER_HOMEPAGE"));
980                                 }
981                                 else if (pValue->CompareTo(L"Cancel") == 0)
982                                 {
983                                         String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
984                                         if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
985                                         {
986                                                 settingInfo[SETTING_MOST_VISITED_SITE].isSelected = true;
987                                                 settingInfo[SETTING_BLANK_PAGE].isSelected = false;
988                                                 settingInfo[SETTING_CURRENT_PAGE].isSelected = false;
989                                                 settingInfo[SETTING_FAVORITE_URL].isSelected = false;
990                                                 SettingPresentationModel::GetInstance()->SetHomepage(L"IDS_BR_BODY_MOST_VISITED_SITES");
991
992                                         }
993                                         else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
994                                         {
995                                                 settingInfo[SETTING_MOST_VISITED_SITE].isSelected = false;
996                                                 settingInfo[SETTING_BLANK_PAGE].isSelected = true;
997                                                 settingInfo[SETTING_CURRENT_PAGE].isSelected = false;
998                                                 settingInfo[SETTING_FAVORITE_URL].isSelected = false;
999                                                 SettingPresentationModel::GetInstance()->SetHomepage(L"IDS_BR_BODY_BLANK_PAGE");
1000                                         }
1001                                         else
1002                                         {
1003                                                 settingInfo[SETTING_MOST_VISITED_SITE].isSelected = false;
1004                                                 settingInfo[SETTING_BLANK_PAGE].isSelected = false;
1005                                                 settingInfo[SETTING_CURRENT_PAGE].isSelected = false;
1006                                                 settingInfo[SETTING_FAVORITE_URL].isSelected = true;
1007                                         }
1008
1009                                 }
1010                         }
1011                 }
1012         }
1013
1014         if (pWindowInfo != null)
1015         {
1016                 __currentURL.Clear();
1017                 __currentURL.Append(pWindowInfo->pageUrl);
1018                 AppLog("current url is %ls",__currentURL.GetPointer());
1019
1020                 if (SettingPresentationModel::GetInstance()->GetFavoriteUrl().CompareTo(L"") == 0)
1021                 {
1022                         if (pWindowInfo->pageUrl.CompareTo(L"") == 0)
1023                         {
1024                                 //settingInfo[SETTING_FAVORITE_URL].titleText = CommonUtil::GetString(L"IDS_SET_HOMEPAGE");
1025                                 settingInfo[SETTING_FAVORITE_URL].titleText = L"http://www.tizen.org";
1026                         }
1027                         else
1028                         {
1029                                 settingInfo[SETTING_FAVORITE_URL].titleText = pWindowInfo->pageUrl;
1030                         }
1031                 }
1032                 else
1033                 {
1034                         settingInfo[SETTING_FAVORITE_URL].titleText = SettingPresentationModel::GetInstance()->GetFavoriteUrl();
1035                 }
1036         }
1037
1038         if (__pList != null)
1039         {
1040                 __pList->UpdateList();
1041                 if (pWindowInfo && pWindowInfo->pageUrl.CompareTo(L"") == 0)
1042                 {
1043                         __isCurrentPageDisable = true;
1044                         AppLog("set item enabled is false");
1045                         __pList->SetItemEnabled(0, 1, false);
1046                 }
1047                 else
1048                 {
1049                         __isCurrentPageDisable = false;
1050                         AppLog("set item enabled is true");
1051                         if (settingInfo[0].isOpen == false)
1052                         {
1053                                 __pList->SetItemEnabled(0,1,false);
1054                         }
1055                         else
1056                         {
1057                                 __pList->SetItemEnabled(0,1,true);
1058                         }
1059                 }
1060                 for(int grpindex = 0; grpindex < groupCount; grpindex++)
1061                 {
1062                         for(int index = 0; index < *(pGroupItemCount+groupCount); index++)
1063                         {
1064                                 int effectiveIndex = 0;
1065                                 for (int i = 0; i < grpindex; i++)
1066                                                 effectiveIndex = effectiveIndex + pGroupItemCount[i];
1067                                         effectiveIndex = effectiveIndex + index;
1068
1069                                         if(effectiveIndex >= SETTING_MAX)
1070                                         {
1071                                                 continue;
1072                                         }
1073                                 if(settingInfo[effectiveIndex].itemType == ITEM_TYPE_TOGGLE || settingInfo[effectiveIndex].itemType == ITEM_TYPE_RADIO )
1074                                 {
1075                                         __pList->SetItemChecked(grpindex, index, settingInfo[effectiveIndex].isSelected);
1076                                 }
1077                         }
1078                 }
1079         }
1080         return;
1081 }
1082
1083 void
1084 SettingForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
1085 {
1086         return;
1087 }
1088
1089 void
1090 SettingForm::ClearHistory(void)
1091 {
1092         if(__pConfirmationPopup)
1093         {
1094                 __pConfirmationPopup->SetShowState(false);
1095                 __pConfirmationPopup->Show();
1096                 delete __pConfirmationPopup;
1097                 __pConfirmationPopup = null;
1098         }
1099         String message = CommonUtil::GetString(L"IDS_BR_BODY_DELETE_BROWSER_HISTORY_Q");
1100         if(!__pConfirmationPopup)
1101         {
1102                 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
1103                 __pConfirmationPopup->Initialize();
1104                 __pConfirmationPopup->RemoveActionListener(*this);
1105                 __pConfirmationPopup->AddActionListener(*this);
1106                 __pConfirmationPopup->setMessage(message);
1107                 __pConfirmationPopup->Show();
1108         }
1109 }
1110
1111 void
1112 SettingForm::ClearCache(void)
1113 {
1114         if(__pConfirmationPopup)
1115         {
1116                 __pConfirmationPopup->SetShowState(false);
1117                 __pConfirmationPopup->Show();
1118                 delete __pConfirmationPopup;
1119                 __pConfirmationPopup = null;
1120         }
1121         String message = CommonUtil::GetString(L"IDS_BR_POP_DELETE_LOCALLY_CACHED_CONTENT_AND_DATABASES_Q");
1122         if(!__pConfirmationPopup)
1123         {
1124                 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
1125                 __pConfirmationPopup->Initialize();
1126                 __pConfirmationPopup->RemoveActionListener(*this);
1127                 __pConfirmationPopup->AddActionListener(*this);
1128                 __pConfirmationPopup->setMessage(message);
1129                 __pConfirmationPopup->Show();
1130         }
1131 }
1132
1133 void
1134 SettingForm::ClearCookie(void)
1135 {
1136         if(__pConfirmationPopup)
1137         {
1138                 __pConfirmationPopup->SetShowState(false);
1139                 __pConfirmationPopup->Show();
1140                 delete __pConfirmationPopup;
1141                 __pConfirmationPopup = null;
1142         }
1143         String message = CommonUtil::GetString(L"IDS_BR_POP_EMPTY_COOKIE_POPUP_BNO");
1144         if(!__pConfirmationPopup)
1145         {
1146                 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
1147                 __pConfirmationPopup->Initialize();
1148                 __pConfirmationPopup->RemoveActionListener(*this);
1149                 __pConfirmationPopup->AddActionListener(*this);
1150                 __pConfirmationPopup->setMessage(message);
1151                 __pConfirmationPopup->Show();
1152         }
1153 }
1154
1155 void
1156 SettingForm::ClearFormData(void)
1157 {
1158         if(__pConfirmationPopup)
1159         {
1160                 __pConfirmationPopup->SetShowState(false);
1161                 __pConfirmationPopup->Show();
1162                 delete __pConfirmationPopup;
1163                 __pConfirmationPopup = null;
1164         }
1165         String message = CommonUtil::GetString(L"IDS_BR_POP_DELETE_ALL_SAVED_FORM_DATA_Q");
1166         if(!__pConfirmationPopup)
1167         {
1168                 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
1169                 __pConfirmationPopup->Initialize();
1170                 __pConfirmationPopup->RemoveActionListener(*this);
1171                 __pConfirmationPopup->AddActionListener(*this);
1172                 __pConfirmationPopup->setMessage(message);
1173                 __pConfirmationPopup->Show();
1174         }
1175 }
1176
1177 void
1178 SettingForm::ClearPasswords(void)
1179 {
1180         if(__pConfirmationPopup)
1181         {
1182                 __pConfirmationPopup->SetShowState(false);
1183                 __pConfirmationPopup->Show();
1184                 delete __pConfirmationPopup;
1185                 __pConfirmationPopup = null;
1186         }
1187         String message = CommonUtil::GetString(L"IDS_BR_POP_DELETE_ALL_SAVED_PASSWORDS_Q");
1188         if(!__pConfirmationPopup)
1189         {
1190                 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
1191                 __pConfirmationPopup->Initialize();
1192                 __pConfirmationPopup->RemoveActionListener(*this);
1193                 __pConfirmationPopup->AddActionListener(*this);
1194                 __pConfirmationPopup->setMessage(message);
1195                 __pConfirmationPopup->Show();
1196         }
1197 }
1198
1199
1200 void
1201 SettingForm::ResetToDefault()
1202 {
1203         if(__pConfirmationPopup)
1204         {
1205                 __pConfirmationPopup->SetShowState(false);
1206                 __pConfirmationPopup->Show();
1207                 delete __pConfirmationPopup;
1208                 __pConfirmationPopup = null;
1209         }
1210         String message = CommonUtil::GetString(L"IDS_BR_POP_ALL_SETTINGS_TO_DEFAULT_CONTINUE_Q");
1211         if(!__pConfirmationPopup)
1212         {
1213                 __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
1214                 __pConfirmationPopup->Initialize();
1215                 __pConfirmationPopup->RemoveActionListener(*this);
1216                 __pConfirmationPopup->AddActionListener(*this);
1217                 __pConfirmationPopup->setMessage(message);
1218                 __pConfirmationPopup->Show();
1219         }
1220 }
1221
1222 void
1223 SettingForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
1224 {
1225         AppLog("receiving userevent for appcontrol %d",requestId);
1226         if (requestId == APPCONTROL_LAUNCH_MAX_LIMIT_REACHED)
1227         {
1228                 AppLog("receiving userevent for appcontrol %d ",requestId);
1229                 if(__pConfirmationPopup)
1230                 {
1231                         __pConfirmationPopup->SetShowState(false);
1232                         delete __pConfirmationPopup;
1233                         __pConfirmationPopup = null;
1234                 }
1235         }
1236         else if (requestId == UPDATE_LIST_COMPLETE)
1237         {
1238                 AppLog("receiving event UPDATE_LIST_COMPLETE");
1239                 Integer *pGroupIndex = static_cast<Integer*>(pArgs->GetAt(0));
1240                 Integer *pItemIndex = static_cast<Integer*>(pArgs->GetAt(1));
1241                 int groupIndex = pGroupIndex->ToInt();
1242                 int itemIndex = pItemIndex->ToInt();
1243
1244                 int effectiveIndex = 0;
1245                 for (int i = 0; i < groupIndex; i++)
1246                         effectiveIndex = effectiveIndex + pGroupItemCount[i];
1247                 effectiveIndex = effectiveIndex + itemIndex;
1248
1249
1250                 if(settingInfo[effectiveIndex].itemType == ITEM_TYPE_TOGGLE || settingInfo[effectiveIndex].itemType == ITEM_TYPE_RADIO )
1251                 {
1252                         AppLog("UPDATE_LIST_COMPLETE SetItemChecked %d, %d, %d",groupIndex, itemIndex, settingInfo[effectiveIndex].isSelected);
1253                         __pList->SetItemChecked(groupIndex, itemIndex, settingInfo[effectiveIndex].isSelected);
1254                         __pList->Invalidate(true);
1255                 }
1256
1257         }
1258 }
1259