supl/locationsuplfw/protocolhandlerapi/src/epos_csuplconnection.cpp
branchRCL_3
changeset 44 2b4ea9893b66
parent 42 02ba3f1733c6
child 45 6b6920c56e2f
--- a/supl/locationsuplfw/protocolhandlerapi/src/epos_csuplconnection.cpp	Thu Aug 19 10:20:18 2010 +0300
+++ b/supl/locationsuplfw/protocolhandlerapi/src/epos_csuplconnection.cpp	Tue Aug 31 15:37:04 2010 +0300
@@ -23,7 +23,7 @@
 #endif
 #include <commdbconnpref.h>
 #include <centralrepository.h>
-#include <extendedconnpref.h> //For OCC
+
 #include "epos_csuplserverprivatecrkeys.h"
 #include "epos_csuplconnection.h"
 #include "epos_csuplsocketreader.h"   
@@ -33,6 +33,7 @@
 #include "epos_psktlsusageprivatecrkeys.h"
 #include "epos_suplpskloger.h"
 
+#include <extendedconnpref.h> //For OCC
 const TInt KMaxGBAUsageLength = 4;
 const TInt KMaxVerLength = 4;
 //const TInt KMaxNewPasswordLength =  8;
@@ -319,8 +320,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 +970,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,20 +991,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 )
-                {
-                TRequestStatus* statusPtr = &aStatus;
-                User::RequestComplete( statusPtr,ret );
-                return;
-                }
+            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();
@@ -1095,7 +1123,7 @@
             TInt ret = iConnection.Open(iSocketServ);
             if( ret != KErrNone )
                 {
-                TRequestStatus* statusPtr = &iStatus;
+                TRequestStatus* statusPtr = &aStatus;
                 User::RequestComplete( statusPtr,ret );
                 return;
                 }
@@ -1199,14 +1227,14 @@
         aStatus = KRequestPending;
         CSuplPacketInfo *packetInfo = NULL;
 
-        TRAP(err, packetInfo = CSuplPacketInfo::NewL(aPacket, aStatus));
+        TRAP(err, packetInfo = CSuplPacketInfo::NewL(aPacket, aStatus);
+                iPktArray.AppendL(packetInfo));
         if (err != KErrNone)
             {
             TRequestStatus *reqStatus = &aStatus;
             User::RequestComplete(reqStatus, err);
             return;
             }
-        iPktArray.Append(packetInfo);
         }
 
     else
@@ -1337,6 +1365,7 @@
         SetActive();
         }
     }
+
 // -----------------------------------------------------------------------------
 // CSuplConnection::ConnectIAP
 // Makes a socket connection to Network