natfw/natfwstunplugin/tsrc/ut_cnatfwstunplugin/stubs/testsettings.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 "testsettings.h"
       
    22 
       
    23 #include <unsafprotocolscrkeys.h>
       
    24 #include "natfwdefaultsettingsvalues.h"
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // CTestSettings::NewL
       
    28 // -----------------------------------------------------------------------------
       
    29 // 
       
    30 CTestSettings* CTestSettings::NewL( const TDesC8& aDomain,
       
    31                                                  TUint aIapId )
       
    32     {
       
    33     CTestSettings* self = CTestSettings::NewLC(aDomain, aIapId );
       
    34     CleanupStack::Pop( self );
       
    35     return self;
       
    36     }
       
    37 
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CTestSettings::NewL
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 CTestSettings* CTestSettings::NewLC( const TDesC8& aDomain,
       
    44                                                   TUint aIapId )
       
    45     {   
       
    46     CTestSettings* self = new( ELeave ) CTestSettings( aIapId );
       
    47     CleanupStack::PushL( self );
       
    48     self->ConstructL( aDomain );
       
    49     return self;
       
    50     }
       
    51     
       
    52     
       
    53 // -----------------------------------------------------------------------------
       
    54 // CTestSettings::CTestSettings
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 CTestSettings::CTestSettings( TUint aIapId )
       
    58     : iIapId( aIapId )
       
    59     {
       
    60     //iUdpTimeOut = KNATFWDefaultUDPTimeout;
       
    61     //iTcpTimeOut = KNATFWDefaultTCPTimeout;
       
    62     iUdpRefreshInterval = KNATFWDefaultIapRefreshIntervalUdp;
       
    63     iTcpRefreshInterval = KNATFWDefaultIapRefreshIntervalTcp;
       
    64     iStunRetransmitTimer = KNATFWDefaultStunRetransmitTimer;
       
    65     iUseSharedSecret = KNATFWDefaultUseSharedSecret;
       
    66     iTurnTimerValue = KNATFWDefaultTURNTimerValue;
       
    67     iPortPoolStartPort = KNATFWDefaultPortPoolStartPort;
       
    68     iPortPoolEndPort = KNATFWDefaultPortPoolEndPort;
       
    69     iEnableCrlfRefresh = KNATFWDefaultCRLFRefreshEnabled;
       
    70     //iConnectivityCheckTimeout = KNATFWDefaultConnectivityCheckTimeout;
       
    71     iStunServerPort = 0;
       
    72  	iTurnServerPort = 0;
       
    73     }
       
    74     
       
    75     
       
    76 // -----------------------------------------------------------------------------
       
    77 // CTestSettings::~CTestSettings
       
    78 // -----------------------------------------------------------------------------
       
    79 //   
       
    80 CTestSettings::~CTestSettings( )
       
    81     {
       
    82     EraseL( KUNSAFProtocolsDomainTableMask, 0xf0000000 );
       
    83  	EraseL( KUNSAFProtocolsIAPTableMask, 0xf0000000 );
       
    84  	delete iLatestConnectedStunServerAddress;
       
    85     delete iLatestConnectedTurnServerAddress;
       
    86     delete iEcomPlugInPriorityOrder;
       
    87     delete iIceUsedPlugIns;
       
    88     delete iServerUsername; 
       
    89     delete iServerPassword;
       
    90     delete iStunServerAddr;
       
    91     delete iTurnServerAddr;
       
    92     delete iRequestedAddress;
       
    93     delete iDomain;
       
    94     }
       
    95     
       
    96     
       
    97 // -----------------------------------------------------------------------------
       
    98 // CTestSettings::ConstructL
       
    99 // -----------------------------------------------------------------------------
       
   100 //    
       
   101 void CTestSettings::ConstructL( const TDesC8& aDomain )
       
   102     {
       
   103     iDomain = aDomain.AllocL();
       
   104 
       
   105     iLatestConnectedStunServerAddress = KNullDesC8().AllocL();
       
   106     iLatestConnectedTurnServerAddress = KNullDesC8().AllocL();
       
   107     iEcomPlugInPriorityOrder = KNATFWDefaultPriorityOrder().AllocL();
       
   108     iIceUsedPlugIns = KNATFWDefaultIceUsedPlugins().AllocL();
       
   109     iServerUsername = KNullDesC8().AllocL(); 
       
   110     iServerPassword = KNullDesC8().AllocL();
       
   111     iStunServerAddr = KNullDesC8().AllocL();
       
   112     iTurnServerAddr = KNullDesC8().AllocL();
       
   113     iRequestedAddress = KNullDesC8().AllocL();
       
   114     
       
   115     ConstructBaseL();
       
   116     }
       
   117 
       
   118 
       
   119 // -----------------------------------------------------------------------------
       
   120 // CTestSettings::GetDomainKey
       
   121 // -----------------------------------------------------------------------------
       
   122 //      
       
   123 TInt CTestSettings::GetDomainKey( TUint32& aDomainKey )
       
   124     {
       
   125     TInt error = ReadDomainSettingsKeyL( *iDomain, aDomainKey );
       
   126     
       
   127     if( KErrNotFound == error )
       
   128         {
       
   129         aDomainKey = CreateNewTableKeyL(
       
   130             KUNSAFProtocolsDomainTableMask, KUNSAFProtocolsFieldTypeMask );
       
   131         StoreL( KUNSAFProtocolsDomainMask | aDomainKey, *iDomain );
       
   132         return KErrNone;
       
   133         }
       
   134     else
       
   135         {
       
   136         return error;
       
   137         }
       
   138     }
       
   139     
       
   140     
       
   141 // -----------------------------------------------------------------------------
       
   142 // CTestSettings::CreateSettingsL
       
   143 // -----------------------------------------------------------------------------
       
   144 //   
       
   145 void CTestSettings::CreateSettingsL()
       
   146     {
       
   147     TUint32 domainKey;
       
   148     User::LeaveIfError( GetDomainKey( domainKey ) );
       
   149 
       
   150     //create key for the stun server settings in the domain settings
       
   151     TUint32 StunServerKey = CreateNewTableKeyL(
       
   152         KUNSAFProtocolsSTUNServerTableMask | domainKey,
       
   153         KUNSAFProtocolsSubTableFieldTypeMask );
       
   154     //create key for the turn server settings in the domain settings
       
   155     TUint32 TurnServerKey = CreateNewTableKeyL(
       
   156         KUNSAFProtocolsTURNServerTableMask | domainKey,
       
   157         KUNSAFProtocolsSubTableFieldTypeMask );
       
   158     //create key for the Iap settings
       
   159     TUint32 IapKey = CreateNewTableKeyL(
       
   160         KUNSAFProtocolsIAPTableMask, KUNSAFProtocolsFieldTypeMask );
       
   161     
       
   162     //Settings
       
   163     /************************************************************************/
       
   164     //Domain spesific settings
       
   165     StoreL( KUNSAFProtocolsDomainSharedSecretNotSupported |
       
   166         domainKey, !iUseSharedSecret );    
       
   167     StoreL( KUNSAFProtocolsPortPoolStartPortMask | domainKey,
       
   168         iPortPoolStartPort );
       
   169     StoreL( KUNSAFProtocolsPortPoolEndPortMask | domainKey, 
       
   170         iPortPoolEndPort );
       
   171     StoreL( KUNSAFProtocolsUsedNATProtocolMask | domainKey, 
       
   172         *iEcomPlugInPriorityOrder );
       
   173     StoreL( KUNSAFProtocolsLatestConnectedSTUNServerAddressMask | domainKey, 
       
   174         *iLatestConnectedStunServerAddress );
       
   175     StoreL( KUNSAFProtocolsLatestConnectedTURNServerAddressMask | domainKey, 
       
   176         *iLatestConnectedTurnServerAddress );
       
   177         
       
   178     /************************************************************************/
       
   179     //STUN-server  settings in the domain
       
   180     StoreL( KUNSAFProtocolsSTUNAddressMask | domainKey | StunServerKey,
       
   181         *iStunServerAddr );
       
   182     /*
       
   183     StoreL( KUNSAFProtocolsSTUNTCPTimeoutMask | domainKey | 
       
   184         StunServerKey, iTcpTimeOut );
       
   185     StoreL( KUNSAFProtocolsSTUNUDPTimeoutMask | domainKey | 
       
   186         StunServerKey, iUdpTimeOut );
       
   187     */
       
   188     StoreL( KNATFWDefaultCRLFRefreshEnabled | domainKey | 
       
   189         StunServerKey, iEnableCrlfRefresh );
       
   190     StoreL( KUNSAFProtocolsSTUNConnectivityCheckTimeoutMask | domainKey |
       
   191         StunServerKey, iConnectivityCheckTimeout );
       
   192     StoreL( KUNSAFProtocolsSTUNUsernameMask | domainKey | StunServerKey,
       
   193         *iServerUsername );
       
   194     StoreL( KUNSAFProtocolsSTUNPasswordMask | domainKey | StunServerKey,
       
   195         *iServerPassword );
       
   196     
       
   197     /************************************************************************/
       
   198     //ICE spesific in the Domain settings
       
   199     StoreL( KUNSAFProtocolsNATUtilities | domainKey,
       
   200         *iIceUsedPlugIns );
       
   201         
       
   202     /************************************************************************/
       
   203     //TURN specific in the Domain settings
       
   204     /*
       
   205     StoreL( KUNSAFProtocolsTURNTimerValueMask | domainKey, 
       
   206         iTurnTimerValue );
       
   207     */
       
   208     /************************************************************************/
       
   209     //TURN Server Settings
       
   210     StoreL( KUNSAFProtocolsTURNAddressMask | domainKey | TurnServerKey,
       
   211         *iTurnServerAddr );
       
   212     /*
       
   213     StoreL( KUNSAFProtocolsTURNTCPTimeoutMask | domainKey | 
       
   214         TurnServerKey, iTcpTimeOut );
       
   215     StoreL( KUNSAFProtocolsTURNUDPTimeoutMask | domainKey | 
       
   216         TurnServerKey, iUdpTimeOut );
       
   217     StoreL( KUNSAFProtocolsTURNEnableCRLFRefreshMask | domainKey | 
       
   218         TurnServerKey, iEnableCrlfRefresh );
       
   219     */
       
   220     StoreL( KUNSAFProtocolsTURNConnectivityCheckTimeoutMask | domainKey |
       
   221         TurnServerKey, iConnectivityCheckTimeout );
       
   222     StoreL( KUNSAFProtocolsTURNUsernameMask | domainKey | TurnServerKey,
       
   223         *iServerUsername );
       
   224     StoreL( KUNSAFProtocolsTURNPasswordMask | domainKey | TurnServerKey,
       
   225         *iServerPassword );
       
   226         
       
   227     /************************************************************************/
       
   228     //IAP Spesific settings
       
   229     StoreL( KUNSAFProtocolsIAPIdMask | IapKey, iIapId );
       
   230     StoreL( KUNSAFProtocolsIntervalTCPMask | IapKey, 
       
   231         iTcpRefreshInterval );
       
   232     StoreL( KUNSAFProtocolsIntervalUDPMask | IapKey, 
       
   233         iUdpRefreshInterval );
       
   234     StoreL( KUNSAFProtocolsSTUNRetransmitTimerMask | IapKey, 
       
   235         iStunRetransmitTimer );
       
   236     }
       
   237