cmmanager/cmmgr/cmmserver/src/cmmcache.cpp
changeset 46 95d45f234cf3
parent 27 489cf6208544
child 53 4af712113915
--- a/cmmanager/cmmgr/cmmserver/src/cmmcache.cpp	Thu May 27 13:17:01 2010 +0300
+++ b/cmmanager/cmmgr/cmmserver/src/cmmcache.cpp	Wed Jun 23 18:39:24 2010 +0300
@@ -154,7 +154,7 @@
 //
 void CCmmCache::OpenDestinationL(
         CCmmDestinationInstance& aDestinationInstance,
-        const TUint32& aDestinationId )
+        const TUint32 aDestinationId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_OPENDESTINATIONL_ENTRY );
 
@@ -175,7 +175,7 @@
 
         // Now that cache has a handle on this destination, copy the relevant
         // data to the session instance.
-        destination->CreateSessionInstanceL( aDestinationInstance );
+        destination->CreateDestinationInstanceL( aDestinationInstance );
 
         iDestinationArray.AppendL( destination );
         CleanupStack::Pop( destination );
@@ -184,7 +184,7 @@
         {
         // Cache already has a handle on this destination. Copy the relevant
         // data to the session instance.
-        iDestinationArray[index]->CreateSessionInstanceL( aDestinationInstance );
+        iDestinationArray[index]->CreateDestinationInstanceL( aDestinationInstance );
         }
 
     // Add list of currently contained connection methods.
@@ -236,14 +236,14 @@
 void CCmmCache::CreateDestinationL(
         CCmmDestinationInstance& aDestinationInstance,
         const TDesC& aName,
-        const TUint32& aId )
+        const TUint32 aId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_CREATEDESTINATIONL_ENTRY );
 
     // Create a new destination with given name.
     CCmmDestinationStruct* destination = CCmmDestinationStruct::NewLC( this, iTrans, aName, aId );
 
-    destination->CreateSessionInstanceL( aDestinationInstance );
+    destination->CreateDestinationInstanceL( aDestinationInstance );
 
     iDestinationArray.AppendL( destination );
     CleanupStack::Pop( destination );
@@ -261,7 +261,7 @@
 void CCmmCache::OpenConnMethodL(
         CCmmConnMethodInstance& aConnMethodInstance,
         CCmmDestinationInstance* aDestinationInstance,
-        const TUint32& aConnMethodId )
+        const TUint32 aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_OPENCONNMETHODL_ENTRY );
 
@@ -319,7 +319,11 @@
     {
     OstTraceFunctionEntry0( CCMMCACHE_REFRESHCONNMETHODL_ENTRY );
 
-    //TODO, what to do with embedded?
+    // If embedded destination --> refresh through destination API.
+    if ( aConnMethodInstance.IsEmbeddedDestination() )
+        {
+        return;
+        }
 
     TInt index = FindConnMethodFromCache( aConnMethodInstance.GetId() );
     if ( index == KErrNotFound )
@@ -352,8 +356,8 @@
 void CCmmCache::CreateConnMethodL(
         CCmmConnMethodInstance& aConnMethodInstance,
         CCmmDestinationInstance* aDestinationInstance,
-        const TUint32& aBearerType,
-        const TUint32& aConnMethodId )
+        const TUint32 aBearerType,
+        const TUint32 aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_CREATECONNMETHODL_ENTRY );
 
@@ -539,7 +543,9 @@
         // referenced from any other destination (in database or in any other
         // client-side destination handles).
         if ( !iInstanceMapping->ValidConnMethodId( id ) ||
-                iInstanceMapping->ConnMethodInOtherDestination( id, aDestinationInstance.GetId() ) ||
+                iInstanceMapping->ConnMethodInOtherDestination(
+                        id,
+                        aDestinationInstance.GetId() ) ||
                 aDestinationInstance.ConnMethodInOtherDestinationInSession( id, 0 ) )
             {
             aDestinationInstance.iConnMethodsToBeDeleted.Remove( i );
@@ -565,7 +571,7 @@
     // Update the connection methods inside this destination.
     for ( TInt i = 0; i < aDestinationInstance.iConnMethodItemArray.Count(); i++ )
         {
-        if ( aDestinationInstance.iConnMethodItemArray[i].iBearerType == KUidEmbeddedDestination )
+        if ( aDestinationInstance.iConnMethodItemArray[i].IsEmbedded() )
             {
             // Embedded destination.
 
@@ -590,7 +596,8 @@
                 //
                 // Skip update since client doesn't have an open handle to this
                 // destination.
-                if ( id >= KTemporaryIdCounterStart || !iInstanceMapping->ValidDestinationId( id ) )
+                if ( id >= KTemporaryIdCounterStart ||
+                        !iInstanceMapping->ValidDestinationId( id ) )
                     {
                     // Remove destination item from array if:
                     // - New destination, but client has already closed the handle for it.
@@ -627,13 +634,15 @@
             if ( aDestinationInstance.ProtectionChanged() )
                 {
                 // Check if the connection method protection level needs to be set.
-                switch ( aDestinationInstance.CurrentProtectionLevel() )
+                switch ( aDestinationInstance.CurrentProtectionLevelL() )
                     {
                     case CMManager::EProtLevel0:
                     case CMManager::EProtLevel2:
                         {
-                        if ( aDestinationInstance.LastProtectionLevel() == CMManager::EProtLevel1 ||
-                                aDestinationInstance.LastProtectionLevel() == CMManager::EProtLevel3 )
+                        if ( aDestinationInstance.LastProtectionLevel() ==
+                                CMManager::EProtLevel1 ||
+                                aDestinationInstance.LastProtectionLevel() ==
+                                CMManager::EProtLevel3 )
                             {
                             connMethodProtectionMustBeSet = ETrue;
                             cmProtected = EFalse;
@@ -775,6 +784,12 @@
     {
     OstTraceFunctionEntry0( CCMMCACHE_UPDATECONNMETHODL_ENTRY );
 
+    // Embedded destinatios cannot be updated as connection methods.
+    if ( aConnMethodInstance.IsEmbeddedDestination() )
+        {
+        User::Leave( KErrNotSupported );
+        }
+
     // Find connection method from cache.
     TUint32 connMethodId( aConnMethodInstance.GetId() );
     TInt index = FindConnMethodFromCache( connMethodId );
@@ -828,7 +843,9 @@
 // same is done for the connection methods inside this destination.
 // ---------------------------------------------------------------------------
 //
-void CCmmCache::DeleteDestinationL( CCmmDestinationInstance& aDestinationInstance, TBool aForced )
+void CCmmCache::DeleteDestinationL(
+        CCmmDestinationInstance& aDestinationInstance,
+        TBool aForced ) //TODO, comment on aForced param?
     {
     OstTraceFunctionEntry0( CCMMCACHE_DELETEDESTINATIONL_ENTRY );
 
@@ -879,7 +896,7 @@
         TInt count( connMethodArray.Count() );
         if ( count )
             {
-            if ( connMethodArray[count - 1].iBearerType == KUidEmbeddedDestination )
+            if ( connMethodArray[count - 1].IsEmbedded() )
                 {
                 connMethodArray.Remove( count - 1 );
                 }
@@ -887,7 +904,9 @@
         // Remove any connection method that belongs to any other destination.
         for ( TInt i = 0; i < connMethodArray.Count(); i++ )
             {
-            if ( iInstanceMapping->ConnMethodInOtherDestination( connMethodArray[i].iId, destinationId ) )
+            if ( iInstanceMapping->ConnMethodInOtherDestination(
+                    connMethodArray[i].iId,
+                    destinationId ) )
                 {
                 connMethodArray.Remove( i );
                 i--;
@@ -978,7 +997,7 @@
 // as deleted (through an already open handle) will restore it.
 // ---------------------------------------------------------------------------
 //
-void CCmmCache::DeleteConnMethodAsPartOfDestinationDeleteL( const TUint32& aConnMethodId )
+void CCmmCache::DeleteConnMethodAsPartOfDestinationDeleteL( const TUint32 aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_DELETECONNMETHODASPARTOFDESTINATIONDELETEL_ENTRY );
 
@@ -1054,6 +1073,7 @@
                 break;
             case ECmmConnMethodStatusToBeDeleted:
                 // Connection method has already been deleted.
+                OstTraceFunctionExit0( DUP2_CCMMCACHE_DELETECONNMETHODASPARTOFDESTINATIONDELETEL_EXIT );
                 return;
             case ECmmConnMethodStatusChanged:
             default:
@@ -1070,7 +1090,7 @@
     TCmmIdStruct idStruct( aConnMethodId, 0 );
     iDeletedConnMethods.AppendL( idStruct );
 
-    OstTraceFunctionExit0( DUP2_CCMMCACHE_DELETECONNMETHODASPARTOFDESTINATIONDELETEL_EXIT );
+    OstTraceFunctionExit0( DUP3_CCMMCACHE_DELETECONNMETHODASPARTOFDESTINATIONDELETEL_EXIT );
     }
 
 // ---------------------------------------------------------------------------
@@ -1084,7 +1104,7 @@
 // ---------------------------------------------------------------------------
 //
 void CCmmCache::DeleteConnMethodAsPartOfDestinationUpdateL(
-        const TUint32& aConnMethodId )
+        const TUint32 aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_DELETECONNMETHODASPARTOFDESTINATIONUPDATEL_ENTRY );
 
@@ -1163,6 +1183,7 @@
                 break;
             case ECmmConnMethodStatusToBeDeleted:
                 // Connection method has already been deleted.
+                OstTraceFunctionExit0( DUP2_CCMMCACHE_DELETECONNMETHODASPARTOFDESTINATIONUPDATEL_EXIT );
                 return;
             case ECmmConnMethodStatusChanged:
             default:
@@ -1178,7 +1199,7 @@
         iDeletedConnMethods.AppendL( idStruct );
         }
 
-    OstTraceFunctionExit0( DUP2_CCMMCACHE_DELETECONNMETHODASPARTOFDESTINATIONUPDATEL_EXIT );
+    OstTraceFunctionExit0( DUP3_CCMMCACHE_DELETECONNMETHODASPARTOFDESTINATIONUPDATEL_EXIT );
     }
 
 // ---------------------------------------------------------------------------
@@ -1256,7 +1277,7 @@
 // aId needs to be in the current valid range (0x1001 - 0x10FF atm).
 // ---------------------------------------------------------------------------
 //
-TBool CCmmCache::DestinationExistsWithId( const TUint32& aId )
+TBool CCmmCache::DestinationExistsWithId( const TUint32 aId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_DESTINATIONEXISTSWITHID_ENTRY );
 
@@ -1271,7 +1292,7 @@
 // If a destination ID is given, that destination is skipped.
 // ---------------------------------------------------------------------------
 //
-TBool CCmmCache::DestinationExistsWithNameL( const TDesC& aName, const TUint32& aDestinationId )
+TBool CCmmCache::DestinationExistsWithNameL( const TDesC& aName, const TUint32 aDestinationId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_DESTINATIONEXISTSWITHNAMEL_ENTRY );
 
@@ -1328,7 +1349,6 @@
         }
 
     OstTraceFunctionExit0( CCMMCACHE_DESTINATIONEXISTSWITHNAMEL_EXIT );
-
     return found;
     }
 
@@ -1340,7 +1360,7 @@
 // with the same ID (The UpdateL() operation would fail for one of them anyway).
 // ---------------------------------------------------------------------------
 //
-TBool CCmmCache::DestinationOpenWithId( const TUint32& aId )
+TBool CCmmCache::DestinationOpenWithId( const TUint32 aId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_DESTINATIONOPENWITHID_ENTRY );
 
@@ -1350,8 +1370,8 @@
         {
         result = ETrue;
         }
+
     OstTraceFunctionExit0( CCMMCACHE_DESTINATIONOPENWITHID_EXIT );
-
     return result;
     }
 
@@ -1368,7 +1388,7 @@
 //
 TBool CCmmCache::NotSavedDestinationOpenWithNameL(
         const TDesC& aName,
-        const TUint32& aDestinationId )
+        const TUint32 aDestinationId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_NOTSAVEDDESTINATIONOPENWITHNAMEL_ENTRY );
 
@@ -1378,8 +1398,8 @@
         {
         res = ETrue;
         }
+
     OstTraceFunctionExit0( CCMMCACHE_NOTSAVEDDESTINATIONOPENWITHNAMEL_EXIT );
-
     return res;
     }
 
@@ -1387,14 +1407,13 @@
 // Check if the given ID belongs to a valid existing connection method.
 // ---------------------------------------------------------------------------
 //
-TBool CCmmCache::ConnMethodExistsWithId( const TUint32& aConnMethodId )
+TBool CCmmCache::ConnMethodExistsWithId( const TUint32 aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_CONNMETHODEXISTSWITHID_ENTRY );
 
     TBool exists = iInstanceMapping->ValidConnMethodId( aConnMethodId );
 
     OstTraceFunctionExit0( CCMMCACHE_CONNMETHODEXISTSWITHID_EXIT );
-
     return exists;
     }
 
@@ -1407,7 +1426,7 @@
 // anyway).
 // ---------------------------------------------------------------------------
 //
-TBool CCmmCache::ConnMethodOpenWithId( const TUint32& aConnMethodId )
+TBool CCmmCache::ConnMethodOpenWithId( const TUint32 aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_CONNMETHODOPENWITHID_ENTRY );
 
@@ -1417,8 +1436,8 @@
         {
         result = ETrue;
         }
+
     OstTraceFunctionExit0( CCMMCACHE_CONNMETHODOPENWITHID_EXIT );
-
     return result;
     }
 
@@ -1431,7 +1450,7 @@
 //
 TBool CCmmCache::DestinationExistsWithMetadataLocalizedL(
         CCmmDestinationInstance& aDestinationInstance,
-        const TUint32& aValue )
+        const TUint32 aValue )
     {
     OstTraceFunctionEntry0( CCMMCACHE_DESTINATIONEXISTSWITHMETADATALOCALIZEDL_ENTRY );
 
@@ -1502,8 +1521,8 @@
             }
         CleanupStack::PopAndDestroy( metaSet );
         }
+
     OstTraceFunctionExit0( CCMMCACHE_DESTINATIONEXISTSWITHMETADATALOCALIZEDL_EXIT );
-
     return result;
     }
 
@@ -1516,7 +1535,7 @@
 //
 TBool CCmmCache::DestinationExistsWithMetadataPurposeL(
         CCmmDestinationInstance& aDestinationInstance,
-        const TUint32& aValue )
+        const TUint32 aValue )
     {
     OstTraceFunctionEntry0( CCMMCACHE_DESTINATIONEXISTSWITHMETADATAPURPOSEL_ENTRY );
 
@@ -1587,8 +1606,8 @@
             }
         CleanupStack::PopAndDestroy( metaSet );
         }
+
     OstTraceFunctionExit0( CCMMCACHE_DESTINATIONEXISTSWITHMETADATAPURPOSEL_EXIT );
-
     return result;
     }
 
@@ -1599,7 +1618,7 @@
 // needed.
 // ---------------------------------------------------------------------------
 //
-void CCmmCache::DbChangeDetected( const TUint32& aTableId )
+void CCmmCache::DbChangeDetected( const TUint32 aTableId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_DBCHANGEDETECTED_ENTRY );
 
@@ -1614,7 +1633,7 @@
 // it has up-to-date information.
 // ---------------------------------------------------------------------------
 //
-void CCmmCache::DbChangeError( const TUint32& aTableId )
+void CCmmCache::DbChangeError( const TUint32 aTableId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_DBCHANGEERROR_ENTRY );
 
@@ -1638,7 +1657,7 @@
 
     if ( index >= 0 )
         {
-        TInt remainingSessionInstances = iDestinationArray[index]->SessionInstanceClosed();
+        TInt remainingSessionInstances = iDestinationArray[index]->DestinationInstanceClosed();
         if ( remainingSessionInstances <= 0)
             {
             // If status is 'to be deleted', then the last handle keeping this
@@ -1679,7 +1698,7 @@
 
     if ( index >= 0 )
         {
-        TInt remainingSessionInstances = iConnMethodArray[index]->SessionInstanceClosed();
+        TInt remainingSessionInstances = iConnMethodArray[index]->ConnMethodInstanceClosed();
         if ( remainingSessionInstances <= 0 )
             {
             // If status is 'to be deleted', then the last handle keeping this
@@ -1714,14 +1733,13 @@
 //
 CommsDat::CMDBSession& CCmmCache::Session() const
     {
-    OstTraceFunctionEntry0( CCMMCACHE_SESSION_ENTRY );
-
+    // No traces.
     return iTrans->Session();
     }
 
 //-----------------------------------------------------------------------------
 // Finds out the bearer type and priority of the service type from given IAP
-// record.
+// record. performs LoadL()-call on the provided IAP record.
 //-----------------------------------------------------------------------------
 //
 void CCmmCache::BearerInfoFromIapRecordL(
@@ -1731,8 +1749,8 @@
     {
     OstTraceFunctionEntry0( CCMMCACHE_BEARERINFOFROMIAPRECORDL_ENTRY );
 
-    // Load the IAP record from IAP table. This is an optimization that plugins
-    // doesn't have to do it every time the CanHandleIapIdL() is called.
+    // Load the IAP record from IAP table. This is an optimization so that
+    // plugins don't have to do it every time the CanHandleIapIdL() is called.
     aIapRecord->LoadL( Session() );
     BearerPriorityFromIapRecordL( aIapRecord, aBearerPriority );
     BearerTypeFromIapRecordL( aIapRecord, aBearerType );
@@ -1778,7 +1796,7 @@
     // Check which bearer handles the given IAP ID.
     for ( TInt i = 0; i < iPlugins->Count(); i++ )
         {
-        TRAP( err, canHandle = (*iPlugins)[i]->CanHandleIapIdL( aIapRecord ) ); //TODO, check leave, trap needed?
+        TRAP( err, canHandle = (*iPlugins)[i]->CanHandleIapIdL( aIapRecord ) );
         if ( !err && canHandle )
             {
             TUint32 thisExtLevel = (*iPlugins)[i]->GetBearerInfoIntL( ECmExtensionLevel );
@@ -1799,6 +1817,23 @@
     OstTraceFunctionExit0( CCMMCACHE_BEARERTYPEFROMIAPRECORDL_EXIT );
     }
 
+// ---------------------------------------------------------------------------
+// Find and return a copy of a connection method item matching the given ID.
+// Returns KErrNotFound, if the connection method is not found.
+// ---------------------------------------------------------------------------
+//
+TInt CCmmCache::GetConnMethodItem(
+        const TUint32 aConnMethodId,
+        TCmmConnMethodItem& aConnMethodItem ) const
+    {
+    OstTraceFunctionEntry0( CCMMCACHE_GETCONNMETHODITEM_ENTRY );
+
+    TInt result = iInstanceMapping->GetConnMethodItem( aConnMethodId, aConnMethodItem );
+
+    OstTraceFunctionExit0( CCMMCACHE_GETCONNMETHODITEM_EXIT );
+    return result;
+    }
+
 //-----------------------------------------------------------------------------
 // Returns all conenction method IDs. Unsupported connection methods are
 // included if aCheckBearerType is set to EFalse.
@@ -1819,7 +1854,7 @@
 // Returns the number of destinations the provided connection method belongs to.
 //-----------------------------------------------------------------------------
 //
-TInt CCmmCache::DestinationsContainingConnMethod( const TUint32& aConnMethodId ) const
+TInt CCmmCache::DestinationsContainingConnMethod( const TUint32 aConnMethodId ) const
     {
     OstTraceFunctionEntry0( CCMMCACHE_CONNMETHODREFERENCECOUNT_ENTRY );
 
@@ -1902,7 +1937,7 @@
 //-----------------------------------------------------------------------------
 //
 void CCmmCache::GetConnMethodsFromDestinationL(
-        const TUint32& aDestinationId,
+        const TUint32 aDestinationId,
         RArray<TCmmConnMethodItem>& aConnMethodArray ) const
     {
     OstTraceFunctionEntry0( CCMMCACHE_GETCONNMETHODSFROMDESTINATIONL_ENTRY );
@@ -1945,8 +1980,8 @@
 //-----------------------------------------------------------------------------
 //
 TBool CCmmCache::ConnMethodInOtherDestination(
-        const TUint32& aConnMethodId,
-        const TUint32& aDestinationId )
+        const TUint32 aConnMethodId,
+        const TUint32 aDestinationId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_CONNMETHODINOTHERDESTINATION_ENTRY );
 
@@ -1984,7 +2019,7 @@
 // Returns either a valid array index or KErrNotFound.
 //-----------------------------------------------------------------------------
 //
-TInt CCmmCache::FindDestinationFromCache( const TUint32& aId )
+TInt CCmmCache::FindDestinationFromCache( const TUint32 aId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_FINDDESTINATIONFROMCACHE_ENTRY );
 
@@ -2013,7 +2048,9 @@
 // Returns either a valid array index or KErrNotFound.
 //-----------------------------------------------------------------------------
 //
-TInt CCmmCache::FindNotSavedDestinationFromCacheL( const TDesC& aName, const TUint32& aDestinationId )
+TInt CCmmCache::FindNotSavedDestinationFromCacheL(
+        const TDesC& aName,
+        const TUint32 aDestinationId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_FINDNOTSAVEDDESTINATIONFROMCACHEL_ENTRY );
 
@@ -2056,7 +2093,7 @@
 // Returns either a valid array index or KErrNotFound.
 //-----------------------------------------------------------------------------
 //
-TInt CCmmCache::FindConnMethodFromCache( const TUint32& aConnMethodId )
+TInt CCmmCache::FindConnMethodFromCache( const TUint32 aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_FINDCONNMETHODFROMCACHE_ENTRY );
 
@@ -2085,7 +2122,7 @@
 //
 void CCmmCache::OpenConnectionMethodInstanceL(
         CCmmConnMethodInstance& aConnMethodInstance,
-        const TUint32& aConnMethodId )
+        const TUint32 aConnMethodId )
     {
     OstTraceFunctionEntry0( CCMMCACHE_OPENCONNECTIONMETHODINSTANCEL_ENTRY );
 
@@ -2130,8 +2167,8 @@
 //-----------------------------------------------------------------------------
 //
 TUint32 CCmmCache::GetConnectionMethodInfoIntL(
-        const TUint32& aCmId,
-        const TUint32& aAttribute )
+        const TUint32 aCmId,
+        const TUint32 aAttribute )
     {
     OstTraceFunctionEntry0( CCMMCACHE_GETCONNECTIONMETHODINFOINTL_ENTRY );
 
@@ -2164,8 +2201,8 @@
 //-----------------------------------------------------------------------------
 //
 TBool CCmmCache::GetConnectionMethodInfoBoolL(
-        const TUint32& aCmId,
-        const TUint32& aAttribute )
+        const TUint32 aCmId,
+        const TUint32 aAttribute )
     {
     OstTraceFunctionEntry0( CCMMCACHE_GETCONNECTIONMETHODINFOBOOLL_ENTRY );
 
@@ -2198,8 +2235,8 @@
 //-----------------------------------------------------------------------------
 //
 HBufC* CCmmCache::GetConnectionMethodInfoStringL(
-        const TUint32& aCmId,
-        const TUint32& aAttribute )
+        const TUint32 aCmId,
+        const TUint32 aAttribute )
     {
     OstTraceFunctionEntry0( CCMMCACHE_GETCONNECTIONMETHODINFOSTRINGL_ENTRY );
 
@@ -2232,8 +2269,8 @@
 //-----------------------------------------------------------------------------
 //
 HBufC8* CCmmCache::GetConnectionMethodInfoString8L(
-        const TUint32& aCmId,
-        const TUint32& aAttribute )
+        const TUint32 aCmId,
+        const TUint32 aAttribute )
     {
     OstTraceFunctionEntry0( CCMMCACHE_GETCONNECTIONMETHODINFOSTRING8L_ENTRY );
 
@@ -2267,8 +2304,8 @@
 //-----------------------------------------------------------------------------
 //
 TUint32 CCmmCache::GetBearerInfoIntL(
-        const TUint32& aBearerType,
-        const TUint32& aAttribute )
+        const TUint32 aBearerType,
+        const TUint32 aAttribute )
     {
     OstTraceFunctionEntry0( CCMMCACHE_GETBEARERINFOINTL_ENTRY );
 
@@ -2298,8 +2335,8 @@
 //-----------------------------------------------------------------------------
 //
 TBool CCmmCache::GetBearerInfoBoolL(
-        const TUint32& aBearerType,
-        const TUint32& aAttribute )
+        const TUint32 aBearerType,
+        const TUint32 aAttribute )
     {
     OstTraceFunctionEntry0( CCMMCACHE_GETBEARERINFOBOOLL_ENTRY );
 
@@ -2329,8 +2366,8 @@
 //-----------------------------------------------------------------------------
 //
 HBufC* CCmmCache::GetBearerInfoStringL(
-        const TUint32& aBearerType,
-        const TUint32& aAttribute )
+        const TUint32 aBearerType,
+        const TUint32 aAttribute )
     {
     OstTraceFunctionEntry0( CCMMCACHE_GETBEARERINFOSTRINGL_ENTRY );
 
@@ -2360,8 +2397,8 @@
 //-----------------------------------------------------------------------------
 //
 HBufC8* CCmmCache::GetBearerInfoString8L(
-        const TUint32& aBearerType,
-        const TUint32& aAttribute )
+        const TUint32 aBearerType,
+        const TUint32 aAttribute )
     {
     OstTraceFunctionEntry0( CCMMCACHE_GETBEARERINFOSTRING8L_ENTRY );
 
@@ -2421,24 +2458,16 @@
         {
         iTrans->OpenTransactionLC();
 
-        TUint defConnType( 0 );
-        TUint internetSnapId( 0 );
-        iInstanceMapping->InternetDestinationIdL( internetSnapId );
-        if ( internetSnapId )
-            {
-            defConnType = ECmDefConnDestination;
-            }
-
         aGenConnSettings.iUsageOfWlan = ECmUsageOfWlanKnown;
         aGenConnSettings.iCellularDataUsageHome = ECmCellularDataUsageAutomatic;
         aGenConnSettings.iCellularDataUsageVisitor = ECmCellularDataUsageConfirm;
 
         defConnRecord->SetRecordId( KCDNewRecordRequest );
-        defConnRecord->iDefConnType = defConnType;
-        defConnRecord->iDefConnUid = internetSnapId;
         defConnRecord->iUsageOfWlan = ( TUint )aGenConnSettings.iUsageOfWlan;
-        defConnRecord->iCellularDataUsageHome = ( TUint )aGenConnSettings.iCellularDataUsageHome;
-        defConnRecord->iCellularDataUsageVisitor = ( TUint )aGenConnSettings.iCellularDataUsageVisitor;
+        defConnRecord->iCellularDataUsageHome =
+                ( TUint )aGenConnSettings.iCellularDataUsageHome;
+        defConnRecord->iCellularDataUsageVisitor =
+                ( TUint )aGenConnSettings.iCellularDataUsageVisitor;
         defConnRecord->StoreL( Session() );
 
         iTrans->CommitTransactionL();
@@ -2537,7 +2566,7 @@
 // connected.
 // ---------------------------------------------------------------------------
 //
-TBool CCmmCache::CheckIfCmConnected( const TUint32& aCmId ) const
+TBool CCmmCache::CheckIfCmConnected( const TUint32 aCmId ) const
     {
     OstTraceFunctionEntry0( CCMMCACHE_CHECKIFCMCONNECTED_ENTRY );
 
@@ -2617,7 +2646,9 @@
                     }
                 else
                     {
-                    iInstanceMapping->GetConnMethodsFromDestinationL( aDestinationId, connMethodArray );
+                    iInstanceMapping->GetConnMethodsFromDestinationL(
+                            aDestinationId,
+                            connMethodArray );
                     }
 
                 // Iterate through all connections.
@@ -2657,7 +2688,7 @@
 // any other destination.
 // ---------------------------------------------------------------------------
 //
-TBool CCmmCache::DestinationIsEmbedded( const TUint32& aDestinationId ) const
+TBool CCmmCache::DestinationIsEmbedded( const TUint32 aDestinationId ) const
     {
     OstTraceFunctionEntry0( CCMMCACHE_DESTINATIONISEMBEDDED_ENTRY );
 
@@ -2671,7 +2702,7 @@
 // Check from database if the given destination has an embedded destination.
 // ---------------------------------------------------------------------------
 //
-TBool CCmmCache::DestinationHasEmbedded( const TUint32& aDestinationId ) const
+TBool CCmmCache::DestinationHasEmbedded( const TUint32 aDestinationId ) const
     {
     OstTraceFunctionEntry0( CCMMCACHE_DESTINATIONHASEMBEDDED_ENTRY );
 
@@ -2686,7 +2717,7 @@
 // IAP.
 // ---------------------------------------------------------------------------
 //
-TBool CCmmCache::DestinationPointedToByVirtualIap( const TUint32& aDestinationId ) const
+TBool CCmmCache::DestinationPointedToByVirtualIap( const TUint32 aDestinationId ) const
     {
     OstTraceFunctionEntry0( CCMMCACHE_DESTINATIONPOINTEDTOBYVIRTUALIAP_ENTRY );
 
@@ -2702,13 +2733,15 @@
 // virtual IAP.
 // ---------------------------------------------------------------------------
 //
-TBool CCmmCache::ConnMethodPointedToByVirtualIap( const TUint32& aConnMethodId ) const
+TBool CCmmCache::ConnMethodPointedToByVirtualIap( const TUint32 aConnMethodId ) const
     {
-
-    TBool pointedByVirtual =
+    OstTraceFunctionEntry0( CCMMCACHE_CONNMETHODPOINTEDTOBYVIRTUALIAP_ENTRY );
+
+    TBool pointedToByVirtual =
             iInstanceMapping->ConnMethodPointedToByVirtualIap( aConnMethodId );
 
-    return pointedByVirtual;
+    OstTraceFunctionExit0( CCMMCACHE_CONNMETHODPOINTEDTOBYVIRTUALIAP_EXIT );
+    return pointedToByVirtual;
     }
 
 // ---------------------------------------------------------------------------
@@ -2717,7 +2750,8 @@
 // ---------------------------------------------------------------------------
 //
 TBool CCmmCache::ConnMethodInDestinationButLocked(
-        const TUint32& aConnMethodId, const TUint32& aDestinationId ) const
+        const TUint32 aConnMethodId,
+        const TUint32 aDestinationId ) const
     {
     OstTraceFunctionEntry0( CCMMCACHE_CONNMETHODINDESTINATIONBUTLOCKED_ENTRY );
 
@@ -2855,7 +2889,7 @@
 // This method is used to find out those real IDs before that.
 // ---------------------------------------------------------------------------
 //
-void CCmmCache::TranslateTemporaryId( const TUint32& aTemporaryId, TUint32& aRealId ) const
+void CCmmCache::TranslateTemporaryId( const TUint32 aTemporaryId, TUint32& aRealId ) const
     {
     OstTraceFunctionEntry0( CCMMCACHE_TRANSLATETEMPORARYID_ENTRY );
 
@@ -2908,7 +2942,9 @@
     iInstanceMapping->GetDestinationsL( dbDestinations );
     for ( TInt i = 0; i < dbDestinations.Count(); i++ )
         {
-        if ( iInstanceMapping->ConnMethodInDestinationButLocked( connMethodId, dbDestinations[i] ) )
+        if ( iInstanceMapping->ConnMethodInDestinationButLocked(
+                connMethodId,
+                dbDestinations[i] ) )
             {
             User::Leave( KErrLocked );
             }
@@ -2925,8 +2961,7 @@
     }
 
 // ---------------------------------------------------------------------------
-// Check if the given connection method can have all references removed and
-// made into an uncategorized connection method. //TODO, fix comment, this looks like copy&paste from above
+// Check if given connection method is referenced from any protected destination.
 // ---------------------------------------------------------------------------
 //
 void CCmmCache::CheckIfConnMethodBelongsToProtectedDestinationL(
@@ -2953,7 +2988,8 @@
         {
         // Check if any of destinations is protected.
         metadata = iInstanceMapping->DestinationMetadata( dbDestinations[i] );
-        TUint32 protlevel = ( metadata & KDestProtectionLevelMask ) >> KBitsToShiftDestProtectionLevel;
+        TUint32 protlevel =
+                ( metadata & KDestProtectionLevelMask ) >> KBitsToShiftDestProtectionLevel;
         if ( protlevel == CMManager::EProtLevel1 || protlevel == CMManager::EProtLevel3 )
             {
             aBelongsToProtectedDestination = ETrue;