2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://floralicense.org/license/
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.
18 * @file StWifiForm.cpp
19 * @brief This is the implementation file for WifiForm class.
23 #include "StResourceManager.h"
24 #include "StSettingScenesList.h"
26 #include "StWifiForm.h"
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Collection;
30 using namespace Tizen::Graphics;
31 using namespace Tizen::Net::Wifi;
32 using namespace Tizen::System;
33 using namespace Tizen::Ui;
34 using namespace Tizen::Ui::Controls;
35 using namespace Tizen::Ui::Scenes;
37 static const int IDA_POPUP_ACTION_ID_BASE = 200;
38 static const int IDA_FOOTER_WIFI_SCAN = IDA_POPUP_ACTION_ID_BASE + 1;
40 static const int W_RESIZE_LABEL_GAP = 170;
41 static const int DIVIDE_BY_TWO = 2;
43 static const int ID_GROUP_STATUS_COUNT_TURN_OFF = 2;
44 static const int ID_GROUP_STATUS_COUNT_TURN_ON = 4;
45 static const int ID_WIFI_STATUS_GROUP_ITEM_ONOFF = 0;
46 static const int WIFI_STATUS_GROUP_ITEM_TOTAL_COUNT = 1;
47 static const int WIFI_NOTIFICATION_GROUP_ITEM_NETOWRK_NOTI = 0;
48 static const int WIFI_NOTIFICATION_GROUP_ITEM_TOTAL_COUNT = 1;
49 static const int WIFI_NETWORK_GROUP_ITEM_BASE = 0;
51 static const int WIFI_DEFAULT_COUNT = 1;
53 static const int WIFI_RSSI_DETAIL_MAX = -70;
54 static const int WIFI_RSSI_DETAIL_MID = -80;
55 static const int WIFI_RSSI_DETAIL_MIN = -90;
56 static const int RELATIVE_LAYOUT_RIGHT_MARGIN_ONOFF_SLIDING = 140;
60 GROUP_INDEX_WIFI_BASE,
61 GROUP_INDEX_0_WIFI_ACTIVATE = GROUP_INDEX_WIFI_BASE,
62 GROUP_INDEX_1_WIFI_NOTIFICATION,
63 GROUP_INDEX_2_WIFI_NETWORK,
64 GROUP_INDEX_3_WIFI_HIDDEN_NETWORK,
68 enum WifiHiddenNetworkGroupItem
70 WIFI_HIDDEN_NETWORK_GROUP_ITEM_BASE,
71 WIFI_HIDDEN_NETWORK_GROUP_ITEM_FIND = WIFI_HIDDEN_NETWORK_GROUP_ITEM_BASE,
72 WIFI_HIDDEN_NETWORK_GROUP_ITEM_TOTAL_COUNT,
73 WIFI_HIDDEN_NETWORK_GROUP_ITEM_MAX
76 WifiForm::WifiForm(void)
77 : __pWifiPresentationModelInstance(null)
78 , __groupTotalCount(ID_GROUP_STATUS_COUNT_TURN_OFF)
79 , __networkGroupItemTotalCount(WIFI_NETWORK_GROUP_ITEM_BASE)
83 WifiForm::~WifiForm(void)
88 WifiForm::CreateFooter(void)
90 Footer* pFooter = GetFooter();
93 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
95 FooterItem footerScan;
96 footerScan.Construct(IDA_FOOTER_WIFI_SCAN);
97 footerScan.SetText(ResourceManager::GetString(L"IDS_ST_BODY_SCAN"));
99 pFooter->AddItem(footerScan);
100 pFooter->SetBackButton();
101 pFooter->AddActionEventListener(*this);
102 pFooter->SetItemEnabled(0, false);
104 SetFormBackEventListener(this);
108 WifiForm::DisableScanFooter(void)
110 Footer* pFooter = GetFooter();
113 pFooter->SetItemEnabled(0, false);
117 WifiForm::EnableScanFooter(void)
119 Footer* pFooter = GetFooter();
122 pFooter->SetItemEnabled(0, true);
126 WifiForm::InitWifiPresentationModelInstance(void)
128 __pWifiPresentationModelInstance = WifiPresentationModel::GetInstance();
129 if (__pWifiPresentationModelInstance == null)
134 __pWifiPresentationModelInstance->SetWifiEventListener(this);
135 if (__pWifiPresentationModelInstance->IsWifiActivated() == true)
143 WifiPresentationModelEvent
144 WifiForm::GetWifiCurrentStatus(void)
146 WifiPresentationModelEvent eStatus = WIFI_PRESENTATION_MODEL_EVENT_DEACTIVATED;
148 if (__pWifiPresentationModelInstance->IsWifiActivated())
150 if (__pWifiPresentationModelInstance->IsWifiConnected())
152 eStatus = WIFI_PRESENTATION_MODEL_EVENT_CONNECTED;
156 eStatus = WIFI_PRESENTATION_MODEL_EVENT_ACTIVATED;
161 eStatus = WIFI_PRESENTATION_MODEL_EVENT_DEACTIVATED;
168 WifiForm::OnInitializing(void)
170 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_WI_FI"));
174 ChangeGroupIndexCount(ID_GROUP_STATUS_COUNT_TURN_OFF, false);
177 if (SystemInfo::GetValue(SYSTEM_INFO_KEY_WIFI, supportedWifi) != E_SUCCESS)
179 AppLogDebug("GetValue Fail.. %d - %s", supportedWifi, GetErrorMessage(GetLastResult()));
183 AppLogDebug("current Value = %d - %s", supportedWifi, GetErrorMessage(GetLastResult()));
191 result r = InitWifiPresentationModelInstance();
195 if (__pWifiPresentationModelInstance->IsWifiActivated())
197 __pWifiPresentationModelInstance->ScanWifi();
198 ChangeGroupIndexCount(ID_GROUP_STATUS_COUNT_TURN_ON, true);
202 ChangeGroupIndexCount(ID_GROUP_STATUS_COUNT_TURN_OFF, true);
209 WifiForm::OnTerminating(void)
211 if (__pWifiPresentationModelInstance != null)
213 __pWifiPresentationModelInstance = null;
217 AppLogDebug("ENTER");
218 SetFormBackEventListener(null);
223 WifiForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
225 if (__pWifiPresentationModelInstance == null)
227 AppLogDebug("__pWifiPresentationModelInstance is null");
231 if (previousSceneId.Equals(IDSCN_WIFI_AP_DETAIL, false))
233 __pWifiPresentationModelInstance->SetWifiEventListener(this);
235 __pWifiPresentationModelInstance->SetWifiActivateScanMode(WIFI_SYSTEM_SCAN_MODE_ACTIVE);
237 __pTableView->UpdateTableView();
241 WifiForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
243 if (__pWifiPresentationModelInstance != null)
245 __pWifiPresentationModelInstance->SetWifiActivateScanMode(WIFI_SYSTEM_SCAN_MODE_PASSIVE);
250 WifiForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
252 SceneManager* pSceneManager = SceneManager::GetInstance();
253 AppAssert(pSceneManager);
255 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
259 WifiForm::GetGroupCount(void)
261 AppLogDebug("GetGroupCount[%d]", __groupTotalCount);
262 return __groupTotalCount;
266 WifiForm::GetItemCount(int groupIndex)
272 case GROUP_INDEX_0_WIFI_ACTIVATE:
274 itemCount = WIFI_STATUS_GROUP_ITEM_TOTAL_COUNT;
278 case GROUP_INDEX_1_WIFI_NOTIFICATION:
280 itemCount = WIFI_NOTIFICATION_GROUP_ITEM_TOTAL_COUNT;
284 case GROUP_INDEX_2_WIFI_NETWORK:
286 itemCount = __networkGroupItemTotalCount;
290 case GROUP_INDEX_3_WIFI_HIDDEN_NETWORK:
292 itemCount = WIFI_HIDDEN_NETWORK_GROUP_ITEM_TOTAL_COUNT;
300 AppLogDebug("GetItemCount %d", itemCount);
305 WifiForm::CreateGroupItem(int groupIndex, int itemWidth)
307 Color itemBGColor = COLOR_BG_GROUP_INDEX_DEFAULT;
308 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
310 int itemLabelTextSize = GetFontSize();
311 Color itemLabelTextColor = COLOR_GROUP_TITLE_TEXT;
312 Rectangle itemRectLabel(X_GROUP_INDEX_DEFAULT_LABEL, Y_GROUP_INDEX_DEFAULT_LABEL, itemWidth, itemHeight);
313 Label* pLabel = null;
314 LabelTextStyle style = LABEL_TEXT_STYLE_BOLD;
316 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
320 case GROUP_INDEX_0_WIFI_ACTIVATE:
323 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
327 case GROUP_INDEX_1_WIFI_NOTIFICATION:
330 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
334 case GROUP_INDEX_3_WIFI_HIDDEN_NETWORK:
336 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
340 case GROUP_INDEX_2_WIFI_NETWORK:
342 groupText = ResourceManager::GetString(L"IDS_ST_BODY_WI_FI_NETWORKS");
343 itemHeight = itemLabelTextSize / DIVIDE_BY_TWO + itemLabelTextSize + H_GROUP_INDEX_TITLE_TEXT_BOTTOM_GAP;
344 itemRectLabel = Rectangle(X_GROUP_INDEX_DEFAULT_LABEL, 0
345 , itemWidth, itemLabelTextSize/DIVIDE_BY_TWO + itemLabelTextSize + H_GROUP_INDEX_TITLE_TEXT_BOTTOM_GAP);
356 RelativeLayout relativeLayout;
357 relativeLayout.Construct();
359 result r = pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
362 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
367 pItem->SetBackgroundColor(itemBGColor);
368 pItem->SetEnabled(false);
370 pLabel = new (std::nothrow) Label();
371 pLabel->Construct(itemRectLabel, groupText);
372 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
373 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
374 pLabel->SetTextConfig(itemLabelTextSize, style);
375 pLabel->SetTextColor(itemLabelTextColor);
377 pItem->AddControl(*pLabel);
378 relativeLayout.SetMargin(*pLabel, itemRectLabel.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
379 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
380 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
386 WifiForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
388 bool isButton = false;
389 bool isCreateIcon = false;
390 bool isConnectState = false;
391 bool isTwoLineItemText = false;
392 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
393 Bitmap* pBitmap = null;
394 int itemHeight = H_GROUP_ITEM_DEFAULT;
395 int fontSize = GetFontSize();
396 Rectangle itemRectangle;
397 Rectangle itemRectSecondLabel;
398 Rectangle itemIconRect;
399 result r = E_FAILURE;
402 String itemTextTwoLine;
404 ItemTypeOneLine(itemRectangle);
406 TableViewItem* pItem = new (std::nothrow) TableViewItem();
410 case GROUP_INDEX_0_WIFI_ACTIVATE:
412 itemText = ResourceManager::GetString(L"IDS_ST_BODY_WI_FI");
413 if (__pWifiPresentationModelInstance != null)
415 if (GetWifiCurrentStatus() != WIFI_PRESENTATION_MODEL_EVENT_DEACTIVATED)
418 __pTableView->SetItemChecked(groupIndex, itemIndex, true);
423 __pTableView->SetItemChecked(groupIndex, itemIndex, false);
426 style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
430 case GROUP_INDEX_1_WIFI_NOTIFICATION:
432 itemText = ResourceManager::GetString(L"IDS_ST_BODY_NETWORK_NOTIFICATION");
434 style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
435 itemRectangle.width -= W_RESIZE_LABEL_GAP;
439 case GROUP_INDEX_2_WIFI_NETWORK:
441 itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_NO_DEVICES_FOUND");
443 int wifiScanBssCount = __pWifiPresentationModelInstance->GetAccessPointCount();
444 if (wifiScanBssCount == 0)
452 isConnectState = __pWifiPresentationModelInstance->IsWifiBssInfoConnect(itemIndex);
454 pBitmap = GetMajorAuthenticationTypeInWifiRssiValueAtBitmapN(itemIndex);
460 itemText = __pWifiPresentationModelInstance->GetSsidInAccessPointListAt(itemIndex);
461 if (IsFailed(GetLastResult()))
467 if (isConnectState == true)
469 itemTextTwoLine = ResourceManager::GetString(L"IDS_WIFI_BODY_CONNECTED");
473 WifiAuthenticationType majorType = __pWifiPresentationModelInstance->GetAuthenticationtypeInAccessPointListAt(itemIndex);
476 case WIFI_AUTHENTICATION_OPEN:
478 itemTextTwoLine = ResourceManager::GetString(L"IDS_ST_BUTTON_OPEN");
482 case WIFI_AUTHENTICATION_SHARED:
484 itemTextTwoLine = ResourceManager::GetString(L"IDS_ST_BODY_SECURED_ABB_M_WIFI_AP_SUMMARY");
485 itemTextTwoLine.Append(L" (");
486 itemTextTwoLine.Append(ResourceManager::GetString(L"IDS_WIFI_BODY_EAP"));
487 itemTextTwoLine.Append(L")");
491 case WIFI_AUTHENTICATION_WPA:
493 case WIFI_AUTHENTICATION_WPA_PSK:
495 case WIFI_AUTHENTICATION_WPA2:
497 case WIFI_AUTHENTICATION_WPA2_PSK:
499 case WIFI_AUTHENTICATION_WPA_WPA2_MIXED_PSK:
501 itemTextTwoLine = ResourceManager::GetString(L"IDS_ST_BODY_SECURED_ABB_M_WIFI_AP_SUMMARY");
502 itemTextTwoLine.Append(L" ");
503 itemTextTwoLine.Append(ResourceManager::GetString(L"IDS_WIFI_BODY_HWPS_AVAILABLE"));
507 case WIFI_AUTHENTICATION_MAX:
511 AppLogDebug("majorType is Invalid");
516 isTwoLineItemText = true;
517 style = TABLE_VIEW_ANNEX_STYLE_DETAILED;
519 ItemTypeIconAndTwoLine(itemIconRect, itemRectangle, itemRectSecondLabel, fontSize);
520 itemHeight = (itemRectangle.height + itemRectSecondLabel.height);
524 case GROUP_INDEX_3_WIFI_HIDDEN_NETWORK:
528 case WIFI_HIDDEN_NETWORK_GROUP_ITEM_FIND:
530 itemText = ResourceManager::GetString(L"IDS_WIFI_OPT_FIND_HIDDEN_NETWORK");
532 style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
546 RelativeLayout relativeLayout;
547 relativeLayout.Construct();
549 r = pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
552 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
557 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
561 Label* pLabel = new (std::nothrow) Label();
564 AppLogDebug("pLabel is null");
568 r = pLabel->Construct(itemIconRect, L"");
571 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
576 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
577 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
578 pLabel->SetBackgroundBitmap(*pBitmap);
580 pItem->AddControl(*pLabel);
585 if (isButton == false)
587 Label* pLabel = new (std::nothrow) Label();
590 AppLogDebug("pLabel is null");
594 r = pLabel->Construct(itemRectangle, itemText);
597 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
602 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
603 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
604 pLabel->SetTextColor(COLOR_MAIN_TEXT);
606 pItem->AddControl(*pLabel);
607 if (style == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING)
609 relativeLayout.SetMargin(*pLabel, itemRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN_ONOFF_SLIDING, 0, 0);
613 relativeLayout.SetMargin(*pLabel, itemRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
615 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
616 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
619 if (isTwoLineItemText == true)
621 Label* pSecondLabel = new (std::nothrow) Label();
622 if (pSecondLabel == null)
624 AppLogDebug("pLabel is null");
628 r = pSecondLabel->Construct(itemRectSecondLabel, itemTextTwoLine);
631 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
636 pSecondLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
637 pSecondLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
638 pSecondLabel->SetTextColor(COLOR_SUB_TEXT);
640 pItem->AddControl(*pSecondLabel);
641 relativeLayout.SetMargin(*pSecondLabel, itemRectSecondLabel.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
642 relativeLayout.SetRelation(*pSecondLabel, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
643 relativeLayout.SetRelation(*pSecondLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
646 if (isButton == true)
648 Button* pButton = new (std::nothrow) Button();
649 r = pButton->Construct(itemRectangle, itemText);
653 AppLogDebug("pButton construct error");
658 pItem->AddControl(*pButton);
659 relativeLayout.SetMargin(*pButton, itemRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
660 relativeLayout.SetRelation(*pButton, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
661 relativeLayout.SetRelation(*pButton, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
668 WifiForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
670 AppLogDebug("ENTER");
679 WifiForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
681 AppLogDebug("[itemTag.groupIndex=%d][itemTag.itemIndex=%d]", groupIndex, itemIndex);
690 WifiForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
692 result r = E_FAILURE;
693 SceneManager* pSceneManager = SceneManager::GetInstance();
694 AppAssert(pSceneManager);
698 case GROUP_INDEX_0_WIFI_ACTIVATE:
700 if (__pWifiPresentationModelInstance != null)
702 r = ToggleWifiActivateStatus(status);
705 AppLogDebug("ToggleWifiActivateStatus is Fail");
710 __pTableView->SetItemChecked(groupIndex, itemIndex, false);
711 // Not supported in the Emulator
712 ShowMessageBox(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_ST_POP_NOT_SUPPORTED"));
718 case GROUP_INDEX_1_WIFI_NOTIFICATION:
720 if (__pWifiPresentationModelInstance != null)
722 if (itemIndex == WIFI_NOTIFICATION_GROUP_ITEM_NETOWRK_NOTI)
724 TogleWifiNotificationStatus(status);
729 __pTableView->SetItemChecked(groupIndex, itemIndex, false);
730 // Not supported in the Emulator
731 ShowMessageBox(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_ST_POP_NOT_SUPPORTED"));
737 case GROUP_INDEX_2_WIFI_NETWORK:
739 if (status == TABLE_VIEW_ITEM_STATUS_MORE) // more
741 ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
744 AppLogDebug("pArgs is null");
748 r = pArgs->Construct();
753 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
757 pArgs->Add(*(new (std::nothrow) String(Integer::ToString(itemIndex))));
758 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_WIFI_AP_DETAIL, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
760 else if (status == TABLE_VIEW_ITEM_STATUS_SELECTED) // select
766 AppLogDebug("Error status (%d)",status);
771 case GROUP_INDEX_3_WIFI_HIDDEN_NETWORK:
781 AppLogDebug("OnTableViewItemStateChanged group[%d] index[%d], status[%d]", groupIndex, itemIndex, status);
785 WifiForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
787 AppLogDebug("ENTER");
788 result r = E_FAILURE;
790 if (actionId == IDA_FOOTER_WIFI_SCAN)
792 r = __pWifiPresentationModelInstance->ScanWifi();
796 AppLogDebug("Scan Failed");
802 Tizen::Graphics::Bitmap*
803 WifiForm::GetMajorAuthenticationTypeInWifiRssiValueAtBitmapN(int itemIndex)
805 if (__pWifiPresentationModelInstance == null)
807 AppLogDebug("__pWifiPresentationModelInstance is null");
811 Bitmap* pBitmap = null;
813 WifiAuthenticationType majorType = __pWifiPresentationModelInstance->GetAuthenticationtypeInAccessPointListAt(itemIndex);
815 if (IsFailed(GetLastResult()))
817 AppLogDebug("GetAuthenticationType fail [%s]", GetErrorMessage(GetLastResult()));
821 long wifiBssInfoRssi = __pWifiPresentationModelInstance->GetRssiInAccessPointListAt(itemIndex);
824 case WIFI_AUTHENTICATION_OPEN:
826 if (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MAX)
828 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_UNLOCK_03);
830 else if ((wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MAX)
831 && (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MID))
833 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_UNLOCK_02);
835 else if ((wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MID)
836 && (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MIN))
838 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_UNLOCK_01);
840 else if (wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MIN)
842 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_UNLOCK_00);
846 AppLogDebug("wifiBssInfoRssi is high (%d)", wifiBssInfoRssi);
851 case WIFI_AUTHENTICATION_SHARED:
853 case WIFI_AUTHENTICATION_WPA:
855 case WIFI_AUTHENTICATION_WPA_PSK:
857 case WIFI_AUTHENTICATION_WPA2:
859 case WIFI_AUTHENTICATION_WPA2_PSK:
861 case WIFI_AUTHENTICATION_WPA_WPA2_MIXED_PSK:
863 if (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MAX)
865 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_LOCK_03);
867 else if ((wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MAX)
868 && (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MID))
870 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_LOCK_02);
872 else if ((wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MID)
873 && (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MIN))
875 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_LOCK_01);
877 else if (wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MIN)
879 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_LOCK_00);
883 AppLogDebug("wifiBssInfoRssi is high (%d)", wifiBssInfoRssi);
888 case WIFI_AUTHENTICATION_MAX:
892 AppLogDebug("majorType is Invalid");
901 WifiForm::ConnectAp(int itemIndex)
903 if (__pWifiPresentationModelInstance == null)
905 AppLogDebug("__pWifiPresentationModelInstance is null");
909 __pWifiPresentationModelInstance->ConnectToAccessPointListAt(itemIndex);
915 WifiForm::ToggleWifiActivateStatus(Tizen::Ui::Controls::TableViewItemStatus itemStatus)
917 if (__pWifiPresentationModelInstance == null)
919 AppLogDebug("__pWifiPresentationModelInstance is null");
925 case TABLE_VIEW_ITEM_STATUS_CHECKED:
927 if (!__pWifiPresentationModelInstance->IsWifiActivated())
929 __pWifiPresentationModelInstance->ActivateWifi();
934 case TABLE_VIEW_ITEM_STATUS_UNCHECKED:
936 if (__pWifiPresentationModelInstance->IsWifiActivated())
938 __pWifiPresentationModelInstance->DeactivateWifi();
951 WifiForm::TogleWifiNotificationStatus(Tizen::Ui::Controls::TableViewItemStatus itemStatus)
953 if (__pWifiPresentationModelInstance == null)
955 AppLogDebug("__pWifiPresentationModelInstance is null");
962 case TABLE_VIEW_ITEM_STATUS_CHECKED:
964 if (!__pWifiPresentationModelInstance->IsActivated())
966 __pWifiPresentationModelInstance->Activate();
971 case TABLE_VIEW_ITEM_STATUS_UNCHECKED:
973 if (__pWifiPresentationModelInstance->IsActivated())
975 __pWifiPresentationModelInstance->Deactivate();
989 WifiForm::ChangeGroupIndexCount(unsigned int grpIndexStatus, bool update)
991 if ((grpIndexStatus + WIFI_DEFAULT_COUNT) > ID_GROUP_STATUS_COUNT_TURN_ON)
993 __groupTotalCount = ID_GROUP_STATUS_COUNT_TURN_ON;
997 __groupTotalCount = grpIndexStatus;
1002 __pTableView->UpdateTableView();
1009 WifiForm::ChangeNetworkGroupItemCount(unsigned int itemCount, bool isAdd)
1013 __networkGroupItemTotalCount = itemCount;
1017 __networkGroupItemTotalCount = GetGroupItemTotalCount(GROUP_INDEX_2_WIFI_NETWORK) - itemCount;
1018 if ( __networkGroupItemTotalCount <= 0)
1020 __networkGroupItemTotalCount = WIFI_NETWORK_GROUP_ITEM_BASE;
1024 return __networkGroupItemTotalCount;
1028 WifiForm::GetGroupItemTotalCount(int groupIndex)
1030 int retItemCount = 0;
1034 retItemCount = __pTableView->GetItemCountAt(groupIndex);
1037 return retItemCount;
1041 WifiForm::GetDefaultGroupItemHeight(void)
1043 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
1047 WifiForm::GetDefaultItemHeight(void)
1049 return H_GROUP_ITEM_DEFAULT;
1053 WifiForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
1058 WifiForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1063 WifiForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1068 WifiForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1072 case GROUP_INDEX_0_WIFI_ACTIVATE:
1077 case GROUP_INDEX_1_WIFI_NOTIFICATION:
1082 case GROUP_INDEX_2_WIFI_NETWORK:
1087 case GROUP_INDEX_3_WIFI_HIDDEN_NETWORK:
1098 WifiForm::OnWifiPresentationModelEventCompleted(WifiPresentationModelEvent requestEvent, result r)
1100 int wifiScanBssCount = 0;
1101 if (__pWifiPresentationModelInstance == null)
1103 AppLogDebug("__pWifiPresentationModelInstance is null");
1106 if (__pTableView == null)
1108 AppLogDebug("__tableView is null");
1111 switch (requestEvent)
1113 case WIFI_PRESENTATION_MODEL_EVENT_NONE:
1118 case WIFI_PRESENTATION_MODEL_EVENT_ACTIVATED:
1123 localGroup = GROUP_INDEX_0_WIFI_ACTIVATE;
1124 localItem = ID_WIFI_STATUS_GROUP_ITEM_ONOFF;
1126 if (!__pTableView->IsItemChecked(localGroup, localItem))
1128 __pTableView->SetItemChecked(localGroup, localItem, true);
1129 __pTableView->RefreshItem(localGroup, localItem, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1131 ChangeGroupIndexCount(ID_GROUP_STATUS_COUNT_TURN_ON, true);
1135 case WIFI_PRESENTATION_MODEL_EVENT_ACTIVATING:
1140 case WIFI_PRESENTATION_MODEL_EVENT_DEACTIVATED:
1142 DisableScanFooter();
1145 localGroup = GROUP_INDEX_0_WIFI_ACTIVATE;
1146 localItem = ID_WIFI_STATUS_GROUP_ITEM_ONOFF;
1147 __pTableView->SetItemChecked(localGroup, localItem, false);
1148 __pTableView->RefreshItem(localGroup, localItem, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1149 ChangeGroupIndexCount(ID_GROUP_STATUS_COUNT_TURN_OFF, true);
1153 case WIFI_PRESENTATION_MODEL_EVENT_DEACTIVATING:
1158 case WIFI_PRESENTATION_MODEL_EVENT_CONNECTED:
1163 case WIFI_PRESENTATION_MODEL_EVENT_SCAN_COMPLETED_N:
1167 localGroup = GROUP_INDEX_0_WIFI_ACTIVATE;
1168 localItem = ID_WIFI_STATUS_GROUP_ITEM_ONOFF;
1170 if (!__pTableView->IsItemChecked(localGroup, localItem))
1172 __pTableView->SetItemChecked(localGroup, localItem, true);
1173 __pTableView->RefreshItem(localGroup, localItem, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1175 wifiScanBssCount = __pWifiPresentationModelInstance->GetAccessPointCount();
1176 if (wifiScanBssCount == 0)
1178 AppLogDebug("Scan Error");
1179 ChangeNetworkGroupItemCount(0, true);
1183 ChangeNetworkGroupItemCount(wifiScanBssCount + WIFI_DEFAULT_COUNT, true);
1185 ChangeGroupIndexCount(ID_GROUP_STATUS_COUNT_TURN_ON, true);
1189 case WIFI_PRESENTATION_MODEL_EVENT_SCANNING:
1194 case WIFI_PRESENTATION_MODEL_EVENT_RSSI_CHANGED:
1196 if (__pWifiPresentationModelInstance->IsWifiActivated())
1198 __pWifiPresentationModelInstance->ScanWifi();
1203 case WIFI_PRESENTATION_MODEL_EVENT_MAX: