63 { |
71 { |
64 delete mLoader; |
72 delete mLoader; |
65 } |
73 } |
66 |
74 |
67 /*! |
75 /*! |
68 * Page initialization. If view is already loaded, does nothing. |
76 * Page initialization. If view is already loaded, does nothing. Inherited from |
|
77 * WlanWizardPage. |
|
78 * @return pointer to widget "occ_add_wlan_06". |
69 */ |
79 */ |
70 HbWidget* WlanWizardPageScanning::initializePage() |
80 HbWidget* WlanWizardPageScanning::initializePage() |
71 { |
81 { |
72 OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESCANNING_INITIALIZEPAGE, |
82 OstTrace0( |
73 "WlanWizardPageScanning::initializePage" ); |
83 TRACE_NORMAL, |
|
84 WLANWIZARDPAGESCANNING_INITIALIZEPAGE, |
|
85 "WlanWizardPageScanning::initializePage"); |
74 |
86 |
75 // Next page id is reset with each initialization. |
87 // Next page id is reset with each initialization. |
76 mNextPageId = WlanWizardPage::PageNone; |
88 mNextPageId = WlanWizardPage::PageNone; |
77 |
89 |
78 if (mWidget == NULL) { |
90 if (mWidget == NULL) { |
79 |
|
80 mLoader = new HbDocumentLoader(mWizard->mainWindow()); |
91 mLoader = new HbDocumentLoader(mWizard->mainWindow()); |
81 |
92 |
82 bool ok; |
93 bool ok; |
83 |
94 |
84 mLoader->load(":/docml/occ_add_wlan_06.docml", &ok); |
95 mLoader->load(":/docml/occ_add_wlan_06.docml", &ok); |
85 Q_ASSERT_X(ok, "WlanWizardPageScanning", "Invalid docml file"); |
96 Q_ASSERT(ok); |
86 |
97 |
87 // Initialize orientation |
98 // Initialize orientation |
88 loadDocml(mWizard->mainWindow()->orientation()); |
99 loadDocmlSection(mWizard->mainWindow()->orientation()); |
89 |
100 |
90 // Load widgets |
101 // Load widgets |
91 mWidget = qobject_cast<HbWidget*> (mLoader->findWidget( |
102 mWidget = qobject_cast<HbWidget*> (mLoader->findWidget( |
92 "occ_add_wlan_06")); |
103 "occ_add_wlan_06")); |
93 Q_ASSERT_X(mWidget != NULL, "WlanWizardPageScanning", "View not found"); |
104 Q_ASSERT(mWidget != NULL); |
94 |
105 |
95 mLabel = qobject_cast<HbLabel*> (mLoader->findWidget("dialog")); |
106 mLabel = qobject_cast<HbLabel*> (mLoader->findWidget("dialog")); |
96 Q_ASSERT_X(mLabel != NULL, "WlanWizardPageScanning", |
107 Q_ASSERT(mLabel != NULL); |
97 "textLabel not found"); |
|
98 |
|
99 mBar = qobject_cast<HbProgressBar*> (mLoader->findWidget("progressBar")); |
|
100 Q_ASSERT_X(mBar != NULL, "WlanWizardPageScanning", |
|
101 "progressBar not found"); |
|
102 |
108 |
103 WlanQtUtils* utils = mWizard->wlanQtUtils(); |
109 WlanQtUtils* utils = mWizard->wlanQtUtils(); |
104 |
110 |
105 // Connect orientation signal from the main window to orientation |
111 // Connect orientation signal from the main window to orientation |
106 // loader. |
112 // loader. |
107 ok &= connect(mWizard->mainWindow(), |
113 ok = connect( |
108 SIGNAL(orientationChanged(Qt::Orientation)), this, |
114 mWizard->mainWindow(), |
109 SLOT(loadDocml(Qt::Orientation))); |
115 SIGNAL(orientationChanged(Qt::Orientation)), |
|
116 this, |
|
117 SLOT(loadDocmlSection(Qt::Orientation))); |
|
118 Q_ASSERT(ok); |
110 |
119 |
111 // Connect direct scan completion signal from wlanQtUtils to result |
120 // Connect direct scan completion signal from wlanQtUtils to result |
112 // handler. |
121 // handler. |
113 ok &= connect(utils, SIGNAL(wlanScanDirectReady()), this, |
122 ok = connect( |
114 SLOT(wlanScanDirectReady())); |
123 utils, |
115 |
124 SIGNAL(wlanScanDirectReady(int)), |
|
125 this, |
|
126 SLOT(wlanScanDirectReady(int))); |
116 Q_ASSERT(ok); |
127 Q_ASSERT(ok); |
117 |
128 } |
118 } |
129 |
119 |
130 mLabel->setPlainText(HbParameterLengthLimiter( |
120 mLabel->setPlainText(hbTrId("txt_occ_dialog_searching").arg( |
131 hbTrId("txt_occ_dialog_searching")).arg(mWizard->configuration( |
121 mWizard->configuration(WlanWizardPrivate::ConfSsid).toString())); |
132 WlanWizardPrivate::ConfSsid).toString())); |
|
133 |
122 |
134 |
123 return mWidget; |
135 return mWidget; |
124 } |
136 } |
125 |
137 |
126 /*! |
138 /*! |
127 * Sends the user to the next page. |
139 * Sends the user to the next page. |
|
140 * @param [out] removeFromStack is always true: this page is removed from the |
|
141 * stacked widget after "Next" button is pressed. |
|
142 * @return the id value of the next page. |
128 */ |
143 */ |
129 int WlanWizardPageScanning::nextId(bool &removeFromStack) const |
144 int WlanWizardPageScanning::nextId(bool &removeFromStack) const |
130 { |
145 { |
131 removeFromStack = true; |
146 removeFromStack = true; |
132 |
147 |
133 return mNextPageId; |
148 return mNextPageId; |
134 } |
149 } |
135 |
150 |
136 /*! |
151 /*! |
137 * Always false. Moving to next page is not done manually. |
152 * This function reimplements WlanWizardPage::previousTriggered. When going |
|
153 * back from scanning view, the ongoing scan operation is also stopped. Since |
|
154 * there is no need to react to following the acknowledgement signal from |
|
155 * wlanQtUtils, the corresponding handler slots are disconnected before the |
|
156 * opration and immediately connected again. |
|
157 * @return one step backwards value. |
|
158 */ |
|
159 int WlanWizardPageScanning::previousTriggered() |
|
160 { |
|
161 disconnect(this, SLOT(wlanScanDirectReady(int))); |
|
162 disconnect(this, SLOT(wlanScanResultPreCheck(int))); |
|
163 |
|
164 WlanQtUtils* utils = mWizard->wlanQtUtils(); |
|
165 |
|
166 utils->stopWlanScan(); |
|
167 |
|
168 bool ok = connect( |
|
169 utils, |
|
170 SIGNAL(wlanScanApReady(int)), |
|
171 this, |
|
172 SLOT(wlanScanResultPreCheck(int))); |
|
173 Q_ASSERT(ok); |
|
174 |
|
175 ok = connect( |
|
176 utils, |
|
177 SIGNAL(wlanScanDirectReady(int)), |
|
178 this, |
|
179 SLOT(wlanScanDirectReady(int))); |
|
180 Q_ASSERT(ok); |
|
181 |
|
182 return OneStepBackwards; |
|
183 |
|
184 } |
|
185 |
|
186 /*! |
|
187 * This method is overrides the default implementation from WlanWizardPage. |
|
188 * It indicates whether the Next-button should be enabled or not. It also resets |
|
189 * the ConfProcessSettings-configuration to false - meaning that if no scan |
|
190 * results are available, no iap is created. |
|
191 * @return always false - the scanning proceeds to next window |
|
192 * automatically or not at all. |
|
193 */ |
|
194 bool WlanWizardPageScanning::showPage() |
|
195 { |
|
196 mWizard->setConfiguration(WlanWizardHelper::ConfProcessSettings, false); |
|
197 return false; |
|
198 } |
|
199 |
|
200 /*! |
|
201 * Reimplements the default function in WlanWizardPage. Indicates to the |
|
202 * framework that startOperation() function must be executed. |
|
203 * @return true |
138 * @see WlanWizardPage |
204 * @see WlanWizardPage |
139 */ |
205 */ |
140 bool WlanWizardPageScanning::showPage() |
206 bool WlanWizardPageScanning::requiresStartOperation() |
141 { |
207 { |
142 return false; |
208 return true; |
143 } |
209 } |
144 |
210 |
145 /*! |
211 /*! |
146 * Loads the document orientation-specific parameters. |
212 * Wlan scan is performed as a "post-initialization" which is executed in a |
147 */ |
213 * separate scheduler loop. If scan results are available, starts reading them. |
148 void WlanWizardPageScanning::loadDocml(Qt::Orientation orientation) |
214 */ |
|
215 void WlanWizardPageScanning::startOperation() |
|
216 { |
|
217 OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESCANNING_STARTOPERATION, |
|
218 "WlanWizardPageScanning::startOperation - start AP scan if results" |
|
219 " are available." ); |
|
220 |
|
221 if (mScanResultsAvailable) { |
|
222 mScanResultsAvailable = false; |
|
223 wlanScanApReady(); |
|
224 } |
|
225 } |
|
226 |
|
227 /*! |
|
228 * Loads the document orientation information from occ_add_wlan_06.docml |
|
229 * This is called each time phone orientation changes. |
|
230 * @param [in] orientation indicates whether the phone is in portrait or |
|
231 * landscape mode. |
|
232 */ |
|
233 void WlanWizardPageScanning::loadDocmlSection(Qt::Orientation orientation) |
149 { |
234 { |
150 OstTrace1( TRACE_NORMAL, WLANWIZARDPAGESCANNING_LOADDOCML, |
235 OstTrace1( TRACE_NORMAL, WLANWIZARDPAGESCANNING_LOADDOCML, |
151 "WlanWizardPageScanning::loadDocml - orientation ;orientation=%x", |
236 "WlanWizardPageScanning::loadDocml - orientation ;orientation=%x", |
152 ( TUint )( orientation ) ); |
237 ( TUint )( orientation ) ); |
153 |
238 |
154 bool ok; |
239 WlanWizardPageInternal::loadDocmlSection( |
155 // Then load the orientation specific section |
240 mLoader, |
156 if (orientation == Qt::Horizontal) { |
241 orientation, |
157 mLoader->load(":/docml/occ_add_wlan_06.docml", "landscape_section", &ok); |
242 ":/docml/occ_add_wlan_06.docml", |
158 Q_ASSERT(ok); |
243 "portrait_section", |
159 } else { |
244 "landscape_section"); |
160 Q_ASSERT(orientation == Qt::Vertical); |
245 } |
161 mLoader->load(":/docml/occ_add_wlan_06.docml", "portrait_section", &ok); |
246 |
162 Q_ASSERT(ok); |
247 /*! |
163 } |
248 * Checks whether the view is active. If it is, execute wlanScanApReady. If |
164 } |
249 * not, set mScanResultsAvailable to true. |
165 |
250 * @param [in] scanStatus indicates whether the scan was succesful, cancelled of |
166 void WlanWizardPageScanning::wlanScanResultPreCheck() |
251 * failed. The argument is saved to a member variable. |
167 { |
252 */ |
|
253 void WlanWizardPageScanning::wlanScanResultPreCheck(int scanStatus) |
|
254 { |
|
255 mScanStatus = scanStatus; |
|
256 |
168 if (!mWidget) { |
257 if (!mWidget) { |
169 OstTrace1( TRACE_BORDER, WLANWIZARDPAGESCANNING_WLANSCANRESULTPRECHECK, |
258 OstTrace1( TRACE_BORDER, WLANWIZARDPAGESCANNING_WLANSCANRESULTPRECHECK, |
170 "WlanWizardPageScanning::wlanScanResultPreCheck no widget;this=%x", |
259 "WlanWizardPageScanning::wlanScanResultPreCheck no widget;this=%x", |
171 this ); |
260 this ); |
172 |
261 |
173 mScanResultsAvailable = true; |
262 mScanResultsAvailable = true; |
174 } |
263 } else { |
175 else { |
|
176 if (mWizard->isCurrentPage(mWidget)) { |
264 if (mWizard->isCurrentPage(mWidget)) { |
177 OstTrace0( TRACE_BORDER, |
265 OstTrace0( TRACE_BORDER, |
178 DUP1_WLANWIZARDPAGESCANNING_WLANSCANRESULTPRECHECK, |
266 DUP1_WLANWIZARDPAGESCANNING_WLANSCANRESULTPRECHECK, |
179 "WlanWizardPageScanning::wlanScanResultPreCheck go to results"); |
267 "WlanWizardPageScanning::wlanScanResultPreCheck go to results"); |
180 |
268 |
181 wlanScanApReady(); |
269 wlanScanApReady(); |
182 } |
270 } else { |
183 else { |
|
184 OstTrace0( TRACE_BORDER, |
271 OstTrace0( TRACE_BORDER, |
185 DUP2_WLANWIZARDPAGESCANNING_WLANSCANRESULTPRECHECK, |
272 DUP2_WLANWIZARDPAGESCANNING_WLANSCANRESULTPRECHECK, |
186 "WlanWizardPageScanning::wlanScanResultPreCheck" |
273 "WlanWizardPageScanning::wlanScanResultPreCheck" |
187 " not current widget" ); |
274 " not current widget" ); |
188 |
275 |
190 } |
277 } |
191 } |
278 } |
192 } |
279 } |
193 |
280 |
194 /*! |
281 /*! |
195 * Public networks did not reveal matches. Direct scan has been performed to |
282 * Processes the direct scan results. |
196 * find out if the network is hidden but in range. If network is found, proceed |
283 * @param [in] scanStatus indicates whether the scan was succesful, canceled or |
197 * to next page according to scan results. |
284 * failed. In case the scan was not succesful, always proceed to manual wizard. |
198 * If nothing is found, proceed to manual network |
285 */ |
199 * mode selection page. |
286 void WlanWizardPageScanning::wlanScanDirectReady(int scanStatus) |
200 */ |
|
201 void WlanWizardPageScanning::wlanScanDirectReady() |
|
202 { |
287 { |
203 OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESCANNING_WLANSCANDIRECTREADY, |
288 OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESCANNING_WLANSCANDIRECTREADY, |
204 "WlanWizardPageScanning::wlanScanDirectReady" ); |
289 "WlanWizardPageScanning::wlanScanDirectReady" ); |
205 |
290 |
206 WlanQtUtils* utils = mWizard->wlanQtUtils(); |
291 WlanQtUtils* utils = mWizard->wlanQtUtils(); |
207 |
292 |
208 Q_ASSERT(utils); |
293 Q_ASSERT(utils); |
209 |
294 |
210 QList<QSharedPointer<WlanQtUtilsAp> > wlanApList; |
295 QList<WlanScanResult> filteredResults; |
211 |
296 |
212 utils->availableWlanAps(wlanApList); |
297 if (scanStatus == WlanQtUtils::ScanStatusOk) { |
213 |
298 QList<QSharedPointer<WlanQtUtilsAp> > directScanResults; |
214 qDebug("WlanWizardPageScanning::wlanScanDirectReady - results read"); |
299 // Read the directed scan results from Qt Utils |
215 |
300 utils->availableWlanAps(directScanResults); |
|
301 |
|
302 // Identify open and hidden networks. |
|
303 getFinalScanResults(directScanResults, mWlanApList, filteredResults); |
|
304 } |
|
305 |
|
306 // Process the scan results. If scan status is not ok, feed an empty |
|
307 // result table to the selection function. |
|
308 selectNextPageActions(filteredResults); |
|
309 } |
|
310 |
|
311 /*! |
|
312 * All wlan channels have been scanned for public networks. After processing the |
|
313 * results a direct scan is initiated. This function also checks whether the |
|
314 * scan was succesful, canceled or failed. In case the scan was not succesful, |
|
315 * always proceed to manual wizard. |
|
316 */ |
|
317 void WlanWizardPageScanning::wlanScanApReady() |
|
318 { |
|
319 OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESCANNING_WLANSCANAPREADY, |
|
320 "WlanWizardPageScanning::wlanScanApReady" ); |
|
321 |
|
322 if (mScanStatus == WlanQtUtils::ScanStatusOk) { |
|
323 WlanQtUtils* utils = mWizard->wlanQtUtils(); |
|
324 Q_ASSERT(utils); |
|
325 |
|
326 QList<QSharedPointer<WlanQtUtilsAp> > openScanResults; |
|
327 |
|
328 // Fetch the list of scan results. |
|
329 utils->availableWlanAps(openScanResults); |
|
330 |
|
331 // The name of the network that we are looking for. |
|
332 QString ssid = |
|
333 mWizard->configuration(WlanWizardPrivate::ConfSsid).toString(); |
|
334 |
|
335 // Store matching scan results. |
|
336 getSsidMatchList(ssid, openScanResults); |
|
337 |
|
338 // Next directed scan. |
|
339 utils->scanWlanDirect(ssid); |
|
340 } |
|
341 else { |
|
342 mWizard->clearConfiguration(WlanWizardHelper::ConfAvailableNetworkOptions); |
|
343 mNextPageId = WlanWizardPageInternal::PageNetworkMode; |
|
344 mWizard->nextPage(); |
|
345 } |
|
346 } |
|
347 |
|
348 /*! |
|
349 * This function stores all the APs that match ssid parameter to mWlanApList |
|
350 * member list. |
|
351 * @param [in] ssid is the name of the network we are interested in. |
|
352 * @param [in] matchList is the list of all APs that were revealed in the scan. |
|
353 */ |
|
354 void WlanWizardPageScanning::getSsidMatchList( |
|
355 QString ssid, |
|
356 const QList<QSharedPointer<WlanQtUtilsAp> > &matchList) |
|
357 { |
|
358 mWlanApList.clear(); |
216 QSharedPointer<WlanQtUtilsAp> item; |
359 QSharedPointer<WlanQtUtilsAp> item; |
217 |
360 |
218 qDebug("%d APs found", wlanApList.size()); |
361 for (int i = 0; i < matchList.size(); i++) { |
219 if(wlanApList.isEmpty()) { |
362 item = matchList.at(i); |
220 qDebug("Match not found. Go to manual settings."); |
363 if (item->value(WlanQtUtilsAp::ConfIdSsid).toString() == ssid) { |
221 mNextPageId = WlanWizardPageInternal::PageNetworkMode; |
364 mWlanApList.append(item); |
222 } |
365 } |
223 else { |
366 } |
224 int strongestSignal = 0; |
367 } |
225 int strongestIndex = 0; |
368 |
226 |
369 /* |
227 for (int i = 0; i < wlanApList.size(); i++) { |
370 * Find out which of the direct scan results are open networks by comparing |
228 // All direct scan results are matches. No need to compare ssids. |
371 * result to open scan results. Return finalResults. |
229 // In case there are multiple matches to direct scan, use the |
372 * @param [in] directScanResults are the results of a directed scan. |
230 // strongest signal on the result list. |
373 * @param [in] openScanResults are the results of a scan inquiring any APs. |
231 item = wlanApList.at(i); |
374 * @param [out] finalResults is a list of APs with visibility flag included. |
232 int str = item->value(WlanQtUtilsAp::ConfIdSignalStrength).toInt(); |
375 */ |
233 if (str > strongestSignal) { |
376 void WlanWizardPageScanning::getFinalScanResults( |
234 qDebug("Strongest signal %d at %d", str, i); |
377 const QList<QSharedPointer<WlanQtUtilsAp> > &directScanResults, |
235 strongestSignal = str; |
378 const QList<QSharedPointer<WlanQtUtilsAp> > &openScanResults, |
236 strongestIndex = i; |
379 QList<WlanScanResult> &finalResults) |
|
380 { |
|
381 finalResults.clear(); |
|
382 |
|
383 // The key assumption of this algorithm is that both direct and public scan |
|
384 // reveal the same set of AP:s with the exception of hidden AP:s. |
|
385 // In other words: Direct scan result set is the whole set with each AP |
|
386 // marked as hidden by default. If an AP has been revealed also by public |
|
387 // scan, it is changed to visible. |
|
388 for (int i = 0; i < directScanResults.size(); i++) { |
|
389 WlanScanResult resultItem; |
|
390 |
|
391 resultItem.scanResult = directScanResults.at(i); |
|
392 |
|
393 // Initialize as hidden. |
|
394 resultItem.networkHidden = true; |
|
395 |
|
396 for (int j = 0; j < openScanResults.size(); j++) { |
|
397 if (WlanQtUtilsAp::compare( |
|
398 openScanResults.at(j).data(), |
|
399 directScanResults.at(i).data()) == 0) { |
|
400 // Mark open, if a public scan revealed the same AP |
|
401 resultItem.networkHidden = false; |
237 } |
402 } |
238 } |
403 } |
239 |
404 |
240 item = wlanApList.at(strongestIndex); |
405 finalResults.append(resultItem); |
241 qDebug("Select AP at %d", strongestIndex); |
406 } |
|
407 } |
|
408 |
|
409 /*! |
|
410 * This function processes the scan results in case multiple results were |
|
411 * acquired with matching SSIDs. |
|
412 * @param [in] finalResults is the list of APs revealed by the last scans. |
|
413 * @return the identifier of the next page. |
|
414 */ |
|
415 int WlanWizardPageScanning::processMultipleScanResults( |
|
416 const QList<WlanScanResult> &finalResults) |
|
417 { |
|
418 WlanWizardScanList networkOptions; |
|
419 int nextPage; |
|
420 |
|
421 // Build the list of results to be placed in the configuration. |
|
422 networkOptions.build(finalResults); |
|
423 |
|
424 QVariant tmp; |
|
425 tmp.setValue(networkOptions); |
|
426 |
|
427 mWizard->setConfiguration( |
|
428 WlanWizardHelper::ConfAvailableNetworkOptions, tmp); |
|
429 |
|
430 // If there are more than one network mode choices, go to manual selection |
|
431 // of network mode. |
|
432 if (networkOptions.netModes() > SingleResult) { |
|
433 nextPage = WlanWizardPageInternal::PageNetworkMode; |
|
434 } else { |
|
435 // if only a single network mode option is available, the mode query |
|
436 // may be skipped and the next page is set to security mode query. |
|
437 WlanNetworkSetting setting = networkOptions.getNetModes().at(0); |
|
438 mWizard->setConfiguration(WlanWizardHelper::ConfNetworkMode, setting.mode); |
|
439 mWizard->setConfiguration(WlanWizardHelper::ConfHiddenWlan, setting.hidden); |
|
440 nextPage = WlanWizardPageInternal::PageNetworkSecurity; |
|
441 } |
|
442 |
|
443 return nextPage; |
|
444 } |
|
445 |
|
446 /*! |
|
447 * This function decides what to do with the scan results. |
|
448 * @param [in] finalResults is the list of APs revealed by the last scans. |
|
449 */ |
|
450 void WlanWizardPageScanning::selectNextPageActions( |
|
451 const QList<WlanScanResult> &finalResults) |
|
452 { |
|
453 mWizard->clearConfiguration(WlanWizardHelper::ConfAvailableNetworkOptions); |
|
454 |
|
455 if (finalResults.isEmpty()) { |
|
456 // In case of no results at all were found. |
|
457 mNextPageId = WlanWizardPageInternal::PageNetworkMode; |
|
458 } else if (finalResults.size() == SingleResult) { |
|
459 // In case there is only a single result. |
|
460 WlanScanResult item = finalResults.first(); |
242 mNextPageId = mWizard->getNextPageId( |
461 mNextPageId = mWizard->getNextPageId( |
243 item->value(WlanQtUtilsAp::ConfIdSsid).toString(), |
462 item.scanResult->value(WlanQtUtilsAp::ConfIdSsid).toString(), |
244 item->value(WlanQtUtilsAp::ConfIdConnectionMode).toInt(), |
463 item.scanResult->value(WlanQtUtilsAp::ConfIdConnectionMode).toInt(), |
245 item->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(), |
464 item.scanResult->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(), |
246 item->value(WlanQtUtilsAp::ConfIdWpaPskUse).toBool(), |
465 item.scanResult->value(WlanQtUtilsAp::ConfIdWpaPskUse).toBool(), |
247 true, // hidden |
466 item.networkHidden, |
248 item->value(WlanQtUtilsAp::ConfIdWpsSupported).toBool()); |
467 item.scanResult->value(WlanQtUtilsAp::ConfIdWpsSupported).toBool()); |
|
468 } else { |
|
469 // In case more than one result is available. |
|
470 mWizard->setConfiguration(WlanWizardHelper::ConfProcessSettings, true); |
|
471 mNextPageId = processMultipleScanResults(finalResults); |
249 } |
472 } |
250 |
473 |
251 mWizard->nextPage(); |
474 mWizard->nextPage(); |
252 |
475 } |
253 } |
|
254 |
|
255 /*! |
|
256 * All wlan channels have been scanned for public networks. Now process the |
|
257 * results. If a network is found which matches the ssid set by the user, |
|
258 * proceed to next page according to the network attributes. |
|
259 * If no ssid match is found, proceed to a direct scan. |
|
260 */ |
|
261 void WlanWizardPageScanning::wlanScanApReady() |
|
262 { |
|
263 OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESCANNING_WLANSCANAPREADY, |
|
264 "WlanWizardPageScanning::wlanScanApReady" ); |
|
265 |
|
266 WlanQtUtils* utils = mWizard->wlanQtUtils(); |
|
267 Q_ASSERT(utils); |
|
268 |
|
269 QList<QSharedPointer<WlanQtUtilsAp> > wlanApList; |
|
270 |
|
271 // Fetch the list of scan results. |
|
272 utils->availableWlanAps(wlanApList); |
|
273 |
|
274 qDebug("WlanWizardPageScanning::wlanScanApReady - results read"); |
|
275 |
|
276 QString ssid = |
|
277 mWizard->configuration(WlanWizardPrivate::ConfSsid).toString(); |
|
278 qDebug() << "SSID scanned by user " << ssid; |
|
279 |
|
280 bool matchFound = false; |
|
281 int strongestSignal = -1; |
|
282 int strongestIndex = 0; |
|
283 QSharedPointer<WlanQtUtilsAp> item; |
|
284 |
|
285 qDebug("%d APs found", wlanApList.size()); |
|
286 |
|
287 for (int i = 0; i < wlanApList.size(); i++) { |
|
288 // In case there are multiple matches to direct scan, use the |
|
289 // strongest signal on the result list. |
|
290 item = wlanApList.at(i); |
|
291 if (item->value(WlanQtUtilsAp::ConfIdSsid).toString() == ssid) { |
|
292 qDebug("Match found"); |
|
293 matchFound = true; |
|
294 |
|
295 int str = item->value(WlanQtUtilsAp::ConfIdSignalStrength).toInt(); |
|
296 if (str > strongestSignal) { |
|
297 qDebug("Strongest signal %d at %d", str, i); |
|
298 strongestSignal = str; |
|
299 strongestIndex = i; |
|
300 } |
|
301 } |
|
302 } |
|
303 |
|
304 if (matchFound) { |
|
305 qDebug("Select AP at %d", strongestIndex); |
|
306 item = wlanApList.at(strongestIndex); |
|
307 mNextPageId = mWizard->getNextPageId( |
|
308 item->value(WlanQtUtilsAp::ConfIdSsid).toString(), |
|
309 item->value(WlanQtUtilsAp::ConfIdConnectionMode).toInt(), |
|
310 item->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(), |
|
311 item->value(WlanQtUtilsAp::ConfIdWpaPskUse).toBool(), |
|
312 false, // public |
|
313 item->value(WlanQtUtilsAp::ConfIdWpsSupported).toBool()); |
|
314 // The ssid indicated by the user was found. Proceed to next page. |
|
315 mWizard->nextPage(); |
|
316 } |
|
317 else { |
|
318 qDebug("Match not found. Perform direct scan."); |
|
319 utils->scanWlanDirect(ssid); |
|
320 } |
|
321 |
|
322 } |
|
323 |
|
324 /*! |
|
325 * Overloaded function from WlanWizardPage. Indicates that this window requires |
|
326 * post-initialization start operations. |
|
327 */ |
|
328 bool WlanWizardPageScanning::requiresStartOperation() |
|
329 { |
|
330 return true; |
|
331 } |
|
332 |
|
333 /*! |
|
334 * Wlan scan is performed as a "post-initialization" which is executed in a |
|
335 * separate scheduler loop. |
|
336 */ |
|
337 void WlanWizardPageScanning::startOperation() |
|
338 { |
|
339 OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESCANNING_STARTOPERATION, |
|
340 "WlanWizardPageScanning::startOperation - start AP scan if results" |
|
341 " are available." ); |
|
342 |
|
343 if (mScanResultsAvailable) { |
|
344 mScanResultsAvailable = false; |
|
345 wlanScanApReady(); |
|
346 } |
|
347 } |
|
348 |
|