bearermanagement/mpm/src/mpmserver.cpp
branchRCL_3
changeset 8 2e6c4614c58e
parent 3 f7816ffc66ed
child 12 ea6e024ea6f9
--- a/bearermanagement/mpm/src/mpmserver.cpp	Tue Feb 02 00:24:11 2010 +0200
+++ b/bearermanagement/mpm/src/mpmserver.cpp	Fri Feb 19 23:12:51 2010 +0200
@@ -41,6 +41,8 @@
 #include "mpmdialog.h"
 #include "mpmprivatecrkeys.h"
 #include "mpmcsidwatcher.h"
+#include "mpmdatausagewatcher.h"
+#include "mpmpropertydef.h"
 
 // ============================= LOCAL FUNCTIONS ===============================
 
@@ -170,6 +172,20 @@
     iMpmCsIdWatcher = CMpmCsIdWatcher::NewL();
     iMpmCsIdWatcher->StartL();
 
+    // Create another central repository watcher and start it
+    // TODO: Trapped, because currently it may fatally leave in HW.
+    // (Possibly because of the capability updates of data usage watcher's CR-keys.)
+    TRAPD( duwErr, iMpmDataUsageWatcher = CMpmDataUsageWatcher::NewL( this ) );
+    if (duwErr == KErrNone)
+        {
+        iMpmDataUsageWatcher->StartL();
+        }
+    else
+        {
+        iMpmDataUsageWatcher = NULL;
+        MPMLOGSTRING( "CMPMServer::ConstructL: CMpmDataUsageWatcher::NewL() failed!" )
+        }
+
     // Define P&S keys (snap & iap) for the user connection
     TInt ret = RProperty::Define( KMPMUserConnectionCategory,
                                   KMPMPSKeyUserConnectionSnap,
@@ -326,6 +342,8 @@
     
     delete iMpmCsIdWatcher;    
     
+    delete iMpmDataUsageWatcher;    
+    
     iDedicatedClients.Close();
 
     delete iCommsDatAccess;    
@@ -1784,7 +1802,7 @@
     RAvailableIAPList iapList;
     CleanupClosePushL( iapList );
 
-    for ( TInt index = 0; index < aIapInfo.iCount; index++ )
+    for ( TUint index = 0; index < aIapInfo.iCount; index++ )
         {
         if ( CommsDatAccess()->CheckWlanL( aIapInfo.iIap[index].iIapId ) != ENotWlanIap )
             {
@@ -1847,7 +1865,7 @@
     RArray<TUint32> packetDataIapIds;
     CleanupClosePushL( packetDataIapIds );
 
-    for ( TInt index = 0; index < aIapInfo.iCount; index++ )
+    for ( TUint index = 0; index < aIapInfo.iCount; index++ )
         {
         if ( CommsDatAccess()->GetBearerTypeL( aIapInfo.iIap[index].iIapId ) ==
             EMPMBearerTypePacketData )
@@ -1876,7 +1894,7 @@
             {
             // Check if used WLAN is still available
             TBool currentWlanIapAvailable = EFalse;
-            for ( TInt iapIndex = 0; iapIndex < aIapInfo.iCount; iapIndex++ )
+            for ( TUint iapIndex = 0; iapIndex < aIapInfo.iCount; iapIndex++ )
                 {
                 if ( aIapInfo.iIap[iapIndex].iIapId ==
                     iActiveBMConns[index].iConnInfo.iIapId )
@@ -2063,6 +2081,49 @@
     return serverSession;
     }
 
+// ---------------------------------------------------------------------------
+// CMPMServer::StopCellularConns
+// Stop all cellular connections except MMS
+// ---------------------------------------------------------------------------
+//
+void CMPMServer::StopCellularConns()
+    {
+    MPMLOGSTRING( "CMPMServer::StopCellularConns" )
+
+    TUint32 iapId;
+	TMPMBearerType bearerType = EMPMBearerTypeNone;
+
+	// No cleanup stack used cause this function doesn't leave.
+    RArray<TUint32> stoppedIaps;
+
+    // Check through active connections
+    for (TInt i = 0; i < iActiveBMConns.Count(); i++)
+        {
+        iapId = iActiveBMConns[i].iConnInfo.iIapId;
+
+        // Don't stop the same IAP twice.
+        if (stoppedIaps.Find( iapId ) == KErrNotFound)
+            {
+            TRAPD( err, bearerType = CommsDatAccess()->GetBearerTypeL( iapId ) );
+            if (err == KErrNone &&
+                    iapId != 0 &&
+                    bearerType == EMPMBearerTypePacketData)
+                {
+                TInt mmsIap( 0 );
+                err = RProperty::Get( KMPMCathegory, KMPMPropertyKeyMMS, mmsIap );
+                // Check that it's not MMS IAP.
+                if (!(err == KErrNone && iapId == mmsIap))
+                    {
+                    // Stop the conn / IAP.
+                    StopConnections( iapId );
+                    stoppedIaps.Append( iapId );
+                    }
+                }
+            }
+        }
+    stoppedIaps.Close();
+    }
+
 // -----------------------------------------------------------------------------
 // TMPMBlackListConnId::Append
 // -----------------------------------------------------------------------------