Tizen 2.0 Release
[pkgs/o/oma-ds-service.git] / data / my_tools / jj / rsa / apps / osp / Settings / src / StWifiApDetailForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                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_LHS_BUTTON = IDA_POPUP_BASE + 1;
83 static const int IDA_FORGET_AP_POPUP_RHS_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->SetBackButton();
120         pFooter->AddActionEventListener(*this);
121
122         SetFormBackEventListener(this);
123 }
124
125 result
126 WifiApDetailForm::OnInitializing(void)
127 {
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         pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
209 }
210
211 int
212 WifiApDetailForm::GetGroupCount(void)
213 {
214         AppLogDebug("ENTER");
215         return ID_GROUP_COUNT;
216 }
217
218 int
219 WifiApDetailForm::GetItemCount(int groupIndex)
220 {
221         int itemCount = 0;
222
223         switch (groupIndex)
224         {
225         case ID_GROUP_WIFI_AP_DETAIL_MAIN:
226                 {
227                         itemCount = ID_GROUP_WIFI_AP_DETAIL_MAIN_ITEM_COUNT;
228                 }
229                 break;
230
231         case ID_GROUP_WIFI_AP_DETAIL_STATIC_IP:
232                 {
233                         itemCount = ID_GROUP_WIFI_AP_DETAIL_STATIC_IP_ITEM_COUNT;
234                 }
235                 break;
236
237         case ID_GROUP_WIFI_AP_DETAIL_STATIC_IP_SUB:
238                 {
239                         itemCount = ID_GROUP_WIFI_AP_DETAIL_STATIC_IP_SUB_ITEM_COUNT;
240                 }
241                 break;
242
243         case ID_GROUP_WIFI_AP_DETAIL_MACK_ADDRESS:
244                 {
245                         itemCount = ID_GROUP_WIFI_AP_DETAIL_MACK_ADDRESS_ITEM_COUNT;
246                 }
247                 break;
248
249         default:
250                 break;
251         }
252
253         AppLogDebug("GetItemCount %d ", itemCount);
254         return itemCount;
255 }
256
257 TableViewGroupItem*
258 WifiApDetailForm::CreateGroupItem(int groupIndex, int itemWidth)
259 {
260         Color itemBGColor = COLOR_BG_GROUP_INDEX_DEFAULT;
261         int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
262         String groupText;
263         int itemLableTextSize = FONT_SIZE_GROUP_TITLE_TEXT;
264         Color itemLableTextColor = COLOR_GROUP_TITLE_TEXT;
265         Rectangle itemRectLable(X_GROUP_INDEX_DEFAULT_LABEL, Y_GROUP_INDEX_DEFAULT_LABEL, itemWidth, itemHeight);
266         Label* pLabel = null;
267         LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
268
269         TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
270
271         switch (groupIndex)
272         {
273         case ID_GROUP_WIFI_AP_DETAIL_STATIC_IP_SUB:
274                 {
275                         delete pItem;
276                         pItem = null;
277                 }
278                 break;
279
280         default:
281                 break;
282         }
283
284         if (pItem)
285         {
286                 RelativeLayout relativeLayout;
287                 relativeLayout.Construct();
288
289                 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
290                 pItem->SetBackgroundColor(itemBGColor);
291                 pItem->SetEnabled(false);
292
293                 pLabel = new (std::nothrow) Label();
294                 pLabel->Construct(itemRectLable, groupText);
295                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
296                 pLabel->SetTextConfig(itemLableTextSize, style);
297                 pLabel->SetTextColor(itemLableTextColor);
298
299                 relativeLayout.SetMargin(*pLabel, itemRectLable.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
300                 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
301                 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
302                 pItem->AddControl(*pLabel);
303         }
304
305         return pItem;
306 }
307
308 TableViewItem*
309 WifiApDetailForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
310 {
311         bool isTwoLineItemText = false;
312         Color itemBGColor = COLOR_BG_GROUP_ITEM_DEFAULT;
313         Rectangle itemRectangle;
314         Rectangle itemRectSecondLabel;
315         Rectangle itemIconRect;
316         String itemText;
317         String itemTextTwoLine;
318         String itemSetname;
319         Color itemLableTextColor = COLOR_MAIN_TEXT;
320         int itemHeight = H_GROUP_ITEM_DEFAULT;
321         Rectangle itemRectLable;
322         int fontSize = GetFontSize();
323         TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
324
325         WifiBssInfo* pWifiBssInfo = null;
326         TableViewItem* pItem = new (std::nothrow) TableViewItem();
327
328         ItemTypeTwoLine(itemRectangle, itemRectSecondLabel, fontSize);
329         itemHeight = (itemRectangle.height + itemRectSecondLabel.height);
330         if (__pWifiPresentationModelInstance == null)
331         {
332                 AppLogDebug("__pWifiPresentationModelInstance is null");
333                 delete pItem;
334                 pItem = null;
335                 return pItem;
336         }
337
338         __wifiApConnectCheck = __pWifiPresentationModelInstance->IsWifiBssInfoConnect(__wifiApIndex);
339
340         if (__wifiApConnectCheck == true)
341         {
342                 AppLogDebug("__wifiApConnectCheck true");
343                 pWifiBssInfo = __pWifiPresentationModelInstance->GetWifiBssInfoInAccessPointListAt();
344         }
345         else
346         {
347                 pWifiBssInfo = __pWifiPresentationModelInstance->GetWifiBssInfoListAt(itemIndex);
348         }
349
350         ItemTypeOneLine(itemRectLable);
351
352         switch (groupIndex)
353         {
354         case ID_GROUP_WIFI_AP_DETAIL_MAIN:
355                 {
356                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_NAME");
357                         itemTextTwoLine = pWifiBssInfo->GetSsid();
358                         isTwoLineItemText = true;
359                 }
360                 break;
361
362         case ID_GROUP_WIFI_AP_DETAIL_STATIC_IP:
363                 {
364                         switch (itemIndex)
365                         {
366                         case ID_ITEM_WIFI_AP_DETAIL_STATIC_IP:
367                                 {
368                                         itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_STATIC_IP");
369                                 }
370                                 break;
371
372                         case ID_ITEM_WIFI_AP_DETAIL_ADDRESS:
373                                 {
374                                         itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_IP_ADDRESS");
375                                         IpAddress* pIpAddress = const_cast<IpAddress*>(pWifiBssInfo->GetLocalAddress());
376                                         if (pIpAddress == null)
377                                         {
378                                                 AppLogDebug("DETAIL_ADDRESS IpAddress is null");
379                                         }
380                                         else
381                                         {
382                                                 itemTextTwoLine = pIpAddress->ToString();
383                                                 isTwoLineItemText = true;
384                                         }
385                                 }
386                                 break;
387
388                         default:
389                                 break;
390                         }
391
392                         if (itemIndex == ID_ITEM_WIFI_AP_DETAIL_STATIC_IP)
393                         {
394                                 style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
395                         }
396                 }
397                 break;
398
399         case ID_GROUP_WIFI_AP_DETAIL_STATIC_IP_SUB:
400                 {
401                         if (!__tableViewCollapseGroup)
402                         {
403                                 delete pItem;
404                                 pItem = null;
405                                 break;
406                         }
407
408                         switch (itemIndex)
409                         {
410                         case ID_ITEM_WIFI_AP_DETAIL_SUBNET_MASK:
411                                 {
412                                         itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_SUBNET_MASK");
413                                         IpAddress* pIpAddress = const_cast<IpAddress*>(pWifiBssInfo->GetSubnetMaskAddress());
414                                         if (pIpAddress == null)
415                                         {
416                                                 AppLogDebug("SUBNET_MASK IpAddress is null");
417                                         }
418                                         else
419                                         {
420                                                 itemTextTwoLine = pIpAddress->ToString();
421                                                 isTwoLineItemText = true;
422                                         }
423                                 }
424                                 break;
425
426                         case ID_ITEM_WIFI_AP_DETAIL_GATEWAY:
427                                 {
428                                         itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_GATEWAY_ADDRESS");
429                                         IpAddress* pIpAddress = const_cast<IpAddress*>(pWifiBssInfo->GetDefaultGatewayAddress());
430                                         if (pIpAddress == null)
431                                         {
432                                                 AppLogDebug("DETAIL_GATEWAY IpAddress is null");
433                                         }
434                                         else
435                                         {
436                                                 itemTextTwoLine = pIpAddress->ToString();
437                                                 isTwoLineItemText = true;
438                                         }
439                                 }
440                                 break;
441
442                         case ID_ITEM_WIFI_AP_DETAIL_DNS_1:
443                                 {
444                                         itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_DNS_1");
445                                         IpAddress* pIpAddress = const_cast<IpAddress*>(pWifiBssInfo->GetPrimaryDnsAddress());
446                                         if (pIpAddress == null)
447                                         {
448                                                 AppLogDebug("DETAIL_DNS_1 IpAddress is null");
449                                         }
450                                         else
451                                         {
452                                                 itemTextTwoLine = pIpAddress->ToString();
453                                                 isTwoLineItemText = true;
454                                         }
455                                 }
456                                 break;
457
458                         case ID_ITEM_WIFI_AP_DETAIL_DNS_2:
459                                 {
460                                         itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_DNS_2");
461                                         IpAddress* pIpAddress = const_cast<IpAddress*>(pWifiBssInfo->GetSecondaryDnsAddress());
462                                         if (pIpAddress == null)
463                                         {
464                                                 AppLogDebug("DETAIL_DNS_2 IpAddress is null");
465                                         }
466                                         else
467                                         {
468                                                 itemTextTwoLine = pIpAddress->ToString();
469                                                 isTwoLineItemText = true;
470                                         }
471                                 }
472                                 break;
473
474                         default:
475                                 break;
476                         }
477                 }
478                 break;
479
480         case ID_GROUP_WIFI_AP_DETAIL_MACK_ADDRESS:
481                 {
482                         switch (itemIndex)
483                         {
484                         case ID_ITEM_WIFI_AP_DETAIL_MAC_ADDRESS:
485                                 {
486                                         itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_MAC_ADDRESS");
487                                         itemTextTwoLine = pWifiBssInfo->GetBssId();
488                                         isTwoLineItemText = true;
489                                 }
490                                 break;
491
492                         case ID_ITEM_WIFI_AP_DETAIL_PROXY_ADDRESS:
493                                 {
494                                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_CONNECTIONSETTINGS_PROXY_ADDRESS");
495                                         itemTextTwoLine = pWifiBssInfo->GetProxyAddress();
496                                         isTwoLineItemText = true;
497                                 }
498                                 break;
499
500                         case ID_ITEM_WIFI_AP_DETAIL_PROXY_PORT:
501                                 {
502                                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_PROXY_PORT");
503                                         isTwoLineItemText = true;
504                                 }
505                                 break;
506
507                         default:
508                                 break;
509                         }
510                 }
511                 break;
512
513         default:
514                 break;
515         }
516
517         if (pItem == null)
518         {
519                 if (__wifiApConnectCheck == true)
520                 {
521                         delete pWifiBssInfo;
522                 }
523                 return pItem;
524         }
525
526         RelativeLayout relativeLayout;
527         relativeLayout.Construct();
528
529         result r = pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
530         if (IsFailed(r))
531         {
532                 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
533                 if (__wifiApConnectCheck == true)
534                 {
535                         delete pWifiBssInfo;
536                 }
537
538                 delete pItem;
539                 return null;
540         }
541
542         pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
543
544         Label* pLabel = new (std::nothrow) Label();
545         if (pLabel == null)
546         {
547                 AppLogDebug("pLabel is null");
548                 if (__wifiApConnectCheck == true)
549                 {
550                         delete pWifiBssInfo;
551                 }
552
553                 return pItem;
554         }
555
556         r = pLabel->Construct(itemRectangle, itemText);
557         if (IsFailed(r))
558         {
559                 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
560                 if (__wifiApConnectCheck == true)
561                 {
562                         delete pWifiBssInfo;
563                 }
564
565                 delete pLabel;
566                 return pItem;
567         }
568
569         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
570         pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
571         pLabel->SetTextColor(COLOR_MAIN_TEXT);
572
573         pItem->AddControl(*pLabel);
574         relativeLayout.SetMargin(*pLabel, itemRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
575         relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
576         relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
577
578         if (isTwoLineItemText == true)
579         {
580                 Label* pSecondLabel = new (std::nothrow) Label();
581                 if (pSecondLabel == null)
582                 {
583                         AppLogDebug("pLabel is null");
584                         if (__wifiApConnectCheck == true)
585                         {
586                                 delete pWifiBssInfo;
587                         }
588
589                         return pItem;
590                 }
591
592                 r = pSecondLabel->Construct(itemRectSecondLabel, itemTextTwoLine);
593                 if (IsFailed(r))
594                 {
595                         AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
596                         if (__wifiApConnectCheck == true)
597                         {
598                                 delete pWifiBssInfo;
599                         }
600
601                         delete pSecondLabel;
602                         return pItem;
603                 }
604
605                 pSecondLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
606                 pSecondLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
607                 pSecondLabel->SetTextColor(COLOR_SUB_TEXT);
608                 pSecondLabel->SetName(itemSetname);
609
610                 pItem->AddControl(*pSecondLabel);
611                 relativeLayout.SetMargin(*pSecondLabel, itemRectSecondLabel.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
612                 relativeLayout.SetRelation(*pSecondLabel, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
613                 relativeLayout.SetRelation(*pSecondLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
614         }
615
616         if (__wifiApConnectCheck == true)
617         {
618                 delete pWifiBssInfo;
619         }
620         return pItem;
621 }
622
623 bool
624 WifiApDetailForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
625 {
626         AppLogDebug("ENTER");
627
628         delete pItem;
629         pItem = null;
630
631         return true;
632 }
633
634 bool
635 WifiApDetailForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
636 {
637         AppLogDebug("ENTER");
638
639         delete pItem;
640         pItem = null;
641
642         return true;
643 }
644
645 void
646 WifiApDetailForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
647 {
648         SceneManager* pSceneManager = SceneManager::GetInstance();
649         AppAssert(pSceneManager);
650
651         if ((groupIndex == ID_GROUP_WIFI_AP_DETAIL_STATIC_IP)
652                 && (itemIndex == ID_ITEM_WIFI_AP_DETAIL_STATIC_IP))
653         {
654                 if (status == TABLE_VIEW_ITEM_STATUS_CHECKED)
655                 {
656                         __tableViewCollapseGroup = true;
657                         tableView.ExpandGroup(ID_GROUP_WIFI_AP_DETAIL_STATIC_IP_SUB);
658                 }
659                 else if (status == TABLE_VIEW_ITEM_STATUS_UNCHECKED)
660                 {
661                         __tableViewCollapseGroup = false;
662                         tableView.CollapseGroup(ID_GROUP_WIFI_AP_DETAIL_STATIC_IP_SUB);
663                 }
664         }
665         AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
666 }
667
668 void
669 WifiApDetailForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
670 {
671         result r = E_FAILURE;
672         switch (actionId)
673         {
674         case IDA_FOOTER_WIFI_AP_DETAIL_FORGET:
675                 {
676                         CreateForgetApPopup();
677                         ShowForgetApPopup();
678                 }
679                 break;
680
681         case IDA_FORGET_AP_POPUP_LHS_BUTTON:
682                 {
683                         AppLogDebug("IDA_FORGET_AP_POPUP_LHS_BUTTON");
684                         SceneManager* pSceneManager = SceneManager::GetInstance();
685                         AppAssert(pSceneManager);
686
687                         HideForgetApPopup();
688                         DestroyForgetApPopup();
689
690                         r = __pWifiPresentationModelInstance->SetWifiBssUnknownAt(__wifiApIndex);
691                         AppLogDebug("forget = [%s]", GetErrorMessage(r));
692
693                         pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
694                 }
695                 break;
696
697         case IDA_FORGET_AP_POPUP_RHS_BUTTON:
698                 {
699                         HideForgetApPopup();
700                         DestroyForgetApPopup();
701                 }
702                 break;
703
704         default:
705                 break;
706         }
707         AppLogDebug("ENTER");
708 }
709
710 result
711 WifiApDetailForm::CreateForgetApPopup(void)
712 {
713         String itemLableText(ResourceManager::GetString(L"IDS_WIFI_POP_AUTOMATIC_CONNECTION_NETWORK_WILL_DISABLED_CONTINUE_Q_MSG"));
714         String itemText;
715         Rectangle itemRect = Rectangle(X_CONFIRM_POPUP_FORGET_AP_LABEL
716                                                                 , Y_CONFIRM_POPUP_FORGET_AP_LABEL
717                                                                 , W_CONFIRM_POPUP_FORGET_AP_LABEL
718                                                                 , H_CONFIRM_POPUP_FORGET_AP_LABEL);
719         Label* pPopupTextLabel;
720         Dimension popupBounds = Dimension(W_CONFIRM_POPUP_FORGET_AP, H_CONFIRM_POPUP_FORGET_AP);
721         Button* pLhsButton = null;
722         Button* pRhsButton = null;
723
724         __pForgetAPPoup = new (std::nothrow) Popup();
725         __pForgetAPPoup->Construct(false, popupBounds);
726
727         pPopupTextLabel = new (std::nothrow) Label();
728         pPopupTextLabel->Construct(itemRect, itemLableText);
729         pPopupTextLabel->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
730         pPopupTextLabel->SetTextConfig(FONT_SIZE_POPUP_TEXT, LABEL_TEXT_STYLE_NORMAL);
731         pPopupTextLabel->SetTextColor(COLOR_POPUP_TEXT);
732
733         __pForgetAPPoup->AddControl(*pPopupTextLabel);
734
735         itemRect = Rectangle(X_CONFIRM_POPUP_FORGET_AP_LHS_BUTTON
736                                                 , Y_CONFIRM_POPUP_FORGET_AP_LHS_BUTTON
737                                                 , W_CONFIRM_POPUP_FORGET_AP_LHS_BUTTON
738                                                 , H_CONFIRM_POPUP_FORGET_AP_LHS_BUTTON);
739
740         itemText = ResourceManager::GetString(L"IDS_ST_BUTTON_OK");
741         
742         pLhsButton = new (std::nothrow) Button();
743         pLhsButton->Construct(itemRect, itemText);
744         pLhsButton->SetActionId(IDA_FORGET_AP_POPUP_LHS_BUTTON);
745
746         __pForgetAPPoup->AddControl(*pLhsButton);
747
748         itemRect = Rectangle(X_CONFIRM_POPUP_FORGET_AP_RHS_BUTTON
749                                                 , Y_CONFIRM_POPUP_FORGET_AP_RHS_BUTTON
750                                                 , W_CONFIRM_POPUP_FORGET_AP_RHS_BUTTON
751                                                 , H_CONFIRM_POPUP_FORGET_AP_RHS_BUTTON);
752
753         itemText = ResourceManager::GetString(L"IDS_ST_BODY_CANCEL");
754         
755         pRhsButton = new (std::nothrow) Button();
756         pRhsButton->Construct(itemRect, itemText);
757         pRhsButton->SetActionId(IDA_FORGET_AP_POPUP_RHS_BUTTON);
758
759         __pForgetAPPoup->AddControl(*pRhsButton);
760
761         pLhsButton->AddActionEventListener(*this);
762         pRhsButton->AddActionEventListener(*this);
763
764         return E_SUCCESS;
765 }
766
767 void
768 WifiApDetailForm::ShowForgetApPopup(void)
769 {
770         __pForgetAPPoup->SetShowState(true);
771         __pForgetAPPoup->Show();
772 }
773
774 void
775 WifiApDetailForm::HideForgetApPopup(void)
776 {
777         __pForgetAPPoup->SetShowState(false);
778         Invalidate(true);
779 }
780
781 void
782 WifiApDetailForm::DestroyForgetApPopup(void)
783 {
784         delete __pForgetAPPoup;
785         __pForgetAPPoup = null;
786 }
787
788 Tizen::Graphics::Bitmap*
789 WifiApDetailForm::GetMajorAuthenticationTypeInWifiRssiValueAtBitmapN(int itemIndex)
790 {
791         if (__pWifiPresentationModelInstance == null)
792         {
793                 AppLogDebug("__pWifiPresentationModelInstance is null");
794                 return null;
795         }
796
797         Bitmap* pBitmap = null;
798
799         WifiAuthenticationType majorType = __pWifiPresentationModelInstance->GetAuthenticationtypeInAccessPointListAt(itemIndex);
800
801         if (IsFailed(GetLastResult()))
802         {
803                 AppLogDebug("GetAuthenticationType fail [%s]", GetErrorMessage(GetLastResult()));
804                 return null;
805         }
806
807         long wifiBssInfoRssi = __pWifiPresentationModelInstance->GetRssiInAccessPointListAt(itemIndex);
808         switch (majorType)
809         {
810         case WIFI_AUTHENTICATION_OPEN:
811                 // fall through
812         case WIFI_AUTHENTICATION_SHARED:
813                 {
814                         if (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MAX)
815                         {
816                                 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_UNLOCK_03);
817                         }
818                         else if ((wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MAX)
819                                 && (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MID))
820                         {
821                                 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_UNLOCK_02);
822                         }
823                         else if ((wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MID)
824                                 && (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MIN))
825                         {
826                                 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_UNLOCK_01);
827                         }
828                         else if (wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MIN)
829                         {
830                                 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_UNLOCK_00);
831                         }
832                         else
833                         {
834                                 AppLogDebug("wifiBssInfoRssi is high (%d)", wifiBssInfoRssi);
835                         }
836                 }
837                 break;
838
839         case WIFI_AUTHENTICATION_WPA:
840                 // fall through
841         case WIFI_AUTHENTICATION_WPA_PSK:
842                 // fall through
843         case WIFI_AUTHENTICATION_WPA2:
844                 // fall through
845         case WIFI_AUTHENTICATION_WPA2_PSK:
846                 // fall through
847         case WIFI_AUTHENTICATION_WPA_WPA2_MIXED_PSK:
848                 {
849                         if (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MAX)
850                         {
851                                 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_LOCK_03);
852                         }
853                         else if ((wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MAX)
854                                 && (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MID))
855                         {
856                                 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_LOCK_02);
857                         }
858                         else if ((wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MID)
859                                 && (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MIN))
860                         {
861                                 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_LOCK_01);
862                         }
863                         else if (wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MIN)
864                         {
865                                 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_LOCK_00);
866                         }
867                         else
868                         {
869                                 AppLogDebug("wifiBssInfoRssi is high (%d)", wifiBssInfoRssi);
870                         }
871                 }
872                 break;
873
874         case WIFI_AUTHENTICATION_MAX:
875                 // fall through
876         default:
877                 {
878                         AppLogDebug("majorType is Invalid");
879                 }
880                 break;
881         }
882
883         return pBitmap;
884 }
885
886 int
887 WifiApDetailForm::GetDefaultGroupItemHeight(void)
888 {
889         return H_GROUP_INDEX_NO_TITLE_DEFAULT;
890 }
891
892 int
893 WifiApDetailForm::GetDefaultItemHeight(void)
894 {
895         return H_GROUP_ITEM_DEFAULT;
896 }
897
898 void
899 WifiApDetailForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
900 {
901 }
902
903 void
904 WifiApDetailForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
905 {
906 }
907
908 void
909 WifiApDetailForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
910 {
911 }
912
913 void
914 WifiApDetailForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
915 {
916 }
917
918 void
919 WifiApDetailForm::OnWifiPresentationModelEventCompleted(WifiPresentationModelEvent requestEvent, result r)
920 {
921         switch (requestEvent)
922         {
923         case WIFI_PRESENTATION_MODEL_EVENT_NONE:
924                 {
925                 }
926                 break;
927
928         case WIFI_PRESENTATION_MODEL_EVENT_ACTIVATED:
929                 {
930                 }
931                 break;
932
933         case WIFI_PRESENTATION_MODEL_EVENT_ACTIVATING:
934                 {
935                 }
936                 break;
937
938         case WIFI_PRESENTATION_MODEL_EVENT_DEACTIVATED:
939                 {
940                 }
941                 break;
942
943         case WIFI_PRESENTATION_MODEL_EVENT_DEACTIVATING:
944                 {
945                 }
946                 break;
947
948         case WIFI_PRESENTATION_MODEL_EVENT_CONNECTED:
949                 {
950                 }
951                 break;
952
953         case WIFI_PRESENTATION_MODEL_EVENT_DISCONNECTED:
954                 {
955                 }
956                 break;
957
958         case WIFI_PRESENTATION_MODEL_EVENT_SCAN_COMPLETED_N:
959                 {
960                 }
961                 break;
962
963         case WIFI_PRESENTATION_MODEL_EVENT_SCANNING:
964                 {
965                 }
966                 break;
967
968         case WIFI_PRESENTATION_MODEL_EVENT_MAX:
969                 {
970                 }
971                 break;
972
973         default:
974                 break;
975         }
976 }