1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * WLAN Wizard Page: Security mode Selection. |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 |
|
20 #include <HbDocumentLoader> |
|
21 #include <HbWidget> |
|
22 #include <HbRadioButtonList> |
|
23 #include <HbMainWindow> |
|
24 #include <HbLabel> |
|
25 |
|
26 #include <cmmanagerdefines_shim.h> |
|
27 |
|
28 // User includes |
|
29 |
|
30 #include "wlanwizard_p.h" |
|
31 #include "wlanwizard.h" |
|
32 #include "wlanwizardpagesecuritymode.h" |
|
33 #include "wlanwizardscanlist.h" |
|
34 |
|
35 #include "OstTraceDefinitions.h" |
|
36 #ifdef OST_TRACE_COMPILER_IN_USE |
|
37 #include "wlanwizardpagesecuritymodeTraces.h" |
|
38 #endif |
|
39 |
|
40 /*! |
|
41 * Constructor method for the Sequrity mode query view object. |
|
42 * @param [in] parent pointer to parent object. |
|
43 */ |
|
44 WlanWizardPageSecurityMode::WlanWizardPageSecurityMode( |
|
45 WlanWizardPrivate* parent) : |
|
46 WlanWizardPageInternal(parent), |
|
47 mWidget(NULL), |
|
48 mList(NULL), |
|
49 mLabel(NULL), |
|
50 mLoader(NULL), |
|
51 mValid(false) |
|
52 { |
|
53 OstTraceFunctionEntry0(WLANWIZARDPAGESECURITYMODE_WLANWIZARDPAGESECURITYMODE_ENTRY); |
|
54 OstTraceFunctionExit0(WLANWIZARDPAGESECURITYMODE_WLANWIZARDPAGESECURITYMODE_EXIT); |
|
55 } |
|
56 |
|
57 /*! |
|
58 * Destructor. Loader widget is deleted. |
|
59 * All document widgets are deleted by wlanwizard_p destructor. |
|
60 */ |
|
61 WlanWizardPageSecurityMode::~WlanWizardPageSecurityMode() |
|
62 { |
|
63 OstTraceFunctionEntry0(DUP1_WLANWIZARDPAGESECURITYMODE_WLANWIZARDPAGESECURITYMODE_ENTRY); |
|
64 |
|
65 delete mLoader; |
|
66 |
|
67 OstTraceFunctionExit0(DUP1_WLANWIZARDPAGESECURITYMODE_WLANWIZARDPAGESECURITYMODE_EXIT); |
|
68 } |
|
69 |
|
70 /*! |
|
71 * Page initialization. If view widget is already loaded, does nothing. |
|
72 * @return pointer to widget "occ_add_wlan_02". |
|
73 */ |
|
74 HbWidget* WlanWizardPageSecurityMode::initializePage() |
|
75 { |
|
76 OstTraceFunctionEntry0(WLANWIZARDPAGESECURITYMODE_INITIALIZEPAGE_ENTRY); |
|
77 |
|
78 OstTrace0( |
|
79 TRACE_NORMAL, |
|
80 WLANWIZARDPAGESECURITYMODE_INITIALIZEPAGE, |
|
81 "WlanWizardPageSecurityMode::initializePage"); |
|
82 |
|
83 if (mWidget==NULL) { |
|
84 |
|
85 mLoader = new HbDocumentLoader(mWizard->mainWindow()); |
|
86 |
|
87 bool ok; |
|
88 |
|
89 mLoader->load( ":/docml/occ_add_wlan_02_03.docml", &ok ); |
|
90 Q_ASSERT(ok); |
|
91 |
|
92 // Initialize orientation |
|
93 loadDocmlSection( mWizard->mainWindow()->orientation() ); |
|
94 |
|
95 // Load widgets |
|
96 mWidget = qobject_cast<HbWidget*> (mLoader->findWidget("occ_add_wlan_02")); |
|
97 Q_ASSERT(mWidget != NULL); |
|
98 |
|
99 mList = qobject_cast<HbRadioButtonList*> (mLoader->findWidget("list")); |
|
100 Q_ASSERT(mList != NULL); |
|
101 |
|
102 mLabel = qobject_cast<HbLabel*> (mLoader->findWidget("dialog_6")); |
|
103 Q_ASSERT(mLabel != NULL); |
|
104 |
|
105 mLabel->setPlainText(hbTrId("txt_occ_dialog_select_network_security_mode")); |
|
106 |
|
107 // Connect orientation signal from the main window to orientation |
|
108 // loader. |
|
109 ok &= connect( mWizard->mainWindow(), |
|
110 SIGNAL(orientationChanged(Qt::Orientation)), |
|
111 this, SLOT(loadDocmlSection(Qt::Orientation))); |
|
112 Q_ASSERT(ok); |
|
113 |
|
114 // Connect signal from the radio button list indicating that an item |
|
115 // has been selected to validation handler. |
|
116 ok &= connect( mList, SIGNAL(itemSelected(int)), |
|
117 this, SLOT(itemSelected())); |
|
118 Q_ASSERT(ok); |
|
119 } |
|
120 |
|
121 // Create contents to the security mode radio button list. |
|
122 populateSecModeList(); |
|
123 |
|
124 OstTraceFunctionExit0(WLANWIZARDPAGESECURITYMODE_INITIALIZEPAGE_EXIT); |
|
125 return mWidget; |
|
126 } |
|
127 |
|
128 /*! |
|
129 * Validates the Sequrity more selection and sets the configuration in |
|
130 * the wlanwizard. |
|
131 * @param [out] removeFromStack returns false. |
|
132 * @return depending on the sequrity mode, returns the appropriate view |
|
133 * identifier. |
|
134 */ |
|
135 int WlanWizardPageSecurityMode::nextId(bool &removeFromStack) const |
|
136 { |
|
137 OstTraceFunctionEntry0(WLANWIZARDPAGESECURITYMODE_NEXTID_ENTRY); |
|
138 |
|
139 removeFromStack = false; |
|
140 |
|
141 // The configuration is selected from the mSecModes list, which is ordered |
|
142 // during the page initialization. |
|
143 mWizard->setConfiguration( |
|
144 WlanWizardPrivate::ConfSecurityMode, |
|
145 mSecModes.at(mList->selected())); |
|
146 |
|
147 // The configuration is selected from the mUsePsk list, which is ordered |
|
148 // during the page initialization. |
|
149 mWizard->setConfiguration( |
|
150 WlanWizardPrivate::ConfUsePsk, |
|
151 mUsePsk.at(mList->selected())); |
|
152 |
|
153 OstTraceFunctionExit0(LANWIZARDPAGESECURITYMODE_NEXTID_EXIT); |
|
154 return mPageIds.at( mList->selected() ); |
|
155 } |
|
156 |
|
157 /*! |
|
158 * This method is overrides the default implementation from WlanWizardPage. |
|
159 * It indicates whether the Next-button should be enabled or not. |
|
160 * @return true, if a mode has been selected. |
|
161 */ |
|
162 bool WlanWizardPageSecurityMode::showPage() |
|
163 { |
|
164 OstTraceFunctionEntry0(WLANWIZARDPAGESECURITYMODE_SHOWPAGE_ENTRY); |
|
165 OstTraceFunctionExit0(WLANWIZARDPAGESECURITYMODE_SHOWPAGE_EXIT); |
|
166 return mValid; |
|
167 } |
|
168 |
|
169 /*! |
|
170 * Is invoked when user selects a mode from the radio button list. |
|
171 * (HbRadioButtonList's itemSelected-signal) |
|
172 */ |
|
173 void WlanWizardPageSecurityMode::itemSelected() |
|
174 { |
|
175 OstTraceFunctionEntry0(WLANWIZARDPAGESECURITYMODE_ITEMSELECTED_ENTRY); |
|
176 |
|
177 OstTrace0( |
|
178 TRACE_BORDER, |
|
179 WLANWIZARDPAGESECURITYMODE_ITEMSELECTED, |
|
180 "WlanWizardPageSecurityMode::itemSelected"); |
|
181 |
|
182 mValid = true; |
|
183 mWizard->enableNextButton(mValid); |
|
184 |
|
185 OstTraceFunctionExit0(WLANWIZARDPAGESECURITYMODE_ITEMSELECTED_EXIT); |
|
186 } |
|
187 |
|
188 /*! |
|
189 * Loads the document orientation information from occ_add_wlan_02_03.docml |
|
190 * This is called each time phone orientation changes. |
|
191 * @param [in] orientation indicates whether the phone is in portrait or |
|
192 * landscape mode. |
|
193 */ |
|
194 void WlanWizardPageSecurityMode::loadDocmlSection(Qt::Orientation orientation) |
|
195 { |
|
196 OstTraceFunctionEntry0(WLANWIZARDPAGESECURITYMODE_LOADDOCMLSECTION_ENTRY); |
|
197 |
|
198 OstTrace1( |
|
199 TRACE_NORMAL, |
|
200 WLANWIZARDPAGESECURITYMODE_LOADDOCML, |
|
201 "WlanWizardPageSecurityMode::loadDocml - orientation;orientation=%x", |
|
202 (TUint)orientation); |
|
203 |
|
204 WlanWizardPageInternal::loadDocmlSection( |
|
205 mLoader, |
|
206 orientation, |
|
207 ":/docml/occ_add_wlan_02_03.docml", |
|
208 "portrait_section", |
|
209 "landscape_section"); |
|
210 |
|
211 OstTraceFunctionExit0(WLANWIZARDPAGESECURITYMODE_LOADDOCMLSECTION_EXIT); |
|
212 } |
|
213 |
|
214 /*! |
|
215 * Support function that creates the contents of the security mode list. |
|
216 */ |
|
217 void WlanWizardPageSecurityMode::populateSecModeList() |
|
218 { |
|
219 OstTraceFunctionEntry0(WLANWIZARDPAGESECURITYMODE_POPULATESECMODELIST_ENTRY); |
|
220 |
|
221 QStringList items; |
|
222 |
|
223 mSecModes.clear(); |
|
224 mPageIds.clear(); |
|
225 mUsePsk.clear(); |
|
226 |
|
227 // A list is created. Since there is no practical way of knowing whether |
|
228 // the new contents are different from the previous contents (if there |
|
229 // even were any in the first place) the validity is always reset. |
|
230 mValid = false; |
|
231 |
|
232 // Create the radio button list to correspond to correct security mode |
|
233 // identifiers and page identifiers. |
|
234 // Populate the list according to network mode selection. |
|
235 addToList( |
|
236 items, |
|
237 hbTrId("txt_occ_list_open"), |
|
238 CMManagerShim::WlanSecModeOpen, |
|
239 WlanWizardPage::PageProcessSettings, |
|
240 false); |
|
241 |
|
242 addToList( |
|
243 items, |
|
244 hbTrId("txt_occ_list_wep_1"), |
|
245 CMManagerShim::WlanSecModeWep, |
|
246 WlanWizardPageInternal::PageKeyQuery, |
|
247 true); |
|
248 |
|
249 // In case of Ad-hoc network, exclude wpa, eap and 802.1X modes. |
|
250 if (mWizard->configuration(WlanWizardPrivate::ConfNetworkMode).toInt() |
|
251 != CMManagerShim::Adhoc) { |
|
252 |
|
253 addToList( |
|
254 items, |
|
255 hbTrId("txt_occ_list_wpa_with_password"), |
|
256 CMManagerShim::WlanSecModeWpa, |
|
257 WlanWizardPageInternal::PageKeyQuery, |
|
258 true); |
|
259 |
|
260 addToList( |
|
261 items, |
|
262 hbTrId("txt_occ_list_wpa_with_eap"), |
|
263 CMManagerShim::WlanSecModeWpa, |
|
264 WlanWizardPage::PageEapStart, |
|
265 false); |
|
266 |
|
267 addToList( |
|
268 items, |
|
269 hbTrId("txt_occ_list_8021x_1"), |
|
270 CMManagerShim::WlanSecMode802_1x, |
|
271 WlanWizardPage::PageEapStart, |
|
272 false); |
|
273 } |
|
274 |
|
275 mList->setItems(items); |
|
276 |
|
277 OstTraceFunctionExit0(WLANWIZARDPAGESECURITYMODE_POPULATESECMODELIST_EXIT); |
|
278 } |
|
279 |
|
280 /*! |
|
281 * A support function to map the radio button list to a generic network |
|
282 * mode list. This enables the changing of button order without it |
|
283 * affecting the entire class. |
|
284 * @param [out] list is a reference to a local list that will be placed as an |
|
285 * argument to the radio button list. |
|
286 * @param [in] item is a reference to the text value that is appended to the |
|
287 * list |
|
288 * @param [in] mode is the security mode associated with the item |
|
289 * @param [in] page is the id of the next wizard page when this item is selected. |
|
290 * @param [in] psk indicates whether password needs to be queried. |
|
291 */ |
|
292 void WlanWizardPageSecurityMode::addToList( |
|
293 QStringList &list, |
|
294 const QString &item, |
|
295 int mode, |
|
296 int page, |
|
297 bool psk) |
|
298 { |
|
299 OstTraceFunctionEntry0(WLANWIZARDPAGESECURITYMODE_ADDTOLIST_ENTRY); |
|
300 |
|
301 if (mWizard->configurationExists(WlanWizardHelper::ConfAvailableNetworkOptions)) { |
|
302 WlanNetworkSetting netMode; |
|
303 netMode.mode = mWizard->configuration(WlanWizardPrivate::ConfNetworkMode).toInt(); |
|
304 netMode.hidden = mWizard->configuration(WlanWizardPrivate::ConfWlanScanSSID).toBool(); |
|
305 netMode.wpsSupported = mWizard->configuration(WlanWizardPrivate::ConfWpsSupported).toBool(); |
|
306 WlanWizardScanList networkOptions = mWizard->configuration( |
|
307 WlanWizardHelper::ConfAvailableNetworkOptions).value<WlanWizardScanList>(); |
|
308 |
|
309 for (int i = 0; i < networkOptions.secModes(netMode); i++) { |
|
310 WlanSecuritySetting secMode = networkOptions.getSecMode(netMode, i); |
|
311 |
|
312 if (secMode.mode == mode && secMode.usePsk == psk) { |
|
313 list << item; |
|
314 mSecModes.append(mode); |
|
315 mPageIds.append(page); |
|
316 mUsePsk.append(psk); |
|
317 } |
|
318 } |
|
319 } |
|
320 else { |
|
321 list << item; |
|
322 mSecModes.append(mode); |
|
323 mPageIds.append(page); |
|
324 mUsePsk.append(psk); |
|
325 } |
|
326 |
|
327 OstTraceFunctionExit0(WLANWIZARDPAGESECURITYMODE_ADDTOLIST_EXIT); |
|
328 } |
|