voipplugins/voipadapters/voipxmlprovisioning/voipxmlprocessor/src/voipxmliaphandler.cpp
branchRCL_3
changeset 20 65a3ef1d5bd0
parent 18 8c9c07ad8b6b
--- a/voipplugins/voipadapters/voipxmlprovisioning/voipxmlprocessor/src/voipxmliaphandler.cpp	Mon Jun 21 15:29:21 2010 +0300
+++ b/voipplugins/voipadapters/voipxmlprovisioning/voipxmlprocessor/src/voipxmliaphandler.cpp	Thu Aug 19 09:45:22 2010 +0300
@@ -522,9 +522,16 @@
         // Get destination ID's for checking if name to be set is reserved.
         CleanupClosePushL( destinationIds ); // CS:3
         cmm.AllDestinationsL( destinationIds );
-        HBufC* newName = HBufC::NewLC( KMaxNodeNameLength ); // CS:4
-        newName->Des().Copy( iDestinationName->Des() );
-
+        HBufC* newName = HBufC::NewLC( KMaxDestinationNameLength + KSpaceForParenthesis ); // CS:4
+        if( iDestinationName->Des().Length() >= KMaxDestinationNameLength )
+            {
+            newName->Des().Copy( iDestinationName->Left( KMaxDestinationNameLength ) );
+            }
+        else
+            {
+            newName->Des().Copy( iDestinationName->Des() );
+            }
+        
         // Check that name is unique.
         const TInt destinationCount = destinationIds.Count();
         for ( TInt counter = 0; counter < destinationCount; counter++ )
@@ -538,7 +545,14 @@
                 {
                 // If the name is changed we need to begin the comparison
                 // again from the first profile.
-                newName->Des().Copy( iDestinationName->Des() );
+                if ( iDestinationName->Des().Length() >= KMaxDestinationNameLength )
+                    {
+                    newName->Des().Copy( iDestinationName->Left( KMaxDestinationNameLength ) );
+                    }
+                else
+                    {
+                    newName->Des().Copy( iDestinationName->Des() );
+                    }
                 newName->Des().Append( KOpenParenthesis() );
                 newName->Des().AppendNum( i );
                 newName->Des().Append( KClosedParenthesis() );  
@@ -571,6 +585,37 @@
         // &newDestination, newName, &destinationIds
         CleanupStack::PopAndDestroy( 3, &destinationIds ); // CS:2
         }
+    
+    // no destination name is defined.
+    else 
+        {
+        RArray<TUint32> destinationIds;
+        CleanupClosePushL( destinationIds ); // CS:3
+        cmm.AllDestinationsL( destinationIds );
+        const TInt count = destinationIds.Count();
+        for (TInt counter = 0; counter < count ; counter ++)     
+            {
+            RCmDestinationExt destination = cmm.DestinationL( destinationIds[counter] );
+            CleanupClosePushL( destination ); // CS:4
+            if ( destination.MetadataL(
+                    CMManager::ESnapMetadataPurpose) == CMManager::ESnapPurposeInternet )
+               {
+               const TInt cmCount = iapIds.Count();
+               for ( TInt i = 0; i < cmCount; i++ ) 
+                   {
+                   RCmConnectionMethodExt connection = cmm.ConnectionMethodL(iapIds[i] );
+                   CleanupClosePushL( connection );
+                   destination.AddConnectionMethodL(connection );
+                   CleanupStack::PopAndDestroy( &connection );
+               }
+           } 
+           destination.UpdateL();
+           CleanupStack::PopAndDestroy( &destination ); // CS:3
+           CleanupStack::PopAndDestroy( &destinationIds ); // CS:2
+           break;
+           }
+        }
+    
     // &iapIds, &cmm
     CleanupStack::PopAndDestroy( 2, &cmm ); // CS:0
     }