multimediacommsengine/tsrc/testdriver/siptester/src/TCmdAddUserToClientResolverCenRep.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:  Implementation
       
    15 *
       
    16 */
       
    17 
       
    18 #include <centralrepository.h>
       
    19 #include "TCmdAddUserToClientResolverCenRep.h"
       
    20 #include "SIPConstants.h"
       
    21 #include "CTcSIPContext.h"
       
    22 #include "sipclientresolverconfigcrkeys.h"
       
    23 
       
    24 /**
       
    25  * INPUT:
       
    26  *   Headers:		-
       
    27  *   Parameters:	UserName, PluginUid, ApplicationUid
       
    28  *   IDs:			-
       
    29  *
       
    30  * OUTPUT:
       
    31  *   Parameters:	-
       
    32  *   IDs:			-
       
    33  */
       
    34 void TCmdAddUserToClientResolverCenRep::ExecuteL()
       
    35 	{
       
    36 	HBufC8* userNameBuf = ExtractHBufLC( KParamClientUserName );
       
    37 	TUid pluginUid = ExtractUidL( KParamPluginUid, ETrue );
       
    38 	TUid clientUid = ExtractUidL( KParamApplicationUid, ETrue );
       
    39     
       
    40 	AddUidL( iContext.Repository(),*userNameBuf,pluginUid,clientUid );
       
    41 	CleanupStack::PopAndDestroy( userNameBuf );
       
    42 	}
       
    43 	
       
    44 // -----------------------------------------------------------------------------
       
    45 // TCmdAddUserToClientResolverCenRep::AddUidL
       
    46 // -----------------------------------------------------------------------------
       
    47 //	
       
    48 void TCmdAddUserToClientResolverCenRep::AddUidL(
       
    49     CRepository& aRepository,
       
    50     const TDesC8& aUserName,
       
    51     const TUid& aPluginUid,
       
    52     const TUid& aClientUid)
       
    53     {
       
    54     TUint32 key = CreateNewKeyL( aRepository,KSIPClientResolverUserNameMask );
       
    55     
       
    56     User::LeaveIfError(
       
    57         aRepository.Create(key|KSIPClientResolverUserNameMask,aUserName));
       
    58     
       
    59     TInt pluginUidValue( aPluginUid.iUid );                 
       
    60     User::LeaveIfError(
       
    61         aRepository.Create(key|KSIPClientResolverPluginUIDMask,pluginUidValue));
       
    62         
       
    63     TInt clientUidValue( aClientUid.iUid );                 
       
    64     User::LeaveIfError(
       
    65         aRepository.Create(key|KSIPClientResolverClientUIDMask,clientUidValue));
       
    66     }
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // TCmdAddUserToClientResolverCenRep::CreateNewKeyL
       
    70 // -----------------------------------------------------------------------------
       
    71 // 
       
    72 TUint32 
       
    73 	TCmdAddUserToClientResolverCenRep::CreateNewKeyL( CRepository& aRepository,
       
    74     											   	  TUint32 aKey) const
       
    75     {
       
    76     TUint32 newKey = 0;
       
    77     RArray<TUint32> keys;
       
    78     CleanupClosePushL( keys );
       
    79     TInt err = aRepository.FindL( aKey,
       
    80                                   KSIPClientResolverFieldTypeMask,
       
    81                                   keys );
       
    82     TInt keyCount = keys.Count();
       
    83     if ( err == KErrNotFound )
       
    84         {
       
    85         newKey = 1;
       
    86         }
       
    87     else
       
    88         {
       
    89         User::LeaveIfError( err );
       
    90         if ( keyCount == 0 )
       
    91             {
       
    92             newKey = 1;
       
    93             }
       
    94         else
       
    95             {
       
    96             // Find the biggest key and increment it by one
       
    97             keys.SortUnsigned();
       
    98             TUint32 maxKey = aKey^keys[ keyCount - 1 ];
       
    99             newKey = maxKey + 1;       
       
   100             }
       
   101         }
       
   102     CleanupStack::PopAndDestroy( &keys );
       
   103     return newKey;
       
   104     }
       
   105 	
       
   106 	
       
   107 	
       
   108 // -----------------------------------------------------------------------------
       
   109 // TCmdAddUserToClientResolverCenRep::Match
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 TBool TCmdAddUserToClientResolverCenRep::Match( const TTcIdentifier& aId )
       
   113 	{
       
   114 	return TTcSIPCommandBase::Match( aId, _L8("AddUserToClientResolverCenRep") );
       
   115 	}
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // TCmdAddUserToClientResolverCenRep::CreateL
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 TTcCommandBase* 
       
   122 	TCmdAddUserToClientResolverCenRep::CreateL( MTcTestContext& aContext )
       
   123 	{
       
   124 	return new( ELeave ) TCmdAddUserToClientResolverCenRep( aContext );
       
   125 	}
       
   126