Applied latest source code
[apps/native/preloaded/Settings.git] / src / StWifiApDetailForm.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                StWifiApDetailForm.cpp
19  * @brief               This is the implementation file for WifiApDetailForm class.
20  */
21
22 #include "StResourceManager.h"
23 #include "StSettingScenesList.h"
24 #include "StTypes.h"
25 #include "StWifiApDetailForm.h"
26
27 using namespace Tizen::Base;
28 using namespace Tizen::Graphics;
29 using namespace Tizen::Net;
30 using namespace Tizen::Net::Wifi;
31 using namespace Tizen::Ui;
32 using namespace Tizen::Ui::Controls;
33 using namespace Tizen::Ui::Scenes;
34
35 static const int W_CONFIRM_POPUP_FORGET_AP = 620;
36 static const int H_CONFIRM_POPUP_FORGET_AP = 340;
37
38 static const int X_CONFIRM_POPUP_FORGET_AP_LABEL = 0;
39 static const int Y_CONFIRM_POPUP_FORGET_AP_LABEL = 0;
40 static const int W_CONFIRM_POPUP_FORGET_AP_LABEL = 580;
41 static const int H_CONFIRM_POPUP_FORGET_AP_LABEL = 220;
42
43 static const int X_CONFIRM_POPUP_FORGET_AP_LHS_BUTTON = 0;
44 static const int Y_CONFIRM_POPUP_FORGET_AP_LHS_BUTTON = 230;
45 static const int W_CONFIRM_POPUP_FORGET_AP_LHS_BUTTON = 285;
46 static const int H_CONFIRM_POPUP_FORGET_AP_LHS_BUTTON = 72;
47
48 static const int X_CONFIRM_POPUP_FORGET_AP_RHS_BUTTON = 295;
49 static const int Y_CONFIRM_POPUP_FORGET_AP_RHS_BUTTON = 230;
50 static const int W_CONFIRM_POPUP_FORGET_AP_RHS_BUTTON = 285;
51 static const int H_CONFIRM_POPUP_FORGET_AP_RHS_BUTTON = 72;
52
53 static const int ID_GROUP_WIFI_AP_DETAIL_MAIN = 0;
54 static const int ID_GROUP_WIFI_AP_DETAIL_MAIN_ITEM_COUNT = 1;
55 static const int ID_ITEM_WIFI_AP_DETAIL_NAME = 0;
56
57 static const int ID_GROUP_WIFI_AP_DETAIL_STATIC_IP = 1;
58 static const int ID_GROUP_WIFI_AP_DETAIL_STATIC_IP_ITEM_COUNT = 2;
59 static const int ID_ITEM_WIFI_AP_DETAIL_STATIC_IP = 0;
60 static const int ID_ITEM_WIFI_AP_DETAIL_ADDRESS = 1;
61
62 static const int ID_GROUP_WIFI_AP_DETAIL_STATIC_IP_SUB = 2;
63 static const int ID_GROUP_WIFI_AP_DETAIL_STATIC_IP_SUB_ITEM_COUNT = 4;
64 static const int ID_ITEM_WIFI_AP_DETAIL_SUBNET_MASK = 0;
65 static const int ID_ITEM_WIFI_AP_DETAIL_GATEWAY = 1;
66 static const int ID_ITEM_WIFI_AP_DETAIL_DNS_1 = 2;
67 static const int ID_ITEM_WIFI_AP_DETAIL_DNS_2 = 3;
68
69 static const int ID_GROUP_WIFI_AP_DETAIL_MACK_ADDRESS = 3;
70 static const int ID_GROUP_WIFI_AP_DETAIL_MACK_ADDRESS_ITEM_COUNT = 3;
71 static const int ID_ITEM_WIFI_AP_DETAIL_MAC_ADDRESS = 0;
72 static const int ID_ITEM_WIFI_AP_DETAIL_PROXY_ADDRESS = 1;
73 static const int ID_ITEM_WIFI_AP_DETAIL_PROXY_PORT = 2;
74
75 static const int ID_GROUP_COUNT = 4;
76 static const int ID_GROUP_MAX_ITEM_COUNT = ID_GROUP_WIFI_AP_DETAIL_STATIC_IP_SUB_ITEM_COUNT;
77
78 static const int IDA_WIFI_AP_DETAIL_BASE = 100;
79 static const int IDA_FOOTER_WIFI_AP_DETAIL_FORGET = IDA_WIFI_AP_DETAIL_BASE + 1;
80
81 static const int IDA_POPUP_BASE = 200;
82 static const int IDA_FORGET_AP_POPUP_OK_BUTTON = IDA_POPUP_BASE + 1;
83 static const int IDA_FORGET_AP_POPUP_CANCEL_BUTTON = IDA_POPUP_BASE + 2;
84
85 static const wchar_t* IDS_FOOTER_FORGET_AP = L"Forget";
86
87 static const int WIFI_RSSI_DETAIL_MAX = -70;
88 static const int WIFI_RSSI_DETAIL_MID = -80;
89 static const int WIFI_RSSI_DETAIL_MIN = -90;
90
91 WifiApDetailForm::WifiApDetailForm(void)
92         : __tableViewCollapseGroup(false)
93         , __wifiApConnectCheck(false)
94         , __pWifiPresentationModelInstance(null)
95         , __wifiApIndex(0)
96         , __pForgetAPPoup(null)
97 {
98 }
99
100 WifiApDetailForm::~WifiApDetailForm(void)
101 {
102         delete __pForgetAPPoup;
103         __pForgetAPPoup = null;
104 }
105
106 void
107 WifiApDetailForm::CreateFooter(void)
108 {
109         Footer* pFooter = GetFooter();
110         AppAssert(pFooter);
111
112         pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
113
114         FooterItem footerForgetAP;
115         footerForgetAP.Construct(IDA_FOOTER_WIFI_AP_DETAIL_FORGET);
116         footerForgetAP.SetText(IDS_FOOTER_FORGET_AP);
117
118         pFooter->AddItem(footerForgetAP);
119         pFooter->AddActionEventListener(*this);
120
121         SetFormBackEventListener(this);
122 }
123
124 result
125 WifiApDetailForm::OnInitializing(void)
126 {
127         SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER | FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE);
128         CreateHeader(ResourceManager::GetString(L"IDS_WIFI_HEADER_DETAILS"));
129         CreateTableView();
130
131         AppLogDebug("ENTER");
132
133         return E_SUCCESS;
134 }
135
136 result
137 WifiApDetailForm::OnTerminating(void)
138 {
139         __pTableView = null;
140         __pForgetAPPoup = null;
141
142         SetFormBackEventListener(null);
143         return E_SUCCESS;
144 }
145
146 void
147 WifiApDetailForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
148 {
149         String* pWifiApIndex = static_cast<String*>(pArgs->GetAt(0));
150         if (pWifiApIndex == null)
151         {
152                 AppLogDebug("pPairedDeviceIndex is null");
153                 return;
154         }
155
156         result r = Integer::Parse(*pWifiApIndex, __wifiApIndex);
157         if ((IsFailed(r))
158                 || (__wifiApIndex < 0))
159         {
160                 AppLogDebug("Integer::Parse fail[%s] __pairedDeviceIndex[%d]", GetErrorMessage(r), __wifiApIndex);
161                 return;
162         }
163
164         r = InitWifiPresentationModelInstance();
165         if (IsFailed(r))
166         {
167                 AppLogDebug("InitWifiPresentationModelInstance fail [%s]", GetErrorMessage(r));
168                 return;
169         }
170
171         CreateTableView();
172
173         __pTableView->UpdateTableView();
174
175         __pTableView->SetItemChecked(ID_GROUP_WIFI_AP_DETAIL_STATIC_IP, ID_ITEM_WIFI_AP_DETAIL_STATIC_IP, false);
176 }
177
178 result
179 WifiApDetailForm::InitWifiPresentationModelInstance(void)
180 {
181         __pWifiPresentationModelInstance = WifiPresentationModel::GetInstance();
182         if (__pWifiPresentationModelInstance == null)
183         {
184                 return E_FAILURE;
185         }
186
187         __pWifiPresentationModelInstance->SetWifiEventListener(this);
188
189         if (__pWifiPresentationModelInstance->IsWifiBssInfoConnect(__wifiApIndex) == true)
190         {
191                 CreateFooter();
192         }
193
194         return E_SUCCESS;
195 }
196
197 void
198 WifiApDetailForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
199 {
200 }
201
202 void
203 WifiApDetailForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
204 {
205         SceneManager* pSceneManager = SceneManager::GetInstance();
206         AppAssert(pSceneManager);
207
208         __pTableView->CollapseGroup(ID_GROUP_WIFI_AP_DETAIL_STATIC_IP_SUB);
209         pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
210 }
211
212 int
213 WifiApDetailForm::GetGroupCount(void)
214 {
215         AppLogDebug("ENTER");
216         return ID_GROUP_COUNT;
217 }
218
219 int
220 WifiApDetailForm::GetItemCount(int groupIndex)
221 {
222         int itemCount = 0;
223
224         switch (groupIndex)
225         {
226         case ID_GROUP_WIFI_AP_DETAIL_MAIN:
227                 {
228                         itemCount = ID_GROUP_WIFI_AP_DETAIL_MAIN_ITEM_COUNT;
229                 }
230                 break;
231
232         case ID_GROUP_WIFI_AP_DETAIL_STATIC_IP:
233                 {
234                         itemCount = ID_GROUP_WIFI_AP_DETAIL_STATIC_IP_ITEM_COUNT;
235                 }
236                 break;
237
238         case ID_GROUP_WIFI_AP_DETAIL_STATIC_IP_SUB:
239                 {
240                         itemCount = ID_GROUP_WIFI_AP_DETAIL_STATIC_IP_SUB_ITEM_COUNT;
241                 }
242                 break;
243
244         case ID_GROUP_WIFI_AP_DETAIL_MACK_ADDRESS:
245                 {
246                         itemCount = ID_GROUP_WIFI_AP_DETAIL_MACK_ADDRESS_ITEM_COUNT;
247                 }
248                 break;
249
250         default:
251                 break;
252         }
253
254         AppLogDebug("GetItemCount %d ", itemCount);
255         return itemCount;
256 }
257
258 TableViewGroupItem*
259 WifiApDetailForm::CreateGroupItem(int groupIndex, int itemWidth)
260 {
261         Color itemBGColor = COLOR_BG_GROUP_INDEX_DEFAULT;
262         int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
263         String groupText;
264         int itemLableTextSize = FONT_SIZE_GROUP_TITLE_TEXT;
265         Color itemLableTextColor = COLOR_GROUP_TITLE_TEXT;
266         Rectangle itemRectLable(X_GROUP_INDEX_DEFAULT_LABEL, Y_GROUP_INDEX_DEFAULT_LABEL, itemWidth, itemHeight);
267         Label* pLabel = null;
268         LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
269
270         TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
271
272         switch (groupIndex)
273         {
274         case ID_GROUP_WIFI_AP_DETAIL_STATIC_IP_SUB:
275                 {
276                         delete pItem;
277                         pItem = null;
278                 }
279                 break;
280
281         default:
282                 break;
283         }
284
285         if (pItem)
286         {
287                 RelativeLayout relativeLayout;
288                 relativeLayout.Construct();
289
290                 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
291                 pItem->SetBackgroundColor(itemBGColor);
292                 pItem->SetEnabled(false);
293
294                 pLabel = new (std::nothrow) Label();
295                 pLabel->Construct(itemRectLable, groupText);
296                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
297                 pLabel->SetTextConfig(itemLableTextSize, style);
298                 pLabel->SetTextColor(itemLableTextColor);
299
300                 relativeLayout.SetMargin(*pLabel, itemRectLable.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
301                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
302                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
303                 pItem->AddControl(pLabel);
304         }
305
306         return pItem;
307 }
308
309 TableViewItem*
310 WifiApDetailForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
311 {
312         bool isTwoLineItemText = false;
313         Color itemBGColor = COLOR_BG_GROUP_ITEM_DEFAULT;
314         Rectangle itemRectangle;
315         Rectangle itemRectSecondLabel;
316         Rectangle itemIconRect;
317         String itemText;
318         String itemTextTwoLine;
319         String itemSetname;
320         Color itemLableTextColor = COLOR_MAIN_TEXT;
321         int itemHeight = H_GROUP_ITEM_DEFAULT;
322         Rectangle itemRectLable;
323         int fontSize = GetFontSize();
324         TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
325
326         WifiBssInfo* pWifiBssInfo = null;
327         TableViewItem* pItem = new (std::nothrow) TableViewItem();
328
329         ItemTypeTwoLine(itemRectangle, itemRectSecondLabel, fontSize);
330         itemHeight = (itemRectangle.height + itemRectSecondLabel.height);
331         if (__pWifiPresentationModelInstance == null)
332         {
333                 AppLogDebug("__pWifiPresentationModelInstance is null");
334                 delete pItem;
335                 pItem = null;
336                 return pItem;
337         }
338
339         __wifiApConnectCheck = __pWifiPresentationModelInstance->IsWifiBssInfoConnect(__wifiApIndex);
340
341         if (__wifiApConnectCheck == true)
342         {
343                 AppLogDebug("__wifiApConnectCheck true");
344                 pWifiBssInfo = __pWifiPresentationModelInstance->GetWifiBssInfoInAccessPointListAt();
345         }
346         else
347         {
348                 pWifiBssInfo = __pWifiPresentationModelInstance->GetWifiBssInfoListAt(itemIndex);
349         }
350
351         ItemTypeOneLine(itemRectLable);
352
353         switch (groupIndex)
354         {
355         case ID_GROUP_WIFI_AP_DETAIL_MAIN:
356                 {
357                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_NAME");
358                         itemTextTwoLine = pWifiBssInfo->GetSsid();
359                         isTwoLineItemText = true;
360                 }
361                 break;
362
363         case ID_GROUP_WIFI_AP_DETAIL_STATIC_IP:
364                 {
365                         switch (itemIndex)
366                         {
367                         case ID_ITEM_WIFI_AP_DETAIL_STATIC_IP:
368                                 {
369                                         itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_STATIC_IP");
370                                 }
371                                 break;
372
373                         case ID_ITEM_WIFI_AP_DETAIL_ADDRESS:
374                                 {
375                                         itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_IP_ADDRESS");
376                                         IpAddress* pIpAddress = const_cast<IpAddress*>(pWifiBssInfo->GetLocalAddress());
377                                         if (pIpAddress == null)
378                                         {
379                                                 AppLogDebug("DETAIL_ADDRESS IpAddress is null");
380                                         }
381                                         else
382                                         {
383                                                 itemTextTwoLine = pIpAddress->ToString();
384                                                 isTwoLineItemText = true;
385                                         }
386                                 }
387                                 break;
388
389                         default:
390                                 break;
391                         }
392
393                         if (itemIndex == ID_ITEM_WIFI_AP_DETAIL_STATIC_IP)
394                         {
395                                 style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
396                         }
397                 }
398                 break;
399
400         case ID_GROUP_WIFI_AP_DETAIL_STATIC_IP_SUB:
401                 {
402                         if (!__tableViewCollapseGroup)
403                         {
404                                 delete pItem;
405                                 pItem = null;
406                                 break;
407                         }
408
409                         switch (itemIndex)
410                         {
411                         case ID_ITEM_WIFI_AP_DETAIL_SUBNET_MASK:
412                                 {
413                                         itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_SUBNET_MASK");
414                                         IpAddress* pIpAddress = const_cast<IpAddress*>(pWifiBssInfo->GetSubnetMaskAddress());
415                                         if (pIpAddress == null)
416                                         {
417                                                 AppLogDebug("SUBNET_MASK IpAddress is null");
418                                         }
419                                         else
420                                         {
421                                                 itemTextTwoLine = pIpAddress->ToString();
422                                                 isTwoLineItemText = true;
423                                         }
424                                 }
425                                 break;
426
427                         case ID_ITEM_WIFI_AP_DETAIL_GATEWAY:
428                                 {
429                                         itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_GATEWAY_ADDRESS");
430                                         IpAddress* pIpAddress = const_cast<IpAddress*>(pWifiBssInfo->GetDefaultGatewayAddress());
431                                         if (pIpAddress == null)
432                                         {
433                                                 AppLogDebug("DETAIL_GATEWAY IpAddress is null");
434                                         }
435                                         else
436                                         {
437                                                 itemTextTwoLine = pIpAddress->ToString();
438                                                 isTwoLineItemText = true;
439                                         }
440                                 }
441                                 break;
442
443                         case ID_ITEM_WIFI_AP_DETAIL_DNS_1:
444                                 {
445                                         itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_DNS_1");
446                                         IpAddress* pIpAddress = const_cast<IpAddress*>(pWifiBssInfo->GetPrimaryDnsAddress());
447                                         if (pIpAddress == null)
448                                         {
449                                                 AppLogDebug("DETAIL_DNS_1 IpAddress is null");
450                                         }
451                                         else
452                                         {
453                                                 itemTextTwoLine = pIpAddress->ToString();
454                                                 isTwoLineItemText = true;
455                                         }
456                                 }
457                                 break;
458
459                         case ID_ITEM_WIFI_AP_DETAIL_DNS_2:
460                                 {
461                                         itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_DNS_2");
462                                         IpAddress* pIpAddress = const_cast<IpAddress*>(pWifiBssInfo->GetSecondaryDnsAddress());
463                                         if (pIpAddress == null)
464                                         {
465                                                 AppLogDebug("DETAIL_DNS_2 IpAddress is null");
466                                         }
467                                         else
468                                         {
469                                                 itemTextTwoLine = pIpAddress->ToString();
470                                                 isTwoLineItemText = true;
471                                         }
472                                 }
473                                 break;
474
475                         default:
476                                 break;
477                         }
478                 }
479                 break;
480
481         case ID_GROUP_WIFI_AP_DETAIL_MACK_ADDRESS:
482                 {
483                         switch (itemIndex)
484                         {
485                         case ID_ITEM_WIFI_AP_DETAIL_MAC_ADDRESS:
486                                 {
487                                         itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_MAC_ADDRESS");
488                                         itemTextTwoLine = pWifiBssInfo->GetBssId();
489                                         isTwoLineItemText = true;
490                                 }
491                                 break;
492
493                         case ID_ITEM_WIFI_AP_DETAIL_PROXY_ADDRESS:
494                                 {
495                                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_CONNECTIONSETTINGS_PROXY_ADDRESS");
496                                         itemTextTwoLine = pWifiBssInfo->GetProxyAddress();
497                                         isTwoLineItemText = true;
498                                 }
499                                 break;
500
501                         case ID_ITEM_WIFI_AP_DETAIL_PROXY_PORT:
502                                 {
503                                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_PROXY_PORT");
504                                         isTwoLineItemText = true;
505                                 }
506                                 break;
507
508                         default:
509                                 break;
510                         }
511                 }
512                 break;
513
514         default:
515                 break;
516         }
517
518         if (pItem == null)
519         {
520                 if (__wifiApConnectCheck == true)
521                 {
522                         delete pWifiBssInfo;
523                 }
524                 return pItem;
525         }
526
527         RelativeLayout relativeLayout;
528         relativeLayout.Construct();
529
530         result r = pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
531         if (IsFailed(r))
532         {
533                 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
534                 if (__wifiApConnectCheck == true)
535                 {
536                         delete pWifiBssInfo;
537                 }
538
539                 delete pItem;
540                 return null;
541         }
542
543         pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
544
545         Label* pLabel = new (std::nothrow) Label();
546         if (pLabel == null)
547         {
548                 AppLogDebug("pLabel is null");
549                 if (__wifiApConnectCheck == true)
550                 {
551                         delete pWifiBssInfo;
552                 }
553
554                 return pItem;
555         }
556
557         r = pLabel->Construct(itemRectangle, itemText);
558         if (IsFailed(r))
559         {
560                 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
561                 if (__wifiApConnectCheck == true)
562                 {
563                         delete pWifiBssInfo;
564                 }
565
566                 delete pLabel;
567                 return pItem;
568         }
569
570         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
571         pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
572         pLabel->SetTextColor(COLOR_MAIN_TEXT);
573
574         pItem->AddControl(pLabel);
575         relativeLayout.SetMargin(*pLabel, itemRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
576         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
577         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
578
579         if (isTwoLineItemText == true)
580         {
581                 Label* pSecondLabel = new (std::nothrow) Label();
582                 if (pSecondLabel == null)
583                 {
584                         AppLogDebug("pLabel is null");
585                         if (__wifiApConnectCheck == true)
586                         {
587                                 delete pWifiBssInfo;
588                         }
589
590                         return pItem;
591                 }
592
593                 r = pSecondLabel->Construct(itemRectSecondLabel, itemTextTwoLine);
594                 if (IsFailed(r))
595                 {
596                         AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
597                         if (__wifiApConnectCheck == true)
598                         {
599                                 delete pWifiBssInfo;
600                         }
601
602                         delete pSecondLabel;
603                         return pItem;
604                 }
605
606                 pSecondLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
607                 pSecondLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
608                 pSecondLabel->SetTextColor(COLOR_SUB_TEXT);
609                 pSecondLabel->SetName(itemSetname);
610
611                 pItem->AddControl(pSecondLabel);
612                 relativeLayout.SetMargin(*pSecondLabel, itemRectSecondLabel.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
613                 relativeLayout.SetRelation(*pSecondLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
614                 relativeLayout.SetRelation(*pSecondLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
615         }
616
617         if (__wifiApConnectCheck == true)
618         {
619                 delete pWifiBssInfo;
620         }
621         return pItem;
622 }
623
624 bool
625 WifiApDetailForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
626 {
627         AppLogDebug("ENTER");
628
629         delete pItem;
630         pItem = null;
631
632         return true;
633 }
634
635 bool
636 WifiApDetailForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
637 {
638         AppLogDebug("ENTER");
639
640         delete pItem;
641         pItem = null;
642
643         return true;
644 }
645
646 void
647 WifiApDetailForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
648 {
649         SceneManager* pSceneManager = SceneManager::GetInstance();
650         AppAssert(pSceneManager);
651
652         if ((groupIndex == ID_GROUP_WIFI_AP_DETAIL_STATIC_IP)
653                 && (itemIndex == ID_ITEM_WIFI_AP_DETAIL_STATIC_IP))
654         {
655                 if (status == TABLE_VIEW_ITEM_STATUS_CHECKED)
656                 {
657                         __tableViewCollapseGroup = true;
658                         tableView.ExpandGroup(ID_GROUP_WIFI_AP_DETAIL_STATIC_IP_SUB);
659                 }
660                 else if (status == TABLE_VIEW_ITEM_STATUS_UNCHECKED)
661                 {
662                         __tableViewCollapseGroup = false;
663                         tableView.CollapseGroup(ID_GROUP_WIFI_AP_DETAIL_STATIC_IP_SUB);
664                 }
665         }
666         AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
667 }
668
669 void
670 WifiApDetailForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
671 {
672         result r = E_FAILURE;
673         switch (actionId)
674         {
675         case IDA_FOOTER_WIFI_AP_DETAIL_FORGET:
676                 {
677                         CreateForgetApPopup();
678                         ShowForgetApPopup();
679                 }
680                 break;
681
682         case IDA_FORGET_AP_POPUP_OK_BUTTON:
683                 {
684                         AppLogDebug("IDA_FORGET_AP_POPUP_OK_BUTTON");
685                         SceneManager* pSceneManager = SceneManager::GetInstance();
686                         AppAssert(pSceneManager);
687
688                         HideForgetApPopup();
689                         DestroyForgetApPopup();
690
691                         r = __pWifiPresentationModelInstance->SetWifiBssUnknownAt(__wifiApIndex);
692                         AppLogDebug("forget = [%s]", GetErrorMessage(r));
693
694                         pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
695                 }
696                 break;
697
698         case IDA_FORGET_AP_POPUP_CANCEL_BUTTON:
699                 {
700                         HideForgetApPopup();
701                         DestroyForgetApPopup();
702                 }
703                 break;
704
705         default:
706                 break;
707         }
708         AppLogDebug("ENTER");
709 }
710
711 result
712 WifiApDetailForm::CreateForgetApPopup(void)
713 {
714         String itemLableText(ResourceManager::GetString(L"IDS_WIFI_POP_AUTOMATIC_CONNECTION_NETWORK_WILL_DISABLED_CONTINUE_Q_MSG"));
715         String itemText;
716         Rectangle itemRect = Rectangle(X_CONFIRM_POPUP_FORGET_AP_LABEL
717                                                                 , Y_CONFIRM_POPUP_FORGET_AP_LABEL
718                                                                 , W_CONFIRM_POPUP_FORGET_AP_LABEL
719                                                                 , H_CONFIRM_POPUP_FORGET_AP_LABEL);
720         Label* pPopupTextLabel;
721         Dimension popupBounds = Dimension(W_CONFIRM_POPUP_FORGET_AP, H_CONFIRM_POPUP_FORGET_AP);
722         Button* pLhsButton = null;
723         Button* pRhsButton = null;
724
725         __pForgetAPPoup = new (std::nothrow) Popup();
726         __pForgetAPPoup->Construct(false, popupBounds);
727
728         pPopupTextLabel = new (std::nothrow) Label();
729         pPopupTextLabel->Construct(itemRect, itemLableText);
730         pPopupTextLabel->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
731         pPopupTextLabel->SetTextConfig(FONT_SIZE_POPUP_TEXT, LABEL_TEXT_STYLE_NORMAL);
732         pPopupTextLabel->SetTextColor(COLOR_POPUP_TEXT);
733
734         __pForgetAPPoup->AddControl(pPopupTextLabel);
735
736         itemRect = Rectangle(X_CONFIRM_POPUP_FORGET_AP_LHS_BUTTON
737                                                 , Y_CONFIRM_POPUP_FORGET_AP_LHS_BUTTON
738                                                 , W_CONFIRM_POPUP_FORGET_AP_LHS_BUTTON
739                                                 , H_CONFIRM_POPUP_FORGET_AP_LHS_BUTTON);
740
741         itemText = ResourceManager::GetString(L"IDS_ST_BODY_CANCEL");
742         
743         pLhsButton = new (std::nothrow) Button();
744         pLhsButton->Construct(itemRect, itemText);
745         pLhsButton->SetActionId(IDA_FORGET_AP_POPUP_CANCEL_BUTTON);
746
747         __pForgetAPPoup->AddControl(pLhsButton);
748
749         itemRect = Rectangle(X_CONFIRM_POPUP_FORGET_AP_RHS_BUTTON
750                                                 , Y_CONFIRM_POPUP_FORGET_AP_RHS_BUTTON
751                                                 , W_CONFIRM_POPUP_FORGET_AP_RHS_BUTTON
752                                                 , H_CONFIRM_POPUP_FORGET_AP_RHS_BUTTON);
753
754         itemText = ResourceManager::GetString(L"IDS_ST_BUTTON_OK");
755         
756         pRhsButton = new (std::nothrow) Button();
757         pRhsButton->Construct(itemRect, itemText);
758         pRhsButton->SetActionId(IDA_FORGET_AP_POPUP_OK_BUTTON);
759
760         __pForgetAPPoup->AddControl(pRhsButton);
761
762         pLhsButton->AddActionEventListener(*this);
763         pRhsButton->AddActionEventListener(*this);
764
765         return E_SUCCESS;
766 }
767
768 void
769 WifiApDetailForm::ShowForgetApPopup(void)
770 {
771         __pForgetAPPoup->SetShowState(true);
772         __pForgetAPPoup->Show();
773 }
774
775 void
776 WifiApDetailForm::HideForgetApPopup(void)
777 {
778         __pForgetAPPoup->SetShowState(false);
779         Invalidate(true);
780 }
781
782 void
783 WifiApDetailForm::DestroyForgetApPopup(void)
784 {
785         delete __pForgetAPPoup;
786         __pForgetAPPoup = null;
787 }
788
789 Tizen::Graphics::Bitmap*
790 WifiApDetailForm::GetMajorAuthenticationTypeInWifiRssiValueAtBitmapN(int itemIndex)
791 {
792         if (__pWifiPresentationModelInstance == null)
793         {
794                 AppLogDebug("__pWifiPresentationModelInstance is null");
795                 return null;
796         }
797
798         Bitmap* pBitmap = null;
799
800         WifiAuthenticationType majorType = __pWifiPresentationModelInstance->GetAuthenticationtypeInAccessPointListAt(itemIndex);
801
802         if (IsFailed(GetLastResult()))
803         {
804                 AppLogDebug("GetAuthenticationType fail [%s]", GetErrorMessage(GetLastResult()));
805                 return null;
806         }
807
808         long wifiBssInfoRssi = __pWifiPresentationModelInstance->GetRssiInAccessPointListAt(itemIndex);
809         switch (majorType)
810         {
811         case WIFI_AUTHENTICATION_OPEN:
812                 // fall through
813         case WIFI_AUTHENTICATION_SHARED:
814                 {
815                         if (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MAX)
816                         {
817                                 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_UNLOCK_03);
818                         }
819                         else if ((wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MAX)
820                                         && (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MID))
821                         {
822                                 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_UNLOCK_02);
823                         }
824                         else if ((wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MID)
825                                         && (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MIN))
826                         {
827                                 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_UNLOCK_01);
828                         }
829                         else if (wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MIN)
830                         {
831                                 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_UNLOCK_00);
832                         }
833                         else
834                         {
835                                 AppLogDebug("wifiBssInfoRssi is high (%d)", wifiBssInfoRssi);
836                         }
837                 }
838                 break;
839
840         case WIFI_AUTHENTICATION_WPA:
841                 // fall through
842         case WIFI_AUTHENTICATION_WPA_PSK:
843                 // fall through
844         case WIFI_AUTHENTICATION_WPA2:
845                 // fall through
846         case WIFI_AUTHENTICATION_WPA2_PSK:
847                 // fall through
848         case WIFI_AUTHENTICATION_WPA_WPA2_MIXED_PSK:
849                 {
850                         if (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MAX)
851                         {
852                                 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_LOCK_03);
853                         }
854                         else if ((wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MAX)
855                                         && (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MID))
856                         {
857                                 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_LOCK_02);
858                         }
859                         else if ((wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MID)
860                                         && (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MIN))
861                         {
862                                 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_LOCK_01);
863                         }
864                         else if (wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MIN)
865                         {
866                                 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_LOCK_00);
867                         }
868                         else
869                         {
870                                 AppLogDebug("wifiBssInfoRssi is high (%d)", wifiBssInfoRssi);
871                         }
872                 }
873                 break;
874
875         case WIFI_AUTHENTICATION_MAX:
876                 // fall through
877         default:
878                 {
879                         AppLogDebug("majorType is Invalid");
880                 }
881                 break;
882         }
883
884         return pBitmap;
885 }
886
887 int
888 WifiApDetailForm::GetDefaultGroupItemHeight(void)
889 {
890         return H_GROUP_INDEX_NO_TITLE_DEFAULT;
891 }
892
893 int
894 WifiApDetailForm::GetDefaultItemHeight(void)
895 {
896         return H_GROUP_ITEM_DEFAULT;
897 }
898
899 void
900 WifiApDetailForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
901 {
902 }
903
904 void
905 WifiApDetailForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
906 {
907 }
908
909 void
910 WifiApDetailForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
911 {
912 }
913
914 void
915 WifiApDetailForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
916 {
917 }
918
919 void
920 WifiApDetailForm::OnWifiPresentationModelEventCompleted(WifiPresentationModelEvent requestEvent, result r)
921 {
922         switch (requestEvent)
923         {
924         case WIFI_PRESENTATION_MODEL_EVENT_NONE:
925                 {
926                 }
927                 break;
928
929         case WIFI_PRESENTATION_MODEL_EVENT_ACTIVATED:
930                 {
931                 }
932                 break;
933
934         case WIFI_PRESENTATION_MODEL_EVENT_ACTIVATING:
935                 {
936                 }
937                 break;
938
939         case WIFI_PRESENTATION_MODEL_EVENT_DEACTIVATED:
940                 {
941                 }
942                 break;
943
944         case WIFI_PRESENTATION_MODEL_EVENT_DEACTIVATING:
945                 {
946                 }
947                 break;
948
949         case WIFI_PRESENTATION_MODEL_EVENT_CONNECTED:
950                 {
951                 }
952                 break;
953
954         case WIFI_PRESENTATION_MODEL_EVENT_DISCONNECTED:
955                 {
956                 }
957                 break;
958
959         case WIFI_PRESENTATION_MODEL_EVENT_SCAN_COMPLETED_N:
960                 {
961                 }
962                 break;
963
964         case WIFI_PRESENTATION_MODEL_EVENT_SCANNING:
965                 {
966                 }
967                 break;
968
969         case WIFI_PRESENTATION_MODEL_EVENT_MAX:
970                 {
971                 }
972                 break;
973
974         default:
975                 break;
976         }
977 }