2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
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;
42 static const int ID_GROUP_STATUS_COUNT_TURN_OFF = 2;
43 static const int ID_GROUP_STATUS_COUNT_TURN_ON = 4;
44 static const int ID_WIFI_STATUS_GROUP_ITEM_ONOFF = 0;
45 static const int WIFI_STATUS_GROUP_ITEM_TOTAL_COUNT = 1;
46 static const int WIFI_NOTIFICATION_GROUP_ITEM_NETOWRK_NOTI = 0;
47 static const int WIFI_NOTIFICATION_GROUP_ITEM_TOTAL_COUNT = 1;
48 static const int WIFI_NETWORK_GROUP_ITEM_BASE = 0;
50 static const int WIFI_DEFAULT_COUNT = 1;
52 static const int WIFI_RSSI_DETAIL_MAX = -70;
53 static const int WIFI_RSSI_DETAIL_MID = -80;
54 static const int WIFI_RSSI_DETAIL_MIN = -90;
58 GROUP_INDEX_WIFI_BASE,
59 GROUP_INDEX_0_WIFI_ACTIVATE = GROUP_INDEX_WIFI_BASE,
60 GROUP_INDEX_1_WIFI_NOTIFICATION,
61 GROUP_INDEX_2_WIFI_NETWORK,
62 GROUP_INDEX_3_WIFI_HIDDEN_NETWORK,
66 enum WifiHiddenNetworkGroupItem
68 WIFI_HIDDEN_NETWORK_GROUP_ITEM_BASE,
69 WIFI_HIDDEN_NETWORK_GROUP_ITEM_FIND = WIFI_HIDDEN_NETWORK_GROUP_ITEM_BASE,
70 WIFI_HIDDEN_NETWORK_GROUP_ITEM_TOTAL_COUNT,
71 WIFI_HIDDEN_NETWORK_GROUP_ITEM_MAX
74 WifiForm::WifiForm(void)
75 : __pWifiPresentationModelInstance(null)
76 , __groupTotalCount(ID_GROUP_STATUS_COUNT_TURN_OFF)
77 , __networkGroupItemTotalCount(WIFI_NETWORK_GROUP_ITEM_BASE)
81 WifiForm::~WifiForm(void)
86 WifiForm::CreateFooter(void)
88 Footer* pFooter = GetFooter();
91 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
93 FooterItem footerScan;
94 footerScan.Construct(IDA_FOOTER_WIFI_SCAN);
95 footerScan.SetText(ResourceManager::GetString(L"IDS_ST_BODY_SCAN"));
97 pFooter->AddItem(footerScan);
98 pFooter->AddActionEventListener(*this);
99 pFooter->SetItemEnabled(0, false);
101 SetFormBackEventListener(this);
105 WifiForm::DisableScanFooter(void)
107 Footer* pFooter = GetFooter();
110 pFooter->SetItemEnabled(0, false);
114 WifiForm::EnableScanFooter(void)
116 Footer* pFooter = GetFooter();
119 pFooter->SetItemEnabled(0, true);
123 WifiForm::InitWifiPresentationModelInstance(void)
125 __pWifiPresentationModelInstance = WifiPresentationModel::GetInstance();
126 if (__pWifiPresentationModelInstance == null)
131 __pWifiPresentationModelInstance->SetWifiEventListener(this);
132 if (__pWifiPresentationModelInstance->IsWifiActivated() == true)
140 WifiPresentationModelEvent
141 WifiForm::GetWifiCurrentStatus(void)
143 WifiPresentationModelEvent eStatus = WIFI_PRESENTATION_MODEL_EVENT_DEACTIVATED;
145 if (__pWifiPresentationModelInstance->IsWifiActivated())
147 if (__pWifiPresentationModelInstance->IsWifiConnected())
149 eStatus = WIFI_PRESENTATION_MODEL_EVENT_CONNECTED;
153 eStatus = WIFI_PRESENTATION_MODEL_EVENT_ACTIVATED;
158 eStatus = WIFI_PRESENTATION_MODEL_EVENT_DEACTIVATED;
165 WifiForm::OnInitializing(void)
167 SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER | FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE);
168 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_WI_FI"));
172 ChangeGroupIndexCount(ID_GROUP_STATUS_COUNT_TURN_OFF, false);
175 if (SystemInfo::GetValue(SYSTEM_INFO_KEY_WIFI, supportedWifi) != E_SUCCESS)
177 AppLogDebug("GetValue Fail.. %d - %s", supportedWifi, GetErrorMessage(GetLastResult()));
181 AppLogDebug("current Value = %d - %s", supportedWifi, GetErrorMessage(GetLastResult()));
189 result r = InitWifiPresentationModelInstance();
193 if (__pWifiPresentationModelInstance->IsWifiActivated())
195 __pWifiPresentationModelInstance->ScanWifi();
196 ChangeGroupIndexCount(ID_GROUP_STATUS_COUNT_TURN_ON, true);
200 ChangeGroupIndexCount(ID_GROUP_STATUS_COUNT_TURN_OFF, true);
207 WifiForm::OnTerminating(void)
209 if (__pWifiPresentationModelInstance != null)
211 __pWifiPresentationModelInstance = null;
215 AppLogDebug("ENTER");
216 SetFormBackEventListener(null);
221 WifiForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
223 if (__pWifiPresentationModelInstance == null)
225 AppLogDebug("__pWifiPresentationModelInstance is null");
229 if (previousSceneId.Equals(IDSCN_WIFI_AP_DETAIL, false))
231 __pWifiPresentationModelInstance->SetWifiEventListener(this);
233 __pWifiPresentationModelInstance->SetWifiActivateScanMode(WIFI_SYSTEM_SCAN_MODE_ACTIVE);
235 __pTableView->UpdateTableView();
239 WifiForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
241 if (__pWifiPresentationModelInstance != null)
243 __pWifiPresentationModelInstance->SetWifiActivateScanMode(WIFI_SYSTEM_SCAN_MODE_PASSIVE);
248 WifiForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
250 SceneManager* pSceneManager = SceneManager::GetInstance();
251 AppAssert(pSceneManager);
253 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
257 WifiForm::GetGroupCount(void)
259 AppLogDebug("GetGroupCount[%d]", __groupTotalCount);
260 return __groupTotalCount;
264 WifiForm::GetItemCount(int groupIndex)
270 case GROUP_INDEX_0_WIFI_ACTIVATE:
272 itemCount = WIFI_STATUS_GROUP_ITEM_TOTAL_COUNT;
276 case GROUP_INDEX_1_WIFI_NOTIFICATION:
278 itemCount = WIFI_NOTIFICATION_GROUP_ITEM_TOTAL_COUNT;
282 case GROUP_INDEX_2_WIFI_NETWORK:
284 itemCount = __networkGroupItemTotalCount;
288 case GROUP_INDEX_3_WIFI_HIDDEN_NETWORK:
290 itemCount = WIFI_HIDDEN_NETWORK_GROUP_ITEM_TOTAL_COUNT;
298 AppLogDebug("GetItemCount %d", itemCount);
303 WifiForm::CreateGroupItem(int groupIndex, int itemWidth)
305 Color itemBGColor = COLOR_BG_GROUP_INDEX_DEFAULT;
306 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
308 int itemLabelTextSize = GetFontSize();
309 Color itemLabelTextColor = COLOR_GROUP_TITLE_TEXT;
310 Rectangle itemRectLabel(X_GROUP_INDEX_DEFAULT_LABEL, Y_GROUP_INDEX_DEFAULT_LABEL, itemWidth, itemHeight);
311 Label* pLabel = null;
312 LabelTextStyle style = LABEL_TEXT_STYLE_BOLD;
314 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
318 case GROUP_INDEX_0_WIFI_ACTIVATE:
321 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
325 case GROUP_INDEX_1_WIFI_NOTIFICATION:
328 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
332 case GROUP_INDEX_3_WIFI_HIDDEN_NETWORK:
334 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
338 case GROUP_INDEX_2_WIFI_NETWORK:
340 groupText = ResourceManager::GetString(L"IDS_ST_BODY_WI_FI_NETWORKS");
341 itemHeight = itemLabelTextSize / DIVIDE_BY_TWO + itemLabelTextSize + H_GROUP_INDEX_TITLE_TEXT_BOTTOM_GAP;
342 itemRectLabel = Rectangle(X_GROUP_INDEX_DEFAULT_LABEL, 0
343 , itemWidth, itemLabelTextSize/DIVIDE_BY_TWO + itemLabelTextSize + H_GROUP_INDEX_TITLE_TEXT_BOTTOM_GAP);
354 RelativeLayout relativeLayout;
355 relativeLayout.Construct();
357 result r = pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
360 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
365 pItem->SetBackgroundColor(itemBGColor);
366 pItem->SetEnabled(false);
368 pLabel = new (std::nothrow) Label();
369 pLabel->Construct(itemRectLabel, groupText);
370 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
371 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
372 pLabel->SetTextConfig(itemLabelTextSize, style);
373 pLabel->SetTextColor(itemLabelTextColor);
375 pItem->AddControl(pLabel);
376 relativeLayout.SetMargin(*pLabel, itemRectLabel.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
377 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
378 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
384 WifiForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
386 bool isButton = false;
387 bool isCreateIcon = false;
388 bool isConnectState = false;
389 bool isTwoLineItemText = false;
390 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
391 Bitmap* pBitmap = null;
392 int itemHeight = H_GROUP_ITEM_DEFAULT;
393 int fontSize = GetFontSize();
394 Rectangle itemRectangle;
395 Rectangle itemRectSecondLabel;
396 Rectangle itemIconRect;
397 result r = E_FAILURE;
400 String itemTextTwoLine;
402 ItemTypeOneLine(itemRectangle);
404 TableViewItem* pItem = new (std::nothrow) TableViewItem();
408 case GROUP_INDEX_0_WIFI_ACTIVATE:
410 itemText = ResourceManager::GetString(L"IDS_ST_BODY_WI_FI");
411 if (__pWifiPresentationModelInstance != null)
413 if (GetWifiCurrentStatus() != WIFI_PRESENTATION_MODEL_EVENT_DEACTIVATED)
416 __pTableView->SetItemChecked(groupIndex, itemIndex, true);
421 __pTableView->SetItemChecked(groupIndex, itemIndex, false);
424 style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
428 case GROUP_INDEX_1_WIFI_NOTIFICATION:
430 itemText = ResourceManager::GetString(L"IDS_ST_BODY_NETWORK_NOTIFICATION");
432 style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
433 itemRectangle.width -= W_RESIZE_LABEL_GAP;
437 case GROUP_INDEX_2_WIFI_NETWORK:
439 itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_NO_DEVICES_FOUND");
441 int wifiScanBssCount = __pWifiPresentationModelInstance->GetAccessPointCount();
442 if (wifiScanBssCount == 0)
450 isConnectState = __pWifiPresentationModelInstance->IsWifiBssInfoConnect(itemIndex);
452 pBitmap = GetMajorAuthenticationTypeInWifiRssiValueAtBitmapN(itemIndex);
458 itemText = __pWifiPresentationModelInstance->GetSsidInAccessPointListAt(itemIndex);
459 if (IsFailed(GetLastResult()))
465 if (isConnectState == true)
467 itemTextTwoLine = ResourceManager::GetString(L"IDS_WIFI_BODY_CONNECTED");
471 WifiAuthenticationType majorType = __pWifiPresentationModelInstance->GetAuthenticationtypeInAccessPointListAt(itemIndex);
474 case WIFI_AUTHENTICATION_OPEN:
476 itemTextTwoLine = ResourceManager::GetString(L"IDS_ST_BUTTON_OPEN");
480 case WIFI_AUTHENTICATION_SHARED:
482 itemTextTwoLine = ResourceManager::GetString(L"IDS_ST_BODY_SECURED_ABB_M_WIFI_AP_SUMMARY");
483 itemTextTwoLine.Append(L" (");
484 itemTextTwoLine.Append(ResourceManager::GetString(L"IDS_WIFI_BODY_EAP"));
485 itemTextTwoLine.Append(L")");
489 case WIFI_AUTHENTICATION_WPA:
491 case WIFI_AUTHENTICATION_WPA_PSK:
493 case WIFI_AUTHENTICATION_WPA2:
495 case WIFI_AUTHENTICATION_WPA2_PSK:
497 case WIFI_AUTHENTICATION_WPA_WPA2_MIXED_PSK:
499 itemTextTwoLine = ResourceManager::GetString(L"IDS_ST_BODY_SECURED_ABB_M_WIFI_AP_SUMMARY");
500 itemTextTwoLine.Append(L" ");
501 itemTextTwoLine.Append(ResourceManager::GetString(L"IDS_WIFI_BODY_HWPS_AVAILABLE"));
505 case WIFI_AUTHENTICATION_MAX:
509 AppLogDebug("majorType is Invalid");
514 isTwoLineItemText = true;
515 style = TABLE_VIEW_ANNEX_STYLE_DETAILED;
517 ItemTypeIconAndTwoLine(itemIconRect, itemRectangle, itemRectSecondLabel, fontSize);
518 itemHeight = (itemRectangle.height + itemRectSecondLabel.height);
522 case GROUP_INDEX_3_WIFI_HIDDEN_NETWORK:
526 case WIFI_HIDDEN_NETWORK_GROUP_ITEM_FIND:
528 itemText = ResourceManager::GetString(L"IDS_WIFI_OPT_FIND_HIDDEN_NETWORK");
530 style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
544 RelativeLayout relativeLayout;
545 relativeLayout.Construct();
547 r = pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
550 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
555 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
559 Label* pLabel = new (std::nothrow) Label();
562 AppLogDebug("pLabel is null");
566 r = pLabel->Construct(itemIconRect, L"");
569 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
574 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
575 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
576 pLabel->SetBackgroundBitmap(*pBitmap);
578 pItem->AddControl(pLabel);
583 if (isButton == false)
585 Label* pLabel = new (std::nothrow) Label();
588 AppLogDebug("pLabel is null");
592 r = pLabel->Construct(itemRectangle, itemText);
595 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
600 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
601 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
602 pLabel->SetTextColor(COLOR_MAIN_TEXT);
604 pItem->AddControl(pLabel);
605 if (style == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING)
607 relativeLayout.SetMargin(*pLabel, itemRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN_ONOFF_SLIDING, 0, 0);
611 relativeLayout.SetMargin(*pLabel, itemRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN_DETAIL_BUTTON, 0, 0);
613 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
614 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
617 if (isTwoLineItemText == true)
619 Label* pSecondLabel = new (std::nothrow) Label();
620 if (pSecondLabel == null)
622 AppLogDebug("pLabel is null");
626 r = pSecondLabel->Construct(itemRectSecondLabel, itemTextTwoLine);
629 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
634 pSecondLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
635 pSecondLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
636 pSecondLabel->SetTextColor(COLOR_SUB_TEXT);
638 pItem->AddControl(pSecondLabel);
639 relativeLayout.SetMargin(*pSecondLabel, itemRectSecondLabel.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
640 relativeLayout.SetRelation(*pSecondLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
641 relativeLayout.SetRelation(*pSecondLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
644 if (isButton == true)
646 Button* pButton = new (std::nothrow) Button();
647 r = pButton->Construct(itemRectangle, itemText);
651 AppLogDebug("pButton construct error");
656 pItem->AddControl(pButton);
657 relativeLayout.SetMargin(*pButton, itemRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
658 relativeLayout.SetRelation(*pButton, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
659 relativeLayout.SetRelation(*pButton, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
666 WifiForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
668 AppLogDebug("ENTER");
677 WifiForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
679 AppLogDebug("[itemTag.groupIndex=%d][itemTag.itemIndex=%d]", groupIndex, itemIndex);
688 WifiForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
690 result r = E_FAILURE;
691 SceneManager* pSceneManager = SceneManager::GetInstance();
692 AppAssert(pSceneManager);
696 case GROUP_INDEX_0_WIFI_ACTIVATE:
698 if (__pWifiPresentationModelInstance != null)
700 r = ToggleWifiActivateStatus(status);
703 AppLogDebug("ToggleWifiActivateStatus is Fail");
708 __pTableView->SetItemChecked(groupIndex, itemIndex, false);
709 // Not supported in the Emulator
710 ShowMessageBox(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_ST_POP_NOT_SUPPORTED"));
716 case GROUP_INDEX_1_WIFI_NOTIFICATION:
718 if (__pWifiPresentationModelInstance != null)
720 if (itemIndex == WIFI_NOTIFICATION_GROUP_ITEM_NETOWRK_NOTI)
722 TogleWifiNotificationStatus(status);
727 __pTableView->SetItemChecked(groupIndex, itemIndex, false);
728 // Not supported in the Emulator
729 ShowMessageBox(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_ST_POP_NOT_SUPPORTED"));
735 case GROUP_INDEX_2_WIFI_NETWORK:
737 if (status == TABLE_VIEW_ITEM_STATUS_MORE) // more
739 ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
742 AppLogDebug("pArgs is null");
746 r = pArgs->Construct();
751 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
755 pArgs->Add(*(new (std::nothrow) String(Integer::ToString(itemIndex))));
756 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_WIFI_AP_DETAIL, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
758 else if (status == TABLE_VIEW_ITEM_STATUS_SELECTED) // select
764 AppLogDebug("Error status (%d)",status);
769 case GROUP_INDEX_3_WIFI_HIDDEN_NETWORK:
779 AppLogDebug("OnTableViewItemStateChanged group[%d] index[%d], status[%d]", groupIndex, itemIndex, status);
783 WifiForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
785 AppLogDebug("ENTER");
786 result r = E_FAILURE;
788 if (actionId == IDA_FOOTER_WIFI_SCAN)
790 r = __pWifiPresentationModelInstance->ScanWifi();
794 AppLogDebug("Scan Failed");
800 Tizen::Graphics::Bitmap*
801 WifiForm::GetMajorAuthenticationTypeInWifiRssiValueAtBitmapN(int itemIndex)
803 if (__pWifiPresentationModelInstance == null)
805 AppLogDebug("__pWifiPresentationModelInstance is null");
809 Bitmap* pBitmap = null;
811 WifiAuthenticationType majorType = __pWifiPresentationModelInstance->GetAuthenticationtypeInAccessPointListAt(itemIndex);
813 if (IsFailed(GetLastResult()))
815 AppLogDebug("GetAuthenticationType fail [%s]", GetErrorMessage(GetLastResult()));
819 long wifiBssInfoRssi = __pWifiPresentationModelInstance->GetRssiInAccessPointListAt(itemIndex);
822 case WIFI_AUTHENTICATION_OPEN:
824 if (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MAX)
826 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_UNLOCK_03);
828 else if ((wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MAX)
829 && (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MID))
831 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_UNLOCK_02);
833 else if ((wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MID)
834 && (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MIN))
836 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_UNLOCK_01);
838 else if (wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MIN)
840 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_UNLOCK_00);
844 AppLogDebug("wifiBssInfoRssi is high (%d)", wifiBssInfoRssi);
849 case WIFI_AUTHENTICATION_SHARED:
851 case WIFI_AUTHENTICATION_WPA:
853 case WIFI_AUTHENTICATION_WPA_PSK:
855 case WIFI_AUTHENTICATION_WPA2:
857 case WIFI_AUTHENTICATION_WPA2_PSK:
859 case WIFI_AUTHENTICATION_WPA_WPA2_MIXED_PSK:
861 if (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MAX)
863 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_LOCK_03);
865 else if ((wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MAX)
866 && (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MID))
868 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_LOCK_02);
870 else if ((wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MID)
871 && (wifiBssInfoRssi > WIFI_RSSI_DETAIL_MIN))
873 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_LOCK_01);
875 else if (wifiBssInfoRssi <= WIFI_RSSI_DETAIL_MIN)
877 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI_RSSI_LOCK_00);
881 AppLogDebug("wifiBssInfoRssi is high (%d)", wifiBssInfoRssi);
886 case WIFI_AUTHENTICATION_MAX:
890 AppLogDebug("majorType is Invalid");
899 WifiForm::ConnectAp(int itemIndex)
901 if (__pWifiPresentationModelInstance == null)
903 AppLogDebug("__pWifiPresentationModelInstance is null");
907 __pWifiPresentationModelInstance->ConnectToAccessPointListAt(itemIndex);
913 WifiForm::ToggleWifiActivateStatus(Tizen::Ui::Controls::TableViewItemStatus itemStatus)
915 if (__pWifiPresentationModelInstance == null)
917 AppLogDebug("__pWifiPresentationModelInstance is null");
923 case TABLE_VIEW_ITEM_STATUS_CHECKED:
925 if (!__pWifiPresentationModelInstance->IsWifiActivated())
927 __pWifiPresentationModelInstance->ActivateWifi();
932 case TABLE_VIEW_ITEM_STATUS_UNCHECKED:
934 if (__pWifiPresentationModelInstance->IsWifiActivated())
936 __pWifiPresentationModelInstance->DeactivateWifi();
949 WifiForm::TogleWifiNotificationStatus(Tizen::Ui::Controls::TableViewItemStatus itemStatus)
951 if (__pWifiPresentationModelInstance == null)
953 AppLogDebug("__pWifiPresentationModelInstance is null");
960 case TABLE_VIEW_ITEM_STATUS_CHECKED:
962 if (!__pWifiPresentationModelInstance->IsActivated())
964 __pWifiPresentationModelInstance->Activate();
969 case TABLE_VIEW_ITEM_STATUS_UNCHECKED:
971 if (__pWifiPresentationModelInstance->IsActivated())
973 __pWifiPresentationModelInstance->Deactivate();
987 WifiForm::ChangeGroupIndexCount(unsigned int grpIndexStatus, bool update)
989 if ((grpIndexStatus + WIFI_DEFAULT_COUNT) > ID_GROUP_STATUS_COUNT_TURN_ON)
991 __groupTotalCount = ID_GROUP_STATUS_COUNT_TURN_ON;
995 __groupTotalCount = grpIndexStatus;
1000 __pTableView->UpdateTableView();
1007 WifiForm::ChangeNetworkGroupItemCount(unsigned int itemCount, bool isAdd)
1011 __networkGroupItemTotalCount = itemCount;
1015 __networkGroupItemTotalCount = GetGroupItemTotalCount(GROUP_INDEX_2_WIFI_NETWORK) - itemCount;
1016 if (__networkGroupItemTotalCount <= 0)
1018 __networkGroupItemTotalCount = WIFI_NETWORK_GROUP_ITEM_BASE;
1022 return __networkGroupItemTotalCount;
1026 WifiForm::GetGroupItemTotalCount(int groupIndex)
1028 int retItemCount = 0;
1032 retItemCount = __pTableView->GetItemCountAt(groupIndex);
1035 return retItemCount;
1039 WifiForm::GetDefaultGroupItemHeight(void)
1041 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
1045 WifiForm::GetDefaultItemHeight(void)
1047 return H_GROUP_ITEM_DEFAULT;
1051 WifiForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
1056 WifiForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1061 WifiForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1066 WifiForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1070 case GROUP_INDEX_0_WIFI_ACTIVATE:
1075 case GROUP_INDEX_1_WIFI_NOTIFICATION:
1080 case GROUP_INDEX_2_WIFI_NETWORK:
1085 case GROUP_INDEX_3_WIFI_HIDDEN_NETWORK:
1096 WifiForm::OnWifiPresentationModelEventCompleted(WifiPresentationModelEvent requestEvent, result r)
1098 int wifiScanBssCount = 0;
1099 if (__pWifiPresentationModelInstance == null)
1101 AppLogDebug("__pWifiPresentationModelInstance is null");
1104 if (__pTableView == null)
1106 AppLogDebug("__tableView is null");
1109 switch (requestEvent)
1111 case WIFI_PRESENTATION_MODEL_EVENT_NONE:
1116 case WIFI_PRESENTATION_MODEL_EVENT_ACTIVATED:
1121 localGroup = GROUP_INDEX_0_WIFI_ACTIVATE;
1122 localItem = ID_WIFI_STATUS_GROUP_ITEM_ONOFF;
1124 if (!__pTableView->IsItemChecked(localGroup, localItem))
1126 __pTableView->SetItemChecked(localGroup, localItem, true);
1127 __pTableView->RefreshItem(localGroup, localItem, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1129 ChangeGroupIndexCount(ID_GROUP_STATUS_COUNT_TURN_ON, true);
1133 case WIFI_PRESENTATION_MODEL_EVENT_ACTIVATING:
1138 case WIFI_PRESENTATION_MODEL_EVENT_DEACTIVATED:
1140 DisableScanFooter();
1143 localGroup = GROUP_INDEX_0_WIFI_ACTIVATE;
1144 localItem = ID_WIFI_STATUS_GROUP_ITEM_ONOFF;
1145 __pTableView->SetItemChecked(localGroup, localItem, false);
1146 __pTableView->RefreshItem(localGroup, localItem, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1147 ChangeGroupIndexCount(ID_GROUP_STATUS_COUNT_TURN_OFF, true);
1151 case WIFI_PRESENTATION_MODEL_EVENT_DEACTIVATING:
1156 case WIFI_PRESENTATION_MODEL_EVENT_CONNECTED:
1161 case WIFI_PRESENTATION_MODEL_EVENT_SCAN_COMPLETED_N:
1165 localGroup = GROUP_INDEX_0_WIFI_ACTIVATE;
1166 localItem = ID_WIFI_STATUS_GROUP_ITEM_ONOFF;
1168 if (!__pTableView->IsItemChecked(localGroup, localItem))
1170 __pTableView->SetItemChecked(localGroup, localItem, true);
1171 __pTableView->RefreshItem(localGroup, localItem, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1173 wifiScanBssCount = __pWifiPresentationModelInstance->GetAccessPointCount();
1174 if (wifiScanBssCount == 0)
1176 AppLogDebug("Scan Error");
1177 ChangeNetworkGroupItemCount(0, true);
1181 ChangeNetworkGroupItemCount(wifiScanBssCount + WIFI_DEFAULT_COUNT, true);
1183 ChangeGroupIndexCount(ID_GROUP_STATUS_COUNT_TURN_ON, true);
1187 case WIFI_PRESENTATION_MODEL_EVENT_SCANNING:
1192 case WIFI_PRESENTATION_MODEL_EVENT_RSSI_CHANGED:
1194 if (__pWifiPresentationModelInstance->IsWifiActivated())
1196 __pWifiPresentationModelInstance->ScanWifi();
1201 case WIFI_PRESENTATION_MODEL_EVENT_MAX: