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 StWifiConnectionForm.cpp
19 * @brief This is the implementation file for WifiConnectionForm class.
22 #include "StResourceManager.h"
23 #include "StSettingScenesList.h"
25 #include "StWifiConnectionForm.h"
27 using namespace Tizen::Base;
28 using namespace Tizen::Graphics;
29 using namespace Tizen::Ui;
30 using namespace Tizen::Ui::Controls;
31 using namespace Tizen::Ui::Scenes;
33 static const int ID_GROUP_WIFI_EAP_CONNECT_MAIN = 0;
34 static const int ID_GROUP_WIFI_EAP_CONNECT_MAIN_ITEM_COUNT = 8;
35 static const int ID_ITEM_WIFI_EAP_CONNECT_EAP_METHOD = 0;
36 static const int ID_ITEM_WIFI_EAP_CONNECT_PROVISIONING = 1;
37 static const int ID_ITEM_WIFI_EAP_CONNECT_PHASE_2_AUTHENTICATION = 2;
38 static const int ID_ITEM_WIFI_EAP_CONNECT_CA_CERTIFICATE = 3;
39 static const int ID_ITEM_WIFI_EAP_CONNECT_USER_CERTIFICATE = 4;
40 static const int ID_ITEM_WIFI_EAP_CONNECT_IDENTITY = 5;
41 static const int ID_ITEM_WIFI_EAP_CONNECT_ANONUMOUS_IDENTITY = 6;
42 static const int ID_ITEM_WIFI_EAP_CONNECT_PASSWORD = 7;
44 static const int ID_GROUP_WIFI_EAP_CONNECT_IP = 1;
45 static const int ID_GROUP_WIFI_EAP_CONNECT_IP_ITEM_COUNT = 2;
46 static const int ID_ITEM_WIFI_EAP_CONNECT_STATIC_IP = 0;
47 static const int ID_ITEM_WIFI_EAP_CONNECT_IP_ADDRESS = 1;
49 static const int ID_GROUP_WIFI_EAP_CONNECT_ADDRESS = 2;
50 static const int ID_GROUP_WIFI_EAP_CONNECT_ADDRESS_ITEM_COUNT = 3;
51 static const int ID_ITEM_WIFI_EAP_CONNECT_MAC_ADDRESS = 0;
52 static const int ID_ITEM_WIFI_EAP_CONNECT_PROXY_ADDRESS = 1;
53 static const int ID_ITEM_WIFI_EAP_CONNECT_PROXY_PORT = 2;
55 static const int ID_GROUP_COUNT = 3;
56 static const int ID_GROUP_MAX_ITEM_COUNT = ID_GROUP_WIFI_EAP_CONNECT_MAIN_ITEM_COUNT;
58 WifiConnectionForm::WifiConnectionForm(void)
62 WifiConnectionForm::~WifiConnectionForm(void)
67 WifiConnectionForm::CreateFooter(void)
69 Footer* pFooter = GetFooter();
72 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
73 pFooter->SetBackButton();
74 pFooter->AddActionEventListener(*this);
76 SetFormBackEventListener(this);
80 WifiConnectionForm::OnInitializing(void)
91 WifiConnectionForm::OnTerminating(void)
95 SetFormBackEventListener(null);
100 WifiConnectionForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
102 __pTableView->UpdateTableView();
106 WifiConnectionForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
111 WifiConnectionForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
113 SceneManager* pSceneManager = SceneManager::GetInstance();
114 AppAssert(pSceneManager);
116 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
120 WifiConnectionForm::GetGroupCount(void)
122 AppLogDebug("ENTER");
123 return ID_GROUP_COUNT;
127 WifiConnectionForm::GetItemCount(int groupIndex)
133 case ID_GROUP_WIFI_EAP_CONNECT_MAIN:
135 itemCount = ID_GROUP_WIFI_EAP_CONNECT_MAIN_ITEM_COUNT;
139 case ID_GROUP_WIFI_EAP_CONNECT_IP:
141 itemCount = ID_GROUP_WIFI_EAP_CONNECT_IP_ITEM_COUNT;
145 case ID_GROUP_WIFI_EAP_CONNECT_ADDRESS:
147 itemCount = ID_GROUP_WIFI_EAP_CONNECT_ADDRESS_ITEM_COUNT;
154 AppLogDebug("GetItemCount %d ", itemCount);
160 WifiConnectionForm::CreateGroupItem(int groupIndex, int itemWidth)
162 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
163 int itemLableTextSize = FONT_SIZE_GROUP_TITLE_TEXT;
164 Color itemBGColor = COLOR_BG_GROUP_INDEX_DEFAULT;
165 Color itemLableTextColor = COLOR_GROUP_TITLE_TEXT;
166 LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
167 Rectangle itemRectLable(X_GROUP_INDEX_DEFAULT_LABEL, Y_GROUP_INDEX_DEFAULT_LABEL, itemWidth, itemHeight);
169 Label* pLabel = null;
171 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
175 RelativeLayout relativeLayout;
176 relativeLayout.Construct();
178 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
179 pItem->SetBackgroundColor(itemBGColor);
180 pItem->SetEnabled(false);
182 pLabel = new (std::nothrow) Label();
183 pLabel->Construct(itemRectLable, groupText);
184 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
185 pLabel->SetTextConfig(itemLableTextSize, style);
186 pLabel->SetTextColor(itemLableTextColor);
188 pItem->AddControl(pLabel);
189 relativeLayout.SetMargin(*pLabel, itemRectLable.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
190 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
191 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
198 WifiConnectionForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
200 int itemLableTextSize = FONT_SIZE_MAIN_TEXT;
201 Color itemBGColor = COLOR_BG_GROUP_ITEM_DEFAULT;
202 Color itemLableTextColor = COLOR_MAIN_TEXT;
203 Rectangle itemRectLable;
205 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
206 Label* pLabel = null;
208 ItemTypeOneLine(itemRectLable);
210 TableViewItem* pItem = new (std::nothrow) TableViewItem();
214 case ID_GROUP_WIFI_EAP_CONNECT_MAIN:
218 case ID_ITEM_WIFI_EAP_CONNECT_EAP_METHOD:
220 itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_EAP_METHOD");
224 case ID_ITEM_WIFI_EAP_CONNECT_PROVISIONING:
226 itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_PROVISIONING");
230 case ID_ITEM_WIFI_EAP_CONNECT_PHASE_2_AUTHENTICATION:
236 case ID_ITEM_WIFI_EAP_CONNECT_CA_CERTIFICATE:
238 itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_CA_CERTIFICATE");
242 case ID_ITEM_WIFI_EAP_CONNECT_USER_CERTIFICATE:
244 itemText = ResourceManager::GetString(L"IDS_ST_BODY_USER_CERTIFICATE");
248 case ID_ITEM_WIFI_EAP_CONNECT_IDENTITY:
250 itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_IDENTITY");
254 case ID_ITEM_WIFI_EAP_CONNECT_ANONUMOUS_IDENTITY:
256 itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_ANONYMOUS_IDENTITY");
260 case ID_ITEM_WIFI_EAP_CONNECT_PASSWORD:
262 itemText = ResourceManager::GetString(L"IDS_ST_BODY_PASSWORD");
270 if (itemIndex < ID_ITEM_WIFI_EAP_CONNECT_CA_CERTIFICATE)
272 style = TABLE_VIEW_ANNEX_STYLE_DETAILED;
277 case ID_GROUP_WIFI_EAP_CONNECT_IP:
281 case ID_ITEM_WIFI_EAP_CONNECT_STATIC_IP:
283 itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_STATIC_IP");
287 case ID_ITEM_WIFI_EAP_CONNECT_IP_ADDRESS:
289 itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_IP_ADDRESS");
297 if (itemIndex == ID_ITEM_WIFI_EAP_CONNECT_STATIC_IP)
299 style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
308 case ID_ITEM_WIFI_EAP_CONNECT_MAC_ADDRESS:
310 itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_MAC_ADDRESS");
314 case ID_ITEM_WIFI_EAP_CONNECT_PROXY_ADDRESS:
316 itemText = ResourceManager::GetString(L"IDS_ST_BODY_CONNECTIONSETTINGS_PROXY_ADDRESS");
320 case ID_ITEM_WIFI_EAP_CONNECT_PROXY_PORT:
322 itemText = ResourceManager::GetString(L"IDS_ST_BODY_PROXY_PORT");
335 RelativeLayout relativeLayout;
336 relativeLayout.Construct();
338 pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
339 pItem->SetBackgroundColor(itemBGColor);
341 pLabel = new (std::nothrow) Label();
342 pLabel->Construct(itemRectLable, itemText);
343 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
344 pLabel->SetTextConfig(itemLableTextSize , LABEL_TEXT_STYLE_NORMAL);
345 pLabel->SetTextColor(itemLableTextColor);
347 pItem->AddControl(pLabel);
348 if (style == TABLE_VIEW_ANNEX_STYLE_DETAILED)
350 relativeLayout.SetMargin(*pLabel, itemRectLable.x, RELATIVE_LAYOUT_RIGHT_MARGIN_DETAIL_BUTTON, 0, 0);
352 else if (style == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING)
354 relativeLayout.SetMargin(*pLabel, itemRectLable.x, RELATIVE_LAYOUT_RIGHT_MARGIN_ONOFF_SLIDING, 0, 0);
358 relativeLayout.SetMargin(*pLabel, itemRectLable.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
360 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
361 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
368 WifiConnectionForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
370 AppLogDebug("ENTER");
379 WifiConnectionForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
381 AppLogDebug("ENTER");
390 WifiConnectionForm::GetDefaultGroupItemHeight(void)
392 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
396 WifiConnectionForm::GetDefaultItemHeight(void)
398 return H_GROUP_ITEM_DEFAULT;
402 WifiConnectionForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
407 WifiConnectionForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
412 WifiConnectionForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
417 WifiConnectionForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
422 WifiConnectionForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)