81 WlanSnifferEngine::WlanSnifferEngine(QObject *parent) : |
81 WlanSnifferEngine::WlanSnifferEngine(QObject *parent) : |
82 QObject(parent), |
82 QObject(parent), |
83 mService(new WlanSnifferService(this)), |
83 mService(new WlanSnifferService(this)), |
84 mSettingsManager(new XQSettingsManager(this)), |
84 mSettingsManager(new XQSettingsManager(this)), |
85 mScanTimerId(0), |
85 mScanTimerId(0), |
|
86 mScanEnabled(false), |
86 mEmbedded(false), |
87 mEmbedded(false), |
87 mWlanQtUtils(new WlanQtUtils()) |
88 mWlanQtUtils(new WlanQtUtils()) |
88 { |
89 { |
89 OstTraceFunctionEntry0(WLANSNIFFERENGINE_WLANSNIFFERENGINE_ENTRY); |
90 OstTraceFunctionEntry0(WLANSNIFFERENGINE_WLANSNIFFERENGINE_ENTRY); |
90 |
91 |
168 |
169 |
169 void WlanSnifferEngine::startWlanScanning() |
170 void WlanSnifferEngine::startWlanScanning() |
170 { |
171 { |
171 OstTraceFunctionEntry0(WLANSNIFFERENGINE_STARTWLANSCANNING_ENTRY); |
172 OstTraceFunctionEntry0(WLANSNIFFERENGINE_STARTWLANSCANNING_ENTRY); |
172 |
173 |
173 // A valid timer ID means scan is ON |
174 if (!mScanEnabled) { |
174 if (mScanTimerId == 0) { |
|
175 OstTrace0( |
175 OstTrace0( |
176 TRACE_NORMAL, |
176 TRACE_NORMAL, |
177 WLANSNIFFERENGINE_STARTWLANSCANNING, |
177 WLANSNIFFERENGINE_STARTWLANSCANNING, |
178 "WlanSnifferEngine::startWlanScanning Periodic WLAN scanning starting"); |
178 "WlanSnifferEngine::startWlanScanning Periodic WLAN scanning starting"); |
179 |
179 |
180 // Connect signal forwarding |
180 mScanEnabled = true; |
|
181 // Connect response signal |
181 bool connectStatus = connect( |
182 bool connectStatus = connect( |
182 mWlanQtUtils.data(), |
183 mWlanQtUtils.data(), |
183 SIGNAL(wlanScanReady()), |
184 SIGNAL(wlanScanReady(int)), |
184 this, |
185 this, |
185 SIGNAL(wlanScanReady())); |
186 SLOT(handleWlanScanReady(int))); |
186 Q_ASSERT(connectStatus); |
187 Q_ASSERT(connectStatus); |
187 |
188 |
188 // Start the first scan |
189 // Start the first scan. Scan timer is started when scan result |
|
190 // signal is received. |
189 mWlanQtUtils->scanWlans(); |
191 mWlanQtUtils->scanWlans(); |
190 |
|
191 // Start timer for the next scan |
|
192 mScanTimerId = startTimer(scanTimerInterval); |
|
193 |
|
194 // The timer start must succeed |
|
195 Q_ASSERT(mScanTimerId != 0); |
|
196 } |
192 } |
197 |
193 |
198 OstTraceFunctionExit0(WLANSNIFFERENGINE_STARTWLANSCANNING_EXIT); |
194 OstTraceFunctionExit0(WLANSNIFFERENGINE_STARTWLANSCANNING_EXIT); |
199 } |
195 } |
200 |
196 |
205 |
201 |
206 void WlanSnifferEngine::stopWlanScanning() |
202 void WlanSnifferEngine::stopWlanScanning() |
207 { |
203 { |
208 OstTraceFunctionEntry0(WLANSNIFFERENGINE_STOPWLANSCANNING_ENTRY); |
204 OstTraceFunctionEntry0(WLANSNIFFERENGINE_STOPWLANSCANNING_ENTRY); |
209 |
205 |
210 // A valid timer ID means scan is ON |
206 if (mScanEnabled) { |
211 if (mScanTimerId != 0) { |
|
212 OstTrace0( |
207 OstTrace0( |
213 TRACE_NORMAL, |
208 TRACE_NORMAL, |
214 WLANSNIFFERENGINE_STOPWLANSCANNING, |
209 WLANSNIFFERENGINE_STOPWLANSCANNING, |
215 "WlanSnifferEngine::stopWlanScanning Periodic WLAN scanning stopped"); |
210 "WlanSnifferEngine::stopWlanScanning Periodic WLAN scanning stopped"); |
216 |
211 |
217 // Disconnect signal forwarding |
212 mScanEnabled = false; |
|
213 // Disconnect response signal |
218 disconnect( |
214 disconnect( |
219 mWlanQtUtils.data(), |
215 mWlanQtUtils.data(), |
220 SIGNAL(wlanScanReady()), |
216 SIGNAL(wlanScanReady(int)), |
221 this, |
217 this, |
222 SIGNAL(wlanScanReady())); |
218 SLOT(handleWlanScanReady(int))); |
223 |
219 |
224 killTimer(mScanTimerId); |
220 if (mScanTimerId != 0) { |
225 mScanTimerId = 0; |
221 killTimer(mScanTimerId); |
|
222 mScanTimerId = 0; |
|
223 } |
226 } |
224 } |
227 |
225 |
228 OstTraceFunctionExit0(WLANSNIFFERENGINE_STOPWLANSCANNING_EXIT); |
226 OstTraceFunctionExit0(WLANSNIFFERENGINE_STOPWLANSCANNING_EXIT); |
229 } |
227 } |
230 |
228 |
415 emit masterWlanStatus(boolean); |
413 emit masterWlanStatus(boolean); |
416 } |
414 } |
417 |
415 |
418 OstTraceFunctionExit1(WLANSNIFFERENGINE_UPDATESETTING_EXIT, this); |
416 OstTraceFunctionExit1(WLANSNIFFERENGINE_UPDATESETTING_EXIT, this); |
419 } |
417 } |
|
418 |
|
419 /*! |
|
420 Slot for handling Wlan scan result. |
|
421 |
|
422 @param [in] status Scan status code. |
|
423 */ |
|
424 |
|
425 void WlanSnifferEngine::handleWlanScanReady(int status) |
|
426 { |
|
427 OstTraceFunctionEntry1(WLANSNIFFERENGINE_HANDLEWLANSCANREADY_ENTRY, this); |
|
428 |
|
429 OstTrace1( |
|
430 TRACE_NORMAL, |
|
431 WLANSNIFFERENGINE_HANDLEWLANSCANREADY, |
|
432 "WlanSnifferEngine::handleWlanScanReady;status=%d", |
|
433 status); |
|
434 |
|
435 // Forward result signal only, if there was no error |
|
436 if (status == WlanQtUtils::ScanStatusOk) { |
|
437 emit wlanScanReady(); |
|
438 } |
|
439 |
|
440 // Start timer for the next scan, if not running already |
|
441 if (mScanTimerId == 0) { |
|
442 mScanTimerId = startTimer(scanTimerInterval); |
|
443 // The timer start must succeed |
|
444 Q_ASSERT(mScanTimerId != 0); |
|
445 } |
|
446 |
|
447 OstTraceFunctionExit1(WLANSNIFFERENGINE_HANDLEWLANSCANREADY_EXIT, this); |
|
448 } |