wlanutilities/wlansniffer/engine/client/inc/wsfsession.h
branchRCL_3
changeset 25 f28ada11abbf
equal deleted inserted replaced
24:63be7eb3fc78 25:f28ada11abbf
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:   Class header for RWsfSession
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 #ifndef R_WSFSESSION_H
       
    23 #define R_WSFSESSION_H
       
    24 
       
    25 //  EXTERNAL INCLUDES
       
    26 #include <e32base.h>
       
    27 
       
    28 //  INTERNAL INCLUDES
       
    29 #include "wsfcommon.h"
       
    30 
       
    31 
       
    32 //  FORWARD DECLARATIONS
       
    33 class CWsfWlanInfoArray;
       
    34 class CWsfEventHandler;
       
    35 class MWsfStateChangeObserver;
       
    36 class TWsfWlanInfo;
       
    37 class CWsfActiveWaiter;
       
    38 
       
    39 
       
    40 //  CLASS DEFINITION
       
    41 /**
       
    42  * Client-side handle to server session
       
    43  *
       
    44  * RWsfSession is the client-side session of a connection to the server. 
       
    45  * It provides an interface through which the different scanning services 
       
    46  * can be reached and results obtained.
       
    47  *
       
    48  * @lib wsfclient.lib
       
    49  * @since S60 5.0
       
    50  */
       
    51 NONSHARABLE_CLASS( RWsfSession ): public RSessionBase
       
    52     {
       
    53         friend class CWsfEventHandler;    
       
    54 
       
    55 
       
    56     public:     // Constructor
       
    57 
       
    58         IMPORT_C RWsfSession();
       
    59 
       
    60 
       
    61     public:     // New methods
       
    62 
       
    63         /**
       
    64         * Initiates a connection to the server and also launches it 
       
    65         * if it was not running yet.
       
    66         * @since S60 5.0
       
    67         */
       
    68         IMPORT_C TInt Connect();
       
    69         
       
    70         /**
       
    71         * Returns the version number of the session class
       
    72         * @since S60 5.0
       
    73         * @return A version structure
       
    74         */
       
    75         inline TVersion Version() const;
       
    76         
       
    77         /**
       
    78         * Closes this session.
       
    79         * @since S60 5.0
       
    80         */    
       
    81         IMPORT_C void Close();
       
    82 
       
    83         /**
       
    84         * Subscribes to server events
       
    85         * @since S60 5.0
       
    86         * @param aObserver The object which should be notified on event
       
    87         */
       
    88         IMPORT_C void NotifyEventL( MWsfStateChangeObserver& aObserver );
       
    89         
       
    90         /**
       
    91         * Cancels the subscription
       
    92         * @since S60 5.0
       
    93         */ 
       
    94         IMPORT_C void CancelNotifyEvent();
       
    95 
       
    96         /**
       
    97         * Sets the wlan scanning on if not already active
       
    98         * @since S60 5.0
       
    99         * @return ETrue on success.
       
   100         */ 
       
   101         IMPORT_C TBool EnableScanL();
       
   102 
       
   103         /**
       
   104         * Disables the scanning 
       
   105         * @since S60 5.0
       
   106         * @return ETrue on success.
       
   107         */
       
   108         IMPORT_C TBool DisableScanL();
       
   109 
       
   110         /**
       
   111         * Queries the current scanning status.
       
   112         * @since S60 5.0
       
   113         * @return ETrue if scanning is enabled, EFalse otherwise.    
       
   114         */
       
   115         IMPORT_C TBool IsScanEnabledL();
       
   116         
       
   117         /**
       
   118         * Requests the scan results from the server 
       
   119         * @since S60 5.0
       
   120         * @param aInfoArray Array for the scan results. Ownership not changed.
       
   121         */ 
       
   122         IMPORT_C void UpdateWlanListL( CWsfWlanInfoArray* aInfoArray );
       
   123         
       
   124         /**
       
   125         * Asyncronous request to the server to return wlan list size
       
   126         * @since S60 5.2
       
   127         * @param aPckg request result
       
   128         * @param aStatus The request status object used to contain 
       
   129         *        the completion status of the request.
       
   130         */
       
   131         IMPORT_C void GetWlanListSize( TPckgBuf<TUint>& aPckg, 
       
   132                                        TRequestStatus& aStatus );
       
   133 
       
   134         
       
   135         /**
       
   136         * Asyncronous request to the server to return wlan list
       
   137         * @since S60 5.2
       
   138         * @param aPckg request result
       
   139 		* @param aPtr wlan list
       
   140         * @param aStatus The request status object used to contain 
       
   141         *        the completion status of the request.
       
   142         */
       
   143         IMPORT_C void GetWlanList( TPckgBuf<TUint>& aPckg, TPtr8& aPtr, 
       
   144                                    TRequestStatus& aStatus );
       
   145 
       
   146         /**
       
   147         * Cancel all pending tasks.
       
   148         * @since S60 5.0
       
   149         */
       
   150         IMPORT_C void CancelAll();
       
   151 
       
   152         /**
       
   153         * Return the connected wlan network name
       
   154         * @since S60 5.0
       
   155         * @return The connected account name, or NULL if not connected
       
   156         */ 
       
   157         IMPORT_C HBufC* ConnectedAccountNameL();
       
   158 
       
   159         /**
       
   160         * Return the connected wlan's details
       
   161         * @since S60 5.0
       
   162         * @param aWlanInfo The wlaninfo object to fill
       
   163         * @return ETrue if success, EFalse otherwise
       
   164         */ 
       
   165         IMPORT_C TBool GetConnectedWlanDetailsL( TWsfWlanInfo& aWlanInfo );
       
   166         
       
   167         /**
       
   168         * Asyncronous request to the server to return connected wlan network
       
   169         * @since S60 5.2
       
   170         * @param aPckg request result
       
   171         * @param aWlanInfo The wlaninfo object to fill
       
   172         * @param aStatus The request status object used to contain 
       
   173         *        the completion status of the request.
       
   174         */
       
   175         IMPORT_C void GetConnectedWlanDetails( TPckgBuf<TBool>& aPckg,
       
   176                                                TWsfWlanInfo& aWlanInfo,
       
   177                                                TRequestStatus& aStatus );
       
   178         
       
   179         /**
       
   180         * Start monitoring events for the specified access point
       
   181         * @since S60 5.0
       
   182         * @param aMonitoredIap The id of the IAP to be monitored
       
   183         */
       
   184         IMPORT_C void MonitorAccessPointL( TUint32 aMonitoredIap );
       
   185         
       
   186         /**
       
   187         * Connect to the given WLAN IAP. The function requests the server, 
       
   188         * then starts a synchronous wait until the connection is established.
       
   189         * @since S60 5.0
       
   190         * @param aIapId The id of the IAP to connect to
       
   191         * @param aConnectOnly ETrue if Connect selected
       
   192         * @param aPersistence The value of the persistence property
       
   193         * @return KErrNone if managed to connect, otherwise error code
       
   194         */
       
   195         IMPORT_C TInt ConnectWlanBearerL( TUint32 aIapId, 
       
   196                                           TBool aConnectOnly,
       
   197                            TWsfIapPersistence aPersistence = EIapPersistent );
       
   198         
       
   199         /**
       
   200          * Asyncronous request to the server to connect
       
   201          * @since S60 5.2
       
   202          * @param aPckg request result
       
   203          * @param aIapId The id of the IAP to connect to
       
   204          * @param aConnectOnly ETrue if Connect selected
       
   205          * @param aPersistence The value of the persistence property
       
   206          * @param aStatus The request status object used to contain 
       
   207          *        the completion status of the request.
       
   208          */
       
   209         IMPORT_C void ConnectWlanBearer( TPckgBuf<TBool>& aPckg,
       
   210                                          TUint32 aIapId, 
       
   211                                          TBool aConnectOnly,
       
   212                                          TWsfIapPersistence aPersistence, 
       
   213                                          TRequestStatus& aStatus );
       
   214         
       
   215         /**
       
   216         * Sets connection result
       
   217         * @since S60 5.2
       
   218         * @param aResult The connection request result
       
   219         */
       
   220         IMPORT_C void SetConnectWlanBearerResult( TInt aResult );
       
   221 
       
   222         /**
       
   223         * Sets the persistence property of the currently monitored IAP
       
   224         * @since S60 5.0
       
   225         * @param aPersistence The value of the property
       
   226         * @return ETrue on success, otherwise false
       
   227         */
       
   228         IMPORT_C TBool SetIapPersistenceL( TWsfIapPersistence aPersistence );
       
   229 
       
   230         /**
       
   231         * Disconnect the current wlan connection
       
   232         * @since S60 5.0
       
   233         * @return ETrue if there was an active connection and it was 
       
   234         *         disconnected successfully, otherwise EFalse
       
   235         */
       
   236         IMPORT_C TBool DisconnectWlanBearerL();
       
   237         
       
   238         /**
       
   239         * Asyncronous request to the server to disconnect
       
   240         * @since S60 5.2
       
   241         * @param aPckg request result
       
   242         * @param aStatus The request status object used to contain 
       
   243         *        the completion status of the request.
       
   244         */
       
   245         IMPORT_C void DisconnectWlanBearer( TPckgBuf<TBool>& aPckg, 
       
   246                                             TRequestStatus& aStatus );
       
   247         
       
   248         /**
       
   249         * Request the server to make a forced scan
       
   250         * @since S60 5.0
       
   251         * @return ETrue on success
       
   252         */
       
   253         IMPORT_C TBool RequestScanL();
       
   254         
       
   255 		/**
       
   256         * Asyncronous request to the server to make a scan
       
   257         * @since S60 5.2
       
   258         * @param aPckg request result
       
   259         * @param aStatus The request status object used to contain 
       
   260         *        the completion status of the request.
       
   261         */
       
   262         IMPORT_C void RequestScan( TPckgBuf<TBool>& aPckg, 
       
   263                                    TRequestStatus& aStatus );
       
   264         
       
   265         /**
       
   266         * Queries if there is an active WLAN connection.
       
   267         * @since S60 5.0
       
   268         * @return ETrue if there is an active WLAN connection, 
       
   269         * *       EFalse otherwise.
       
   270         */
       
   271         IMPORT_C TBool IsConnectedL();
       
   272         
       
   273         /**
       
   274         * Aborts the currently ongoing connecting process
       
   275         * @since S60 5.0
       
   276         */
       
   277         IMPORT_C void AbortConnectingL();
       
   278         
       
   279         /**
       
   280         * Aborts the currently ongoing scanning process 
       
   281         * @since S60 5.0
       
   282         */
       
   283         IMPORT_C void AbortScanningL();
       
   284         
       
   285         /**
       
   286         * Controls the auto-disconnect timer in the server 
       
   287         * for owned connections
       
   288         * @since S60 5.0
       
   289         * @param aAdcCommand Command bitmask for the timer, 
       
   290         *                    see TWsfAutoDisconnectCommand
       
   291         * @return ETrue if the timer has been started (also if it had been 
       
   292         *         started earlier), EFalse if the timer couldn't be started
       
   293         *         (e.g. because there is no owned connection).
       
   294         */
       
   295         IMPORT_C TBool ControlDisconnectTimerL( TUint aAdcCommand );
       
   296         
       
   297         
       
   298     private:
       
   299         /**
       
   300         * Starts the server if it was not running already.
       
   301         * @since S60 5.0
       
   302         * @return KErrNone on success, otherwise error code
       
   303         */
       
   304         TInt StartServer();
       
   305 
       
   306         
       
   307     private:
       
   308         /**
       
   309         * Cancels the notifications from the server. 
       
   310         * Only called by CWsfEventHandler.
       
   311         * @since S60 5.0
       
   312         */    
       
   313         void DoCancelNotifyEvent();
       
   314 
       
   315         /**
       
   316         * Tries to restart the server after it died because of an error.
       
   317         * Only called by CWsfEventHandler.
       
   318         * @since S60 5.0
       
   319         * @param aObserver The object which should be notified on 
       
   320         *                  server events. (This call just passes the current 
       
   321         *                  observer of the event handler, which is needed 
       
   322         *                  for the initialisation.)
       
   323         * @return ETrue if the restart succeeded
       
   324         */    
       
   325         TBool RecoverFromServerTermination( 
       
   326                                         MWsfStateChangeObserver& aObserver );
       
   327 
       
   328         /**
       
   329         * Stops the waiting for connection creation started by 
       
   330         * ConnectWlanBearerL.
       
   331         * @since S60 5.0
       
   332         */
       
   333         void StopConnectingWait();
       
   334         
       
   335 
       
   336     private: // Data
       
   337         /**
       
   338         * Event handler active object for the server-generated events. Owned.
       
   339         */
       
   340         CWsfEventHandler* iEventHandler;
       
   341         
       
   342         /**
       
   343         * Indicates the result of the connecting process
       
   344         */
       
   345         TInt iConnectingResult;
       
   346         
       
   347         /**
       
   348         * Waiter to make the asynchronous connect call synchronous 
       
   349         * on client-side
       
   350         */
       
   351         CActiveSchedulerWait* iConnWaiter;
       
   352     };
       
   353 
       
   354 #endif // R_WSFSESSION_H