wlanutilities/wlansniffer/wlansnifferkeepalive/inc/wsfkeepalive.h
branchRCL_3
changeset 25 f28ada11abbf
parent 24 63be7eb3fc78
equal deleted inserted replaced
24:63be7eb3fc78 25:f28ada11abbf
     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 * Main implementation of Wlan Sniffer Keepalive application.
       
    16 */
       
    17 
       
    18 #ifndef WSFKEEPALIVE_H
       
    19 #define WSFKEEPALIVE_H
       
    20 
       
    21 // System includes
       
    22  
       
    23 // User includes
       
    24 
       
    25 #include "wsfkeepalivetimer.h"
       
    26  
       
    27 // Forward declarations
       
    28 
       
    29 class CWsfKeepaliveCmm;
       
    30 class CWsfKeepaliveConnMon;
       
    31 class CWsfKeepaliveConnMonDisc;
       
    32 class CWsfKeepaliveEsock;
       
    33  
       
    34 // External data types
       
    35 
       
    36 // Global function prototypes
       
    37  
       
    38 // Constants
       
    39 
       
    40 // Class declaration
       
    41 
       
    42 /**
       
    43  *  Main implementation of Wlan Sniffer Keepalive application.
       
    44  *  
       
    45  *  This class contains the actual application logic, which monitors
       
    46  *  Wlan connections and keeps them alive, if needed.
       
    47  */
       
    48 class CWsfKeepalive : public CBase, public MWsfKeepaliveTimerNotify
       
    49     {
       
    50     // Friend classes:
       
    51     friend class CWsfKeepaliveTestSuite;
       
    52 
       
    53 public:
       
    54     
       
    55     // Data types
       
    56 
       
    57     // Constants
       
    58     
       
    59     /** Invalid/not available connection ID */
       
    60     static const TUint KInvalidConnectionId = 0;
       
    61 
       
    62     /** Constructors */
       
    63     
       
    64     /**
       
    65      * Two-phased constructor.
       
    66      * 
       
    67      * @return New object allocated from heap
       
    68      */
       
    69     static CWsfKeepalive* NewL();
       
    70     
       
    71     /**> Destructor */
       
    72     virtual ~CWsfKeepalive();
       
    73 
       
    74 public:
       
    75     
       
    76     /**
       
    77      * Timer expiration handler. Disconnects the monitored connection,
       
    78      * if needed. Restarts timer, if needed.
       
    79      *
       
    80      * @param aError Status of the timer event
       
    81      */
       
    82     void TimerExpired( TInt aError );
       
    83 
       
    84     /**
       
    85      * Wlan connection event handler. Shares and starts to monitor the
       
    86      * opened connection, if necessary.
       
    87      *
       
    88      * @param aConnectionId ID of the opened connection
       
    89      * @param aIapId IAP ID of the opened connection
       
    90      */
       
    91     void WlanConnectionOpenedL( TUint aConnectionId, TUint aIapId );
       
    92     
       
    93     /**
       
    94      * Wlan connection event handler. Stops monitoring the connection.
       
    95      */
       
    96     void WlanConnectionClosed();
       
    97 
       
    98 protected:
       
    99     
       
   100 private:
       
   101     
       
   102     CWsfKeepalive();
       
   103 
       
   104     void ConstructL();
       
   105     
       
   106     TBool OpenedByWlanSniffer( TUint aConnectionId );
       
   107     
       
   108     TBool NoRealClients( TUint aConnectionId );
       
   109     
       
   110     void SetState( TUint aState );
       
   111         
       
   112 private: // Data
       
   113 
       
   114     // Constants
       
   115 
       
   116     /**
       
   117      * State values for the keepalive implementation
       
   118      */
       
   119     enum
       
   120         {
       
   121         /** Not monitoring any connection */
       
   122         EInactive,
       
   123         /** Monitoring connection, which has no real clients */
       
   124         EActiveNoClients,
       
   125         /** Monitoring connection, which has one or more real clients */
       
   126         EActiveWithClients
       
   127         };
       
   128     
       
   129     /**
       
   130      * Timer for polling users of a connection
       
   131      */
       
   132     CWsfKeepaliveTimer* iTimer;
       
   133 
       
   134     /**
       
   135      * Connection Method Manager class reference
       
   136      */
       
   137     CWsfKeepaliveCmm* iCmMgr;
       
   138     
       
   139     /**
       
   140      * Connection Monitor class reference
       
   141      */
       
   142     CWsfKeepaliveConnMon* iConnMon;
       
   143 
       
   144     /**
       
   145      * Connection Disconnector class reference
       
   146      */
       
   147     CWsfKeepaliveConnMonDisc* iConnMonDisc;
       
   148     
       
   149     /**
       
   150      * RConnection handler class reference
       
   151      */
       
   152     CWsfKeepaliveEsock* iEsock;
       
   153     
       
   154     /**
       
   155      * Time when keepalive started for monitored connection
       
   156      */
       
   157     TTime iKeepaliveStart;
       
   158     
       
   159     /**
       
   160      * ID of monitored connection, KInvalidConnectionId if not valid
       
   161      */
       
   162     TUint iConnectionId;
       
   163 
       
   164     /**
       
   165      * State of the keepalive implementation
       
   166      */
       
   167     TUint iState;
       
   168     
       
   169     /**
       
   170      * IapId of the connection
       
   171      */
       
   172     TUint iIapId;
       
   173     };
       
   174 
       
   175 #endif // WSFKEEPALIVE_H