497 // --------------------------------------------------------------------------- |
497 // --------------------------------------------------------------------------- |
498 // |
498 // |
499 void CVoipXmlSipHandler::CreateProviderNameL( const TDesC8& aName ) |
499 void CVoipXmlSipHandler::CreateProviderNameL( const TDesC8& aName ) |
500 { |
500 { |
501 DBG_PRINT( "CVoipXmlSipHandler::CreateProviderNameL begin" ); |
501 DBG_PRINT( "CVoipXmlSipHandler::CreateProviderNameL begin" ); |
502 |
502 |
|
503 const TInt maxModifyLength = |
|
504 KMaxNodeNameLength - KMaxProfileNameAppendLength; |
|
505 |
503 RPointerArray<CSIPProfile> profiles; |
506 RPointerArray<CSIPProfile> profiles; |
504 CleanupResetAndDestroyL( profiles ); // CS:1 |
507 CleanupResetAndDestroyL( profiles ); // CS:1 |
505 |
508 |
506 // Get all profiles based on profile types. |
509 // Get all profiles based on profile types. |
507 iRegistry->ProfilesL( profiles ); |
510 iRegistry->ProfilesL( profiles ); |
508 const TInt profileCount = profiles.Count(); |
511 const TInt profileCount = profiles.Count(); |
509 |
512 |
510 // Go through loaded profiles and check for name duplicates. |
513 // Go through loaded profiles and check for name duplicates. |
511 HBufC8* name = HBufC8::NewLC( KMaxNodeNameLength ); // CS:2 |
514 HBufC8* name = HBufC8::NewLC( KMaxNodeNameLength ); // CS:2 |
512 name->Des().Copy( aName ); |
515 name->Des().Copy( aName.Left( maxModifyLength ) ); |
513 TUint i( 1 ); // Add number to the name if name already in use. |
516 TUint i( 1 ); // Add number to the name if name already in use. |
514 const TInt count( profiles.Count() ); |
517 const TInt count( profiles.Count() ); |
515 for ( TInt counter = 0; counter < count; counter++ ) |
518 for ( TInt counter = 0; counter < count; counter++ ) |
516 { |
519 { |
517 CSIPManagedProfile* profile = |
520 CSIPManagedProfile* profile = |
518 static_cast<CSIPManagedProfile*>( profiles[counter] ); |
521 static_cast<CSIPManagedProfile*>( profiles[counter] ); |
519 const TDesC8* existingName; |
522 const TDesC8* existingName; |
520 profile->GetParameter( KSIPProviderName, existingName ); |
523 profile->GetParameter( KSIPProviderName, existingName ); |
521 if ( 0 == existingName->Compare( *name ) ) |
524 if ( 0 == existingName->Compare( *name ) ) |
522 { |
525 { |
523 name->Des().Copy( aName ); |
526 name->Des().Copy( aName.Left( maxModifyLength ) ); |
524 name->Des().Append( KOpenParenthesis8() ); |
527 name->Des().Append( KOpenParenthesis8() ); |
525 name->Des().AppendNum( i ); |
528 name->Des().AppendNum( i ); |
526 name->Des().Append( KClosedParenthesis8() ); |
529 name->Des().Append( KClosedParenthesis8() ); |
527 counter = 0; |
530 counter = 0; |
528 i++; |
531 i++; |