wlanutilities/wlanlogin/wlanloginapp/inc/wlanloginengine.h
branchRCL_3
changeset 24 63be7eb3fc78
equal deleted inserted replaced
23:b852595f5cbe 24:63be7eb3fc78
       
     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  * Engine of Wlan Login application.
       
    16  */
       
    17 
       
    18 #ifndef WLANLOGINENGINE_H
       
    19 #define WLANLOGINENGINE_H
       
    20 
       
    21 // System includes
       
    22 #include <QObject>
       
    23 #include <HbAction>
       
    24 
       
    25 // User includes
       
    26 #include "qnetworkconfigmanager.h"
       
    27 #include "qnetworkconfiguration.h"
       
    28 #include "qnetworksession.h"
       
    29 #include "wlanloginservice.h"
       
    30 #include "ictsqtwrapper.h"
       
    31 #include "wlanloginnetworkaccessmanager.h"
       
    32 
       
    33 // Forward declarations
       
    34 
       
    35 // External data types
       
    36 
       
    37 // Constants
       
    38 
       
    39 /*!
       
    40     Total polling time for ICTS in microseconds
       
    41 */ 
       
    42 const int totalPollingTime = 20000000;
       
    43 
       
    44 /*!
       
    45     Polling interval time for ICTS in microseconds
       
    46 */ 
       
    47 const int pollingInterval = 4000000;
       
    48 
       
    49 /*!
       
    50     Message box time out value in milliseconds
       
    51 */ 
       
    52 const int messageBoxTimeout = 3000;
       
    53 
       
    54 
       
    55 QTM_USE_NAMESPACE
       
    56 
       
    57 // Class declaration
       
    58 class WlanLoginEngine : public QObject
       
    59     {
       
    60     Q_OBJECT
       
    61 
       
    62 public:
       
    63     
       
    64     /*!
       
    65         Enumeration type for storing current engine state
       
    66     */ 
       
    67     enum EngineState { 
       
    68         WaitingForStart = 0, //!< Engine waiting start from Qt Highway
       
    69         UpdatingNetworkConfigurations, //!< Engine is updating netowk configuration states
       
    70         OpeningNetworkSession, //!< Engine is opening network session
       
    71         NetworkSessionOpened, //!< Network session is opened by engine
       
    72         RunningIcts, //!< Internet connectivity test ongoing
       
    73         IctsFailed, //!< Internet connectivity test has failed
       
    74         IctsOk, //!< Internet connectivity test has been ran successfully
       
    75         WaitingForStopRequest, //!< Waiting for stop service request
       
    76     };
       
    77     
       
    78     explicit WlanLoginEngine(QObject *parent = 0);
       
    79     ~WlanLoginEngine();
       
    80 
       
    81     void openSession();
       
    82     void stopIcts();
       
    83     void showConnectionDroppedMessageBox();
       
    84     void emitCompleteServiceRequest(WlanLoginService::WlanLoginStatus status);    
       
    85     WlanLoginNetworkAccessManager* networkAccessManager() const;
       
    86     EngineState engineState();
       
    87     void setEngineState(EngineState newState);
       
    88     
       
    89 signals:
       
    90     void completeServiceRequest(int status);
       
    91     void connectionReady(QUrl url);
       
    92     void ictsOk();    
       
    93     
       
    94 private slots:
       
    95     void handleStartLogin(int iapId, int netId, QUrl redirectionUrl);
       
    96     void handleStopLogin();
       
    97     void handleUpdateCompleted();
       
    98     void handleSessionOpened();   
       
    99 
       
   100     void handleSessionStateChanged(QNetworkSession::State newState);
       
   101     void handleSessionError(QNetworkSession::SessionError error);
       
   102     void connectionDroppedMessageBoxClosed(HbAction* action);
       
   103 
       
   104     void handleStartIcts();
       
   105     void handleConnectivityTestResult(IctsWrapper::ConnectivityTestResult result, QUrl redirectUrl);
       
   106     void handleCancelTriggered();
       
   107     void handleNextTriggered();
       
   108     
       
   109 private: // Data
       
   110     
       
   111     // Not owned data
       
   112 
       
   113     // Owned data
       
   114     EngineState mEngineState; //!< current state of the Engine
       
   115     bool mStartRequestCompleted; //!<  Variable for storing service request state
       
   116     QNetworkConfigurationManager* mNetConfigurationManager; //!< pointer to network configuration manager 
       
   117     WlanLoginNetworkAccessManager* mNetworkAccessManager; //!< pointer to network access manager
       
   118     QNetworkSession* mNetworkSession; //!< pointer to network session
       
   119     IctsWrapper* mIctsWrapper; //!< pointer to ICTS client wrapper
       
   120     bool mIctsFirstRun; //!< Flag to check if we are running ICTS first time
       
   121     int mIap; //!< IAP that was provided in startup
       
   122     int mNetId; //!< network ID that was provided in startup
       
   123     QUrl mRedirectionUrl; //!< redirection URL that was provided in startup
       
   124     };
       
   125 
       
   126 #endif // WLANLOGINENGINE_H