supl/locationomasuplprotocolhandler/provisioninghandler/src/epos_comasuplsettings.cpp
branchRCL_3
changeset 44 2b4ea9893b66
parent 0 667063e416a2
child 45 6b6920c56e2f
--- a/supl/locationomasuplprotocolhandler/provisioninghandler/src/epos_comasuplsettings.cpp	Thu Aug 19 10:20:18 2010 +0300
+++ b/supl/locationomasuplprotocolhandler/provisioninghandler/src/epos_comasuplsettings.cpp	Tue Aug 31 15:37:04 2010 +0300
@@ -20,7 +20,7 @@
 
 #include <CWPParameter.h>
 #include <WPAdapterUtil.h>
-#include <ApUtils.h>
+//#include <ApUtils.h>
 
 #include "epos_comasupltrace.h"
 #include "epos_comasuplsettings.h"
@@ -30,6 +30,11 @@
 #include "epos_omasuplprovhandler.hrh"
 #include <epos_omasuplprovhandlerres.rsg>
 
+#include <cmmanagerext.h>
+#include <cmdestinationext.h>
+#include <cmconnectionmethodext.h>
+#include <cmconnectionmethoddef.h>
+
 
 _LIT( KTraceSuplSettings, "epos_comasuplsettings.cpp" );
 
@@ -146,12 +151,59 @@
 //
 TUint32 COMASuplSettings::IapIdFromWapIdL( TUint32 aWapId ) const
     {
-    CApUtils* apUtils = CApUtils::NewLC( *iCommsDb );
+    /*CApUtils* apUtils = CApUtils::NewLC( *iCommsDb );
     TUint32 iapId = NULL;
     iapId = apUtils->IapIdFromWapIdL( aWapId );
     __ASSERT_ALWAYS( iapId, Panic( SuplAdapterInvalidId ) );
     CleanupStack::PopAndDestroy( apUtils );
     return iapId;
+    return ;*/
+    
+    RCmManagerExt cmManager;
+    cmManager.OpenLC(); // CS:1
+    RArray<TUint32> iapIds;
+    TUint32 iapId( 0 );
+
+    // First get all free IAP ID's.
+    cmManager.ConnectionMethodL( iapIds );
+    CleanupClosePushL( iapIds ); // CS:2
+
+    // Then get IAP ID's from all destinations.
+    RArray<TUint32> destIds;
+    cmManager.AllDestinationsL( destIds );
+    CleanupClosePushL( destIds ); // CS:3
+    TInt destCount = destIds.Count();
+    for ( TInt destIndex = 0; destIndex < destCount; destIndex++ )
+        {
+        RCmDestinationExt dest = cmManager.DestinationL( 
+            destIds[destIndex] );
+        CleanupClosePushL( dest ); // CS:4
+        TInt cmCount = dest.ConnectionMethodCount();
+        for ( TInt cmIndex = 0; cmIndex < cmCount; cmIndex++ )
+            {
+            TUint32 apId = dest.ConnectionMethodL( 
+                cmIndex ).GetIntAttributeL( CMManager::ECmIapId );
+            iapIds.AppendL( apId );
+            }
+        CleanupStack::PopAndDestroy( &dest ); // CS:3
+        }
+    // Finally, go through all connection methods and find correct IAP ID.
+    const TInt cmCount = iapIds.Count();
+    for ( TInt counter = 0; counter < cmCount; counter++ )
+        {
+        TUint32 id = cmManager.GetConnectionMethodInfoIntL( 
+            iapIds[counter], CMManager::ECmWapId );
+        if ( id == aWapId )
+            {
+            iapId = iapIds[counter];
+            // No need to go through rest of IAPs.
+            break;
+            }
+        }
+    // PopAndDestroy destIds, iapIds, cmManager.
+    CleanupStack::PopAndDestroy( 3, &cmManager ); // CS:0
+    return iapId;
+    
     }