natfw/tsrc/natfwtestconsoles/natfwtestconsole/src/generalsettings.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2007 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:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "generalsettings.h"
       
    22 
       
    23 #include <unsafprotocolscrkeys.h>
       
    24 
       
    25 
       
    26 //  CONSTANTS
       
    27 
       
    28 /******************************************************/
       
    29 //Settings
       
    30 //Domain spesific settings
       
    31 
       
    32 _LIT8( KSTUNServAddr, "193.65.183.3:3478" );
       
    33 //const TInt KNATRefreshTCP = 500;
       
    34 //const TInt KNATRefreshUDP = 500;
       
    35 //const TInt KEnableCRLFRefresh = 0;
       
    36 _LIT8( KSTUNServUsername, "username" );
       
    37 _LIT8( KSTUNServPassword, "password" );
       
    38 // none additional STUN server settings
       
    39 _LIT8( KNatProtocol, "nokia.stun" );
       
    40 const TInt KSharedsecretNotSupported = 1; // 0 = supported
       
    41 const TInt KPortPoolStartPort = 5000;
       
    42 const TInt KPortPoolEndPort = 5100;
       
    43 //ICE spesific in the Domain settings 
       
    44 //TURN specific in the Domain settings 
       
    45 //const TInt KLifeTime = 500;
       
    46 //const TInt KTimerValue = 500;
       
    47 //IAP Spesific settings
       
    48 const TInt KIAPNATRefreshTCP = 100;
       
    49 const TInt KIAPNATRefreshUDP = 100;
       
    50 const TInt KIAPSTUNRetransmit = 20;
       
    51 
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CGeneralSettings::NewL
       
    55 // -----------------------------------------------------------------------------
       
    56 // 
       
    57 CGeneralSettings* CGeneralSettings::NewL( const TDesC8& aDomain,
       
    58                                                  TUint aIapId )
       
    59     {
       
    60     CGeneralSettings* self = CGeneralSettings::NewLC(aDomain, aIapId );
       
    61     CleanupStack::Pop( self );
       
    62     return self;
       
    63     }
       
    64 
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // CGeneralSettings::NewL
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 CGeneralSettings* CGeneralSettings::NewLC( const TDesC8& aDomain,
       
    71                                                   TUint aIapId )
       
    72     {   
       
    73     CGeneralSettings* self = new( ELeave ) CGeneralSettings( aIapId );
       
    74     CleanupStack::PushL( self );
       
    75     self->ConstructL( aDomain );
       
    76     return self;
       
    77     }
       
    78     
       
    79     
       
    80 // -----------------------------------------------------------------------------
       
    81 // CGeneralSettings::CGeneralSettings
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 CGeneralSettings::CGeneralSettings( TUint aIapId )
       
    85     : iIapId( aIapId )
       
    86     {
       
    87     }
       
    88     
       
    89     
       
    90 // -----------------------------------------------------------------------------
       
    91 // CGeneralSettings::~CGeneralSettings
       
    92 // -----------------------------------------------------------------------------
       
    93 //   
       
    94 CGeneralSettings::~CGeneralSettings( )
       
    95     {
       
    96     EraseL( KUNSAFProtocolsDomainTableMask, 0xf0000000 );
       
    97  	EraseL( KUNSAFProtocolsIAPTableMask, 0xf0000000 );
       
    98  	delete iDomain;
       
    99     }
       
   100     
       
   101     
       
   102 // -----------------------------------------------------------------------------
       
   103 // CGeneralSettings::ConstructL
       
   104 // -----------------------------------------------------------------------------
       
   105 //    
       
   106 void CGeneralSettings::ConstructL( const TDesC8& aDomain )
       
   107     {
       
   108     iDomain = aDomain.AllocL();
       
   109     ConstructBaseL();
       
   110     }
       
   111 
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // CGeneralSettings::GetDomainKey
       
   115 // -----------------------------------------------------------------------------
       
   116 //      
       
   117 TInt CGeneralSettings::GetDomainKey( TUint32& aDomainKey )
       
   118     {
       
   119     TInt error = ReadDomainSettingsKeyL( *iDomain, aDomainKey );
       
   120     
       
   121     if( KErrNotFound == error )
       
   122         {
       
   123         aDomainKey = CreateNewTableKeyL(
       
   124             KUNSAFProtocolsDomainTableMask, KUNSAFProtocolsFieldTypeMask );
       
   125         StoreL( KUNSAFProtocolsDomainMask | aDomainKey, *iDomain );
       
   126         return KErrNone;
       
   127         }
       
   128     else
       
   129         {
       
   130         return error;
       
   131         }
       
   132     }
       
   133     
       
   134     
       
   135 // -----------------------------------------------------------------------------
       
   136 // CGeneralSettings::CreateSettingsL
       
   137 // -----------------------------------------------------------------------------
       
   138 //   
       
   139 void CGeneralSettings::CreateSettingsL()
       
   140     {
       
   141     TUint32 domainKey;
       
   142     User::LeaveIfError( GetDomainKey( domainKey ) );
       
   143 
       
   144     //create key for the stun server settings in the domain settings
       
   145     TUint32 STUNServerKey = CreateNewTableKeyL(
       
   146         KUNSAFProtocolsSTUNServerTableMask | domainKey,
       
   147         KUNSAFProtocolsSubTableFieldTypeMask );
       
   148     //create key for the Iap settings
       
   149     TUint32 IapKey = CreateNewTableKeyL(
       
   150         KUNSAFProtocolsIAPTableMask, KUNSAFProtocolsFieldTypeMask );
       
   151     
       
   152     //Settings
       
   153     /************************************************************************/
       
   154     //Domain spesific settings
       
   155     StoreL( KUNSAFProtocolsDomainSharedSecretNotSupported |
       
   156         domainKey, KSharedsecretNotSupported );    
       
   157     StoreL( KUNSAFProtocolsPortPoolStartPortMask | domainKey,
       
   158         KPortPoolStartPort );
       
   159     StoreL( KUNSAFProtocolsPortPoolEndPortMask | domainKey, 
       
   160         KPortPoolEndPort );
       
   161     /************************************************************************/
       
   162     //STUN-server  settings in the domain
       
   163     StoreL( KUNSAFProtocolsSTUNAddressMask | domainKey | STUNServerKey,
       
   164         KSTUNServAddr );
       
   165     /*
       
   166     StoreL( KUNSAFProtocolsSTUNTCPTimeoutMask | domainKey | 
       
   167         STUNServerKey, KNATRefreshTCP );
       
   168     StoreL( KUNSAFProtocolsSTUNUDPTimeoutMask | domainKey | 
       
   169         STUNServerKey, KNATRefreshUDP );
       
   170     StoreL( KUNSAFProtocolsSTUNEnableCRLFRefreshMask | domainKey | 
       
   171         STUNServerKey, KEnableCRLFRefresh );
       
   172     */
       
   173     StoreL( KUNSAFProtocolsSTUNUsernameMask | domainKey | STUNServerKey,
       
   174         KSTUNServUsername );
       
   175     StoreL( KUNSAFProtocolsSTUNPasswordMask | domainKey | STUNServerKey,
       
   176         KSTUNServPassword );
       
   177     
       
   178     /************************************************************************/
       
   179     //ICE spesific in the Domain settings
       
   180     /*
       
   181     StoreL( KUNSAFProtocolsICECandidateTimerMask | domainKey,
       
   182         KAnotherCanditateTimer );
       
   183     */
       
   184     StoreL( KUNSAFProtocolsUsedNATProtocolMask | domainKey, 
       
   185         KNatProtocol );
       
   186     /************************************************************************/
       
   187     //TURN specific in the Domain settings
       
   188     /*
       
   189     StoreL( KUNSAFProtocolsTURNLifeTimeMask | domainKey, KLifeTime );
       
   190     StoreL( KUNSAFProtocolsTURNTimerValueMask | domainKey, 
       
   191         KTimerValue );
       
   192     */
       
   193     /************************************************************************/
       
   194     //IAP Spesific settings
       
   195     StoreL( KUNSAFProtocolsIAPIdMask | IapKey, iIapId );
       
   196     StoreL( KUNSAFProtocolsIntervalTCPMask | IapKey, 
       
   197         KIAPNATRefreshTCP );
       
   198     StoreL( KUNSAFProtocolsIntervalUDPMask | IapKey, 
       
   199         KIAPNATRefreshUDP );
       
   200     StoreL( KUNSAFProtocolsSTUNRetransmitTimerMask | IapKey, 
       
   201         KIAPSTUNRetransmit );
       
   202     }
       
   203