multimediacommsengine/tsrc/testdriver/siptester/src/TCmdSetDomainParams.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <centralrepository.h>
       
    20 #include <unsafprotocolscrkeys.h>
       
    21 #include "CTcSIPContext.h"
       
    22 #include "TCmdSetDomainParams.h"
       
    23 #include "SIPConstants.h"
       
    24 
       
    25 
       
    26 /**
       
    27  *
       
    28  * If value KErrNotFound (-1) is given in KParamUNSAFSharedSecretNotSupported or 
       
    29  * KParamUNSAFBindingRequestFailed, the corresponding value is removed from CR
       
    30  *
       
    31  * INPUT:
       
    32  *   Headers:		-
       
    33  *   Parameters:	KParamDomainName, KParamUNSAFSharedSecretNotSupported*,
       
    34  *                  KParamUNSAFBindingRequestFailed*
       
    35  *   IDs:			-
       
    36  *
       
    37  * OUTPUT:
       
    38  *   Parameters:	-
       
    39  *   IDs:			-
       
    40  */
       
    41 void TCmdSetDomainParams::ExecuteL()
       
    42 	{
       
    43 	TPtrC8 proxy = ExtractTextL( KParamDomainName, ETrue );
       
    44 	
       
    45 	TInt sharedSecretNotSupported = ExtractIntegerL( KParamUNSAFSharedSecretNotSupported, KErrGeneral, EFalse );
       
    46 	
       
    47 	TInt bindingRequestFailed = ExtractIntegerL( KParamUNSAFBindingRequestFailed, KErrGeneral, EFalse );
       
    48 
       
    49 	CRepository* repository = CRepository::NewLC( KCRUidUNSAFProtocols );
       
    50 	TUint32 key( 0 );
       
    51 	TInt status = FindDomainKeyL( *repository, proxy, key );
       
    52 	__ASSERT_ALWAYS( status == KErrNone || status == KErrNotFound,
       
    53 					 User::Leave( status ) );
       
    54 
       
    55 	User::LeaveIfError(
       
    56 		repository->StartTransaction(
       
    57 			CRepository::EConcurrentReadWriteTransaction ) );
       
    58     repository->CleanupCancelTransactionPushL();
       
    59 
       
    60 	if ( status == KErrNotFound )
       
    61 		{
       
    62 		key = CreateNewKeyL( *repository,
       
    63                              KUNSAFProtocolsDomainMask,
       
    64                              KUNSAFProtocolsDomainTableMask );
       
    65     	WriteL( *repository, KUNSAFProtocolsDomainMask | key, proxy );
       
    66 		}
       
    67 
       
    68 	
       
    69 	if ( sharedSecretNotSupported >= 0 ) 	
       
    70 	    {
       
    71 		WriteL( *repository, 
       
    72 		        KUNSAFProtocolsDomainSharedSecretNotSupported | key, 
       
    73 		        sharedSecretNotSupported );
       
    74 		}
       
    75     if ( sharedSecretNotSupported == KErrNotFound )
       
    76         {
       
    77        	RemoveParameterL( *repository,
       
    78 					      KUNSAFProtocolsDomainSharedSecretNotSupported | key );
       
    79         }
       
    80         
       
    81     if ( bindingRequestFailed >= 0 ) 	
       
    82 	    {
       
    83 		WriteL( *repository, 
       
    84 		        KUNSAFProtocolsDomainBindingRequestFailed | key, 
       
    85 		        bindingRequestFailed );
       
    86 		}
       
    87     if ( bindingRequestFailed == KErrNotFound )
       
    88         {
       
    89        	RemoveParameterL( *repository,
       
    90 					      KUNSAFProtocolsDomainBindingRequestFailed | key );
       
    91         }
       
    92 
       
    93 	TUint32 dummy( 0 );
       
    94     User::LeaveIfError( repository->CommitTransaction( dummy ) );
       
    95     CleanupStack::Pop( 1 ); // transaction
       
    96 
       
    97 	CleanupStack::PopAndDestroy( repository );	
       
    98 	}
       
    99 
       
   100 TBool TCmdSetDomainParams::Match( const TTcIdentifier& aId )
       
   101 	{
       
   102 	return TTcSIPCommandBase::Match( aId, _L8("SetDomainParams") );	
       
   103 	}
       
   104 
       
   105 TTcCommandBase* TCmdSetDomainParams::CreateL( MTcTestContext& aContext )
       
   106 	{
       
   107 	return new( ELeave ) TCmdSetDomainParams( aContext );
       
   108 	}