wlanutilities/wlansniffer/engine/server/inc/wsfengine.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 CWsfModel
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_WSFENGINE_H
       
    21 #define C_WSFENGINE_H
       
    22 
       
    23 //  EXTERNAL INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <commsdattypesv1_1.h>
       
    26 #include <cmmanagerext.h>
       
    27 
       
    28 //  INTERNAL INCLUDES
       
    29 #include "wsfwlanscannerobserver.h"
       
    30 #include "wsfwlanmonitorobserver.h"
       
    31 #include "wsfcommon.h"
       
    32 
       
    33 
       
    34 //  FORWARD DECLARATIONS
       
    35 class CWsfWlanScanner;
       
    36 class MWsfEngineObserver;
       
    37 class CWsfWlanBearerConnectionMonitor;
       
    38 class TWsfWlanInfo;
       
    39 class MWsfServerCloserAdapter;
       
    40 
       
    41 //  CLASS DEFINITION
       
    42 /**
       
    43  * Sniffer engine class.
       
    44  * This class manages the objects responsible for connection creation, 
       
    45  * closing and monitoring, communication with the WLAN engine etc.
       
    46  *
       
    47  * @since S60 5.0
       
    48  * @lib wsfserver.exe
       
    49  */
       
    50 NONSHARABLE_CLASS( CWsfEngine ): public CBase, 
       
    51                                  public MWsfWlanScannerObserver, 
       
    52                                  public MWsfWlanMonitorObserver
       
    53     {
       
    54     public:     // Constructors and destructor
       
    55         /**
       
    56         * Factory function.
       
    57         * @since S60 5.0
       
    58         * @param aServerCloser Reference to the server closer object.
       
    59         *                      Ownership not passed.
       
    60         * @return Server instance
       
    61         */
       
    62         static CWsfEngine* NewL( MWsfServerCloserAdapter& aServerCloser );
       
    63 
       
    64         /**
       
    65         * Factory function.
       
    66         * @since S60 5.0
       
    67         * @param aServerCloser Reference to the server closer object.
       
    68         *                      Ownership not passed.
       
    69         * @return Server instance
       
    70         */
       
    71         static CWsfEngine* NewLC( MWsfServerCloserAdapter& aServerCloser );
       
    72 
       
    73         /**
       
    74         * Destructor
       
    75         */        
       
    76         ~CWsfEngine();
       
    77         
       
    78 
       
    79     private:    // Constructors
       
    80         /**
       
    81         * Constructor
       
    82         * @since S60 5.0
       
    83         * @param aServerCloser Reference to the server closer object.
       
    84         *                      Ownership not passed.
       
    85         */
       
    86         CWsfEngine( MWsfServerCloserAdapter& aServerCloser );
       
    87 
       
    88         /**
       
    89         * Second-phase constructor.
       
    90         * @since S60 5.0
       
    91         */
       
    92         void ConstructL();
       
    93 
       
    94 
       
    95     public:     // New methods
       
    96  
       
    97         /** 
       
    98         * Gets the result of complete wlan scan
       
    99         * @since S60 5.0
       
   100         * @return Buffer pointer containing a serialized array of 
       
   101         *         wlaninfo items
       
   102         */ 
       
   103         HBufC8* GetScanResults();
       
   104 
       
   105         /**
       
   106         * Sets wlan scanning on
       
   107         * @since S60 5.0
       
   108         */
       
   109         void EnableScanningL();
       
   110         
       
   111         /**
       
   112         * Sets wlan scanning off
       
   113         * @since S60 5.0
       
   114         */ 
       
   115         void DisableScanningL();
       
   116         
       
   117         /**
       
   118         * Returns whether scanning is enabled
       
   119         * @since S60 5.0
       
   120         * @return ETrue if scanning has been enabled, EFalse otherwise
       
   121         */
       
   122         TBool IsScanning();
       
   123 
       
   124         /**
       
   125         * Checks if there is an active wlan connection and returns connection
       
   126         * name (SSID) if appropriate.
       
   127         * @since S60 5.0
       
   128         * @return The SSID of connected access point or empty descriptor 
       
   129         *         if not connected
       
   130         */
       
   131         HBufC* ConnectedWlanSsidL();
       
   132 
       
   133         /**
       
   134         * Fills the wlaninfo with the details of the active WLAN connection
       
   135         * @since S60 5.0
       
   136         * @param aWlanInfo The wlaninfo record to be filled
       
   137         *                  Ownership not passed.
       
   138         * @return ETrue if success, EFalse on failure
       
   139         */
       
   140         TBool ConnectedWlanConnectionDetailsL( TWsfWlanInfo& aWlanInfo );
       
   141 
       
   142         /**
       
   143         * Connects to the given IAP
       
   144         * @since S60 5.0
       
   145         * @param aIapId The IAP to connect to
       
   146         * @param aPersistence Persistence property of the IAP
       
   147         * @return KErrNone if successful, otherwise error code
       
   148         */
       
   149         TInt ConnectWlanL( TUint32 aIapId, TWsfIapPersistence aPersistence );
       
   150 
       
   151         /**
       
   152         * Disconnects the active WLAN connection
       
   153         * @since S60 5.0
       
   154         * @return ETrue on success, EFalse if there was nothing to disconnect
       
   155         */
       
   156         TBool DisconnectWlan();
       
   157     
       
   158         /**
       
   159         * Requests a wlan scan
       
   160         * @since S60 5.0
       
   161         * @return ETrue if scanning is restarted
       
   162         */
       
   163         TBool RefreshScanResults();
       
   164         
       
   165         /**
       
   166         * Requests the server to monitor an access point
       
   167         * @since S60 5.0
       
   168         * @param aApId Access Point to be monitored
       
   169         */
       
   170         void MonitorAccessPointL( TUint32 aApId );
       
   171 
       
   172         /**
       
   173         * Queries if there is an active WLAN connection.
       
   174         * @since S60 5.0
       
   175         * @return ETrue if there is an active WLAN connection, 
       
   176         *         EFalse otherwise.
       
   177         */
       
   178         TBool IsConnected();
       
   179         
       
   180         /**
       
   181         * Aborts the currently ongoing connecting process 
       
   182         * @since S60 5.0
       
   183         */
       
   184         void AbortConnectingL();
       
   185         
       
   186         /**
       
   187         * Aborts the currently ongoing scanning process 
       
   188         * @since S60 5.0
       
   189         */
       
   190         void AbortScanning();
       
   191         
       
   192         /**
       
   193         * Sets the persistence property for the currently monitored IAP
       
   194         * @since S60 5.0
       
   195         * @param aPersistence The value of the property
       
   196         * @return ETrue on success
       
   197         */
       
   198         TBool SetIapPersistenceL( TWsfIapPersistence aPersistence );
       
   199 
       
   200         /**
       
   201         * Controls the auto-disconnect timer in the server 
       
   202         * for owned connections
       
   203         * @since S60 5.0
       
   204         * @param aAdcCommand Command for the timer,
       
   205         *                    see TWsfAutoDisconnectCommand
       
   206         * @return ETrue if the timer has been started (also if it had been 
       
   207         *         started earlier), EFalse if the timer couldn't be started
       
   208         *         (e.g. because there is no owned connection).
       
   209         */
       
   210         TBool ControlDisconnectTimer( TUint aAdcCommand );
       
   211         
       
   212         /**
       
   213          * Resets the iSuppressIapDeletion flag.
       
   214          * @since S60 5.0
       
   215          */
       
   216         void ResetSuppressIapDeletion ();
       
   217                 
       
   218     
       
   219     public:  // new methods
       
   220 
       
   221         /**
       
   222         * Adds the given observer to the notification list
       
   223         * @since S60 5.0
       
   224         * @param aObserver The observer to add. Ownership not passed.
       
   225         */
       
   226         void AttachL( MWsfEngineObserver* aObserver );
       
   227 
       
   228         /**
       
   229         * Deletes the given observer from the notification list
       
   230         * @since S60 5.0
       
   231         * @param aObserver The observer to remove. Ownership not passed.
       
   232         */
       
   233         void Detach( MWsfEngineObserver* aObserver );
       
   234    
       
   235 
       
   236        protected: // from MWsfWlanScannerObserver
       
   237        
       
   238         /**
       
   239         * When the scan cycle has completed this function is called to report 
       
   240         * the completion.
       
   241         * @since S60 5.0
       
   242         */
       
   243         void WlanScanCompleteL();
       
   244 
       
   245         /**
       
   246         * Called when the scan cycle has started  
       
   247         * @since S60 5.0
       
   248         */
       
   249         void WlanScanStarted();
       
   250 
       
   251         /**
       
   252         * Called when an error occured while scanning wlan data  
       
   253         * @since S60 5.0
       
   254         * @param aError System wide error code
       
   255         */
       
   256         void NotifyError( TInt aError );        
       
   257            
       
   258           
       
   259        protected: // from MWsfWlanMonitorObserver       
       
   260 
       
   261         /**
       
   262         * Called when a wlan connection is established
       
   263         * @since S60 5.0
       
   264         * @param aConnectionName WLAN connection name (SSID)
       
   265         */
       
   266         virtual void ConnectionEstablishedL( const TDesC& aConnectionName );
       
   267 
       
   268         /**
       
   269         * Called when wlan connection has been lost
       
   270         * @since S60 5.0
       
   271         */
       
   272         virtual void ConnectionLostL();
       
   273         
       
   274         /**
       
   275         * Called when the connection process failed for some reason
       
   276         * @since S60 5.0
       
   277         * @param aError System wide error code
       
   278         */
       
   279         virtual void ConnectingFailedL( TInt aError );
       
   280         
       
   281         /**
       
   282         * Called when the connection no longer needs the IAP it was using
       
   283         * @since S60 5.0
       
   284         */
       
   285         virtual void ConnectedIapReleasedL();
       
   286 
       
   287         
       
   288     private:
       
   289     
       
   290         /**
       
   291         * Tries to delete the corresponding IAP
       
   292         * @since S60 5.0
       
   293         * @param aIapId The IAP to be deleted
       
   294         */
       
   295         void DeleteIapL( TUint32 aIapId );
       
   296 
       
   297 
       
   298     private:    // Data
       
   299         /**
       
   300         * Reference to the server closer (not owned)
       
   301         */
       
   302         MWsfServerCloserAdapter& iServerCloser;
       
   303         
       
   304         /**
       
   305         * WLAN scanner object (owned)
       
   306         */
       
   307         CWsfWlanScanner* iScanner;
       
   308         
       
   309         /**
       
   310         * Handle to the commsdat database (owned)
       
   311         */
       
   312         CommsDat::CMDBSession* iDbSession;
       
   313         
       
   314         /**
       
   315         * WLAN connection monitor object (owned)
       
   316         */
       
   317         CWsfWlanBearerConnectionMonitor* iWlanBearerMonitor;
       
   318  
       
   319         /**
       
   320         * Reference counter for scan enabling requests
       
   321         */
       
   322         TInt iEnableScanning;
       
   323         
       
   324         /**
       
   325         * Array of references to the observers of the engine 
       
   326         * (elements not owned)
       
   327         */        
       
   328         RPointerArray<MWsfEngineObserver> iObservers;
       
   329         
       
   330         /**
       
   331         * Accesspoint to be monitored
       
   332         */
       
   333         TUint32 iMonitoredIap;
       
   334 
       
   335         /**
       
   336         * Indicates the persistence property of monitored IAP
       
   337         */
       
   338         TWsfIapPersistence iIapPersistence;
       
   339 
       
   340         /**
       
   341         * Indicates whether to postpone IAP deletion
       
   342         */
       
   343         TBool iSuppressIapDeletion;
       
   344     };
       
   345 
       
   346 #endif      //  C_WSFENGINE_H
       
   347 
       
   348 // End of file