bearermanagement/mpm/inc/mpmcommsdataccess.h
changeset 0 5a93021fdf25
child 3 f7816ffc66ed
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     1 /*
       
     2 * Copyright (c) 2007-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: MPM CommsDat Access class definitions
       
    15 *
       
    16 */
       
    17 
       
    18 /**
       
    19 @file mpmcommsdataccess.h
       
    20 Mobility Policy Manager CommsDat Access class definitions.
       
    21 */
       
    22 
       
    23 #ifndef MPMCOMMSDATACCESS_H
       
    24 #define MPMCOMMSDATACCESS_H
       
    25 
       
    26 
       
    27 //  INCLUDES
       
    28 //
       
    29 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    30 #include <commsdat_partner.h>
       
    31 #endif
       
    32 #include <e32base.h>
       
    33 #include <commsdattypesv1_1.h>
       
    34 #include <cmpluginwlandef.h>
       
    35 #include <cmmanager.h>
       
    36 
       
    37 #include "mpmserversession.h"
       
    38 #include "mpmlogger.h"
       
    39 
       
    40 class CCDWlanServiceRecord;
       
    41 
       
    42 using namespace CommsDat;
       
    43 using namespace CMManager;
       
    44 
       
    45 const TInt KMpmDoubleLength = 2;
       
    46 
       
    47 // Modem bearer names for WLAN Access Points
       
    48 _LIT( KModemBearerWLAN, "WLANBearer" );
       
    49 
       
    50 // Length for allocating space for commsdat text fields
       
    51 //
       
    52 const TInt KCommsDatTextBufferLength = KMaxTextLength + 1;
       
    53 
       
    54 enum TWlanIapType
       
    55     {
       
    56     ENotWlanIap,
       
    57     EWlanIap,
       
    58     EEasyWlanIap
       
    59     };
       
    60 
       
    61 // Structure containing WLAN WEP key data
       
    62 // 
       
    63 class TWepKeyData
       
    64     {
       
    65 public:
       
    66     inline TWepKeyData(): 
       
    67     iWep1(),
       
    68     iWep2(),
       
    69     iWep3(),
       
    70     iWep4(),
       
    71     iWepFormat1( 0 ),
       
    72     iWepFormat2( 0 ),
       
    73     iWepFormat3( 0 ),
       
    74     iWepFormat4( 0 ),
       
    75     iDefaultWep( EWlanDefaultWepKey1 )
       
    76     {};
       
    77     
       
    78     TWlanWepKey iWep1;
       
    79     TWlanWepKey iWep2;
       
    80     TWlanWepKey iWep3;
       
    81     TWlanWepKey iWep4;
       
    82     TUint iWepFormat1;
       
    83     TUint iWepFormat2;
       
    84     TUint iWepFormat3;
       
    85     TUint iWepFormat4;
       
    86     TWlanDefaultWepKey iDefaultWep;
       
    87     };
       
    88 
       
    89 // CLASS DECLARATION
       
    90 /**
       
    91 *  
       
    92 *  @lib MPMServer.exe
       
    93 *  @since 
       
    94 */
       
    95 class CMPMCommsDatAccess : public CBase
       
    96     {
       
    97 
       
    98     public: // Constructors and destructor
       
    99 
       
   100         /**
       
   101         * Two-phased constructor.
       
   102         */
       
   103         static CMPMCommsDatAccess* NewL();
       
   104 
       
   105         /**
       
   106         * Destructor.
       
   107         */
       
   108         virtual ~CMPMCommsDatAccess();
       
   109 
       
   110     public: // New methods
       
   111 
       
   112         /**
       
   113         * Validates the given IAP.
       
   114         * @since 3.1
       
   115         * @param aConnId Connection Id
       
   116         * @param aIapId IAP Id to be validated
       
   117         * @param aNetId Network ID for the IAP
       
   118         * @param aLanOrWlan IAP uses either LAN or WLAN bearer
       
   119         * @param aSession Handle to session class
       
   120         */
       
   121 
       
   122         void ValidateIapL( const TConnectionId      aConnId, 
       
   123                            TUint32&                 aIapId, 
       
   124                            TUint32&                 aNetId, 
       
   125                            TBool&                   aLanOrWlan,
       
   126                            CMPMServerSession&       aSession );
       
   127 
       
   128         /**
       
   129         * Checks the bearer type of given IAP.
       
   130         * @since 3.1
       
   131         * @param aIapId IAP Id to be checked
       
   132         * @param aLanOrWlan IAP uses either LAN or WLAN bearer
       
   133         * @param aAvailableIAPList List of IAPs
       
   134         */
       
   135         void CheckBearerL( TUint32&                 aIapId, 
       
   136                            TBool&                   aLanOrWlan, 
       
   137                            const RAvailableIAPList& aAvailableIAPList,
       
   138                            CMPMServerSession&       aSession );
       
   139     
       
   140         /**
       
   141         * Checks if given IAP is Easy WLan.
       
   142         * @since 3.1
       
   143         * @param aIapId IAP Id to be checked
       
   144         * @return ETrue if IAP Id is Easy WLan, otherwise EFalse.
       
   145         */
       
   146         TBool CheckEasyWLanL( TUint32 aIapId ) const;
       
   147 
       
   148         /**
       
   149         * Find all snap ids
       
   150         *
       
   151         * @since 3.2
       
   152         * @param aSnapIds Array which will be set to 
       
   153         * contain the snap ids
       
   154         */
       
   155         void FindAllSnapsL( RArray<TUint>& aSnapIds );
       
   156 
       
   157         /**
       
   158         * Dump CommsDat IAPs to log in order to support testing.
       
   159         * @since 3.0
       
   160         */
       
   161         void DumpIAPsL() const;
       
   162 
       
   163         /**
       
   164         * Dump CommsDat Snaps to log in order to support 
       
   165         * testing.
       
   166         * @since 3.1
       
   167         */
       
   168         void DumpSnapsL();
       
   169 
       
   170         /**
       
   171         * Determine the priority for the Iap Id.
       
   172         * @since 3.1
       
   173         * @param aDNIaps List of found DN-IAP entries
       
   174         * @param aAvailableIAPs List of IAPs
       
   175 		* @param aSession Handle to session class.
       
   176         */
       
   177         void DeterminePrioritiesL( RArray<TNetIap>&         aDNIaps, 
       
   178                                    const RAvailableIAPList& aAvailableIAPs,
       
   179                                    CMPMServerSession&       aSession );
       
   180 
       
   181         /**
       
   182         * Finds the service type for the IAP and returns the global 
       
   183         * bearer priority for that service type.
       
   184         * @since 3.1
       
   185         * @param aIapId Given Iap Id
       
   186         * @param aPriority Global bearer priority for the service type
       
   187         */
       
   188         void GlobalBearerPriorityL( const TUint32    aIapId,
       
   189                                     TUint32&         aPriority);
       
   190 
       
   191         /**
       
   192         * Checks if there is a WLAN IAP in CommsDat.
       
   193         * @since 3.2
       
   194         * @param Handle to session class.
       
   195         */
       
   196         void CheckWLANIapL(CMPMServerSession& aSession);
       
   197 
       
   198         /**
       
   199         * Checks whether there is a wlan iap which matches the 
       
   200         * parameter settings.
       
   201         *
       
   202         * @since 3.2
       
   203         * @param aSsid Wlan iap ssid
       
   204         * @param aSecMode Wlan iap security mode
       
   205         * @param aConnMode Wlan iap connection mode
       
   206         */
       
   207         TUint32 CheckWLANIapWithSsidL( TWlanSsid& aSsid, 
       
   208                                        TUint32 aSecMode,
       
   209                                        TWlanNetMode aConnMode );
       
   210 
       
   211         /**
       
   212         * Stores easy wlan settings into commsdat. 
       
   213         *
       
   214         * @since 3.2
       
   215         * @param aSsid Wlan iap ssid, stored in used ssid field
       
   216         * @param aSecMode Wlan iap security mode
       
   217         * @param aConnMode Wlan iap connection mode
       
   218         * @param aWepData WEP key data
       
   219         * @param aEnableWpaPsk Wlan iap enable psk mode
       
   220         * @param aWpaPsk Wlan iap wpa psk
       
   221         * @param aWpaKeyLen Wlan iap wpa key length
       
   222         */
       
   223         void SetEasyWlanDataL( const TWlanSsid& aSsid,
       
   224                                TUint            aSecMode,
       
   225                                TWlanNetMode     aConnMode,
       
   226                                TWepKeyData      aWepData,
       
   227                                TUint            aEnableWpaPsk,
       
   228                                const TDesC8&    aWpaPsk,
       
   229                                TUint            aWpaKeyLen  );
       
   230 
       
   231         /**
       
   232         * Returns Easy wlan service record id.
       
   233         * @since 3.2
       
   234         * @param aDb DB session
       
   235         * return Easy wlan service record id
       
   236         */
       
   237         TUint32 FindEasyWlanServiceIdL( CMDBSession* aDb );
       
   238         
       
   239         /**
       
   240         * Checks if the HiddenAgent metadata is set for this IAP.
       
   241         * @since 3.2
       
   242         * @param aIapId Given Iap Id 
       
   243         * return ETrue if HiddenAgent metadata is set, otherwise EFalse.
       
   244         */
       
   245         TBool CheckHiddenAgentL( const TUint32 aIapId ) const;
       
   246 
       
   247         /**
       
   248         * Checks if the given IAP Id shares the same SSID 
       
   249         * as the active WLAN connection.
       
   250         * @since 3.2
       
   251         * @param aSSID the id of active wlan network.
       
   252         * @param aIapId IAP Id to be checked.
       
   253         * @param aMatchFound ETrue if the given IAP Id shares the same SSID 
       
   254         * as the active WLAN connection, otherwise EFalse.
       
   255         * @param aSession Handle to session class.
       
   256         */
       
   257         void MatchSSIDL( const TWlanSsid&   aSSID,
       
   258                          TUint32            aIapId, 
       
   259                          TBool&             aMatchFound,
       
   260                          CMPMServerSession& aSession );
       
   261         /**
       
   262         * Determines whether the IAP is a virtual IAP.
       
   263         * @since 3.2
       
   264         * @param aVirtualIapId Given virtual Iap Id
       
   265         */
       
   266         TBool IsVirtualIapL( const TUint32 aVirtualIapId ) const;
       
   267 
       
   268         /**
       
   269         * Determines whether the SNAP contains at least the 
       
   270         * specified number of WLAN IAPs.
       
   271         * @since 3.2
       
   272         * @param aSnapRecord Id of the SNAP record
       
   273         * @param aIapPath Chain of Iaps traversed this far. 
       
   274         * @param aMinNrWlan Minimum number of WLAN IAPs to search for 
       
   275         * Used for detecting loops in configuration
       
   276         */
       
   277         TBool SnapContainsWlanL( TUint32		aSnapRecord, 
       
   278         						 RArray<TUint>& aIapPath,
       
   279         						 TInt 			aMinNrWlan );
       
   280         
       
   281         /**
       
   282         * Calls SearchDNEntries for SNAP and if the SNAP contains
       
   283         * embedded SNAP also calls SearchDNEntries for that.
       
   284         * @since 3.2
       
   285         * @param aSnap SNAP id
       
   286         * @param aDestNetIaps Iaps of original SNAP are store here
       
   287         * @param aEmbeddedIaps Iaps of embedded SNAP are store here
       
   288         */
       
   289         void SearchDNEntriesWithEmbeddedL( TUint32 aSnap, 
       
   290                                            RArray<TNetIap>& aDestNetIaps,
       
   291                                            RArray<TNetIap>& aEmbeddedIaps );
       
   292 
       
   293         /**
       
   294         * Checks if given IAP is WLAN and whether it is EasyWLAN IAP.
       
   295         * @since 3.2
       
   296         * @param aIapId IAP Id to be checked
       
   297         * @return One of TWlanIapType values depending on 
       
   298         * whether IAP is WLAN or Easy WLAN
       
   299         */
       
   300         TWlanIapType CheckWlanL( TUint32 aIapId ) const;
       
   301 
       
   302         /**
       
   303         * Removes categorised IAPs from the list of available IAPs.
       
   304         * @since 3.2
       
   305         * @param aIAPList List of IAPs
       
   306         */
       
   307         void RemoveCategorisedIapsL( RAvailableIAPList& aIAPList );
       
   308 
       
   309        /**
       
   310         * Get service id of an iap.
       
   311         * @since 3.2
       
   312         * @param aIapId Id of an Iap.
       
   313         */
       
   314        TUint32 GetIapServiceIdL( TUint32 aIapId );
       
   315 
       
   316        /**
       
   317         * Returns ElementId of the record with attribute and flags bit 
       
   318         * removed. 
       
   319         * 
       
   320         * THIS METHOD MUST BE USED INSTEAD OF COMMSDAT ElementId() 
       
   321         * in order to clear possible attribute/flag bits. 
       
   322         * Otherwise Find may fail if incorrect element id is used.
       
   323         *
       
   324         * @since 3.2
       
   325         * @param aRecord A record to get the element id from
       
   326         * @return Element id value
       
   327         */        
       
   328         static TUint32 GetRealElementId( CMDBRecordBase* aRecord );
       
   329         
       
   330         /**
       
   331          * Check if the Wlan background scan is on.
       
   332          * @return ETrue if set.
       
   333          */
       
   334         TBool WlanBackgroundScanIsOnL();
       
   335 
       
   336        /**
       
   337         * Returns true if destination is internet or 
       
   338         * iap belongs to internet destination.
       
   339         * @since 5.1
       
   340         * @param aIapId IAP id
       
   341         * @param aSnapId Snap id
       
   342         * @return True or false depending on destination type.
       
   343         */
       
   344         TBool IsInternetSnapL( TUint32 aIapId, TUint32 aSnapId );
       
   345 
       
   346        /**
       
   347         * Used to get bearer type of the iap.
       
   348         *
       
   349         * @since 5.0
       
   350         * @param aIapId Iap id of the connection.
       
   351         * @return Type of the bearer.
       
   352         */
       
   353         TMPMBearerType GetBearerTypeL( TUint32 aIapId );
       
   354         
       
   355        /**
       
   356         * Check if all active connections are in same snap.
       
   357         *
       
   358         * @since 5.0
       
   359         * @param aActiveBMConns Array of active connections.
       
   360         * @param aSnapId Destination where connections are located is returned
       
   361         *                to this parameter.
       
   362         * @return ETrue if all active connections are in same snap.
       
   363         */
       
   364         TBool AreActiveIapsInSameSnapL ( RArray<TActiveBMConn>& aActiveBMConns,
       
   365                                          TUint32& aSnapId );
       
   366 
       
   367        /**
       
   368         * Select active connection according to snap priorities.
       
   369         *
       
   370         * @since 5.0
       
   371         * @param aSnapId Snap id of the connection.
       
   372         * @param aActiveBMConns Array of active connections.
       
   373         * @param aActiveIapId Iap id of the selected active connection.
       
   374         * @param aActiveSnapId Snap id of the selected active connection.
       
   375         * @param aActiveBearerType Bearer type of the selected active connection.
       
   376         * @param aSession Handle to session class.
       
   377         */
       
   378         void SelectActiveConnectionL ( const TUint32 aSnapId,
       
   379                                        RArray<TActiveBMConn>& aActiveBMConns,
       
   380                                        TUint32& aActiveIapId,
       
   381                                        TUint32& aActiveSnapId,
       
   382                                        TMPMBearerType& aActiveBearerType,
       
   383                                        CMPMServerSession& aSession );
       
   384 
       
   385        /**
       
   386         * Check if snap is empty.
       
   387         *
       
   388         * @since 5.0
       
   389         * @param aSnapId Snap id of the connection.
       
   390         * @return ETrue if snap is empty.
       
   391         */
       
   392         TBool IsSnapEmptyL( TUint32 aSnapId );
       
   393 
       
   394        /**
       
   395         * Verifies that Iap exists. Leaves with error code otherwise
       
   396         * @since 9.1
       
   397         * @param aIapId Iap
       
   398         */        
       
   399         void VerifyIapExistsL( TUint32 aIapId );
       
   400 
       
   401         /**
       
   402          * Gets SnapTierTagId
       
   403          * @param aDbs commsdat session
       
   404          * @param ElementId
       
   405          * @return TagId
       
   406          */
       
   407         TInt TierLinktoTagIdL( CMDBSession* aDbs, TUint32 aElementId ); 
       
   408 
       
   409         /**
       
   410          * Maps SNAP RecId to SNAP AP
       
   411          * @since 9.1
       
   412          * @param aApRecId netid
       
   413          * @return SNAP AP
       
   414          */
       
   415          TInt MapAPRecIdtoSnapAPL( TInt aApRecId );
       
   416 
       
   417         /**
       
   418          * Maps NetId to SNAP AP
       
   419          * @since 9.1
       
   420          * @param aNetId netid
       
   421          * @return SNAP AP
       
   422          */
       
   423          TInt MapNetIdtoSnapAPL( TInt aNetId );
       
   424 
       
   425         /**
       
   426          * Maps SNAP AP to NetId
       
   427          * @since 9.1
       
   428          * @param aAP APId
       
   429          * @return NetId
       
   430          */
       
   431          TInt MapSnapAPtoNetIdL( TInt aAP );
       
   432 
       
   433 
       
   434         /**
       
   435         * Finds DN-IAP entries based on given Snap Id.
       
   436         * @since 3.1
       
   437         * @param aSnapId Given Snap Id
       
   438         * @param aDestNetIds List of found DN-IAP entries
       
   439         */
       
   440         void SearchDNEntriesL( const TUint32&   aSnapId,
       
   441                                RArray<TNetIap>& aDestNetIds );
       
   442 
       
   443         /**
       
   444          * Get current forced roam setting
       
   445          * @since 5.2
       
   446          * @return Current forced roam setting in commsdat.
       
   447          */
       
   448         TCmUsageOfWlan ForcedRoamingL() const;
       
   449                 
       
   450         /**
       
   451          * Read current general connection settings from CommsDat
       
   452          * @since 5.2
       
   453          * @return Current general connection settings from CommsDat.
       
   454          */        
       
   455         TCmGenConnSettings ReadGenConnSettingsL() const;
       
   456         
       
   457         /**
       
   458          * Write general connection settings to CommsDat
       
   459          * @since 5.2
       
   460          * @param aGenConnSettings General connection settings to written to CommsDat
       
   461          */
       
   462         void WriteGenConnSettingsL(TCmGenConnSettings& aGenConnSettings);
       
   463         
       
   464         /**
       
   465         * Returns Snap id of destination requested in Snap purpose.
       
   466         * @since 5.2
       
   467         * @return Snap id.
       
   468         */
       
   469         TUint32 DestinationIdL( CMManager::TSnapPurpose aSnapPurpose );
       
   470         	
       
   471     private:
       
   472 
       
   473        /**
       
   474         * Loads Iap record based on record id.
       
   475         * @since 3.2
       
   476         * @param aIapId Id of an Iap.
       
   477         * @param aDb DB session.
       
   478         * @return Iap record
       
   479         */
       
   480         CCDIAPRecord* LoadIapRecordLC( const TUint32 aIapId, CMDBSession* aDb ) const;
       
   481 
       
   482         /**
       
   483         * Finds access network Id based on given IAP Id.
       
   484         * @since 3.1
       
   485         * @param aIapId Given IAP Id
       
   486         * @param aNetId Found access network Id
       
   487         */
       
   488         void SearchAccessNetIdL( const TUint32&  aIapId,
       
   489                                  TUint32&        aNetId );
       
   490 
       
   491         /**
       
   492         * Checks if given virtual IAP may use underlying WLAN IAP.
       
   493         * @since 3.2
       
   494         * @param aVirtualIapId IAP Id to be checked
       
   495         * @param aIapPath Chain of Iaps traversed this far. 
       
   496         * Used for detecting loops in configuration
       
   497         * @return ETrue WLAN IAP exists under the virtual IAP, 
       
   498         * otherwise EFalse.
       
   499         */
       
   500         TBool WlanUnderVirtualL( const TUint32 aVirtualIapId, RArray<TUint>& aIapPath  );
       
   501 
       
   502         /**
       
   503         * Finds the real IAP behind the virtual IAP.
       
   504         * @since 3.1
       
   505         * @param aVirtualIapId Given virtual Iap Id
       
   506         * @param aRealIapId Real Iap Id
       
   507         * @param aAvailableIAPList List of IAPs
       
   508         * @param aSession Handle to session class
       
   509         */
       
   510         void FindRealIapL( const TUint32             aVirtualIapId,
       
   511                            TUint32&                  aRealIapId, 
       
   512                            const RAvailableIAPList&  aAvailableIAPList,
       
   513                            CMPMServerSession&        aSession );
       
   514 
       
   515        /**
       
   516         * loads linked record using element id.
       
   517         * @since 3.2
       
   518         * @param aSession DB Session to use
       
   519         * @param aElementId Link element id 
       
   520         * @return Pointer to allocated record structure.
       
   521         */        
       
   522         CCDRecordBase* LoadLinkedRecordL( CMDBSession&  aSession, 
       
   523                                           TMDBElementId aElementId );
       
   524 
       
   525         /**
       
   526          * Sets WEP key data for WLAN service record
       
   527          * @since 9.1
       
   528          * @param aFormatId Id of the field where WEP format is stored
       
   529          * @param aKeyId Id of the field where WEP key is stored
       
   530          * @param aWepData WEP key value
       
   531          * @param aWepFormat WEP key format value
       
   532          * @param aRecord WLAN service record where data is stored
       
   533          */        
       
   534        void SetWepKeyL( TMDBElementId       aFormatId,
       
   535                         TMDBElementId       aKeyId, 
       
   536                         TWlanWepKey         aWepData,
       
   537                         TUint               aWepFormat,
       
   538                         CMDBGenericRecord*  aRecord );
       
   539         
       
   540        /**
       
   541         * Converts ascii data to hex
       
   542         * @since 3.2
       
   543         * @param aSource Ascii data
       
   544         * @param aDest hex data to be filled in
       
   545         */        
       
   546         void ConvertAsciiToHex( const TDesC8& aSource, 
       
   547 				                HBufC8*      aDest );
       
   548 
       
   549        /**
       
   550         * Returns true if destination is internet.
       
   551         * @since 5.1
       
   552         * @param aDb Handle to database session. 
       
   553         * @param aSnapId Destination id
       
   554         * @return True or false depending on destination type.
       
   555         */
       
   556         TBool IsInternetSnapL( CMDBSession& aDb, TUint32 aSnapId );
       
   557 
       
   558        /**
       
   559         * Check whether bearer type is wlan
       
   560         *
       
   561         * @since 5.0
       
   562         * @param aWlanArray Array of wlan bearers
       
   563         * @param aBearerId Bearer id
       
   564         * @return Returns ETrue in case of wlan bearer
       
   565         */
       
   566         TBool IsWlanBearer(RArray<TUint32>& aWlanArray, TInt aBearerId);
       
   567 
       
   568        /**
       
   569         * Builds wlan bearer array
       
   570         * 
       
   571         * @since 5.0
       
   572         * @param aDb Handle to database session
       
   573         * @param aWlanArray Array of wlan bearers
       
   574         */
       
   575         void BuildWlanArrayL(CMDBSession& aDb, RArray<TUint32>& aWlanArray);
       
   576         
       
   577        /**
       
   578         * Get snap id for the iap
       
   579         * 
       
   580         * @since 5.0
       
   581         * @param aIapId Id of the iap
       
   582         * @return Id of the snap
       
   583         */
       
   584         TUint32 GetSnapIdL( TUint32 aIapId );
       
   585 
       
   586         /**
       
   587         * C++ default constructor.
       
   588         */
       
   589         CMPMCommsDatAccess();
       
   590 
       
   591         /**
       
   592         * 2nd phase constructor.
       
   593         */
       
   594         void ConstructL();
       
   595 
       
   596     };
       
   597 
       
   598 #endif // MPMCOMMSDATACCESS_H
       
   599 
       
   600 // End of File