wlanutilities/wlanlogin/wlanloginapp/src/wlanloginengine.cpp
changeset 62 b47b808de481
parent 56 de27cc8389dd
equal deleted inserted replaced
58:301aeb18ae47 62:b47b808de481
    23 #include <HbMessagebox>
    23 #include <HbMessagebox>
    24 #include <HbAction>
    24 #include <HbAction>
    25 #include <qnetworkconfigmanager.h>
    25 #include <qnetworkconfigmanager.h>
    26 #include <qnetworkconfiguration.h>
    26 #include <qnetworkconfiguration.h>
    27 #include <qnetworksession.h>
    27 #include <qnetworksession.h>
       
    28 #include <apgtask.h>
    28 
    29 
    29 //User includes
    30 //User includes
    30 #include "wlanloginengine.h"
    31 #include "wlanloginengine.h"
    31 #include "wlanloginapplication.h"
    32 #include "wlanloginapplication.h"
    32 #include "wlanloginmainwindow.h"
    33 #include "wlanloginmainwindow.h"
   142         mEngineState);
   143         mEngineState);
   143     
   144     
   144     OstTraceFunctionExit0(WLANLOGINENGINE_SETENGINESTATE_EXIT);
   145     OstTraceFunctionExit0(WLANLOGINENGINE_SETENGINESTATE_EXIT);
   145 }
   146 }
   146 
   147 
       
   148 /*!
       
   149     Function that brings WLAN Sniffer to foreground
       
   150     
       
   151     @param [in] newState New state of the engine to be set
       
   152  */
       
   153 bool WlanLoginEngine::bringSnifferToForeground()
       
   154 {
       
   155     OstTraceFunctionEntry0(WLANLOGINENGINE_BRINGSNIFFERTOFOREGROUND_ENTRY);
       
   156 
       
   157     bool retVal = false;
       
   158     RWsSession wsSession;
       
   159 
       
   160     if(KErrNone != wsSession.Connect()){
       
   161         OstTrace0(TRACE_NORMAL, 
       
   162         WLANLOGINENGINE_BRINGSNIFFERTOFOREGROUND_WS_SESSION_FAILED, 
       
   163         "WARNING: Session could not be opened to Window server");
       
   164         
       
   165     } else {
       
   166         TApaTaskList taskList(wsSession);
       
   167         //Find WLAN Sniffer's task by using it's UID as reference
       
   168         TApaTask task = taskList.FindApp(TUid::Uid(0x10281CAA));
       
   169      
       
   170         if(task.Exists())
       
   171         {
       
   172             task.BringToForeground();
       
   173             retVal = true;
       
   174         } else {
       
   175             OstTrace0(TRACE_NORMAL, 
       
   176             WLANLOGINENGINE_BRINGSNIFFERTOFOREGROUND_TASK_NOT_FOUND,
       
   177             "WARNING: WLAN Sniffer was not found from the task list");
       
   178         }
       
   179         wsSession.Close();       
       
   180     }
       
   181     OstTraceFunctionExit0(WLANLOGINENGINE_BRINGSNIFFERTOFOREGROUND_EXIT);
       
   182 
       
   183     return retVal;
       
   184 }
       
   185 
   147 
   186 
   148 /*!
   187 /*!
   149     This slot handles startLogin signal from Qt Highway service provider
   188     This slot handles startLogin signal from Qt Highway service provider
   150     
   189     
   151     @param [in] iapId Internet access point ID for a connection that we should attach to'
   190     @param [in] iapId Internet access point ID for a connection that we should attach to'
   463 void WlanLoginEngine::handleCancelTriggered()
   502 void WlanLoginEngine::handleCancelTriggered()
   464 {
   503 {
   465     OstTraceFunctionEntry0(WLANLOGINENGINE_HANDLECANCELTRIGGERED_ENTRY);
   504     OstTraceFunctionEntry0(WLANLOGINENGINE_HANDLECANCELTRIGGERED_ENTRY);
   466     
   505     
   467     //Check if Qt Highway request is completed
   506     //Check if Qt Highway request is completed
   468      if (mStartRequestCompleted == false){
   507      if (mStartRequestCompleted == false) {
   469         
   508         
       
   509          if (!bringSnifferToForeground()) {
       
   510              //WLAN Sniffer was not found so make exit as there is nobody to close us
       
   511              qApp->exit();
       
   512          }
       
   513          
   470          switch (engineState()) {
   514          switch (engineState()) {
   471             
   515             
   472          case UpdatingNetworkConfigurations:
   516          case UpdatingNetworkConfigurations:
   473          case OpeningNetworkSession:
   517          case OpeningNetworkSession:
   474          case NetworkSessionOpened:
   518          case NetworkSessionOpened:
   510  */
   554  */
   511 void WlanLoginEngine::handleNextTriggered()
   555 void WlanLoginEngine::handleNextTriggered()
   512 {
   556 {
   513     OstTraceFunctionEntry0(WLANLOGINENGINE_HANDLENEXTTRIGGERED_ENTRY);
   557     OstTraceFunctionEntry0(WLANLOGINENGINE_HANDLENEXTTRIGGERED_ENTRY);
   514 
   558 
   515     if (mStartRequestCompleted == false ) {    
   559     if (mStartRequestCompleted == false ) {
   516         emitCompleteServiceRequest(WlanLoginService::WlanLoginStatusNext);
   560         if (bringSnifferToForeground()) {
   517     }
   561             emitCompleteServiceRequest(WlanLoginService::WlanLoginStatusNext);
   518     
   562         } else {
   519     //put application to background:
   563             qApp->exit();
   520     WlanLoginApplication* app = static_cast<WlanLoginApplication *>(this->parent());    
   564         }
   521     app->mainWindow()->lower();
   565     } else {
   522     
   566         //put application to background:
       
   567         WlanLoginApplication* app = static_cast<WlanLoginApplication *>(this->parent());    
       
   568         app->mainWindow()->lower();
       
   569     }
   523     OstTraceFunctionExit0(WLANLOGINENGINE_HANDLENEXTTRIGGERED_EXIT);
   570     OstTraceFunctionExit0(WLANLOGINENGINE_HANDLENEXTTRIGGERED_EXIT);
   524 }
   571 }
       
   572 
   525 
   573 
   526 /*!
   574 /*!
   527     This function shows connection dropped message box to the user
   575     This function shows connection dropped message box to the user
   528         
   576         
   529  */
   577  */