56 Constructor. |
56 Constructor. |
57 */ |
57 */ |
58 WlanLoginEngine::WlanLoginEngine(QObject *parent): |
58 WlanLoginEngine::WlanLoginEngine(QObject *parent): |
59 QObject(parent), |
59 QObject(parent), |
60 mEngineState(WaitingForStart), |
60 mEngineState(WaitingForStart), |
61 mServiceRequestCompleted(false), |
61 mStartRequestCompleted(false), |
62 mNetConfigurationManager(new QNetworkConfigurationManager(this)), |
62 mNetConfigurationManager(new QNetworkConfigurationManager(this)), |
63 mNetworkAccessManager(new WlanLoginNetworkAccessManager(this)), |
63 mNetworkAccessManager(new WlanLoginNetworkAccessManager(this)), |
64 mNetworkSession(NULL), |
64 mNetworkSession(NULL), |
65 mIctsWrapper(NULL), |
65 mIctsWrapper(NULL), |
66 mIctsFirstRun(true), |
66 mIctsFirstRun(true), |
101 |
101 |
102 @return Pointer to WlanLoginNetworkAccessManager |
102 @return Pointer to WlanLoginNetworkAccessManager |
103 */ |
103 */ |
104 WlanLoginNetworkAccessManager* WlanLoginEngine::networkAccessManager() const |
104 WlanLoginNetworkAccessManager* WlanLoginEngine::networkAccessManager() const |
105 { |
105 { |
|
106 OstTraceFunctionEntry0(WLANLOGINENGINE_NETWORKACCESSMANAGER_ENTRY); |
|
107 OstTraceFunctionExit0(WLANLOGINENGINE_NETWORKACCESSMANAGER_EXIT); |
|
108 |
106 return mNetworkAccessManager; |
109 return mNetworkAccessManager; |
|
110 |
107 } |
111 } |
108 |
112 |
109 |
113 |
110 /*! |
114 /*! |
111 Function that returns current state of the engine. |
115 Function that returns current state of the engine. |
112 |
116 |
113 @return engine state |
117 @return engine state |
114 */ |
118 */ |
115 WlanLoginEngine::EngineState WlanLoginEngine::engineState() |
119 WlanLoginEngine::EngineState WlanLoginEngine::engineState() |
116 { |
120 { |
117 return mEngineState; |
121 OstTraceFunctionEntry0(WLANLOGINENGINE_ENGINESTATE_ENTRY); |
|
122 OstTraceFunctionExit0(WLANLOGINENGINE_ENGINESTATE_EXIT); |
|
123 |
|
124 return mEngineState; |
118 } |
125 } |
119 |
126 |
120 |
127 |
121 /*! |
128 /*! |
122 Function that sets the current state of the engine. |
129 Function that sets the current state of the engine. |
123 |
130 |
124 @param [in] newState New state of the engine to be set |
131 @param [in] newState New state of the engine to be set |
125 */ |
132 */ |
126 void WlanLoginEngine::setEngineState(WlanLoginEngine::EngineState newState) |
133 void WlanLoginEngine::setEngineState(WlanLoginEngine::EngineState newState) |
127 { |
134 { |
|
135 OstTraceFunctionEntry0(WLANLOGINENGINE_SETENGINESTATE_ENTRY); |
|
136 |
128 mEngineState = newState; |
137 mEngineState = newState; |
|
138 OstTrace1( |
|
139 TRACE_NORMAL, |
|
140 WLANLOGINENGINE_SETENGINESTATE_STATE_TRACE, |
|
141 "WlanLoginEngine::setEngineState;mEngineState=%d", |
|
142 mEngineState); |
|
143 |
|
144 OstTraceFunctionExit0(WLANLOGINENGINE_SETENGINESTATE_EXIT); |
129 } |
145 } |
130 |
146 |
131 |
147 |
132 /*! |
148 /*! |
133 This slot handles startLogin signal from Qt Highway service provider |
149 This slot handles startLogin signal from Qt Highway service provider |
211 OstTraceFunctionEntry0(WLANLOGINENGINE_HANDLEUPDATECOMPLETED_ENTRY); |
227 OstTraceFunctionEntry0(WLANLOGINENGINE_HANDLEUPDATECOMPLETED_ENTRY); |
212 |
228 |
213 //States of the available configurations are now updated and |
229 //States of the available configurations are now updated and |
214 //we can open the network session to provided IAP |
230 //we can open the network session to provided IAP |
215 |
231 |
216 openSession(); |
232 //Check that cancel has not been pressed |
217 |
233 if (engineState() != WaitingForStopRequest) { |
|
234 openSession(); |
|
235 } |
|
236 |
218 OstTraceFunctionExit0(WLANLOGINENGINE_HANDLEUPDATECOMPLETED_EXIT); |
237 OstTraceFunctionExit0(WLANLOGINENGINE_HANDLEUPDATECOMPLETED_EXIT); |
219 } |
238 } |
220 |
239 |
221 /*! |
240 /*! |
222 This function handles opening of the network session to the specified IAP. |
241 This function handles opening of the network session to the specified IAP. |
310 */ |
329 */ |
311 void WlanLoginEngine::handleSessionOpened() |
330 void WlanLoginEngine::handleSessionOpened() |
312 { |
331 { |
313 OstTraceFunctionEntry0(WLANLOGINENGINE_HANDLESESSIONOPENED_ENTRY); |
332 OstTraceFunctionEntry0(WLANLOGINENGINE_HANDLESESSIONOPENED_ENTRY); |
314 |
333 |
315 setEngineState(NetworkSessionOpened); |
334 //Check that cancel has not been pressed |
316 //Send indication to view that connection is ready |
335 if (engineState() != WaitingForStopRequest) { |
317 emit connectionReady(mRedirectionUrl); |
336 setEngineState(NetworkSessionOpened); |
|
337 //Send indication to view that connection is ready |
|
338 emit connectionReady(mRedirectionUrl); |
|
339 } |
318 |
340 |
319 OstTraceFunctionExit0(WLANLOGINENGINE_HANDLESESSIONOPENED_EXIT); |
341 OstTraceFunctionExit0(WLANLOGINENGINE_HANDLESESSIONOPENED_EXIT); |
320 } |
342 } |
321 |
343 |
322 |
344 |
356 case OpeningNetworkSession: |
378 case OpeningNetworkSession: |
357 showConnectionDroppedMessageBox(); |
379 showConnectionDroppedMessageBox(); |
358 break; |
380 break; |
359 |
381 |
360 case NetworkSessionOpened: |
382 case NetworkSessionOpened: |
361 case IctsRan: |
383 case IctsOk: |
|
384 case IctsFailed: |
362 if (error == QNetworkSession::SessionAbortedError ) { |
385 if (error == QNetworkSession::SessionAbortedError ) { |
363 showConnectionDroppedMessageBox(); |
386 showConnectionDroppedMessageBox(); |
364 } |
387 } |
365 break; |
388 break; |
366 |
389 |
419 { |
442 { |
420 OstTraceFunctionEntry0(WLANLOGINENGINE_HANDLECONNECTIVITYTESTRESULT_ENTRY); |
443 OstTraceFunctionEntry0(WLANLOGINENGINE_HANDLECONNECTIVITYTESTRESULT_ENTRY); |
421 |
444 |
422 Q_UNUSED(redirectUrl); |
445 Q_UNUSED(redirectUrl); |
423 |
446 |
424 setEngineState(IctsRan); |
|
425 mIctsFirstRun = false; |
447 mIctsFirstRun = false; |
426 |
448 |
427 if (result == IctsWrapper::ConnectionOk){ |
449 if (result == IctsWrapper::ConnectionOk){ |
|
450 setEngineState(IctsOk); |
428 emit ictsOk(); |
451 emit ictsOk(); |
|
452 } else { |
|
453 setEngineState(IctsFailed); |
429 } |
454 } |
430 |
455 |
431 OstTraceFunctionExit0(WLANLOGINENGINE_HANDLECONNECTIVITYTESTRESULT_EXIT); |
456 OstTraceFunctionExit0(WLANLOGINENGINE_HANDLECONNECTIVITYTESTRESULT_EXIT); |
432 } |
457 } |
433 |
458 |
437 */ |
462 */ |
438 void WlanLoginEngine::handleCancelTriggered() |
463 void WlanLoginEngine::handleCancelTriggered() |
439 { |
464 { |
440 OstTraceFunctionEntry0(WLANLOGINENGINE_HANDLECANCELTRIGGERED_ENTRY); |
465 OstTraceFunctionEntry0(WLANLOGINENGINE_HANDLECANCELTRIGGERED_ENTRY); |
441 |
466 |
442 //Stop ICTS if it is running: |
467 //Check if Qt Highway request is completed |
443 if (engineState() == RunningIcts) { |
468 if (mStartRequestCompleted == false){ |
444 stopIcts(); |
469 |
445 if (mIctsFirstRun) { |
470 switch (engineState()) { |
446 emitCompleteServiceRequest(WlanLoginService::WlanLoginStatusCancel); |
471 |
447 } else { |
472 case UpdatingNetworkConfigurations: |
448 //Previous ICTS must have failed as cancel action can't be selected from UI if |
473 case OpeningNetworkSession: |
449 //it has passed |
474 case NetworkSessionOpened: |
450 emitCompleteServiceRequest(WlanLoginService::WlanLoginStatusFailed); |
475 setEngineState(WaitingForStopRequest); |
451 } |
476 emitCompleteServiceRequest(WlanLoginService::WlanLoginStatusCancel); |
452 } else if (engineState() == IctsRan) { |
477 break; |
453 //ICTS must have failed as cancel action can't be selected from UI if |
478 |
454 //it has passed |
479 case RunningIcts: |
455 emitCompleteServiceRequest(WlanLoginService::WlanLoginStatusFailed); |
480 stopIcts(); |
|
481 setEngineState(WaitingForStopRequest); |
|
482 if (mIctsFirstRun) { |
|
483 emitCompleteServiceRequest(WlanLoginService::WlanLoginStatusCancel); |
|
484 } else { |
|
485 emitCompleteServiceRequest(WlanLoginService::WlanLoginStatusFailed); |
|
486 } |
|
487 break; |
|
488 |
|
489 case IctsFailed: |
|
490 setEngineState(WaitingForStopRequest); |
|
491 emitCompleteServiceRequest(WlanLoginService::WlanLoginStatusFailed); |
|
492 break; |
|
493 |
|
494 default: |
|
495 break; |
|
496 } |
456 } else { |
497 } else { |
457 //ICTS not run yet |
498 //Check race condition |
458 emitCompleteServiceRequest(WlanLoginService::WlanLoginStatusCancel); |
499 if(engineState() != WaitingForStopRequest) { |
|
500 qApp->exit(); |
|
501 } |
459 } |
502 } |
460 |
503 |
461 OstTraceFunctionExit0(WLANLOGINENGINE_HANDLECANCELTRIGGERED_EXIT); |
504 OstTraceFunctionExit0(WLANLOGINENGINE_HANDLECANCELTRIGGERED_EXIT); |
462 } |
505 } |
463 |
506 |
466 |
509 |
467 */ |
510 */ |
468 void WlanLoginEngine::handleNextTriggered() |
511 void WlanLoginEngine::handleNextTriggered() |
469 { |
512 { |
470 OstTraceFunctionEntry0(WLANLOGINENGINE_HANDLENEXTTRIGGERED_ENTRY); |
513 OstTraceFunctionEntry0(WLANLOGINENGINE_HANDLENEXTTRIGGERED_ENTRY); |
471 |
514 |
472 emitCompleteServiceRequest(WlanLoginService::WlanLoginStatusNext); |
515 if (mStartRequestCompleted == false ) { |
|
516 emitCompleteServiceRequest(WlanLoginService::WlanLoginStatusNext); |
|
517 } |
473 |
518 |
474 //put application to background: |
519 //put application to background: |
475 WlanLoginApplication* app = static_cast<WlanLoginApplication *>(this->parent()); |
520 WlanLoginApplication* app = static_cast<WlanLoginApplication *>(this->parent()); |
476 app->mainWindow()->lower(); |
521 app->mainWindow()->lower(); |
477 |
522 |
478 OstTraceFunctionExit0(WLANLOGINENGINE_HANDLENEXTTRIGGERED_EXIT); |
523 OstTraceFunctionExit0(WLANLOGINENGINE_HANDLENEXTTRIGGERED_EXIT); |
479 } |
|
480 |
|
481 /*! |
|
482 This slot handles continueTriggered signal from the view |
|
483 |
|
484 */ |
|
485 void WlanLoginEngine::handleContinueTriggered() |
|
486 { |
|
487 OstTraceFunctionEntry0(WLANLOGINENGINE_HANDLECONTINUETRIGGERED_ENTRY); |
|
488 |
|
489 //put application to background: |
|
490 WlanLoginApplication* app = static_cast<WlanLoginApplication *>(this->parent()); |
|
491 app->mainWindow()->lower(); |
|
492 |
|
493 OstTraceFunctionExit0(WLANLOGINENGINE_HANDLECONTINUETRIGGERED_EXIT); |
|
494 } |
524 } |
495 |
525 |
496 /*! |
526 /*! |
497 This function shows connection dropped message box to the user |
527 This function shows connection dropped message box to the user |
498 |
528 |
513 { |
543 { |
514 OstTraceFunctionEntry0(WLANLOGINENGINE_HANDLEMESSAGEBOXCLOSED_ENTRY); |
544 OstTraceFunctionEntry0(WLANLOGINENGINE_HANDLEMESSAGEBOXCLOSED_ENTRY); |
515 |
545 |
516 Q_UNUSED(action); |
546 Q_UNUSED(action); |
517 |
547 |
518 if (mServiceRequestCompleted == false ) { |
548 if (mStartRequestCompleted == false ) { |
519 emitCompleteServiceRequest(WlanLoginService::WlanLoginStatusConnectionDropped); |
549 emitCompleteServiceRequest(WlanLoginService::WlanLoginStatusConnectionDropped); |
520 |
550 |
521 } else { |
551 } else { |
522 //If Qt Highway service request is already completed when connection drops, we have to make exit by our own |
552 //If Qt Highway service request is already completed when connection drops, we have to make exit by our own |
523 qApp->exit(); |
553 qApp->exit(); |
524 } |
554 } |
525 |
555 |
526 OstTraceFunctionEntry0(WLANLOGINENGINE_HANDLEMESSAGEBOXCLOSED_EXIT); |
556 OstTraceFunctionExit0(WLANLOGINENGINE_HANDLEMESSAGEBOXCLOSED_EXIT); |
527 } |
557 } |
528 |
558 |
529 /*! |
559 /*! |
530 This function completes Qt Highway service request |
560 This function completes Qt Highway service request |
531 @param [in] status completeing status of the service request |
561 @param [in] status completeing status of the service request |
532 */ |
562 */ |
533 void WlanLoginEngine::emitCompleteServiceRequest(WlanLoginService::WlanLoginStatus status ) |
563 void WlanLoginEngine::emitCompleteServiceRequest(WlanLoginService::WlanLoginStatus status ) |
534 { |
564 { |
535 OstTraceFunctionEntry0(WLANLOGINENGINE_EMITCOMPLETESERVICEREQUEST_ENTRY); |
565 OstTraceFunctionEntry0(WLANLOGINENGINE_EMITCOMPLETESERVICEREQUEST_ENTRY); |
536 |
566 |
537 mServiceRequestCompleted = true; |
567 mStartRequestCompleted = true; |
538 OstTrace1( |
568 OstTrace1( |
539 TRACE_BORDER, |
569 TRACE_BORDER, |
540 WLANLOGINENGINE_EMITCOMPLETESERVICEREQUEST_EMIT_TRACE, |
570 WLANLOGINENGINE_EMITCOMPLETESERVICEREQUEST_EMIT_TRACE, |
541 "WlanLoginEngine::emitCompleteServiceRequest with status:;status=%d", |
571 "WlanLoginEngine::emitCompleteServiceRequest with status:;status=%d", |
542 status); |
572 status); |