wlanutilities/wlansniffer/engine/client/inc/wsfsession.h
changeset 19 10810c91db26
parent 3 ff3b37722600
child 22 498f36116140
equal deleted inserted replaced
3:ff3b37722600 19:10810c91db26
     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         * Cancel all pending tasks.
       
   126         * @since S60 5.0
       
   127         */
       
   128         IMPORT_C void CancelAll();
       
   129 
       
   130         /**
       
   131         * Return the connected wlan network name
       
   132         * @since S60 5.0
       
   133         * @return The connected account name, or NULL if not connected
       
   134         */ 
       
   135         IMPORT_C HBufC* ConnectedAccountNameL();
       
   136 
       
   137         /**
       
   138         * Return the connected wlan's details
       
   139         * @since S60 5.0
       
   140         * @param aWlanInfo The wlaninfo object to fill
       
   141         * @return ETrue if success, EFalse otherwise
       
   142         */ 
       
   143         IMPORT_C TBool GetConnectedWlanDetailsL( TWsfWlanInfo& aWlanInfo );
       
   144         
       
   145         /**
       
   146         * Start monitoring events for the specified access point
       
   147         * @since S60 5.0
       
   148         * @param aMonitoredIap The id of the IAP to be monitored
       
   149         */
       
   150         IMPORT_C void MonitorAccessPointL( TUint32 aMonitoredIap );
       
   151         
       
   152         /**
       
   153         * Connect to the given WLAN IAP. The function requests the server, 
       
   154         * then starts a synchronous wait until the connection is established.
       
   155         * @since S60 5.0
       
   156         * @param aIapId The id of the IAP to connect to
       
   157         * @param aPersistence The value of the persistence property
       
   158         * @return KErrNone if managed to connect, otherwise error code
       
   159         */
       
   160         IMPORT_C TInt ConnectWlanBearerL( TUint32 aIapId, 
       
   161                            TWsfIapPersistence aPersistence = EIapPersistent );
       
   162         
       
   163         /**
       
   164         * Connect to the given WLAN IAP. The function requests connection from 
       
   165         * server without waiting the connection process to finish
       
   166         * @since S60 5.2
       
   167         * @param aIapId The id of the IAP to connect to
       
   168         * @param aPersistence The value of the persistence property
       
   169         * @return KErrNone if connection request is succesfully sent to server
       
   170         */
       
   171         IMPORT_C TInt ConnectWlanBearerWithoutConnWaiterL( TUint32 aIapId, 
       
   172                            TWsfIapPersistence aPersistence = EIapPersistent );
       
   173 
       
   174         /**
       
   175         * Sets the persistence property of the currently monitored IAP
       
   176         * @since S60 5.0
       
   177         * @param aPersistence The value of the property
       
   178         * @return ETrue on success, otherwise false
       
   179         */
       
   180         IMPORT_C TBool SetIapPersistenceL( TWsfIapPersistence aPersistence );
       
   181 
       
   182         /**
       
   183         * Disconnect the current wlan connection
       
   184         * @since S60 5.0
       
   185         * @return ETrue if there was an active connection and it was 
       
   186         *         disconnected successfully, otherwise EFalse
       
   187         */
       
   188         IMPORT_C TBool DisconnectWlanBearerL();
       
   189         
       
   190         /**
       
   191         * Request the server to make a forced scan
       
   192         * @since S60 5.0
       
   193         * @return ETrue on success
       
   194         */
       
   195         IMPORT_C TBool RequestScanL();
       
   196         
       
   197         /**
       
   198         * Queries if there is an active WLAN connection.
       
   199         * @since S60 5.0
       
   200         * @return ETrue if there is an active WLAN connection, 
       
   201         * *       EFalse otherwise.
       
   202         */
       
   203         IMPORT_C TBool IsConnectedL();
       
   204         
       
   205         /**
       
   206         * Aborts the currently ongoing connecting process
       
   207         * @since S60 5.0
       
   208         */
       
   209         IMPORT_C void AbortConnectingL();
       
   210         
       
   211         /**
       
   212         * Aborts the currently ongoing scanning process 
       
   213         * @since S60 5.0
       
   214         */
       
   215         IMPORT_C void AbortScanningL();
       
   216         
       
   217         /**
       
   218         * Controls the auto-disconnect timer in the server 
       
   219         * for owned connections
       
   220         * @since S60 5.0
       
   221         * @param aAdcCommand Command bitmask for the timer, 
       
   222         *                    see TWsfAutoDisconnectCommand
       
   223         * @return ETrue if the timer has been started (also if it had been 
       
   224         *         started earlier), EFalse if the timer couldn't be started
       
   225         *         (e.g. because there is no owned connection).
       
   226         */
       
   227         IMPORT_C TBool ControlDisconnectTimerL( TUint aAdcCommand );
       
   228         
       
   229         
       
   230     private:
       
   231         /**
       
   232         * Starts the server if it was not running already.
       
   233         * @since S60 5.0
       
   234         * @return KErrNone on success, otherwise error code
       
   235         */
       
   236         TInt StartServer();
       
   237 
       
   238         
       
   239     private:
       
   240         /**
       
   241         * Cancels the notifications from the server. 
       
   242         * Only called by CWsfEventHandler.
       
   243         * @since S60 5.0
       
   244         */    
       
   245         void DoCancelNotifyEvent();
       
   246 
       
   247         /**
       
   248         * Tries to restart the server after it died because of an error.
       
   249         * Only called by CWsfEventHandler.
       
   250         * @since S60 5.0
       
   251         * @param aObserver The object which should be notified on 
       
   252         *                  server events. (This call just passes the current 
       
   253         *                  observer of the event handler, which is needed 
       
   254         *                  for the initialisation.)
       
   255         * @return ETrue if the restart succeeded
       
   256         */    
       
   257         TBool RecoverFromServerTermination( 
       
   258                                         MWsfStateChangeObserver& aObserver );
       
   259 
       
   260         /**
       
   261         * Stops the waiting for connection creation started by 
       
   262         * ConnectWlanBearerL.
       
   263         * @since S60 5.0
       
   264         */
       
   265         void StopConnectingWait();
       
   266         
       
   267 
       
   268     private: // Data
       
   269         /**
       
   270         * Event handler active object for the server-generated events. Owned.
       
   271         */
       
   272         CWsfEventHandler* iEventHandler;
       
   273         
       
   274         /**
       
   275         * Indicates the result of the connecting process
       
   276         */
       
   277         TInt iConnectingResult;
       
   278         
       
   279         /**
       
   280         * Waiter to make the asynchronous connect call synchronous 
       
   281         * on client-side
       
   282         */
       
   283         CActiveSchedulerWait* iConnWaiter;
       
   284     };
       
   285 
       
   286 #endif // R_WSFSESSION_H