supl/locationsuplfw/protocolhandlerapi/src/epos_csuplcommunicationmanager.cpp
changeset 39 3efc7a0e8755
parent 0 667063e416a2
--- a/supl/locationsuplfw/protocolhandlerapi/src/epos_csuplcommunicationmanager.cpp	Fri Jul 23 19:40:48 2010 +0530
+++ b/supl/locationsuplfw/protocolhandlerapi/src/epos_csuplcommunicationmanager.cpp	Fri Aug 06 19:34:22 2010 +0530
@@ -36,8 +36,8 @@
 
 // ============================ MEMBER FUNCTIONS ===============================
 
-CSuplCommunicationManager::CSuplCommunicationManager():
-	iServerConnected(EFalse)
+CSuplCommunicationManager::CSuplCommunicationManager(MSuplConnectionMonitor& aConnMonitor):
+	iServerConnected(EFalse), iConnMonitor(aConnMonitor)
     {
     }
 
@@ -49,9 +49,9 @@
 	iTrace->Trace(_L("CSuplCommunicationManager::ConstructL"), KTraceFileName, __LINE__); 
     }
 
-EXPORT_C CSuplCommunicationManager* CSuplCommunicationManager::NewL()
+EXPORT_C CSuplCommunicationManager* CSuplCommunicationManager::NewL(MSuplConnectionMonitor& aConnMonitor)
     {
-    CSuplCommunicationManager* self = new( ELeave ) CSuplCommunicationManager;
+    CSuplCommunicationManager* self = new( ELeave ) CSuplCommunicationManager(aConnMonitor);
     
     CleanupStack::PushL( self );
     self->ConstructL();
@@ -125,9 +125,10 @@
     if(NULL == (suplConnection = FindConnection(aHostAddress, aPort)))
     	{
     	suplConnection = CSuplConnection::NewL(iSocketServ, aHostAddress, aPort, aIAPId, this);	
-    	iConnArray.Append(suplConnection);
+    	iConnArray.AppendL(suplConnection);
     	iTrace->Trace(_L("CSuplCommunicationManager::CreateConnectionL New Connection Created"), KTraceFileName, __LINE__);
-    	}
+    	iConnMonitor.ConnectionOpened();
+    }
     else
     	{
     	// Check if we have exceeded the max no. of sessions 
@@ -138,10 +139,11 @@
     	if(suplConnection->RefCount() >= KMaxSessionPerConn)
     		{
     		suplConnection = CSuplConnection::NewL(iSocketServ, aHostAddress, aPort, aIAPId, this);
-    		iConnArray.Append(suplConnection);
+    		iConnArray.AppendL(suplConnection);
     		iTrace->Trace(_L("CSuplCommunicationManager::CreateConnectionL New Connection Created"), KTraceFileName, __LINE__);
-    		}
+        	iConnMonitor.ConnectionOpened();
     	}
+    }
     
     // Increment the Ref Count
     suplConnection->IncRefCount();
@@ -180,7 +182,8 @@
     if(NULL == (suplConnection = FindConnection(aHostAddress, aPort)))
     	{
         suplConnection = CSuplConnection::NewL(iSocketServ, aHostAddress, aPort, aIAPId, aTls, aPskTls, this); 
-        iConnArray.Append(suplConnection);
+        iConnArray.AppendL(suplConnection);
+       	iConnMonitor.ConnectionOpened();
         iTrace->Trace(_L("CSuplCommunicationManager::CreateConnectionL New Connection Created"), KTraceFileName, __LINE__);
     	}
     else
@@ -193,10 +196,11 @@
         if(suplConnection->RefCount() >= KMaxSessionPerConn)
         	{
             suplConnection = CSuplConnection::NewL(iSocketServ, aHostAddress, aPort, aIAPId, aTls, aPskTls, this);
-            iConnArray.Append(suplConnection);
+            iConnArray.AppendL(suplConnection);
+        	iConnMonitor.ConnectionOpened();
             iTrace->Trace(_L("CSuplCommunicationManager::CreateConnectionL New Connection Created"), KTraceFileName, __LINE__);
         	}
-    	}
+    	}      
     
     // Increment the Ref Count
     suplConnection->IncRefCount();
@@ -243,6 +247,8 @@
     iTrace->Trace(_L("CSuplCommunicationManager::DestroyConnection Destroy Connection"), KTraceFileName, __LINE__);
     aConnection->Destroy();
     
+    iConnMonitor.ConnectionClosed();
+    
     return KErrNone;
     }