Fixed N_SE-38563, N_SE-38552
[apps/osp/Settings.git] / src / StDeveloperOptionForm.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                StDeveloperOptionForm.cpp
19  * @brief               This is the implementation file for DeveloperOptionForm class.
20  */
21
22 #include <FSystem.h>
23 #include "StDeveloperOptionForm.h"
24 #include "StResourceManager.h"
25 #include "StTypes.h"
26
27 using namespace Tizen::App;
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Collection;
30 using namespace Tizen::Graphics;
31 using namespace Tizen::System;
32 using namespace Tizen::Ui;
33 using namespace Tizen::Ui::Controls;
34 using namespace Tizen::Ui::Scenes;
35
36 static const int ID_GROUP_DEVELOPER_USB_DEBUGGING = 0;
37 static const int ID_GROUP_DEVELOPER_MAIN_ITEM_COUNT = 1;
38 static const int ID_ITEM_DEVELOPER_USB_DEBUGGING = 0;
39
40 static const int ID_GROUP_DEVELOPER_GPU_RENDERING = 1;
41 static const int ID_GROUP_DEVELOPER_GPU_RENDERING_ITEM_COUNT = 1;
42 static const int ID_ITEM_DEVELOPER_GPU_RENDERING = 0;
43
44 static const int ID_GROUP_DEVELOPER_GPU_RENDERING_HELP = 2;
45 static const int ID_GROUP_DEVELOPER_GPU_RENDERING_HELP_ITEM_COUNT = 0;
46
47 static const int ID_GROUP_DEVELOPER_CPU = 3;
48 static const int ID_GROUP_DEVELOPER_CPU_ITEM_COUNT = 0;
49 static const int ID_ITEM_DEVELOPER_CPU_USAGE = 0;
50
51 static const int ID_GROUP_DEVELOPER_CPU_RENDERING = 4;
52 static const int ID_GROUP_DEVELOPER_CPU_RENDERING_ITEM_COUNT = 1;
53 static const int ID_ITEM_DEVELOPER_CPU_RENDERING = 0;
54
55 static const int ID_GROUP_DEVELOPER_LIMIT_PROCESS = 5;
56 static const int ID_GROUP_DEVELOPER_LIMIT_PROCESS_ITEM_COUNT = 1;
57 static const int ID_ITEM_DEVELOPER_LIMIT_PROCESS = 0;
58
59 static const int IDA_USB_DEBUGGING_POPUP_OK = 100;
60 static const int IDA_USB_DEBUGGING_POPUP_CANCEL = 200;
61
62 static const int ID_GROUP_COUNT = 3;
63 static const int ID_GROUP_MAX_ITEM_COUNT = ID_GROUP_DEVELOPER_GPU_RENDERING_ITEM_COUNT;
64 static const int H_HELP_TEXT_GAP = 3;
65 static const int W_RESIZE_LABEL_GAP = 170;
66
67 static const int Y_ALERT_POPUP_CLIENT_RECT_DEFAULT = 160;
68 static const int Y_ALERT_POPUP_ITEM_RECT_LABEL_DEFAULT = 20;
69 static const int H_ALERT_POPUP_ITEM_RECT_LABEL_DEFAULT = 340;
70 static const int W_ALERT_POPUP_ITEM_RECT_LABEL_DEFAULT = 690;
71 static const int X_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT = 30;
72 static const int Y_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT = 410;
73 static const int W_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT = 310;
74 static const int H_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT = 80;
75 static const int X_ALERT_POPUP_ITEM_RECT_RHS_BUTTON_RESIZE = 20;
76 static const int ALERT_POPUP_LABEL_FONT_SIZE = 40;
77
78 static const int W_ALERT_POPUP_CLIENT_RECT_DEFAULT = 700;
79 static const int H_ALERT_POPUP_CLIENT_RECT_DEFAULT = 600;
80
81 static const int H_FONT_GAP = 20;
82
83 DeveloperOptionForm::DeveloperOptionForm(void)
84         : __isAppControlRequest(false)
85         , __usbDebuggingPopup(null)
86 {
87 }
88
89 DeveloperOptionForm::~DeveloperOptionForm(void)
90 {
91 }
92
93 void
94 DeveloperOptionForm::CreateFooter(void)
95 {
96         Footer* pFooter = GetFooter();
97         AppAssert(pFooter);
98
99         pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
100         pFooter->SetBackButton();
101         pFooter->AddActionEventListener(*this);
102
103         SetFormBackEventListener(this);
104 }
105
106 result
107 DeveloperOptionForm::OnInitializing(void)
108 {
109         CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_DEVELOPER_OPTIONS"));
110         CreateFooter();
111         CreateTableView();
112         AppLogDebug("ENTER");
113
114         return E_SUCCESS;
115 }
116
117 result
118 DeveloperOptionForm::OnTerminating(void)
119 {
120         delete __usbDebuggingPopup;
121         __usbDebuggingPopup = null;
122         __pTableView = null;
123
124         SetFormBackEventListener(null);
125         return E_SUCCESS;
126 }
127
128 void
129 DeveloperOptionForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
130 {
131         result r = E_FAILURE;
132
133         bool itemStatus= false;
134
135         if (pArgs != null)
136         {
137                 String categoryCheck = static_cast<String*>(pArgs->GetAt(0))->GetPointer();
138
139                 if (categoryCheck == L"category:USB")
140                 {
141                         __isAppControlRequest = true;
142                 }
143                 delete pArgs;
144         }
145         __pTableView->UpdateTableView();
146
147         if ((r = SettingInfo::GetValue(SETTING_INFO_KEY_USB_DEBUGGING, itemStatus)) == E_SUCCESS)
148         {
149                 __pTableView->SetItemChecked(ID_GROUP_DEVELOPER_USB_DEBUGGING, ID_ITEM_DEVELOPER_USB_DEBUGGING, itemStatus);
150         }
151         else
152         {
153                 AppLogDebug("result Read usbDebugging [%s] value[%d]", GetErrorMessage(r), itemStatus);
154         }
155
156         itemStatus= false;
157
158         if ((r = SettingInfo::GetValue(SETTING_INFO_KEY_FORCE_GPU_RENDERING, itemStatus)) == E_SUCCESS)
159         {
160                 __pTableView->SetItemChecked(ID_GROUP_DEVELOPER_GPU_RENDERING, ID_ITEM_DEVELOPER_GPU_RENDERING, itemStatus);
161         }
162         else
163         {
164                 AppLogDebug("result Read GPU Rendering [%s] value[%d]", GetErrorMessage(r), itemStatus);
165         }
166 }
167
168 void
169 DeveloperOptionForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
170 {
171 }
172
173 void
174 DeveloperOptionForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
175 {
176         SceneManager* pSceneManager = SceneManager::GetInstance();
177         AppAssert(pSceneManager);
178
179         if (__isAppControlRequest == true)
180         {
181                 UiApp* pApp = UiApp::GetInstance();
182                 AppAssert(pApp);
183                 pApp->Terminate();
184         }
185         else
186         {
187                 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
188         }
189 }
190
191 int
192 DeveloperOptionForm::GetGroupCount(void)
193 {
194         AppLogDebug("ENTER");
195         return ID_GROUP_COUNT;
196 }
197
198 int
199 DeveloperOptionForm::GetItemCount(int groupIndex)
200 {
201         int itemCount = 0;
202
203         switch (groupIndex)
204         {
205         case ID_GROUP_DEVELOPER_USB_DEBUGGING:
206                 //fall through
207         case ID_GROUP_DEVELOPER_GPU_RENDERING:
208                 {
209                         itemCount = ID_GROUP_MAX_ITEM_COUNT;
210                 }
211                 break;
212
213         default:
214                 break;
215         }
216
217         AppLogDebug("GetItemCount %d", itemCount);
218         return itemCount;
219 }
220
221 TableViewGroupItem*
222 DeveloperOptionForm::CreateGroupItem(int groupIndex, int itemWidth)
223 {
224         AppLogDebug("ENTER");
225
226         int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
227         int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
228         LabelTextStyle style = LABEL_TEXT_STYLE_BOLD;
229         Rectangle itemMainRectangle;
230         String groupText;
231         Label* pLabel = null;
232         int fontSize = GetFontSize();
233
234         TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
235
236         switch (groupIndex)
237         {
238         case ID_GROUP_DEVELOPER_GPU_RENDERING_HELP:
239                 {
240                         style = LABEL_TEXT_STYLE_NORMAL;
241                         yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
242                         groupText = ResourceManager::GetString(L"IDS_ST_BODY_USE_2D_HARDWARE_ACCELERATION_IN_APPLICATIONS_ABB");
243                         itemHeight = GetHeightForStringArea(groupText, itemWidth, fontSize) + H_FONT_GAP;
244                 }
245                 break;
246
247         case ID_GROUP_DEVELOPER_USB_DEBUGGING:
248                 {
249                         yItemOffset = Y_GROUP_INDEX_DEFAULT;
250                         itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
251                 }
252                 break;
253
254         case ID_GROUP_DEVELOPER_CPU:
255                 {
256                         style = LABEL_TEXT_STYLE_NORMAL;
257                         yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
258                         groupText = ResourceManager::GetString(L"IDS_ST_BODY_DEBUGGING_MODE_LAUNCHES_WHEN_USB_IS_CONNECTED");
259                         itemHeight = GetHeightForStringArea(groupText, itemWidth, fontSize);
260                 }
261                 break;
262
263         case ID_GROUP_DEVELOPER_CPU_RENDERING:
264                 {
265                         style = LABEL_TEXT_STYLE_NORMAL;
266                         yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
267                         itemHeight = ((H_GROUP_INDEX_HELP_TEXT * LINE_COUNT_2) + H_GROUP_INDEX_NO_TITLE_TEXT_GAP);
268                 }
269                 break;
270
271         case ID_GROUP_DEVELOPER_LIMIT_PROCESS:
272                 {
273                         style = LABEL_TEXT_STYLE_NORMAL;
274                         yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
275                         itemHeight = ((H_GROUP_INDEX_HELP_TEXT * LINE_COUNT_2) + H_GROUP_INDEX_NO_TITLE_TEXT_GAP);
276                 }
277                 break;
278
279         default:
280                 {
281                         yItemOffset = Y_GROUP_INDEX_DEFAULT;
282                         itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
283                 }
284                 break;
285         }
286
287         itemMainRectangle.x = X_GROUP_INDEX_DEFAULT_LABEL;
288         itemMainRectangle.y = yItemOffset;
289         itemMainRectangle.width = itemWidth;
290         itemMainRectangle.height = itemHeight;
291
292         RelativeLayout relativeLayout;
293         relativeLayout.Construct();
294
295         pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
296         pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
297
298         pLabel = new (std::nothrow) Label();
299         pLabel->Construct(itemMainRectangle, groupText);
300         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
301         pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
302         pLabel->SetTextConfig(fontSize, style);
303         pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
304
305         pItem->AddControl(pLabel);
306         relativeLayout.SetMargin(*pLabel, 0, 0, 0, 0);
307         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
308         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
309         pItem->SetEnabled(false);
310
311         return pItem;
312 }
313
314 TableViewItem*
315 DeveloperOptionForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
316 {
317         AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
318
319         TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
320         Rectangle itemMainRectangle;
321         String itemMainText;
322         Label* pLabel = null;
323         int fontSize = GetFontSize();
324
325         TableViewItem* pItem = new (std::nothrow) TableViewItem();
326
327         ItemTypeOneLine(itemMainRectangle);
328
329         switch (groupIndex)
330         {
331         case ID_GROUP_DEVELOPER_USB_DEBUGGING:
332                 {
333                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_USB_DEBUGGING");
334                         itemMainRectangle.width -= W_RESIZE_LABEL_GAP;
335                 }
336                 break;
337
338         case ID_GROUP_DEVELOPER_GPU_RENDERING:
339                 {
340                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_FORCE_GPU_RENDERING_ABB");
341                         itemMainRectangle.width -= W_RESIZE_LABEL_GAP;
342                 }
343                 break;
344
345         default:
346                 break;
347         }
348
349         RelativeLayout relativeLayout;
350         relativeLayout.Construct();
351
352         pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
353         pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
354
355         pLabel = new (std::nothrow) Label();
356         pLabel->Construct(itemMainRectangle, itemMainText);
357         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
358         pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
359         pLabel->SetTextColor(COLOR_MAIN_TEXT);
360
361         pItem->AddControl(pLabel);
362         relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN_ONOFF_SLIDING, 0, 0);
363         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
364         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
365
366         return pItem;
367 }
368
369 bool
370 DeveloperOptionForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
371 {
372         AppLogDebug("ENTER");
373
374         delete pItem;
375         pItem = null;   
376
377         return true;
378 }
379
380 bool
381 DeveloperOptionForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
382 {
383         AppLogDebug("ENTER");
384
385         delete pItem;
386         pItem = null;
387
388         return true;
389 }
390
391 void
392 DeveloperOptionForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
393 {
394         SceneManager* pSceneManager = SceneManager::GetInstance();
395         AppAssert(pSceneManager);
396
397         bool itemSelectStatus = tableView.IsItemChecked(groupIndex, itemIndex);
398
399         AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
400
401         switch (groupIndex)
402         {
403         case ID_GROUP_DEVELOPER_USB_DEBUGGING:
404                 {
405                         if (itemIndex == ID_ITEM_DEVELOPER_USB_DEBUGGING)
406                         {
407                                 result r = E_FAILURE;
408                                 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
409                                 {
410                                         itemSelectStatus = !itemSelectStatus;
411                                 }
412
413                                 if (itemSelectStatus)
414                                 {
415                                         CreateAlertPopup();
416                                         ShowAlertPopup();
417                                 }
418                                 else
419                                 {
420                                         if ((r = SettingInfo::SetValueForPrivilegedKey(SETTING_INFO_KEY_USB_DEBUGGING, itemSelectStatus)) == E_SUCCESS)
421                                         {
422                                                 __pTableView->SetItemChecked(ID_GROUP_DEVELOPER_USB_DEBUGGING, ID_ITEM_DEVELOPER_USB_DEBUGGING, itemSelectStatus);
423                                         }
424                                         else
425                                         {
426                                                 AppLogDebug("result[%s]", GetErrorMessage(r));
427                                                 __pTableView->SetItemChecked(ID_GROUP_DEVELOPER_USB_DEBUGGING, ID_ITEM_DEVELOPER_USB_DEBUGGING, true);
428                                                 ShowMessageBox(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_ST_POP_NOT_SUPPORTED"));
429                                         }
430                                 }
431                         }
432                 }
433                 break;
434
435         case ID_GROUP_DEVELOPER_GPU_RENDERING:
436                 {
437                         result r = E_FAILURE;
438                         if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
439                         {
440                                 itemSelectStatus = !itemSelectStatus;
441                         }
442
443                         if ((r = SettingInfo::SetValue(SETTING_INFO_KEY_FORCE_GPU_RENDERING, itemSelectStatus)) == E_SUCCESS)
444                         {
445                                 __pTableView->SetItemChecked(ID_GROUP_DEVELOPER_GPU_RENDERING, ID_ITEM_DEVELOPER_GPU_RENDERING, itemSelectStatus);
446                         }
447                         else
448                         {
449                                 AppLogDebug("rendering result[%s]", GetErrorMessage(r));
450                                 __pTableView->SetItemChecked(ID_GROUP_DEVELOPER_GPU_RENDERING, ID_ITEM_DEVELOPER_GPU_RENDERING, false);
451                         }
452                 }
453                 break;
454
455         case ID_GROUP_DEVELOPER_CPU:
456                 {
457                         if (itemIndex == ID_ITEM_DEVELOPER_CPU_USAGE)
458                         {
459                                 // TODO: Show CPU usage on/off.
460                         }
461                 }
462                 break;
463
464         case ID_GROUP_DEVELOPER_CPU_RENDERING:
465                 {
466                         if (itemIndex == ID_ITEM_DEVELOPER_CPU_RENDERING)
467                         {
468                                 // TODO: Show CPU rendering on/off
469                         }
470                 }
471                 break;
472
473         case ID_GROUP_DEVELOPER_LIMIT_PROCESS:
474                 {
475                         if (itemIndex == ID_ITEM_DEVELOPER_LIMIT_PROCESS)
476                         {
477                                 // TODO: Limit background process.
478                         }
479                 }
480                 break;
481
482         default:
483                 break;
484         }
485 }
486
487 int
488 DeveloperOptionForm::GetDefaultGroupItemHeight(void)
489 {
490         return H_GROUP_INDEX_NO_TITLE_DEFAULT;
491 }
492
493 int
494 DeveloperOptionForm::GetDefaultItemHeight(void)
495 {
496         return H_GROUP_ITEM_DEFAULT;
497 }
498
499 void
500 DeveloperOptionForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
501 {
502 }
503
504 void
505 DeveloperOptionForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
506 {
507 }
508
509 void
510 DeveloperOptionForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
511 {
512 }
513
514 void
515 DeveloperOptionForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
516 {
517 }
518
519 result
520 DeveloperOptionForm::CreateAlertPopup(void)
521 {
522         String buttonText;
523         Label* pLabel = null;
524         Button* pLhsButton = null;
525         Button* pRhslButton = null;
526
527         Rectangle clientRect = GetClientAreaBounds();
528         Rectangle itemRectLabel;
529         Rectangle itemRectLhsButton;
530         Rectangle itemRectRhsButton;
531
532         clientRect.x = 0;
533         clientRect.y = Y_ALERT_POPUP_CLIENT_RECT_DEFAULT;
534         clientRect.width = W_ALERT_POPUP_CLIENT_RECT_DEFAULT;
535         clientRect.height = H_ALERT_POPUP_CLIENT_RECT_DEFAULT;
536
537         itemRectLabel.x = Y_ALERT_POPUP_ITEM_RECT_LABEL_DEFAULT;
538         itemRectLabel.y = Y_ALERT_POPUP_ITEM_RECT_LABEL_DEFAULT + itemRectLabel.x;
539         itemRectLabel.width = W_ALERT_POPUP_ITEM_RECT_LABEL_DEFAULT;
540         itemRectLabel.height = H_ALERT_POPUP_ITEM_RECT_LABEL_DEFAULT;
541
542         itemRectLhsButton.x = X_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT;
543         itemRectLhsButton.y = Y_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT;
544         itemRectLhsButton.width = W_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT;
545         itemRectLhsButton.height = H_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT;
546
547         itemRectRhsButton = itemRectLhsButton;
548         itemRectRhsButton.x = itemRectLhsButton.x + itemRectLhsButton.width + X_ALERT_POPUP_ITEM_RECT_RHS_BUTTON_RESIZE;
549
550         Dimension bounds = Dimension(clientRect.width, clientRect.height);
551
552         __usbDebuggingPopup = new (std::nothrow) Popup();
553         __usbDebuggingPopup->Construct(true, bounds);
554         __usbDebuggingPopup->SetTitleText(ResourceManager::GetString(L"IDS_ST_HEADER_ALLOW_USB_DEBUGGING_Q_ABB"));
555         __usbDebuggingPopup->SetTitleTextColor(COLOR_SUB_TEXT);
556
557         pLabel = new (std::nothrow) Label();
558         pLabel->Construct(itemRectLabel, ResourceManager::GetString(L"IDS_ST_BODY_USB_DEBUGGING_IS_INTENDED_FOR_DEVELOPMENT_PURPOSES_ONLY_MSG"));
559         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
560         pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
561         pLabel->SetTextConfig(ALERT_POPUP_LABEL_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
562
563         __usbDebuggingPopup->AddControl(pLabel);
564
565         buttonText = ResourceManager::GetString(L"IDS_ST_BUTTON_OK");
566         pLhsButton = new (std::nothrow) Button();
567         pLhsButton->Construct(itemRectLhsButton, buttonText);
568         pLhsButton->SetActionId(IDA_USB_DEBUGGING_POPUP_OK);
569
570         __usbDebuggingPopup->AddControl(pLhsButton);
571
572         buttonText = ResourceManager::GetString(L"IDS_ST_BODY_CANCEL");
573
574         pRhslButton = new (std::nothrow) Button();
575         pRhslButton->Construct(itemRectRhsButton, buttonText);
576         pRhslButton->SetActionId(IDA_USB_DEBUGGING_POPUP_CANCEL);
577
578         __usbDebuggingPopup->AddControl(pRhslButton);
579
580         pLhsButton->AddActionEventListener(*this);
581         pRhslButton->AddActionEventListener(*this);
582
583         return E_SUCCESS;
584 }
585
586 void
587 DeveloperOptionForm::ShowAlertPopup(void)
588 {
589         __usbDebuggingPopup->SetShowState(true);
590         __usbDebuggingPopup->Show();
591 }
592
593 void
594 DeveloperOptionForm::HideAlertPopup(void)
595 {
596         __usbDebuggingPopup->SetShowState(false);
597         __usbDebuggingPopup->Invalidate(true);
598 }
599
600 void
601 DeveloperOptionForm::OnActionPerformed(const Control& source, int actionId)
602 {
603         result r = E_FAILURE;
604
605         switch (actionId)
606         {
607         case IDA_USB_DEBUGGING_POPUP_OK:
608                 {
609                         r = SettingInfo::SetValueForPrivilegedKey(SETTING_INFO_KEY_USB_DEBUGGING, true);
610
611                         switch (r)
612                         {
613                         case E_UNSUPPORTED_OPERATION:
614                                 {
615                                         HideAlertPopup();
616                                         ShowMessageBox(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_ST_POP_NOT_SUPPORTED"));
617                                 }
618                                 break;
619
620                         case E_SUCCESS:
621                                 {
622                                         __pTableView->SetItemChecked(ID_GROUP_DEVELOPER_USB_DEBUGGING, ID_ITEM_DEVELOPER_USB_DEBUGGING, true);
623                                         HideAlertPopup();
624                                 }
625                                 break;
626
627                         default:
628                                 break;
629                         }
630                         AppLogDebug("Set UsbDebugging result [%s] ", GetErrorMessage(r));
631                 }
632                 break;
633
634         case IDA_USB_DEBUGGING_POPUP_CANCEL:
635                 {
636                         __pTableView->SetItemChecked(ID_GROUP_DEVELOPER_USB_DEBUGGING, ID_ITEM_DEVELOPER_USB_DEBUGGING, false);
637                         HideAlertPopup();
638                 }
639                 break;
640
641         default:
642                 break;
643         }
644         __pTableView->UpdateTableView();
645 }