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->AddActionEventListener(*this);
75 SetFormBackEventListener(this);
79 WifiConnectionForm::OnInitializing(void)
89 WifiConnectionForm::OnTerminating(void)
93 SetFormBackEventListener(null);
98 WifiConnectionForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
100 __pTableView->UpdateTableView();
104 WifiConnectionForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
109 WifiConnectionForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
111 SceneManager* pSceneManager = SceneManager::GetInstance();
112 AppAssert(pSceneManager);
114 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
118 WifiConnectionForm::GetGroupCount(void)
120 AppLogDebug("ENTER");
121 return ID_GROUP_COUNT;
125 WifiConnectionForm::GetItemCount(int groupIndex)
131 case ID_GROUP_WIFI_EAP_CONNECT_MAIN:
133 itemCount = ID_GROUP_WIFI_EAP_CONNECT_MAIN_ITEM_COUNT;
137 case ID_GROUP_WIFI_EAP_CONNECT_IP:
139 itemCount = ID_GROUP_WIFI_EAP_CONNECT_IP_ITEM_COUNT;
143 case ID_GROUP_WIFI_EAP_CONNECT_ADDRESS:
145 itemCount = ID_GROUP_WIFI_EAP_CONNECT_ADDRESS_ITEM_COUNT;
152 AppLogDebug("GetItemCount %d ", itemCount);
158 WifiConnectionForm::CreateGroupItem(int groupIndex, int itemWidth)
160 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
161 int itemLableTextSize = FONT_SIZE_GROUP_TITLE_TEXT;
162 Color itemBGColor = COLOR_BG_GROUP_INDEX_DEFAULT;
163 Color itemLableTextColor = COLOR_GROUP_TITLE_TEXT;
164 LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
165 Rectangle itemRectLable(X_GROUP_INDEX_DEFAULT_LABEL, Y_GROUP_INDEX_DEFAULT_LABEL, itemWidth, itemHeight);
167 Label* pLabel = null;
169 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
173 RelativeLayout relativeLayout;
174 relativeLayout.Construct();
176 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
177 pItem->SetBackgroundColor(itemBGColor);
178 pItem->SetEnabled(false);
180 pLabel = new (std::nothrow) Label();
181 pLabel->Construct(itemRectLable, groupText);
182 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
183 pLabel->SetTextConfig(itemLableTextSize, style);
184 pLabel->SetTextColor(itemLableTextColor);
186 pItem->AddControl(pLabel);
187 relativeLayout.SetMargin(*pLabel, itemRectLable.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
188 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
189 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
196 WifiConnectionForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
198 int itemLableTextSize = FONT_SIZE_MAIN_TEXT;
199 Color itemBGColor = COLOR_BG_GROUP_ITEM_DEFAULT;
200 Color itemLableTextColor = COLOR_MAIN_TEXT;
201 Rectangle itemRectLable;
203 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
204 Label* pLabel = null;
206 ItemTypeOneLine(itemRectLable);
208 TableViewItem* pItem = new (std::nothrow) TableViewItem();
212 case ID_GROUP_WIFI_EAP_CONNECT_MAIN:
216 case ID_ITEM_WIFI_EAP_CONNECT_EAP_METHOD:
218 itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_EAP_METHOD");
222 case ID_ITEM_WIFI_EAP_CONNECT_PROVISIONING:
224 itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_PROVISIONING");
228 case ID_ITEM_WIFI_EAP_CONNECT_PHASE_2_AUTHENTICATION:
234 case ID_ITEM_WIFI_EAP_CONNECT_CA_CERTIFICATE:
236 itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_CA_CERTIFICATE");
240 case ID_ITEM_WIFI_EAP_CONNECT_USER_CERTIFICATE:
242 itemText = ResourceManager::GetString(L"IDS_ST_BODY_USER_CERTIFICATE");
246 case ID_ITEM_WIFI_EAP_CONNECT_IDENTITY:
248 itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_IDENTITY");
252 case ID_ITEM_WIFI_EAP_CONNECT_ANONUMOUS_IDENTITY:
254 itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_ANONYMOUS_IDENTITY");
258 case ID_ITEM_WIFI_EAP_CONNECT_PASSWORD:
260 itemText = ResourceManager::GetString(L"IDS_ST_BODY_PASSWORD");
268 if (itemIndex < ID_ITEM_WIFI_EAP_CONNECT_CA_CERTIFICATE)
270 style = TABLE_VIEW_ANNEX_STYLE_DETAILED;
275 case ID_GROUP_WIFI_EAP_CONNECT_IP:
279 case ID_ITEM_WIFI_EAP_CONNECT_STATIC_IP:
281 itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_STATIC_IP");
285 case ID_ITEM_WIFI_EAP_CONNECT_IP_ADDRESS:
287 itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_IP_ADDRESS");
295 if (itemIndex == ID_ITEM_WIFI_EAP_CONNECT_STATIC_IP)
297 style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
306 case ID_ITEM_WIFI_EAP_CONNECT_MAC_ADDRESS:
308 itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_MAC_ADDRESS");
312 case ID_ITEM_WIFI_EAP_CONNECT_PROXY_ADDRESS:
314 itemText = ResourceManager::GetString(L"IDS_ST_BODY_CONNECTIONSETTINGS_PROXY_ADDRESS");
318 case ID_ITEM_WIFI_EAP_CONNECT_PROXY_PORT:
320 itemText = ResourceManager::GetString(L"IDS_ST_BODY_PROXY_PORT");
333 RelativeLayout relativeLayout;
334 relativeLayout.Construct();
336 pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
337 pItem->SetBackgroundColor(itemBGColor);
339 pLabel = new (std::nothrow) Label();
340 pLabel->Construct(itemRectLable, itemText);
341 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
342 pLabel->SetTextConfig(itemLableTextSize , LABEL_TEXT_STYLE_NORMAL);
343 pLabel->SetTextColor(itemLableTextColor);
345 pItem->AddControl(pLabel);
346 if (style == TABLE_VIEW_ANNEX_STYLE_DETAILED)
348 relativeLayout.SetMargin(*pLabel, itemRectLable.x, RELATIVE_LAYOUT_RIGHT_MARGIN_DETAIL_BUTTON, 0, 0);
350 else if (style == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING)
352 relativeLayout.SetMargin(*pLabel, itemRectLable.x, RELATIVE_LAYOUT_RIGHT_MARGIN_ONOFF_SLIDING, 0, 0);
356 relativeLayout.SetMargin(*pLabel, itemRectLable.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
358 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
359 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
366 WifiConnectionForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
368 AppLogDebug("ENTER");
377 WifiConnectionForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
379 AppLogDebug("ENTER");
388 WifiConnectionForm::GetDefaultGroupItemHeight(void)
390 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
394 WifiConnectionForm::GetDefaultItemHeight(void)
396 return H_GROUP_ITEM_DEFAULT;
400 WifiConnectionForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
405 WifiConnectionForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
410 WifiConnectionForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
415 WifiConnectionForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
420 WifiConnectionForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)