Added multi-language resources for the Privacy
[apps/osp/Settings.git] / src / StMainMenuForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://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 /**
18  * @file                StMainMenuForm.cpp
19  * @brief               This is the implementation file for MainMenuForm class.
20  */
21
22 #include <FIo.h>
23 #include "StAppSettingManager.h"
24 #include "StBluetoothPresentationModel.h"
25 #include "StMainMenuForm.h"
26 #include "StNfcPresentationModel.h"
27 #include "StResourceManager.h"
28 #include "StSettingScenesList.h"
29 #include "StTypes.h"
30
31 using namespace Tizen::App;
32 using namespace Tizen::App::Package;
33 using namespace Tizen::Base;
34 using namespace Tizen::Base::Collection;
35 using namespace Tizen::Base::Utility;
36 using namespace Tizen::Graphics;
37 using namespace Tizen::Io;
38 using namespace Tizen::Net::Bluetooth;
39 using namespace Tizen::System;
40 using namespace Tizen::Ui;
41 using namespace Tizen::Ui::Controls;
42 using namespace Tizen::Ui::Scenes;
43
44 //static const int W_RESIZE_LABEL_GAP = 110;
45
46 static const int H_GROUP_FONT_SIZE_GIANT = 146;
47 static const int H_GROUP_FONT_SIZE_HUGE = 128;
48 static const int H_GROUP_FONT_SIZE_LARGE = 110;
49 static const int H_GROUP_FONT_SIZE_DEFAULT = 80;
50 static const int H_GROUP_TITLE_TEXT = (H_GROUP_INDEX_TITLE_TEXT / 4);
51 static const int MAIN_RELATIVE_LAYOUT_RIGHT_MARGIN = 60;
52
53 static const wchar_t* APPCONTROL_OPERATION_ID_CONFIGURE = L"http://tizen.org/appcontrol/operation/configure";
54 static const wchar_t* APPCONTROL_PROVIDER_ID_PHONE = L"tizen.phone";
55 static const wchar_t* APPCONTROL_PROVIDER_ID_ACCOUNT = L"ZsnYtAdjl2.Account";
56
57 static const wchar_t* ID_RELATIVE_SETTING_XML_FILE_PATH = L"/setting/setting.xml";
58 static const wchar_t* ID_APPLICATION_DEFAULT_FOLDER_PATH = L"/opt/apps/";
59
60 static const int ID_GROUP_CONNECTIVITY = 0;
61 static const int ID_ITEM_CONNECTIVITY_WIFI = 0;
62 static const int ID_ITEM_CONNECTIVITY_BLUETOOTH = 1;
63 static const int ID_ITEM_CONNECTIVITY_NETWORK = 2;
64 static const int ID_ITEM_CONNECTIVITY_NFC = 3;
65 static const int ID_GROUP_CONNECTIVITY_ITEM_COUNT = 4;
66
67 //static const int ID_GROUP_MODE = 1;
68 //static const int ID_ITEM_MODE_FLIGHT_MODE = 0;
69 //static const int ID_GROUP_MODE_ITEM_COUNT = 1;
70
71 static const int ID_GROUP_PERSONAL = 1;
72 static const int ID_ITEM_PERSONAL_HOME_SCREEN = 0;
73 static const int ID_ITEM_PERSONAL_LOCK_SCREEN = 1;
74 static const int ID_ITEM_PERSONAL_ACCOUNTS = 2;
75 static const int ID_ITEM_PERSONAL_PRIVACY = 3;
76 static const int ID_GROUP_PERSONAL_ITEM_COUNT = 4;
77
78 static const int ID_GROUP_DEVICE = 2;
79 static const int ID_ITEM_DEVICE_DISPLAY = 0;
80 static const int ID_ITEM_DEVICE_SOUND = 1;
81 static const int ID_ITEM_DEVICE_LOCATION = 2;
82 static const int ID_ITEM_DEVICE_CALL_SETTING = 3;
83 static const int ID_ITEM_DEVICE_ACCESSIBILITY = 6;
84 static const int ID_ITEM_DEVICE_DATE_TIME = 4;
85 static const int ID_ITEM_DEVICE_LANGUAGE_KEYBOARD = 5;
86 static const int ID_GROUP_DEVICE_ITEM_COUNT = 6;
87
88 static const int ID_GROUP_SYSTEM = 3;
89 static const int ID_ITEM_SYSTEM_MANAGE_APPLICATION = 0;
90 static const int ID_ITEM_SYSTEM_DEVELOPER_OPTION = 2;
91 static const int ID_ITEM_SYSTEM_ABOUT_PHONE = 1;
92 static const int ID_GROUP_SYSTEM_ITEM_COUNT = 2;
93
94 static const int ID_GROUP_APPSETTING = 4;
95 static const int ID_GROUP_NO_APPSETTING = 4;
96 static const int ID_MAIN_MENU_DEFAULT_COUNT = 1;
97
98 //void
99 //IFlightModeSetValueAsyncResultListener::OnResultReceivedForSetValueAsync(const Tizen::Base::String& key, result r)
100 //{
101 //      AppLogDebug("key(%ls) r(%s)", key.GetPointer(), GetErrorMessage(r));
102 //}
103
104 MainMenuForm::MainMenuForm(void)
105         : __pDownloadAppIdKeyList(null)
106         , __pAppIdHashMap(null)
107         , __pAppIconPathHashMap(null)
108 //      , __pFlightModeSetValueAsyncResultListener(null)
109 {
110 }
111
112 MainMenuForm::~MainMenuForm(void)
113 {
114 }
115
116 void
117 MainMenuForm::CreateFooter(void)
118 {
119         Footer* pFooter = GetFooter();
120         AppAssert(pFooter);
121
122         pFooter->SetBackButton();
123         pFooter->AddActionEventListener(*this);
124 }
125
126 result
127 MainMenuForm::OnInitializing(void)
128 {
129         AppLogDebug("ENTER");
130
131         CreateHeader(ResourceManager::GetString(L"IDS_COM_BODY_SETTINGS"));
132         CreateFooter();
133         CreateTableView();
134         SetAppIdListFromPackageManager();
135
136         return E_SUCCESS;
137 }
138
139 result
140 MainMenuForm::OnTerminating(void)
141 {
142         RemoveAllDownLoadAppIdKeyList();
143         RemoveAllAppIdList();
144         __pTableView = null;
145
146         return E_SUCCESS;
147 }
148
149 void
150 MainMenuForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
151 {
152         Header* pHeader = GetHeader();
153         pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_SETTINGS"));
154
155         RemoveAllDownLoadAppIdKeyList();
156         SetAppIdListFromPackageManager();
157
158         __pTableView->UpdateTableView();
159
160 //      bool flightModeEnableStatus = false;
161 //      if (SettingInfo::GetValue(SETTING_INFO_KEY_NETWORK_FLIGHTMODE, flightModeEnableStatus) == E_SUCCESS)
162 //      {
163 //              __pTableView->SetItemChecked(ID_GROUP_MODE, ID_ITEM_MODE_FLIGHT_MODE, flightModeEnableStatus);
164 //      }
165 }
166
167 void
168 MainMenuForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
169 {
170 }
171
172 int
173 MainMenuForm::GetGroupCount(void)
174 {
175         int groupItemCount = ID_GROUP_NO_APPSETTING;
176         if (GetDownLoadAppCount() > 0)
177         {
178                 groupItemCount = ID_GROUP_APPSETTING + ID_MAIN_MENU_DEFAULT_COUNT;
179         }
180
181         return groupItemCount;
182 }
183
184 int
185 MainMenuForm::GetItemCount(int groupIndex)
186 {
187         AppLogDebug("ENTER");
188
189         int itemCount = 0;
190
191         switch (groupIndex)
192         {
193         case ID_GROUP_CONNECTIVITY:
194                 {
195                         itemCount = ID_GROUP_CONNECTIVITY_ITEM_COUNT;
196                 }
197                 break;
198
199 //      case ID_GROUP_MODE:
200 //              {
201 //                      itemCount = ID_GROUP_MODE_ITEM_COUNT;
202 //              }
203 //              break;
204
205         case ID_GROUP_DEVICE:
206                 {
207                         itemCount = ID_GROUP_DEVICE_ITEM_COUNT;
208                 }
209                 break;
210
211         case ID_GROUP_PERSONAL:
212                 {
213                         itemCount = ID_GROUP_PERSONAL_ITEM_COUNT;
214                 }
215                 break;
216
217         case ID_GROUP_SYSTEM:
218                 {
219                         itemCount = ID_GROUP_SYSTEM_ITEM_COUNT;
220                 }
221                 break;
222
223         case ID_GROUP_APPSETTING:
224                 {
225                         itemCount = GetDownLoadAppCount();
226                 }
227                 break;
228
229         default:
230                 break;
231         }
232
233         return itemCount;
234 }
235
236 TableViewGroupItem*
237 MainMenuForm::CreateGroupItem(int groupIndex, int itemWidth)
238 {
239         AppLogDebug("ENTER");
240
241         int itemHeight = H_GROUP_INDEX_DEFAULT;
242         LabelTextStyle style = LABEL_TEXT_STYLE_BOLD;
243         Rectangle itemRectangle;
244         String groupText;
245         Label* pLabel = null;
246         int fontSize = GetFontSize();
247
248         switch (groupIndex)
249         {
250         case ID_GROUP_CONNECTIVITY:
251                 {
252                         groupText = ResourceManager::GetString(L"IDS_ST_BODY_CONNECTIVITY");
253                 }
254                 break;
255
256 //      case ID_GROUP_MODE:
257 //              {
258 //                      groupText = ResourceManager::GetString(L"IDS_ST_BODY_MODE");
259 //              }
260 //              break;
261
262         case ID_GROUP_PERSONAL:
263                 {
264                         groupText = ResourceManager::GetString(L"IDS_ST_BODY_PERSONAL");
265                 }
266                 break;
267
268         case ID_GROUP_DEVICE:
269                 {
270                         groupText = ResourceManager::GetString(L"IDS_ST_BODY_DEVICE");
271                 }
272                 break;
273
274         case ID_GROUP_SYSTEM:
275                 {
276                         groupText = ResourceManager::GetString(L"IDS_ST_BODY_SYSTEM");
277                 }
278                 break;
279
280         case ID_GROUP_APPSETTING:
281                 {
282                         groupText = ResourceManager::GetString(L"IDS_ST_BODY_DOWNLOADED_APPLICATIONS");
283                 }
284                 break;
285
286         default:
287                 break;
288         }
289
290         TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
291
292         itemRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
293         itemRectangle.y = H_GROUP_TITLE_TEXT;
294         itemRectangle.width = itemWidth - itemRectangle.x;
295
296         if (fontSize == FONT_MAIN_TEXT_SIZE_GIANT)
297         {
298                 itemHeight = itemRectangle.height = H_GROUP_FONT_SIZE_GIANT;
299         }
300         else if (fontSize == FONT_MAIN_TEXT_SIZE_HUGE)
301         {
302                 itemHeight = itemRectangle.height = H_GROUP_FONT_SIZE_HUGE;
303         }
304         else if (fontSize == FONT_MAIN_TEXT_SIZE_LARGE)
305         {
306                 itemHeight = itemRectangle.height = H_GROUP_FONT_SIZE_LARGE;
307         }
308         else
309         {
310                 itemHeight = itemRectangle.height = H_GROUP_FONT_SIZE_DEFAULT;
311         }
312
313         RelativeLayout relativeLayout;
314         relativeLayout.Construct();
315
316         pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
317         pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
318
319         pLabel = new (std::nothrow) Label();
320         pLabel->Construct(itemRectangle, groupText);
321         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
322         pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
323         pLabel->SetTextConfig(fontSize, style);
324         pLabel->SetTextColor(COLOR_GROUP_TITLE_TEXT);
325
326         pItem->AddControl(*pLabel);
327         relativeLayout.SetMargin(*pLabel, itemRectangle.x, 0, 0, 0);
328         relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
329         relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
330         pItem->SetEnabled(false);
331
332         return pItem;
333 }
334
335 TableViewItem*
336 MainMenuForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
337 {
338         AppLogDebug("group[%d] item[%d]", groupIndex, itemIndex);
339
340         int fontSize = GetFontSize();
341
342         unsigned int itemHeight = 0;
343         bool isDrawBitmapIcon = true;
344         Rectangle itemRectIcon;
345         Rectangle itemRectLabel;
346         Rectangle itemRectSecondLabel;
347         String itemText;
348         String itemTextTwoLine;
349         TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
350         Bitmap* pBitmap = null;
351         Label* pLabel = null;
352
353         itemHeight = H_GROUP_ITEM_DEFAULT_LABEL;
354         ItemTypeIconAndOneLine(itemRectIcon, itemRectLabel);
355
356         switch (groupIndex)
357         {
358         case ID_GROUP_CONNECTIVITY:
359                 {
360                         switch (itemIndex)
361                         {
362                         case ID_ITEM_CONNECTIVITY_WIFI:
363                                 {
364                                         pBitmap = ResourceManager::GetBitmapN(IDB_WIFI);
365                                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_WI_FI");
366                                 }
367                                 break;
368
369                         case ID_ITEM_CONNECTIVITY_BLUETOOTH:
370                                 {
371                                         ItemTypeIconAndOneLine(itemRectIcon, itemRectLabel);
372                                         itemHeight = itemRectLabel.height;
373
374                                         pBitmap = ResourceManager::GetBitmapN(IDB_BLUETOOTH);
375                                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_BLUETOOTH");
376                                 }
377                                 break;
378
379                         case ID_ITEM_CONNECTIVITY_NETWORK:
380                                 {
381                                         pBitmap = ResourceManager::GetBitmapN(IDB_NETWORK);
382                                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_NETWORK");
383                                 }
384                                 break;
385
386                         case ID_ITEM_CONNECTIVITY_NFC:
387                                 {
388                                         ItemTypeIconAndOneLine(itemRectIcon, itemRectLabel);
389                                         itemHeight = (itemRectLabel.height + itemRectSecondLabel.height);
390
391                                         pBitmap = ResourceManager::GetBitmapN(IDB_NFC);
392                                         itemText = ResourceManager::GetString(L"IDS_NFC_BODY_NFC");
393                                 }
394                                 break;
395
396                         default:
397                                 break;
398                         }
399                 }
400                 break;
401
402 //      case ID_GROUP_MODE:
403 //              {
404 //                      style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
405 //                      itemRectLabel.width -= W_RESIZE_LABEL_GAP;
406 //                      pBitmap = ResourceManager::GetBitmapN(IDB_FLIGHT_MODE);
407 //                      itemText = ResourceManager::GetString(L"IDS_ST_BODY_FLIGHT_MODE");
408 //              }
409 //              break;
410
411         case ID_GROUP_PERSONAL:
412                 {
413                         switch (itemIndex)
414                         {
415                         case ID_ITEM_PERSONAL_HOME_SCREEN:
416                                 {
417                                         pBitmap = ResourceManager::GetBitmapN(IDB_HOME_SCREEN);
418                                         itemText = ResourceManager::GetString(L"IDS_ST_HEADER_HOME_SCREEN");
419                                 }
420                                 break;
421
422                         case ID_ITEM_PERSONAL_LOCK_SCREEN:
423                                 {
424                                         pBitmap = ResourceManager::GetBitmapN(IDB_LOCK_SCREEN);
425                                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_LOCK_SCREEN");
426                                 }
427                                 break;
428
429                         case ID_ITEM_PERSONAL_ACCOUNTS:
430                                 {
431                                         pBitmap = ResourceManager::GetBitmapN(IDB_ACCOUNTS);
432                                         itemText = ResourceManager::GetString(L"IDS_COM_BODY_ACCOUNTS");
433                                 }
434                                 break;
435
436                         case ID_ITEM_PERSONAL_PRIVACY:
437                                 {
438                                         pBitmap = ResourceManager::GetBitmapN(IDB_PRIVACY);
439                                         itemText = ResourceManager::GetString(L"IDS_COM_BODY_PRIVACY");
440                                 }
441                                 break;
442
443                         default:
444                                 break;
445                         }
446                 }
447                 break;
448
449         case ID_GROUP_DEVICE:
450                 {
451                         switch (itemIndex)
452                         {
453                         case ID_ITEM_DEVICE_DISPLAY:
454                                 {
455                                         pBitmap = ResourceManager::GetBitmapN(IDB_DISPLAY);
456                                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_DISPLAY");
457                                 }
458                                 break;
459
460                         case ID_ITEM_DEVICE_SOUND:
461                                 {
462                                         pBitmap = ResourceManager::GetBitmapN(IDB_SOUND);
463                                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_SOUNDS");
464                                 }
465                                 break;
466
467                         case ID_ITEM_DEVICE_LOCATION:
468                                 {
469                                         pBitmap = ResourceManager::GetBitmapN(IDB_LOCATION);
470                                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_LOCATIONS");
471                                 }
472                                 break;
473
474                         case ID_ITEM_DEVICE_CALL_SETTING:
475                                 {
476                                         pBitmap = ResourceManager::GetBitmapN(IDB_PHONE);
477                                         itemText = ResourceManager::GetString(L"IDS_CST_BODY_CALL_SETTINGS");
478                                 }
479                                 break;
480
481                         case ID_ITEM_DEVICE_ACCESSIBILITY:
482                                 {
483                                         pBitmap = ResourceManager::GetBitmapN(IDB_ACCESSIBILITY);
484                                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_ACCESSIBILITY");
485                                 }
486                                 break;
487
488                         case ID_ITEM_DEVICE_DATE_TIME:
489                                 {
490                                         pBitmap = ResourceManager::GetBitmapN(IDB_DATE_AND_TIME);
491                                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_DATE_AND_TIME");
492                                 }
493                                 break;
494
495                         case ID_ITEM_DEVICE_LANGUAGE_KEYBOARD:
496                                 {
497                                         pBitmap = ResourceManager::GetBitmapN(IDB_LANGUAGE_KEYBOARD);
498                                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_LANGUAGE_AND_KEYBOARD");
499                                 }
500                                 break;
501
502                         default:
503                                 break;
504                         }
505                 }
506                 break;
507
508         case ID_GROUP_SYSTEM:
509                 {
510                         switch (itemIndex)
511                         {
512                         case ID_ITEM_SYSTEM_MANAGE_APPLICATION:
513                                 {
514                                         pBitmap = ResourceManager::GetBitmapN(IDB_MANAGE_APPLICATION);
515                                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_MANAGE_APPLICATIONS");
516                                 }
517                                 break;
518
519                         case ID_ITEM_SYSTEM_DEVELOPER_OPTION:
520                                 {
521                                         pBitmap = ResourceManager::GetBitmapN(IDB_DEVELOPER_OPTION);
522                                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_DEVELOPER_OPTIONS");
523                                 }
524                                 break;
525
526                         case ID_ITEM_SYSTEM_ABOUT_PHONE:
527                                 {
528                                         pBitmap = ResourceManager::GetBitmapN(IDB_ABOUT_PHONE);
529                                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_ABOUT_PHONE");
530                                 }
531                                 break;
532
533                         default:
534                                 break;
535                         }
536                 }
537                 break;
538
539         case ID_GROUP_APPSETTING:
540                 {
541                         String appIdKey = GetDownLoadAppIdKeyAt(itemIndex);
542                         String iconPath = GetAppSettingIconPathFromAppIdListAt(appIdKey);
543
544                         itemText = GetDownLoadAppNameAt(itemIndex);
545
546                         if (iconPath.IsEmpty() == true)
547                         {
548                                 pBitmap = ResourceManager::GetBitmapN(IDB_DEFAULT_ICON);
549                         }
550                         else
551                         {
552                                 pBitmap = ResourceManager::GetApplicationBitmapN(iconPath);
553                         }
554                 }
555                 break;
556
557         default:
558                 break;
559         }
560
561         TableViewItem* pItem = new (std::nothrow) TableViewItem();
562
563         if (pItem)
564         {
565                 RelativeLayout relativeLayout;
566                 relativeLayout.Construct();
567
568                 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
569                 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
570
571                 if (isDrawBitmapIcon)
572                 {
573                         pLabel = new (std::nothrow) Label();
574                         pLabel->Construct(itemRectIcon, L"");
575                         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
576                         pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
577                         pLabel->SetBackgroundBitmap(*pBitmap);
578
579                         pItem->AddControl(*pLabel);
580                 }
581
582                 pLabel = new (std::nothrow) Label();
583                 pLabel->Construct(itemRectLabel, itemText);
584                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
585                 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
586                 pLabel->SetTextColor(COLOR_MAIN_TEXT);
587
588                 pItem->AddControl(*pLabel);
589                 relativeLayout.SetMargin(*pLabel, itemRectLabel.x, MAIN_RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
590                 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
591                 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
592         }
593
594         return pItem;
595 }
596
597 Tizen::Base::String
598 MainMenuForm::GetAppSettingIconPathFromAppIdListAt(Tizen::Base::String& id)
599 {
600         String iconPath;
601
602         if (__pAppIconPathHashMap)
603         {
604                 if (__pAppIconPathHashMap->ContainsKey(id) == true)
605                 {
606                         iconPath = *(static_cast<String*>(__pAppIconPathHashMap->GetValue((id))));
607                 }
608         }
609         return iconPath;
610 }
611
612 bool
613 MainMenuForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
614 {
615         AppLogDebug("ENTER");
616
617         delete pItem;
618         pItem = null;
619
620         return true;
621 }
622
623 bool
624 MainMenuForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
625 {
626         AppLogDebug("ENTER");
627
628         delete pItem;
629         pItem = null;
630
631         return true;
632 }
633
634 void
635 MainMenuForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
636 {
637         SceneManager* pSceneManager = SceneManager::GetInstance();
638         AppAssert(pSceneManager);
639
640         ArrayList* pArgs = null;
641         const wchar_t* pSceneName = null;
642
643         AppLogDebug("Group(%d) index(%d)", groupIndex, itemIndex);
644
645         switch (groupIndex)
646         {
647         case ID_GROUP_CONNECTIVITY:
648                 {
649                         pSceneName = GroupConnectivitySceneConnect(__currentTableViewList, itemIndex, status);
650                 }
651                 break;
652
653 //      case ID_GROUP_MODE:
654 //              {
655 //                      if (itemIndex == ID_ITEM_MODE_FLIGHT_MODE)
656 //                      {
657 //                              bool flightModeStatus = tableView.IsItemChecked(groupIndex, itemIndex);
658 //                              if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
659 //                              {
660 //                                      flightModeStatus = (!(flightModeStatus));
661 //                              }
662 //
663 //                              SetIFlightModeSetValueAsyncResultListener();
664 //                              if (SettingInfo::SetValueAsyncForPrivilegedKey(SETTING_INFO_KEY_NETWORK_FLIGHTMODE, flightModeStatus, __pFlightModeSetValueAsyncResultListener) == E_SUCCESS)
665 //                              {
666 //                                      tableView.SetItemChecked(groupIndex, itemIndex, flightModeStatus);
667 //                                      AppLogDebug("flightmode(%d) GetLastResult(%s)", flightModeStatus, GetErrorMessage(GetLastResult()));
668 //                              }
669 //                              else
670 //                              {
671 //                                      AppLogDebug("flightmode(%d) GetLastResult(%s)", flightModeStatus, GetErrorMessage(GetLastResult()));
672 //                              }
673 //                      }
674 //              }
675 //              break;
676
677         case ID_GROUP_PERSONAL:
678                 {
679                         pSceneName = GroupPersonalSceneConnect(__currentTableViewList, itemIndex, status);
680
681                         if ((itemIndex != ID_ITEM_PERSONAL_HOME_SCREEN)
682                                 && (itemIndex != ID_ITEM_PERSONAL_LOCK_SCREEN))
683                         {
684                                 break;
685                         }
686
687                         pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
688                         if (pArgs == null)
689                         {
690                                 AppLogDebug("pArgs is null");
691                                 break;
692                         }
693
694                         result r = pArgs->Construct();
695                         if (IsFailed(r))
696                         {
697                                 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
698                                 break;
699                         }
700
701                         switch (itemIndex)
702                         {
703                         case ID_ITEM_PERSONAL_HOME_SCREEN:
704                                 {
705                                         pArgs->Add(*(new (std::nothrow) String(Integer::ToString(itemIndex))));
706                                 }
707                                 break;
708
709                         case ID_ITEM_PERSONAL_LOCK_SCREEN:
710                                 {
711                                         pArgs->Add(*(new (std::nothrow) String(Integer::ToString(itemIndex))));
712                                 }
713                                 break;
714                         }
715                 }
716                 break;
717
718         case ID_GROUP_DEVICE:
719                 {
720                         pSceneName = GroupDeviceSceneConnect(__currentTableViewList, itemIndex, status);
721                 }
722                 break;
723
724         case ID_GROUP_SYSTEM:
725                 {
726                         pSceneName = GroupSystemSceneConnect(__currentTableViewList, itemIndex, status);
727                 }
728                 break;
729
730         case ID_GROUP_APPSETTING:
731                 {
732                         String appIdKey = GetDownLoadAppIdKeyAt(itemIndex);
733                         if (appIdKey.IsEmpty() == true)
734                         {
735                                 AppLogDebug("GetDownLoadAppIdKeyAt[%d] fail", itemIndex);
736                                 break;
737                         }
738
739                         String appSettingFilepath = GetAppSettingFilePathFromAppIdListAt(appIdKey);
740                         if (appSettingFilepath.IsEmpty() == true)
741                         {
742                                 AppLogDebug("GetAppSettingFilePathFromAppIdListAt[%ls] fail", appIdKey.GetPointer());
743                                 break;
744                         }
745
746                         pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
747                         if (pArgs == null)
748                         {
749                                 AppLogDebug("pArgs is null");
750                                 break;
751                         }
752
753                         result r = pArgs->Construct();
754                         if (IsFailed(r))
755                         {
756                                 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
757                                 break;
758                         }
759
760                         pArgs->Add(*(new (std::nothrow) String(appIdKey)));
761                         pArgs->Add(*(new (std::nothrow) String(appSettingFilepath)));
762
763                         pSceneName = IDSCN_XML_PARSER;
764                 }
765                 break;
766
767         default:
768                 break;
769         }
770
771         if (pSceneName != IDSCN_NULL)
772         {
773                 AppLogDebug("pSceneName[%ls]", pSceneName);
774                 pSceneManager->GoForward(ForwardSceneTransition(pSceneName, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
775         }
776 }
777
778 result
779 MainMenuForm::SetDownLoadAppIdKeyList(void)
780 {
781         RemoveAllDownLoadAppIdKeyList();
782
783         if (__pAppIdHashMap == null)
784         {
785                 AppLogDebug("__pAppIdHashMap is null");
786                 return E_FAILURE;
787         }
788
789         __pDownloadAppIdKeyList = __pAppIdHashMap->GetKeysN();
790         if (__pDownloadAppIdKeyList == null)
791         {
792                 AppLogDebug("__pDownloadAppIdKeyList is null");
793                 return E_FAILURE;
794         }
795
796         return E_SUCCESS;
797 }
798
799 void
800 MainMenuForm::RemoveAllDownLoadAppIdKeyList(void)
801 {
802         if (__pDownloadAppIdKeyList != null)
803         {
804                 __pDownloadAppIdKeyList->RemoveAll();
805                 delete __pDownloadAppIdKeyList;
806                 __pDownloadAppIdKeyList = null;
807         }
808 }
809
810 result
811 MainMenuForm::SetAppIdListFromPackageManager(void)
812 {
813         RemoveAllAppIdList();
814
815         __pAppIdHashMap = new (std::nothrow) HashMap();
816         if (__pAppIdHashMap == null)
817         {
818                 AppLogDebug("__pAppIdHashMap is null");
819                 return E_FAILURE;
820         }
821
822         result r = __pAppIdHashMap->Construct();
823         if (IsFailed(r))
824         {
825                 AppLogDebug("Construct fail [%s]", GetErrorMessage(GetLastResult()));
826                 RemoveAllAppIdList();
827                 return E_FAILURE;
828         }
829
830         __pAppIconPathHashMap = new (std::nothrow) HashMap();
831         if (__pAppIconPathHashMap == null)
832         {
833                 AppLogDebug("__pAppIconPathHashMap is null");
834                 return E_FAILURE;
835         }
836         r = __pAppIconPathHashMap->Construct();
837         if (IsFailed(r))
838         {
839                 AppLogDebug("Construct fail [%s]", GetErrorMessage(GetLastResult()));
840                 RemoveAllAppIdList();
841                 return E_FAILURE;
842         }
843
844         IList* pList = null;
845         PackageManager* pPackageManager = PackageManager::GetInstance();
846         if (pPackageManager == null)
847         {
848                 AppLogDebug("pPackageManager is null");
849                 RemoveAllAppIdList();
850                 return E_FAILURE;
851         }
852
853         pList = pPackageManager->GetPackageInfoListN();
854         if (pList == null)
855         {
856                 AppLogDebug("pList is null");
857                 RemoveAllAppIdList();
858                 return E_FAILURE;
859         }
860
861         IEnumerator* pEnumerator = pList->GetEnumeratorN();
862         if (pEnumerator == null)
863         {
864                 AppLogDebug("pEnumerator is null");
865                 pList->RemoveAll();
866                 delete pList;
867                 RemoveAllAppIdList();
868                 return E_FAILURE;
869         }
870
871         bool isFindXml = false;
872         UiApp* pApp = UiApp::GetInstance();
873         AppAssert(pApp);
874
875         while (pEnumerator->MoveNext() == E_SUCCESS)
876         {
877                 PackageInfo* pPackage = static_cast<PackageInfo*>(pEnumerator->GetCurrent());
878                 if (pPackage != null && pPackage->GetType() == PACKAGE_TYPE_TPK)
879                 {
880                         String path(ID_APPLICATION_DEFAULT_FOLDER_PATH);
881                         path.Append(pPackage->GetId());
882
883                         path.Append(ID_RELATIVE_SETTING_XML_FILE_PATH);
884
885                         if ((File::IsFileExist(path) == true)
886                                 && (!pApp->GetAppId().Contains(pPackage->GetId())))
887                         {
888                                 String key(pPackage->GetDisplayName());
889                                 key.Append(L":");
890                                 key.Append(pPackage->GetId());
891
892                                 String currentAppId = pPackage->GetMainAppId();
893                                 PackageAppInfo* pPackageInfo = static_cast<PackageAppInfo*>(pPackage->GetPackageAppInfoN(currentAppId));
894                                 String iconPath = pPackageInfo->GetAppMenuIconPath();
895
896                                 __pAppIdHashMap->Add(*(new (std::nothrow) String(key)), *(new (std::nothrow) String(path)));
897                                 __pAppIconPathHashMap->Add(*(new (std::nothrow) String(key)), *(new (std::nothrow) String(iconPath)));
898                                 isFindXml = true;
899                         }
900                 }
901         }
902         delete pEnumerator;
903         delete pList;
904
905         if (isFindXml == false)
906         {
907                 RemoveAllAppIdList();
908                 return E_FAILURE;
909         }
910
911         r = SetDownLoadAppIdKeyList();
912         if (IsFailed(r))
913         {
914                 RemoveAllDownLoadAppIdKeyList();
915                 RemoveAllAppIdList();
916                 return E_FAILURE;
917         }
918
919         return E_SUCCESS;
920 }
921
922 void
923 MainMenuForm::RemoveAllAppIdList(void)
924 {
925         if (__pAppIdHashMap != null)
926         {
927                 __pAppIdHashMap->RemoveAll();
928                 delete __pAppIdHashMap;
929                 __pAppIdHashMap = null;
930         }
931
932         if (__pAppIconPathHashMap != null)
933         {
934                 __pAppIconPathHashMap->RemoveAll();
935                 delete __pAppIconPathHashMap;
936                 __pAppIconPathHashMap = null;
937         }
938 }
939
940 Tizen::Base::String
941 MainMenuForm::GetAppSettingFilePathFromAppIdListAt(Tizen::Base::String key)
942 {
943         String appSettingFilePath;
944         if (__pAppIdHashMap == null)
945         {
946                 AppLogDebug("__pAppIdHashMap is null");
947                 return appSettingFilePath;
948         }
949
950         bool isFind = false;
951         result r = __pAppIdHashMap->ContainsKey(key, isFind);
952         if ((isFind == false)
953                 || (IsFailed(r)))
954         {
955                 if (isFind == false)
956                 {
957                         AppLogDebug("key[%ls] is not found", key.GetPointer());
958                 }
959                 else
960                 {
961                         AppLogDebug("ContainsKey fail [%s]", GetErrorMessage(r));
962                 }
963                 return appSettingFilePath;
964         }
965
966         String* pValue = static_cast<String*>(__pAppIdHashMap->GetValue(key));
967         if (pValue == null)
968         {
969                 AppLogDebug("pValue is null");
970                 return appSettingFilePath;
971         }
972
973         appSettingFilePath.Append(*pValue);
974         return appSettingFilePath;
975 }
976
977 Tizen::Base::String
978 MainMenuForm::GetDownLoadAppNameAt(unsigned int index)
979 {
980         String appName;
981         if (__pDownloadAppIdKeyList == null)
982         {
983                 AppLogDebug("__pDownloadAppIdKeyList is null");
984                 return appName;
985         }
986
987         String* pAppKey = static_cast<String*>(__pDownloadAppIdKeyList->GetAt(index));
988         if (pAppKey == null)
989         {
990                 AppLogDebug("pAppKey is null");
991                 return appName;
992         }
993
994         StringTokenizer stringTokenizer(*pAppKey, L":");
995         result r = stringTokenizer.GetNextToken(appName);
996         if (IsFailed(r))
997         {
998                 AppLogDebug("GetNextToken fail[%s]",GetErrorMessage(r));
999                 return appName;
1000         }
1001
1002         return appName;
1003 }
1004
1005 Tizen::Base::String
1006 MainMenuForm::GetDownLoadAppIdKeyAt(unsigned int index)
1007 {
1008         String appIdKey;
1009         if (__pDownloadAppIdKeyList == null)
1010         {
1011                 AppLogDebug("__pDownloadAppIdKeyList is null");
1012                 return appIdKey;
1013         }
1014
1015         String* pAppKey = static_cast<String*>(__pDownloadAppIdKeyList->GetAt(index));
1016         if (pAppKey == null)
1017         {
1018                 AppLogDebug("pAppKey is null");
1019                 return appIdKey;
1020         }
1021
1022         appIdKey.Append(*pAppKey);
1023
1024         return appIdKey;
1025 }
1026
1027 unsigned int
1028 MainMenuForm::GetDownLoadAppCount(void)
1029 {
1030         unsigned int downLoadAppCount = 0;
1031         if (__pDownloadAppIdKeyList == null)
1032         {
1033                 AppLogDebug("__pDownloadAppIdKeyList is null");
1034                 return downLoadAppCount;
1035         }
1036
1037         downLoadAppCount = __pDownloadAppIdKeyList->GetCount();
1038         return downLoadAppCount;
1039 }
1040
1041 const wchar_t*
1042 MainMenuForm::GroupConnectivitySceneConnect(int viewMode, int itemIndex, Tizen::Ui::Controls::TableViewItemStatus status)
1043 {
1044         const wchar_t* pScene = null;
1045
1046         switch (itemIndex)
1047         {
1048         case ID_ITEM_CONNECTIVITY_WIFI:
1049                 {
1050 //                      if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
1051                         {
1052                                 pScene = IDSCN_WIFI;
1053                         }
1054                 }
1055                 break;
1056
1057         case ID_ITEM_CONNECTIVITY_BLUETOOTH:
1058                 {
1059 //                      if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
1060                         {
1061                                 pScene = IDSCN_BLUETOOTH;
1062                         }
1063                 }
1064                 break;
1065
1066         case ID_ITEM_CONNECTIVITY_NETWORK:
1067                 {
1068                         pScene = IDSCN_NETWORK;
1069                 }
1070                 break;
1071
1072         case ID_ITEM_CONNECTIVITY_NFC:
1073                 {
1074                         pScene = IDSCN_NFC;
1075                 }
1076                 break;
1077
1078         default:
1079                 {
1080                         pScene = IDSCN_NULL;
1081                 }
1082                 break;
1083         }
1084
1085         return pScene;
1086 }
1087
1088 const wchar_t*
1089 MainMenuForm::GroupPersonalSceneConnect (int viewMode, int itemIndex, Tizen::Ui::Controls::TableViewItemStatus status)
1090 {
1091         const wchar_t* pScene = null;
1092
1093         switch (itemIndex)
1094         {
1095         case ID_ITEM_PERSONAL_HOME_SCREEN:
1096                 {
1097                         pScene = IDSCN_WALLPAPER_ALBUM_LIST;
1098                 }
1099                 break;
1100
1101         case ID_ITEM_PERSONAL_LOCK_SCREEN:
1102                 {
1103                         pScene = IDSCN_WALLPAPER_ALBUM_LIST;
1104                 }
1105                 break;
1106
1107         case ID_ITEM_PERSONAL_ACCOUNTS:
1108                 {
1109                         pScene = IDSCN_NULL;
1110
1111                         FindAppControlScene(itemIndex);
1112                 }
1113                 break;
1114
1115         case ID_ITEM_PERSONAL_PRIVACY:
1116                 {
1117                         pScene = IDSCN_PRIVACY;
1118                 }
1119                 break;
1120
1121         default:
1122                 {
1123                         pScene = IDSCN_NULL;
1124                 }
1125                 break;
1126         }
1127         return pScene;
1128 }
1129
1130 const wchar_t*
1131 MainMenuForm::GroupDeviceSceneConnect(int viewMode, int itemIndex, Tizen::Ui::Controls::TableViewItemStatus status)
1132 {
1133         const wchar_t* pScene = null;
1134
1135         switch (itemIndex)
1136         {
1137         case ID_ITEM_DEVICE_DISPLAY:
1138                 {
1139                         pScene = IDSCN_DISPLAY;
1140                 }
1141                 break;
1142
1143         case ID_ITEM_DEVICE_SOUND:
1144                 {
1145                         pScene = IDSCN_SOUNDS;
1146                 }
1147                 break;
1148
1149         case ID_ITEM_DEVICE_LOCATION:
1150                 {
1151                         pScene = IDSCN_LOCATION;
1152                 }
1153                 break;
1154
1155         case ID_ITEM_DEVICE_CALL_SETTING:
1156                 {
1157                         pScene = IDSCN_NULL;
1158
1159                         FindAppControlScene(itemIndex);
1160                 }
1161                 break;
1162
1163         case ID_ITEM_DEVICE_ACCESSIBILITY:
1164                 {
1165                         pScene = IDSCN_ACCESSIBILITY;
1166                 }
1167                 break;
1168
1169         case ID_ITEM_DEVICE_DATE_TIME:
1170                 {
1171                         pScene = IDSCN_DATE_TIME;
1172                 }
1173                 break;
1174
1175         case ID_ITEM_DEVICE_LANGUAGE_KEYBOARD:
1176                 {
1177                         pScene = IDSCN_LOCALE;
1178                 }
1179                 break;
1180
1181         default:
1182                 {
1183                         pScene = IDSCN_NULL;
1184                 }
1185                 break;
1186         }
1187         return pScene;
1188 }
1189
1190 const wchar_t*
1191 MainMenuForm::GroupSystemSceneConnect(int viewMode, int itemIndex, Tizen::Ui::Controls::TableViewItemStatus status)
1192 {
1193         const wchar_t* pScene = null;
1194
1195         switch (itemIndex)
1196         {
1197         case ID_ITEM_SYSTEM_MANAGE_APPLICATION:
1198                 {
1199                         pScene = IDSCN_MANAGE_APPLICATION;
1200                 }
1201                 break;
1202
1203         case ID_ITEM_SYSTEM_DEVELOPER_OPTION:
1204                 {
1205                         pScene = IDSCN_DEVELOPER_OPTION;
1206                 }
1207                 break;
1208
1209         case ID_ITEM_SYSTEM_ABOUT_PHONE:
1210                 {
1211                         pScene = IDSCN_PHONE_INFO;
1212                 }
1213                 break;
1214
1215         default:
1216                 {
1217                         pScene = IDSCN_NULL;
1218                 }
1219                 break;
1220         }
1221         return pScene;
1222 }
1223
1224 void
1225 MainMenuForm::FindAppControlScene(int itemIndex)
1226 {
1227         String providerId;
1228         String operationId = APPCONTROL_OPERATION_ID_CONFIGURE;
1229
1230         ArrayList* pDataList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1231
1232         pDataList->Construct();
1233
1234         switch (itemIndex)
1235         {
1236         case ID_ITEM_PERSONAL_ACCOUNTS:
1237                 {
1238                         providerId = APPCONTROL_PROVIDER_ID_ACCOUNT;
1239                 }
1240                 break;
1241
1242         case ID_ITEM_DEVICE_CALL_SETTING:
1243                 {
1244                         providerId = APPCONTROL_PROVIDER_ID_PHONE;
1245                 }
1246                 break;
1247
1248         default:
1249                 break;
1250         }
1251
1252         if (providerId != L"")
1253         {
1254                 AppControl* pAppControl = AppManager::FindAppControlN(providerId, operationId);
1255
1256                 if (pAppControl)
1257                 {
1258                         pAppControl->Start(pDataList, null);
1259                         delete pAppControl;
1260                 }
1261         }
1262
1263         delete pDataList;
1264         pDataList = null;
1265 }
1266
1267 int
1268 MainMenuForm::GetDefaultGroupItemHeight(void)
1269 {
1270         return H_GROUP_INDEX_NO_TITLE_DEFAULT;
1271 }
1272
1273 int
1274 MainMenuForm::GetDefaultItemHeight(void)
1275 {
1276         return H_GROUP_ITEM_DEFAULT;
1277 }
1278
1279 void
1280 MainMenuForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
1281 {
1282 }
1283
1284 void
1285 MainMenuForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1286 {
1287 }
1288
1289 void
1290 MainMenuForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1291 {
1292 }
1293
1294 void
1295 MainMenuForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1296 {
1297 }
1298
1299 void
1300 MainMenuForm::OnResultReceivedForSetValueAsync(const Tizen::Base::String& key, result r)
1301 {
1302         AppLogDebug("ENTER");
1303 }
1304
1305 //void
1306 //MainMenuForm::SetIFlightModeSetValueAsyncResultListener(void)
1307 //{
1308 //      __pFlightModeSetValueAsyncResultListener = new (std::nothrow) IFlightModeSetValueAsyncResultListener();
1309 //}
1310
1311 void
1312 MainMenuForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
1313 {
1314         Invalidate(true);
1315 }
1316
1317 void
1318 MainMenuForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1319 {
1320         if (requestId == FRFRESH_REQUEST_EVENT)
1321         {
1322                 if (__pTableView)
1323                 {
1324                         RemoveAllDownLoadAppIdKeyList();
1325                         SetAppIdListFromPackageManager();
1326                         __pTableView->UpdateTableView();
1327                 }
1328                 if (pArgs)
1329                 {
1330                         pArgs->RemoveAll(true);
1331                         delete pArgs;
1332                 }
1333         }
1334 }