Fixed N_SE-38563, N_SE-38552
[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.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 /**
18  * @file                StMainMenuForm.cpp
19  * @brief               This is the implementation file for MainMenuForm class.
20  */
21
22 #include "StBluetoothPresentationModel.h"
23 #include "StMainMenuForm.h"
24 #include "StNfcPresentationModel.h"
25 #include "StResourceManager.h"
26 #include "StSettingScenesList.h"
27 #include "StTypes.h"
28
29 using namespace Tizen::App;
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Graphics;
33 using namespace Tizen::Net::Bluetooth;
34 using namespace Tizen::System;
35 using namespace Tizen::Ui;
36 using namespace Tizen::Ui::Controls;
37 using namespace Tizen::Ui::Scenes;
38
39 static const int W_RESIZE_LABEL_GAP = 110;
40
41 static const int H_GROUP_FONT_SIZE_GIANT = 146;
42 static const int H_GROUP_FONT_SIZE_HUGE = 128;
43 static const int H_GROUP_FONT_SIZE_LARGE = 110;
44 static const int H_GROUP_FONT_SIZE_DEFAULT = 80;
45 static const int H_GROUP_TITLE_TEXT = (H_GROUP_INDEX_TITLE_TEXT / 4);
46 static const int MAIN_RELATIVE_LAYOUT_RIGHT_MARGIN = 60;
47
48 static const wchar_t* APPCONTROL_OPERATION_ID_CONFIGURE = L"http://tizen.org/appcontrol/operation/configure";
49 static const wchar_t* APPCONTROL_PROVIDER_ID_PHONE = L"tizen.phone";
50 static const wchar_t* APPCONTROL_PROVIDER_ID_ACCOUNT = L"ZsnYtAdjl2.Account";
51
52 static const int ID_GROUP_CONNECTIVITY = 0;
53 static const int ID_ITEM_CONNECTIVITY_WIFI = 0;
54 static const int ID_ITEM_CONNECTIVITY_BLUETOOTH = 1;
55 static const int ID_ITEM_CONNECTIVITY_NETWORK = 2;
56 static const int ID_ITEM_CONNECTIVITY_NFC = 3;
57 static const int ID_GROUP_CONNECTIVITY_ITEM_COUNT = 4;
58
59 static const int ID_GROUP_MODE = 1;
60 static const int ID_ITEM_MODE_FLIGHT_MODE = 0;
61 static const int ID_GROUP_MODE_ITEM_COUNT = 1;
62
63 static const int ID_GROUP_PERSONAL = 2;
64 static const int ID_ITEM_PERSONAL_HOME_SCREEN = 0;
65 static const int ID_ITEM_PERSONAL_LOCK_SCREEN = 1;
66 static const int ID_ITEM_PERSONAL_ACCOUNTS = 2;
67 static const int ID_ITEM_PERSONAL_PRIVACY = 3;
68 static const int ID_GROUP_PERSONAL_ITEM_COUNT = 4;
69
70 static const int ID_GROUP_DEVICE = 3;
71 static const int ID_ITEM_DEVICE_DISPLAY = 0;
72 static const int ID_ITEM_DEVICE_SOUND = 1;
73 static const int ID_ITEM_DEVICE_LOCATION = 2;
74 static const int ID_ITEM_DEVICE_CALL_SETTING = 3;
75 static const int ID_ITEM_DEVICE_ACCESSIBILITY = 6;
76 static const int ID_ITEM_DEVICE_DATE_TIME = 4;
77 static const int ID_ITEM_DEVICE_LANGUAGE_KEYBOARD = 5;
78 static const int ID_GROUP_DEVICE_ITEM_COUNT = 6;
79
80 static const int ID_GROUP_SYSTEM = 4;
81 static const int ID_ITEM_SYSTEM_MANAGE_APPLICATION = 0;
82 static const int ID_ITEM_SYSTEM_DOWNLOADED_APPLICATION = 1;
83 static const int ID_ITEM_SYSTEM_DEVELOPER_OPTION = 2;
84 static const int ID_ITEM_SYSTEM_ABOUT_PHONE = 3;
85 static const int ID_GROUP_SYSTEM_ITEM_COUNT = 4;
86
87 static const int ID_GROUP_APPSETTING = 5;
88 static const int ID_GROUP_NO_APPSETTING = 4;
89 static const int ID_MAIN_MENU_DEFAULT_COUNT = 1;
90 static const int EMULATOR_DEFAULT_COUNT = 1;
91
92 void
93 IFlightModeSetValueAsyncResultListener::OnResultReceivedForSetValueAsync(const Tizen::Base::String& key, result r)
94 {
95         AppLogDebug("key(%ls) r(%s)", key.GetPointer(), GetErrorMessage(r));
96
97         if (IsFailed(r))
98         {
99                 MainMenuForm* pMainMenuForm = dynamic_cast<MainMenuForm*>(SceneManager::GetInstance()->GetCurrentScene()->GetForm());
100                 if (pMainMenuForm)
101                 {
102                         bool flightModeEnableStatus = false;
103                         if (SettingInfo::GetValue(SETTING_INFO_KEY_NETWORK_FLIGHTMODE, flightModeEnableStatus) == E_SUCCESS)
104                         {
105                                 pMainMenuForm->__pTableView->SetItemChecked(ID_GROUP_MODE, ID_ITEM_MODE_FLIGHT_MODE, flightModeEnableStatus);
106                                 pMainMenuForm->__pTableView->RefreshItem(ID_GROUP_MODE, ID_ITEM_MODE_FLIGHT_MODE, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
107                         }
108                 }
109         }
110 }
111
112 MainMenuForm::MainMenuForm(void)
113         : __currentTableViewList(0)
114         , __isRunningAppControl(false)
115         , __pFlightModeSetValueAsyncResultListener(null)
116 {
117 }
118
119 MainMenuForm::~MainMenuForm(void)
120 {
121 }
122
123 void
124 MainMenuForm::CreateFooter(void)
125 {
126         Footer* pFooter = GetFooter();
127         AppAssert(pFooter);
128
129         pFooter->SetBackButton();
130         pFooter->AddActionEventListener(*this);
131 }
132
133 result
134 MainMenuForm::OnInitializing(void)
135 {
136         AppLogDebug("ENTER");
137
138         CreateHeader(ResourceManager::GetString(L"IDS_COM_BODY_SETTINGS"));
139         CreateFooter();
140         CreateTableView();
141         __isEmulator = IsEmulator();
142
143         AddFocusEventListener(*this);
144
145         return E_SUCCESS;
146 }
147
148 result
149 MainMenuForm::OnTerminating(void)
150 {
151         __pTableView = null;
152
153         return E_SUCCESS;
154 }
155
156 void
157 MainMenuForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
158 {
159         Header* pHeader = GetHeader();
160         pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_SETTINGS"));
161
162         __pTableView->UpdateTableView();
163
164         bool flightModeEnableStatus = false;
165         if (SettingInfo::GetValue(SETTING_INFO_KEY_NETWORK_FLIGHTMODE, flightModeEnableStatus) == E_SUCCESS)
166         {
167                 __pTableView->SetItemChecked(ID_GROUP_MODE, ID_ITEM_MODE_FLIGHT_MODE, flightModeEnableStatus);
168         }
169 }
170
171 void
172 MainMenuForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
173 {
174 }
175
176 int
177 MainMenuForm::GetGroupCount(void)
178 {
179         int groupItemCount = ID_GROUP_NO_APPSETTING;
180
181         if (__isEmulator == false)
182         {
183                 groupItemCount += ID_MAIN_MENU_DEFAULT_COUNT;
184         }
185
186         return groupItemCount;
187 }
188
189 int
190 MainMenuForm::GetItemCount(int groupIndex)
191 {
192         AppLogDebug("ENTER");
193
194         if ((__isEmulator == true)
195                 && (groupIndex >= ID_GROUP_MODE))
196         {
197                 groupIndex += EMULATOR_DEFAULT_COUNT;
198         }
199
200         int itemCount = 0;
201
202         switch (groupIndex)
203         {
204         case ID_GROUP_CONNECTIVITY:
205                 {
206                         itemCount = ID_GROUP_CONNECTIVITY_ITEM_COUNT;
207                 }
208                 break;
209
210         case ID_GROUP_MODE:
211                 {
212                         itemCount = ID_GROUP_MODE_ITEM_COUNT;
213                 }
214                 break;
215
216         case ID_GROUP_DEVICE:
217                 {
218                         itemCount = ID_GROUP_DEVICE_ITEM_COUNT;
219                 }
220                 break;
221
222         case ID_GROUP_PERSONAL:
223                 {
224                         itemCount = ID_GROUP_PERSONAL_ITEM_COUNT;
225                 }
226                 break;
227
228         case ID_GROUP_SYSTEM:
229                 {
230                         itemCount = ID_GROUP_SYSTEM_ITEM_COUNT;
231                 }
232                 break;
233
234         case ID_GROUP_APPSETTING:
235                 {
236                         itemCount = ID_MAIN_MENU_DEFAULT_COUNT;
237                 }
238                 break;
239
240         default:
241                 break;
242         }
243
244         return itemCount;
245 }
246
247 TableViewGroupItem*
248 MainMenuForm::CreateGroupItem(int groupIndex, int itemWidth)
249 {
250         AppLogDebug("ENTER");
251
252         int itemHeight = H_GROUP_INDEX_DEFAULT;
253         LabelTextStyle style = LABEL_TEXT_STYLE_BOLD;
254         Rectangle itemRectangle;
255         String groupText;
256         Label* pLabel = null;
257         int fontSize = GetFontSize();
258
259         if ((__isEmulator == true)
260                 && (groupIndex >= ID_GROUP_MODE))
261         {
262                 groupIndex += EMULATOR_DEFAULT_COUNT;
263         }
264
265         switch (groupIndex)
266         {
267         case ID_GROUP_CONNECTIVITY:
268                 {
269                         groupText = ResourceManager::GetString(L"IDS_ST_BODY_CONNECTIVITY");
270                 }
271                 break;
272
273         case ID_GROUP_MODE:
274                 {
275                         groupText = ResourceManager::GetString(L"IDS_ST_BODY_MODE");
276                 }
277                 break;
278
279         case ID_GROUP_PERSONAL:
280                 {
281                         groupText = ResourceManager::GetString(L"IDS_ST_BODY_PERSONAL");
282                 }
283                 break;
284
285         case ID_GROUP_DEVICE:
286                 {
287                         groupText = ResourceManager::GetString(L"IDS_ST_BODY_DEVICE");
288                 }
289                 break;
290
291         case ID_GROUP_SYSTEM:
292                 {
293                         groupText = ResourceManager::GetString(L"IDS_ST_BODY_SYSTEM");
294                 }
295                 break;
296
297         case ID_GROUP_APPSETTING:
298                 {
299                         groupText = ResourceManager::GetString(L"IDS_ST_BODY_DOWNLOADED_APPLICATIONS");
300                 }
301                 break;
302
303         default:
304                 break;
305         }
306
307         TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
308
309         itemRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
310         itemRectangle.y = H_GROUP_TITLE_TEXT;
311         itemRectangle.width = itemWidth - itemRectangle.x;
312
313         if (fontSize == FONT_MAIN_TEXT_SIZE_GIANT)
314         {
315                 itemHeight = itemRectangle.height = H_GROUP_FONT_SIZE_GIANT;
316         }
317         else if (fontSize == FONT_MAIN_TEXT_SIZE_HUGE)
318         {
319                 itemHeight = itemRectangle.height = H_GROUP_FONT_SIZE_HUGE;
320         }
321         else if (fontSize == FONT_MAIN_TEXT_SIZE_LARGE)
322         {
323                 itemHeight = itemRectangle.height = H_GROUP_FONT_SIZE_LARGE;
324         }
325         else
326         {
327                 itemHeight = itemRectangle.height = H_GROUP_FONT_SIZE_DEFAULT;
328         }
329
330         RelativeLayout relativeLayout;
331         relativeLayout.Construct();
332
333         pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
334         pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
335
336         pLabel = new (std::nothrow) Label();
337         pLabel->Construct(itemRectangle, groupText);
338         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
339         pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
340         pLabel->SetTextConfig(fontSize, style);
341         pLabel->SetTextColor(COLOR_GROUP_TITLE_TEXT);
342
343         pItem->AddControl(pLabel);
344         relativeLayout.SetMargin(*pLabel, itemRectangle.x, 0, 0, 0);
345         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
346         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
347         pItem->SetEnabled(false);
348
349         return pItem;
350 }
351
352 TableViewItem*
353 MainMenuForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
354 {
355         AppLogDebug("group[%d] item[%d]", groupIndex, itemIndex);
356
357         if ((__isEmulator == true)
358                 && (groupIndex >= ID_GROUP_MODE))
359         {
360                 groupIndex += EMULATOR_DEFAULT_COUNT;
361         }
362
363         int fontSize = GetFontSize();
364
365         unsigned int itemHeight = 0;
366         bool isDrawBitmapIcon = true;
367         Rectangle itemIconRectangle;
368         Rectangle itemMainRectangle;
369         Rectangle itemSubRectangle;
370         String itemMainText;
371         TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
372         Bitmap* pBitmap = null;
373         Label* pLabel = null;
374
375         ItemTypeIconAndOneLine(itemIconRectangle, itemMainRectangle);
376         itemHeight = itemMainRectangle.height;
377
378         switch (groupIndex)
379         {
380         case ID_GROUP_CONNECTIVITY:
381                 {
382                         switch (itemIndex)
383                         {
384                         case ID_ITEM_CONNECTIVITY_WIFI:
385                                 {
386                                         if (__isEmulator)
387                                         {
388                                                 itemHeight = 0;
389                                         }
390                                         else
391                                         {
392                                                 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI);
393                                                 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_WI_FI");
394                                         }
395                                 }
396                                 break;
397
398                         case ID_ITEM_CONNECTIVITY_BLUETOOTH:
399                                 {
400                                         if (__isEmulator)
401                                         {
402                                                 itemHeight = 0;
403                                         }
404                                         else
405                                         {
406                                                 ItemTypeIconAndOneLine(itemIconRectangle, itemMainRectangle);
407                                                 itemHeight = itemMainRectangle.height;
408
409                                                 pBitmap = ResourceManager::GetBitmapN(IDB_BLUETOOTH);
410                                                 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_BLUETOOTH");
411                                         }
412                                 }
413                                 break;
414
415                         case ID_ITEM_CONNECTIVITY_NETWORK:
416                                 {
417                                         pBitmap = ResourceManager::GetBitmapN(IDB_NETWORK);
418                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_NETWORK");
419                                 }
420                                 break;
421
422                         case ID_ITEM_CONNECTIVITY_NFC:
423                                 {
424                                         ItemTypeIconAndOneLine(itemIconRectangle, itemMainRectangle);
425                                         itemHeight = (itemMainRectangle.height + itemSubRectangle.height);
426
427                                         pBitmap = ResourceManager::GetBitmapN(IDB_NFC);
428                                         itemMainText = ResourceManager::GetString(L"IDS_NFC_BODY_NFC");
429                                 }
430                                 break;
431
432                         default:
433                                 break;
434                         }
435                 }
436                 break;
437
438         case ID_GROUP_MODE:
439                 {
440                         style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
441                         itemMainRectangle.width -= W_RESIZE_LABEL_GAP;
442                         pBitmap = ResourceManager::GetBitmapN(IDB_FLIGHT_MODE);
443                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_FLIGHT_MODE");
444                 }
445                 break;
446
447         case ID_GROUP_PERSONAL:
448                 {
449                         switch (itemIndex)
450                         {
451                         case ID_ITEM_PERSONAL_HOME_SCREEN:
452                                 {
453                                         pBitmap = ResourceManager::GetBitmapN(IDB_HOME_SCREEN);
454                                         itemMainText = ResourceManager::GetString(L"IDS_ST_HEADER_HOME_SCREEN");
455                                 }
456                                 break;
457
458                         case ID_ITEM_PERSONAL_LOCK_SCREEN:
459                                 {
460                                         pBitmap = ResourceManager::GetBitmapN(IDB_LOCK_SCREEN);
461                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_LOCK_SCREEN");
462                                 }
463                                 break;
464
465                         case ID_ITEM_PERSONAL_ACCOUNTS:
466                                 {
467                                         pBitmap = ResourceManager::GetBitmapN(IDB_ACCOUNTS);
468                                         itemMainText = ResourceManager::GetString(L"IDS_COM_BODY_ACCOUNTS");
469                                 }
470                                 break;
471
472                         case ID_ITEM_PERSONAL_PRIVACY:
473                                 {
474                                         pBitmap = ResourceManager::GetBitmapN(IDB_PRIVACY);
475                                         itemMainText = ResourceManager::GetString(L"IDS_COM_BODY_PRIVACY");
476                                 }
477                                 break;
478
479                         default:
480                                 break;
481                         }
482                 }
483                 break;
484
485         case ID_GROUP_DEVICE:
486                 {
487                         switch (itemIndex)
488                         {
489                         case ID_ITEM_DEVICE_DISPLAY:
490                                 {
491                                         pBitmap = ResourceManager::GetBitmapN(IDB_DISPLAY);
492                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_DISPLAY");
493                                 }
494                                 break;
495
496                         case ID_ITEM_DEVICE_SOUND:
497                                 {
498                                         pBitmap = ResourceManager::GetBitmapN(IDB_SOUND);
499                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_SOUNDS");
500                                 }
501                                 break;
502
503                         case ID_ITEM_DEVICE_LOCATION:
504                                 {
505                                         pBitmap = ResourceManager::GetBitmapN(IDB_LOCATION);
506                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_LOCATIONS");
507                                 }
508                                 break;
509
510                         case ID_ITEM_DEVICE_CALL_SETTING:
511                                 {
512                                         pBitmap = ResourceManager::GetBitmapN(IDB_PHONE);
513                                         itemMainText = ResourceManager::GetString(L"IDS_CST_BODY_CALL_SETTINGS");
514                                 }
515                                 break;
516
517                         case ID_ITEM_DEVICE_ACCESSIBILITY:
518                                 {
519                                         pBitmap = ResourceManager::GetBitmapN(IDB_ACCESSIBILITY);
520                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_ACCESSIBILITY");
521                                 }
522                                 break;
523
524                         case ID_ITEM_DEVICE_DATE_TIME:
525                                 {
526                                         pBitmap = ResourceManager::GetBitmapN(IDB_DATE_AND_TIME);
527                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_DATE_AND_TIME");
528                                 }
529                                 break;
530
531                         case ID_ITEM_DEVICE_LANGUAGE_KEYBOARD:
532                                 {
533                                         pBitmap = ResourceManager::GetBitmapN(IDB_LANGUAGE_KEYBOARD);
534                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_LANGUAGE_AND_KEYBOARD");
535                                 }
536                                 break;
537
538                         default:
539                                 break;
540                         }
541                 }
542                 break;
543
544         case ID_GROUP_SYSTEM:
545                 {
546                         switch (itemIndex)
547                         {
548                         case ID_ITEM_SYSTEM_MANAGE_APPLICATION:
549                                 {
550                                         pBitmap = ResourceManager::GetBitmapN(IDB_MANAGE_APPLICATION);
551                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_MANAGE_APPLICATIONS");
552                                 }
553                                 break;
554
555                         case ID_ITEM_SYSTEM_DOWNLOADED_APPLICATION:
556                                 {
557                                         pBitmap = ResourceManager::GetBitmapN(IDB_DEFAULT_ICON);
558                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_DOWNLOADED_APPLICATIONS");
559                                 }
560                                 break;
561
562                         case ID_ITEM_SYSTEM_DEVELOPER_OPTION:
563                                 {
564                                         if (__isEmulator)
565                                         {
566                                                 itemHeight = 0;
567                                         }
568                                         else
569                                         {
570                                                 pBitmap = ResourceManager::GetBitmapN(IDB_DEVELOPER_OPTION);
571                                                 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_DEVELOPER_OPTIONS");
572                                         }
573                                 }
574                                 break;
575
576                         case ID_ITEM_SYSTEM_ABOUT_PHONE:
577                                 {
578                                         pBitmap = ResourceManager::GetBitmapN(IDB_ABOUT_PHONE);
579                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_ABOUT_PHONE");
580                                 }
581                                 break;
582
583                         default:
584                                 break;
585                         }
586                 }
587                 break;
588
589         default:
590                 break;
591         }
592
593         TableViewItem* pItem = new (std::nothrow) TableViewItem();
594
595         if (pItem)
596         {
597                 RelativeLayout relativeLayout;
598                 relativeLayout.Construct();
599
600                 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
601                 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
602
603                 if (isDrawBitmapIcon)
604                 {
605                         pLabel = new (std::nothrow) Label();
606                         pLabel->Construct(itemIconRectangle, L"");
607                         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
608                         pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
609                         pLabel->SetBackgroundBitmap(*pBitmap);
610
611                         pItem->AddControl(pLabel);
612                 }
613
614                 pLabel = new (std::nothrow) Label();
615                 pLabel->Construct(itemMainRectangle, itemMainText);
616                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
617                 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
618                 pLabel->SetTextColor(COLOR_MAIN_TEXT);
619
620                 pItem->AddControl(pLabel);
621                 if (style == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING)
622                 {
623                         relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN_ONOFF_SLIDING, 0, 0);
624                 }
625                 else
626                 {
627                         relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, MAIN_RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
628                 }
629                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
630                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
631         }
632
633         return pItem;
634 }
635
636 bool
637 MainMenuForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
638 {
639         AppLogDebug("ENTER");
640
641         delete pItem;
642         pItem = null;
643
644         return true;
645 }
646
647 bool
648 MainMenuForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
649 {
650         AppLogDebug("ENTER");
651
652         delete pItem;
653         pItem = null;
654
655         return true;
656 }
657
658 void
659 MainMenuForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
660 {
661         if (__isRunningAppControl)
662         {
663                 AppLogDebug("busy status");
664                 return;
665         }
666
667         SceneManager* pSceneManager = SceneManager::GetInstance();
668         AppAssert(pSceneManager);
669
670         if ((__isEmulator == true)
671                 && (groupIndex >= ID_GROUP_MODE))
672         {
673                 groupIndex += EMULATOR_DEFAULT_COUNT;
674         }
675         ArrayList* pArgs = null;
676         const wchar_t* pSceneName = null;
677
678         AppLogDebug("Group(%d) index(%d)", groupIndex, itemIndex);
679
680         switch (groupIndex)
681         {
682         case ID_GROUP_CONNECTIVITY:
683                 {
684                         pSceneName = GroupConnectivitySceneConnect(__currentTableViewList, itemIndex, status);
685
686                         AppControl* pAppControl = null;
687
688                         if (pSceneName == IDSCN_WIFI)
689                         {
690                                 pAppControl = AppManager::GetInstance()->FindAppControlN(L"wifi-efl-ug", L"");
691                         }
692                         else if (pSceneName == IDSCN_BLUETOOTH)
693                         {
694                                 pAppControl = AppManager::GetInstance()->FindAppControlN(L"ug-bluetooth-efl", L"");
695                         }
696
697                         if (pAppControl)
698                         {
699                                 HashMap* pExtraData = new (std::nothrow) HashMap(SingleObjectDeleter);
700                                 pExtraData->Construct();
701
702                                 pExtraData->Add(new (std::nothrow) String(L"caller"), new (std::nothrow) String(L"osp-setting"));
703
704                                 if (pAppControl->Start(null, null, pExtraData, null) == E_SUCCESS)
705                                 {
706                                         __isRunningAppControl = true;
707                                 }
708
709                                 delete pAppControl;
710                                 delete pExtraData;
711                                 return;
712                         }
713                 }
714                 break;
715
716         case ID_GROUP_MODE:
717                 {
718                         if (itemIndex == ID_ITEM_MODE_FLIGHT_MODE)
719                         {
720                                 bool flightModeStatus = tableView.IsItemChecked(groupIndex, itemIndex);
721                                 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
722                                 {
723                                         flightModeStatus = (!(flightModeStatus));
724                                 }
725
726                                 SetIFlightModeSetValueAsyncResultListener();
727                                 if (SettingInfo::SetValueAsyncForPrivilegedKey(SETTING_INFO_KEY_NETWORK_FLIGHTMODE, flightModeStatus, __pFlightModeSetValueAsyncResultListener) == E_SUCCESS)
728                                 {
729                                         tableView.SetItemChecked(groupIndex, itemIndex, flightModeStatus);
730                                         AppLogDebug("flightmode(%d) GetLastResult(%s)", flightModeStatus, GetErrorMessage(GetLastResult()));
731                                 }
732                                 else
733                                 {
734                                         AppLogDebug("flightmode(%d) GetLastResult(%s)", flightModeStatus, GetErrorMessage(GetLastResult()));
735                                 }
736                         }
737                 }
738                 break;
739
740         case ID_GROUP_PERSONAL:
741                 {
742                         pSceneName = GroupPersonalSceneConnect(__currentTableViewList, itemIndex, status);
743
744                         if ((itemIndex != ID_ITEM_PERSONAL_HOME_SCREEN)
745                                 && (itemIndex != ID_ITEM_PERSONAL_LOCK_SCREEN))
746                         {
747                                 break;
748                         }
749
750                         pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
751                         if (pArgs == null)
752                         {
753                                 AppLogDebug("pArgs is null");
754                                 break;
755                         }
756
757                         result r = pArgs->Construct();
758                         if (IsFailed(r))
759                         {
760                                 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
761                                 break;
762                         }
763
764                         switch (itemIndex)
765                         {
766                         case ID_ITEM_PERSONAL_HOME_SCREEN:
767                                 {
768                                         pArgs->Add(*(new (std::nothrow) String(Integer::ToString(itemIndex))));
769                                 }
770                                 break;
771
772                         case ID_ITEM_PERSONAL_LOCK_SCREEN:
773                                 {
774                                         pArgs->Add(*(new (std::nothrow) String(Integer::ToString(itemIndex))));
775                                 }
776                                 break;
777                         }
778                 }
779                 break;
780
781         case ID_GROUP_DEVICE:
782                 {
783                         pSceneName = GroupDeviceSceneConnect(__currentTableViewList, itemIndex, status);
784                 }
785                 break;
786
787         case ID_GROUP_SYSTEM:
788                 {
789                         pSceneName = GroupSystemSceneConnect(__currentTableViewList, itemIndex, status);
790                 }
791                 break;
792
793         default:
794                 break;
795         }
796
797         if (pSceneName != IDSCN_NULL)
798         {
799                 AppLogDebug("pSceneName[%ls]", pSceneName);
800                 pSceneManager->GoForward(ForwardSceneTransition(pSceneName, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
801         }
802 }
803
804 const wchar_t*
805 MainMenuForm::GroupConnectivitySceneConnect(int viewMode, int itemIndex, Tizen::Ui::Controls::TableViewItemStatus status)
806 {
807         const wchar_t* pScene = null;
808
809         switch (itemIndex)
810         {
811         case ID_ITEM_CONNECTIVITY_WIFI:
812                 {
813 //                      if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
814                         {
815                                 pScene = IDSCN_WIFI;
816                         }
817                 }
818                 break;
819
820         case ID_ITEM_CONNECTIVITY_BLUETOOTH:
821                 {
822 //                      if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
823                         {
824                                 pScene = IDSCN_BLUETOOTH;
825                         }
826                 }
827                 break;
828
829         case ID_ITEM_CONNECTIVITY_NETWORK:
830                 {
831                         pScene = IDSCN_NETWORK;
832                 }
833                 break;
834
835         case ID_ITEM_CONNECTIVITY_NFC:
836                 {
837                         pScene = IDSCN_NFC;
838                 }
839                 break;
840
841         default:
842                 {
843                         pScene = IDSCN_NULL;
844                 }
845                 break;
846         }
847
848         return pScene;
849 }
850
851 const wchar_t*
852 MainMenuForm::GroupPersonalSceneConnect (int viewMode, int itemIndex, Tizen::Ui::Controls::TableViewItemStatus status)
853 {
854         const wchar_t* pScene = null;
855
856         switch (itemIndex)
857         {
858         case ID_ITEM_PERSONAL_HOME_SCREEN:
859                 {
860                         pScene = IDSCN_HOME_AND_LOCK_SCREEN; 
861                 }
862                 break;
863
864         case ID_ITEM_PERSONAL_LOCK_SCREEN:
865                 {
866                         pScene = IDSCN_HOME_AND_LOCK_SCREEN;
867                 }
868                 break;
869
870         case ID_ITEM_PERSONAL_ACCOUNTS:
871                 {
872                         pScene = IDSCN_NULL;
873
874                         FindAppControlScene(itemIndex);
875                 }
876                 break;
877
878         case ID_ITEM_PERSONAL_PRIVACY:
879                 {
880                         pScene = IDSCN_PRIVACY;
881                 }
882                 break;
883
884         default:
885                 {
886                         pScene = IDSCN_NULL;
887                 }
888                 break;
889         }
890         return pScene;
891 }
892
893 const wchar_t*
894 MainMenuForm::GroupDeviceSceneConnect(int viewMode, int itemIndex, Tizen::Ui::Controls::TableViewItemStatus status)
895 {
896         const wchar_t* pScene = null;
897
898         switch (itemIndex)
899         {
900         case ID_ITEM_DEVICE_DISPLAY:
901                 {
902                         pScene = IDSCN_DISPLAY;
903                 }
904                 break;
905
906         case ID_ITEM_DEVICE_SOUND:
907                 {
908                         pScene = IDSCN_SOUNDS;
909                 }
910                 break;
911
912         case ID_ITEM_DEVICE_LOCATION:
913                 {
914                         pScene = IDSCN_LOCATION;
915                 }
916                 break;
917
918         case ID_ITEM_DEVICE_CALL_SETTING:
919                 {
920                         pScene = IDSCN_NULL;
921
922                         FindAppControlScene(itemIndex);
923                 }
924                 break;
925
926         case ID_ITEM_DEVICE_ACCESSIBILITY:
927                 {
928                         pScene = IDSCN_ACCESSIBILITY;
929                 }
930                 break;
931
932         case ID_ITEM_DEVICE_DATE_TIME:
933                 {
934                         pScene = IDSCN_DATE_TIME;
935                 }
936                 break;
937
938         case ID_ITEM_DEVICE_LANGUAGE_KEYBOARD:
939                 {
940                         pScene = IDSCN_LOCALE;
941                 }
942                 break;
943
944         default:
945                 {
946                         pScene = IDSCN_NULL;
947                 }
948                 break;
949         }
950         return pScene;
951 }
952
953 const wchar_t*
954 MainMenuForm::GroupSystemSceneConnect(int viewMode, int itemIndex, Tizen::Ui::Controls::TableViewItemStatus status)
955 {
956         const wchar_t* pScene = null;
957
958         switch (itemIndex)
959         {
960         case ID_ITEM_SYSTEM_MANAGE_APPLICATION:
961                 {
962                         pScene = IDSCN_MANAGE_APPLICATION;
963                 }
964                 break;
965
966         case ID_ITEM_SYSTEM_DOWNLOADED_APPLICATION:
967                 {
968                         pScene = IDSCN_DOWNLOADED_APPLICATION;
969                 }
970                 break;
971
972         case ID_ITEM_SYSTEM_DEVELOPER_OPTION:
973                 {
974                         pScene = IDSCN_DEVELOPER_OPTION;
975                 }
976                 break;
977
978         case ID_ITEM_SYSTEM_ABOUT_PHONE:
979                 {
980                         pScene = IDSCN_PHONE_INFO;
981                 }
982                 break;
983
984         default:
985                 {
986                         pScene = IDSCN_NULL;
987                 }
988                 break;
989         }
990         return pScene;
991 }
992
993 bool
994 MainMenuForm::IsEmulator(void)
995 {
996         String modelName;
997         if (SystemInfo::GetValue(SYSTEM_INFO_KEY_MODELNAME, modelName) != E_SUCCESS)
998         {
999                 AppLogDebug("GetValue is error %s", GetErrorMessage(GetLastResult()));
1000                 return false;
1001         }
1002
1003         return modelName.Equals(L"Emulator", false);
1004 }
1005
1006 void
1007 MainMenuForm::FindAppControlScene(int itemIndex)
1008 {
1009         if (__isRunningAppControl)
1010         {
1011                 AppLogDebug("busy status");
1012                 return;
1013         }
1014
1015         String providerId;
1016         String operationId = APPCONTROL_OPERATION_ID_CONFIGURE;
1017
1018         ArrayList* pDataList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1019
1020         pDataList->Construct();
1021
1022         switch (itemIndex)
1023         {
1024         case ID_ITEM_PERSONAL_ACCOUNTS:
1025                 {
1026                         providerId = APPCONTROL_PROVIDER_ID_ACCOUNT;
1027                 }
1028                 break;
1029
1030         case ID_ITEM_DEVICE_CALL_SETTING:
1031                 {
1032                         providerId = APPCONTROL_PROVIDER_ID_PHONE;
1033                 }
1034                 break;
1035
1036         default:
1037                 break;
1038         }
1039
1040         if (providerId != L"")
1041         {
1042                 AppControl* pAppControl = AppManager::FindAppControlN(providerId, operationId);
1043
1044                 if (pAppControl)
1045                 {
1046                         if (pAppControl->Start(pDataList, null) == E_SUCCESS)
1047                         {
1048                                 __isRunningAppControl = true;
1049                         }
1050                         delete pAppControl;
1051                 }
1052         }
1053
1054         delete pDataList;
1055         pDataList = null;
1056 }
1057
1058 int
1059 MainMenuForm::GetDefaultGroupItemHeight(void)
1060 {
1061         return H_GROUP_INDEX_NO_TITLE_DEFAULT;
1062 }
1063
1064 int
1065 MainMenuForm::GetDefaultItemHeight(void)
1066 {
1067         return H_GROUP_ITEM_DEFAULT;
1068 }
1069
1070 void
1071 MainMenuForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
1072 {
1073 }
1074
1075 void
1076 MainMenuForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1077 {
1078 }
1079
1080 void
1081 MainMenuForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1082 {
1083 }
1084
1085 void
1086 MainMenuForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1087 {
1088 }
1089
1090 void
1091 MainMenuForm::OnResultReceivedForSetValueAsync(const Tizen::Base::String& key, result r)
1092 {
1093         AppLogDebug("ENTER");
1094 }
1095
1096 void
1097 MainMenuForm::SetIFlightModeSetValueAsyncResultListener(void)
1098 {
1099         __pFlightModeSetValueAsyncResultListener = new (std::nothrow) IFlightModeSetValueAsyncResultListener();
1100 }
1101
1102 void
1103 MainMenuForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
1104 {
1105         Invalidate(true);
1106 }
1107
1108 void
1109 MainMenuForm::OnFocusGained(const Tizen::Ui::Control& source)
1110 {
1111         __isRunningAppControl = false;
1112 }
1113
1114 void
1115 MainMenuForm::OnFocusLost(const Tizen::Ui::Control& source)
1116 {
1117 }