supl/locationsuplfw/protocolhandlerapi/src/epos_csuplconnection.cpp
branchRCL_3
changeset 49 10852b179f64
parent 47 fce0ae2e4223
child 55 ea98413ce11f
--- a/supl/locationsuplfw/protocolhandlerapi/src/epos_csuplconnection.cpp	Tue Sep 14 22:09:33 2010 +0300
+++ b/supl/locationsuplfw/protocolhandlerapi/src/epos_csuplconnection.cpp	Wed Sep 15 12:40:28 2010 +0300
@@ -319,8 +319,10 @@
     // Cancel Any outstanding request
     Cancel();
 
-    iTrace->Trace(_L("CSuplConnection::Destructor...Deleting Socket Reader"),
-            KTraceFileName, __LINE__);
+    if (iTrace)
+        iTrace->Trace(_L(
+                "CSuplConnection::Destructor...Deleting Socket Reader"),
+                KTraceFileName, __LINE__);
     //Delete the Socket Reader
     delete iSocketReader;
 
@@ -967,7 +969,12 @@
         {
         aStatus = KRequestPending;
         TRequestStatus *reqStatus = &aStatus;
-        iConnArray.Append(reqStatus);
+        TInt error = iConnArray.Append(reqStatus);
+        if (error != KErrNone)
+            {
+            User::RequestComplete(reqStatus, error);
+            return;
+            }
         }
 
     if (!iConnectStarted)
@@ -983,14 +990,40 @@
             iConnectStarted = ETrue;
 
 #ifndef __WINS__
-            TCommDbConnPref prefs;
-            prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
-            prefs.SetDirection(ECommDbConnectionDirectionOutgoing);
-            prefs.SetIapId(iIAPId);
+            TExtendedConnPref OCCPrefs;
+            TConnPrefList prefList;
+
+            OCCPrefs.SetForcedRoaming(EFalse); //do not switch networks during an ongoing connection            
+            OCCPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourDefault);
+
+            if(iIAPId != -1) //if a IAP was configured
+
+                {
+                iTrace->Trace(_L("CSuplConnection::Connect : IAP configured"), KTraceFileName, __LINE__);
+                OCCPrefs.SetIapId(iIAPId);
+                // since IAP Id is set SNAP purpose should not be set - set to unknown
+                OCCPrefs.SetSnapPurpose(CMManager::ESnapPurposeUnknown);
+                OCCPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerUnknown);
+                }
+            else
+                {
+                OCCPrefs.SetSnapPurpose(CMManager::ESnapPurposeInternet);
+                //WLAN and Cellular Networks allowed for connection
+                OCCPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerWLAN | TExtendedConnPref::EExtendedConnBearerCellular);
+
+                //if SNAP purpose is set IAP Id should be zero - zero by default not explicitly set
+                iTrace->Trace(_L("CSuplConnection::Connect : IAP not configured"), KTraceFileName, __LINE__);
+                }
+
+            TRAP_IGNORE(prefList.AppendL(&OCCPrefs));
 
             TInt ret = iConnection.Open(iSocketServ);
+            if(ret != KErrNone)
+            iTrace->Trace(_L("RConnection Open returned error"), KTraceFileName, __LINE__);
+
+            iTrace->Trace(_L("RConnection Start Called, State is ERetriveIAP"), KTraceFileName, __LINE__);
             // Start an Outgoing Connection with overrides
-            iConnection.Start(prefs,iStatus);
+            iConnection.Start(prefList,iStatus);
             // Set state to ERetriveIAP
             iState = ERetriveIAP;
             SetActive();
@@ -1019,92 +1052,99 @@
 EXPORT_C void CSuplConnection::Connect(TRequestStatus &aStatus,
         TBool aPrompt, TBool aWlanOnly)
     {
+
     // Log
-        iTrace->Trace(_L("CSuplConnection::Connect"), KTraceFileName, __LINE__);
-        iPrompt = aPrompt;
-        iWlanOnly = aWlanOnly;
-        
-        if (iState == EConnected)
-            {
-            aStatus = KRequestPending;
-            TRequestStatus *reqStatus = &aStatus;
-            User::RequestComplete(reqStatus, KErrNone); 
-            iConnectClients++;
-            return;
-            }                
+    iTrace->Trace(_L("CSuplConnection::Connect"), KTraceFileName, __LINE__);
+    iPrompt = aPrompt;
+    iWlanOnly = aWlanOnly;
+
+    aStatus = KRequestPending;
+    TRequestStatus *reqStatus = &aStatus;
+
+    if (iState == EConnected)
+        {
+        User::RequestComplete(reqStatus, KErrNone);
+        iConnectClients++;
+        return;
+        }
 
-        // Check if Connect() is started.  If started, add status to Q
-        //if (iConnectStarted)
-          //  {
-            aStatus = KRequestPending;
-            TRequestStatus *reqStatus = &aStatus;
-            iConnArray.Append(reqStatus);
-           // }                
-        
-        if (!iConnectStarted)
-            {                
-            iTrace->Trace(_L("CSuplConnection::Connect : Connection not started"), KTraceFileName, __LINE__);
+    TInt error = iConnArray.Append(reqStatus);
+    if (error != KErrNone)
+        {
+        User::RequestComplete(reqStatus, error);
+        return;
+        }
+
+    if (!iConnectStarted)
+        {
+        iTrace->Trace(
+                _L("CSuplConnection::Connect : Connection not started"),
+                KTraceFileName, __LINE__);
         // Connect only if not already connected
-        if(iState == ENotConnected || iState == EFailure)
-        {   
-            iTrace->Trace(_L("CSuplConnection::Connect : ENotConnected"), KTraceFileName, __LINE__);
+        if (iState == ENotConnected || iState == EFailure)
+            {
+            iTrace->Trace(_L("CSuplConnection::Connect : ENotConnected"),
+                    KTraceFileName, __LINE__);
             iConnectStarted = ETrue;
 
 #ifndef __WINS__
-            
+
             iTrace->Trace(_L("CSuplConnection::Connect ExtendedConnPref"), KTraceFileName, __LINE__);
-            
+
             TExtendedConnPref OCCPrefs;
             TConnPrefList prefList;
 
-               if(iWlanOnly)
-                    {
-                    iTrace->Trace(_L("CSuplConnection::Connect : iWLANOnly used"), KTraceFileName, __LINE__);
-                    OCCPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerWLAN);
-                    OCCPrefs.SetSnapPurpose(CMManager::ESnapPurposeInternet);
-                    }
-                else
-                    {
-                    iTrace->Trace(_L("CSuplConnection::Connect using OCC"), KTraceFileName, __LINE__);   
-                    iTrace->Trace(_L("CSuplConnection::Connect OCC GPRS Connection.."), KTraceFileName, __LINE__);
-                    OCCPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerCellular);
-                    OCCPrefs.SetSnapPurpose(CMManager::ESnapPurposeInternet);
-                   }
-                
-                if(!iPrompt)
-                   {
-                    iTrace->Trace(_L("CSuplConnection::Connect : silent connection"), KTraceFileName, __LINE__);
-                    OCCPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent);
-                   }
-                else
-                    {
-                    iTrace->Trace(_L("CSuplConnection::Connect : Dialog prompt"), KTraceFileName, __LINE__);
-                    OCCPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourDefault);
-                    }
-                
-              
-            
+            if(iWlanOnly)
+                {
+                iTrace->Trace(_L("CSuplConnection::Connect : iWLANOnly used"), KTraceFileName, __LINE__);
+                OCCPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerWLAN);
+                }
+            else
+                {
+                iTrace->Trace(_L("CSuplConnection::Connect OCC GPRS Connection.."), KTraceFileName, __LINE__);
+                OCCPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerCellular);
+                }
+            OCCPrefs.SetSnapPurpose(CMManager::ESnapPurposeInternet);
+
+            if(!iPrompt)
+                {
+                iTrace->Trace(_L("CSuplConnection::Connect : silent connection"), KTraceFileName, __LINE__);
+                OCCPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent);
+                }
+            else
+                {
+                iTrace->Trace(_L("CSuplConnection::Connect : Dialog prompt"), KTraceFileName, __LINE__);
+                OCCPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourDefault);
+                }
+
             TRAP_IGNORE(prefList.AppendL(&OCCPrefs));
-            
-            
+
             TInt ret = iConnection.Open(iSocketServ);
+            if( ret != KErrNone )
+                {
+                TRequestStatus* statusPtr = &aStatus;
+                User::RequestComplete( statusPtr,ret );
+                return;
+                }
             // Start an Outgoing Connection with overrides
             iConnection.Start(prefList,iStatus);
             // Set state to ERetriveIAP
-            iState = ERetriveIAP;   
-            SetActive();     
-            
-            
-            
+            iState = ERetriveIAP;
+            SetActive();
+
 #else
             ConnectIAP();
 #endif
+            }
         }
-            }
-        else
-            iTrace->Trace(_L("CSuplConnection::Connect : Conn in progress, request queued"), KTraceFileName, __LINE__);
+    else
+        iTrace->Trace(
+                _L(
+                        "CSuplConnection::Connect : Conn in progress, request queued"),
+                KTraceFileName, __LINE__);
     // Log
-    iTrace->Trace(_L("CSuplConnection::Connect:Exit"), KTraceFileName, __LINE__);
+    iTrace->Trace(_L("CSuplConnection::Connect:Exit"), KTraceFileName,
+            __LINE__);
     }
 
 // -----------------------------------------------------------------------------
@@ -1324,6 +1364,7 @@
         SetActive();
         }
     }
+
 // -----------------------------------------------------------------------------
 // CSuplConnection::ConnectIAP
 // Makes a socket connection to Network