bearermanagement/mpm/inc/mpmconnmonevents.h
changeset 0 5a93021fdf25
child 8 2e6c4614c58e
child 18 fcbbe021d614
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     1 /*
       
     2 * Copyright (c) 2005-2009 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: Interface for receiving ConnMon events in MPM.
       
    15 *
       
    16 */
       
    17 
       
    18 /**
       
    19 @file mpmconnmonevents.h
       
    20 Interface for receiving ConnMon events in MPM.
       
    21 */
       
    22 
       
    23 #ifndef MPMCONNMONEVENTS_H
       
    24 #define MPMCONNMONEVENTS_H
       
    25 
       
    26 //  INCLUDES
       
    27 #include <e32base.h>
       
    28 #include <rconnmon.h>
       
    29 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    30 #include <commsdat.h>
       
    31 #else
       
    32 #include <commsdat.h>
       
    33 #include <commsdat_partner.h>
       
    34 #endif
       
    35 #include <NIFVAR.H>
       
    36 #include "mpmserver.h"
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 class CMPMConnMonReqs;
       
    40 class CWlanAvailability;
       
    41 class MWlanAvailability;
       
    42 
       
    43 // CONSTANTS
       
    44 
       
    45 // CLASS DECLARATION
       
    46 /**
       
    47 *  TConnInfo
       
    48 *  Record for connection information storage
       
    49 *  @lib MPMServer.exe
       
    50 *  @since 3.1
       
    51 */
       
    52 class TConnInfo
       
    53     { 
       
    54     public: // Constructors and destructor
       
    55 
       
    56         /**
       
    57         * Constructor.
       
    58         */
       
    59         TConnInfo();
       
    60 
       
    61     public: // Data
       
    62         // Connection Id
       
    63         TUint iConnId;
       
    64 
       
    65         // IAP Id
       
    66         TUint32 iIapId;
       
    67 
       
    68         // Presumed IAP Id which connection thinks it's using. 
       
    69         // The actual IAP Id ( iIapId ) maybe different because 
       
    70         // of SSID sharing or PDP context management.  
       
    71         TUint32 iPresumedIapId;
       
    72 
       
    73         // Network Id
       
    74         TUint32 iNetId;
       
    75         
       
    76         // Access point name
       
    77         TBuf<CommsDat::KMaxMedTextLength> iAPN;
       
    78 
       
    79         // SSID of WLAN
       
    80         TWlanSsid iSSID;
       
    81 
       
    82         // Connection type
       
    83         TConnectionType iConnType; 
       
    84     };
       
    85 
       
    86 // CLASS DECLARATION
       
    87 /**
       
    88 *  MPM ConnMon interface class definition.
       
    89 *
       
    90 *  @lib MPMServer.exe
       
    91 *  @since 3.0
       
    92 */
       
    93 class CMPMConnMonEvents : public CBase, public MConnectionMonitorObserver
       
    94     {
       
    95 
       
    96     public:    // Constructors and destructor
       
    97     
       
    98         /**
       
    99         * Two-phased constructor.
       
   100         */
       
   101         static CMPMConnMonEvents* NewL( CMPMServer& aServer, 
       
   102                                         CMPMServerSession& aSession );
       
   103 
       
   104         /**
       
   105         * Destructor.
       
   106         */
       
   107         virtual ~CMPMConnMonEvents();
       
   108         
       
   109     public: // New methods
       
   110     
       
   111         /**
       
   112         * Remove pointer from the array.
       
   113         * @since 3.1
       
   114         * @param aReq
       
   115         */                
       
   116         void RemoveReqPtr( const CMPMConnMonReqs* aReq );
       
   117 
       
   118         /**
       
   119         * Appending connection info.
       
   120         * @since 3.2
       
   121         * @param aConnId Connection Id.
       
   122         */                
       
   123         void AppendConnInfo( const TUint& aConnId );
       
   124 
       
   125         /**
       
   126         * Removing connection info.
       
   127         * @since 3.2
       
   128         * @param aConnId Connection Id.
       
   129         */                
       
   130         void RemoveConnInfo( const TUint& aConnId );
       
   131 
       
   132         /**
       
   133         * Setting connection info.
       
   134         * @since 3.2
       
   135         * @param aConnId Connection Id
       
   136         * @param aIapId IAP Id
       
   137         * @param aPresumedIapId The IAP Id that application presumes to use
       
   138         * @param aNetId Network Id
       
   139         * @param aAPN Access Point Name
       
   140         */                
       
   141         void SetConnInfo( const TUint& aConnId, 
       
   142                           const TUint& aIapId, 
       
   143                           const TUint& aPresumedIapId, 
       
   144                           const TUint& aNetId, 
       
   145                           const TDesC& aAPN );
       
   146 
       
   147         /**
       
   148         * Setting connection info in case of SSID, 
       
   149         * in other words WLAN IAP.
       
   150         * @since 3.2
       
   151         * @param aConnId Connection Id
       
   152         * @param aIapId IAP id
       
   153         * @param aPresumedIapId The IAP Id that application presumes to use
       
   154         * @param aNetId Network id
       
   155         * @param aSSID the id of selected wlan network
       
   156         */
       
   157         void SetConnInfo( const TUint&      aConnId, 
       
   158                           const TUint&      aIapId, 
       
   159                           const TUint&      aPresumedIapId, 
       
   160                           const TUint&      aNetId, 
       
   161                           const TWlanSsid&   aSSID );
       
   162 
       
   163         /**
       
   164         * Setting SSID for certain iap
       
   165         * @since 3.2
       
   166         * @param aIapId IAP id
       
   167         * @param aSSID the id of selected wlan network
       
   168         */
       
   169         void SetConnInfoIapSsid( const TUint&       aIapId, 
       
   170                                  const TWlanSsid&    aSSID  );
       
   171 
       
   172         /**
       
   173         * Reset connection info.
       
   174         * @since 3.2
       
   175         * @param aConnId Connection Id
       
   176         */
       
   177         void ResetConnInfo( const TUint& aConnId );
       
   178 
       
   179         /**
       
   180         * Reset connection info for all connections using given IAP.
       
   181         * @since 3.2
       
   182         * @param aIapId IAP id
       
   183         */
       
   184         void ResetIapConnInfo( const TUint32 aIapId );
       
   185 
       
   186         /**
       
   187         * Getting IDs of available IAPs.
       
   188         * @since 3.1
       
   189         * @return IDs of available IAPs 
       
   190         */                                              
       
   191         const TConnMonIapInfo& GetAvailableIAPs();
       
   192         
       
   193         /**
       
   194         * Setting IDs of available IAPs.
       
   195         * @since 3.1
       
   196         * @param aAvailableIAPs IDs of available IAPs
       
   197         */                                              
       
   198         void SetAvailableIAPs( const TConnMonIapInfo& aAvailableIAPs );
       
   199         
       
   200         /**
       
   201         * Find if connection to APN already exists
       
   202         * @since 3.1
       
   203         * @param aDes APN to be checked
       
   204         * @param aIapId On return contains the changed IAP Id
       
   205         * @param aNetId On return contains the changed Network Id
       
   206         */        
       
   207         void FindAPN( const TDesC& aDes, TUint32& aIapId, TUint32& aNetId );
       
   208 
       
   209         /**
       
   210         * Find if connection to SSID already exists
       
   211         * @since 3.2
       
   212         * @param aSSID the id of selected wlan network
       
   213         * @param aIapId On return contains the changed IAP Id
       
   214         * @param aNetId On return contains the changed Network Id
       
   215         */        
       
   216         void FindSSID( const TWlanSsid&  aSSID, 
       
   217                        TUint32&         aIapId, 
       
   218                        TUint32&         aNetId );
       
   219 
       
   220         /**
       
   221         * Checks if there is active WLAN connection.
       
   222         * @since 3.2
       
   223         * @param aSSID the id of active wlan network
       
   224         * @param aIapId the IAP Id of active wlan network
       
   225         */        
       
   226         TBool ActiveWlanConnection( TWlanSsid&  aSSID, 
       
   227                                     TUint32&    aIapId );
       
   228 
       
   229         /**
       
   230         * Starts WLANNetworks request towards Connection monitor.
       
   231         * @since 3.2
       
   232         * @param aSession MPM server session requesting the wlan scan, Null if none.
       
   233         * @param aId ConnectionId.
       
   234         * @param aCallback Callback type to use after WLAN scan completed
       
   235         * @param aForceRefreshIntervalSeconds if the last interval is executed withing this time
       
   236         * the scan is not executed. 0 to do available iap query always.  
       
   237         */
       
   238         void ScanWLANNetworksL( CMPMServerSession* aSession,
       
   239                                 const TConnectionId& aId,
       
   240                                 TWlanScanCallback aCallback,
       
   241                                 TInt aForceRefreshIntervalSeconds = 0 );
       
   242 
       
   243         /**
       
   244         * Cancels WLANNetworks request towards Connection monitor.
       
   245         * @param aSession Pointer to session
       
   246         * @since 3.1
       
   247         */
       
   248         void CancelScanL( CMPMServerSession& aSession );
       
   249 
       
   250         /**
       
   251         * Gets the presumed Iap Id of Connection Id.
       
   252         * @since 3.2
       
   253         * @param aConnId Connection Id
       
   254         * @param aIapId IAP id
       
   255         */
       
   256         TUint32 PresumedIapId( const TUint& aConnId, 
       
   257                                const TUint& aIapId );
       
   258 
       
   259         /**
       
   260         * Updates the internal IAP refresh time stamp.
       
   261         * @since 3.2
       
   262         */
       
   263         void UpdateIAPRefreshTime();
       
   264         
       
   265         /**
       
   266         * Gets the internal IAP refresh time stamp.
       
   267         * @since 3.2
       
   268         * @return TTime latest refresh time
       
   269         */
       
   270         TTime& GetIAPRefreshTime();
       
   271 
       
   272         /**
       
   273         * Sets connection count.
       
   274         * @since 3.2
       
   275         * @param aValue Connection count value.
       
   276         */
       
   277         void SetConnectionCounter( const TUint aValue ); 
       
   278 
       
   279         /**
       
   280         * Enables discarding availability notifications from Connection Monitor.
       
   281         * @since 3.2
       
   282         */
       
   283         inline void EnableDiscarding(); 
       
   284 
       
   285         /**
       
   286         * Disables discarding availability notifications from Connection Monitor.
       
   287         * @since 3.2
       
   288         */
       
   289         inline void DisableDiscarding(); 
       
   290 
       
   291         /**
       
   292         * Returns the setting for discarding availability notifications. 
       
   293         * @since 3.2
       
   294         * @return ETrue if availability notifications are discarded. 
       
   295         */
       
   296         inline TBool DiscardAvailabilityNotification(); 
       
   297         
       
   298         /**
       
   299          * Creates preferred carrier available notification when needed.
       
   300          * @since 5.1
       
   301          */
       
   302         void IapAvailabilityChange();
       
   303 
       
   304         /**
       
   305          * Asks WLAN bearer availability info from Connection monitor.
       
   306          * @since 5.2
       
   307          * @param aObserver pointer to the caller
       
   308          */
       
   309         void CheckWlanAvailabilityL( MWlanAvailability* aObserver );
       
   310         
       
   311         /**
       
   312          * Cancels WLAN bearer availability check for an observer.
       
   313          * @since 5.2
       
   314          * @param aObserver pointer to the caller
       
   315          */
       
   316         void CancelCheckWlanWlanAvailability( MWlanAvailability* aObserver );
       
   317     
       
   318         /**
       
   319          * Sets iWlanAvailability pointer to NULL because object has
       
   320          * deleted itself.
       
   321          * @since 5.2
       
   322          */
       
   323         void SetWlanAvailabilityPtrNull();
       
   324 
       
   325         
       
   326     public: // Functions from base classes
       
   327     
       
   328         /**
       
   329         * From MConnectionMonitorObserver. Event from Connection Monitor.
       
   330         * @since 3.1
       
   331         * @param aConnMonEvent
       
   332         */                
       
   333         void EventL( const CConnMonEventBase& aConnMonEvent );
       
   334         
       
   335     private: // New methods
       
   336 
       
   337         /**
       
   338         * C++ default constructor.
       
   339         */
       
   340         CMPMConnMonEvents( CMPMServer& aServer );
       
   341 
       
   342         /**
       
   343         * 2nd phase constructor.
       
   344         */
       
   345         void ConstructL( CMPMServerSession& aSession );
       
   346 
       
   347     private: // Data
       
   348         // Handle to connection monitor
       
   349         RConnectionMonitor              iConnMon;
       
   350 
       
   351         // Server object reference
       
   352         CMPMServer&                     iMyServer;
       
   353         
       
   354         // Request object pointer array
       
   355         RPointerArray<CMPMConnMonReqs>  iReqPtrs;
       
   356         
       
   357         // Info about connections
       
   358         RArray<TConnInfo>               iConnInfoArray;
       
   359         
       
   360         // Available IAPs
       
   361         TConnMonIapInfo                 iAvailableIAPs;
       
   362         
       
   363         // Time stamp of last IAP availability check
       
   364         TTime                           iLastIAPRefreshTime;
       
   365         
       
   366         // Discard availability notifications from Connection Monitor 
       
   367         // until MPM initiated WLAN scan request has completed. 
       
   368         TBool iDiscardAvailabilityNotification;
       
   369 
       
   370 #ifdef _DEBUG 
       
   371         TBool iFilterEvents; // by default off. (CBase)
       
   372     public:
       
   373         void FilterAvailableIAPEvents( const TBool aVal ) { iFilterEvents = aVal; }
       
   374 #endif //_DEBUG
       
   375 
       
   376        CWlanAvailability*               iWlanAvailability;
       
   377     };
       
   378 
       
   379 // -----------------------------------------------------------------------------
       
   380 // CMPMConnMonEvents::EnableDiscarding
       
   381 // -----------------------------------------------------------------------------
       
   382 //
       
   383 inline void CMPMConnMonEvents::EnableDiscarding()
       
   384     {
       
   385     iDiscardAvailabilityNotification = ETrue;
       
   386     }
       
   387 
       
   388 // -----------------------------------------------------------------------------
       
   389 // CMPMConnMonEvents::DisableDiscarding
       
   390 // -----------------------------------------------------------------------------
       
   391 //
       
   392 inline void CMPMConnMonEvents::DisableDiscarding()
       
   393     {
       
   394     iDiscardAvailabilityNotification = EFalse;
       
   395     }
       
   396 
       
   397 // -----------------------------------------------------------------------------
       
   398 // CMPMConnMonEvents::DiscardAvailabilityNotification
       
   399 // -----------------------------------------------------------------------------
       
   400 //
       
   401 inline TBool CMPMConnMonEvents::DiscardAvailabilityNotification()
       
   402     {
       
   403     return iDiscardAvailabilityNotification;
       
   404     }
       
   405 
       
   406 #endif // MPMCONNMONEVENTS_H
       
   407 
       
   408 // End of file