supl/locationsuplfw/protocolhandlerapi/src/epos_csuplconnection.cpp
branchRCL_3
changeset 44 2b4ea9893b66
parent 42 02ba3f1733c6
child 45 6b6920c56e2f
equal deleted inserted replaced
42:02ba3f1733c6 44:2b4ea9893b66
    21 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    21 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    22 #include <ssl_internal.h>
    22 #include <ssl_internal.h>
    23 #endif
    23 #endif
    24 #include <commdbconnpref.h>
    24 #include <commdbconnpref.h>
    25 #include <centralrepository.h>
    25 #include <centralrepository.h>
    26 #include <extendedconnpref.h> //For OCC
    26 
    27 #include "epos_csuplserverprivatecrkeys.h"
    27 #include "epos_csuplserverprivatecrkeys.h"
    28 #include "epos_csuplconnection.h"
    28 #include "epos_csuplconnection.h"
    29 #include "epos_csuplsocketreader.h"   
    29 #include "epos_csuplsocketreader.h"   
    30 #include "epos_csuplsockettimer.h"
    30 #include "epos_csuplsockettimer.h"
    31 #include "epos_csuplconntrace.h"
    31 #include "epos_csuplconntrace.h"
    32 #include "epos_csuplpacketinfo.h"
    32 #include "epos_csuplpacketinfo.h"
    33 #include "epos_psktlsusageprivatecrkeys.h"
    33 #include "epos_psktlsusageprivatecrkeys.h"
    34 #include "epos_suplpskloger.h"
    34 #include "epos_suplpskloger.h"
    35 
    35 
       
    36 #include <extendedconnpref.h> //For OCC
    36 const TInt KMaxGBAUsageLength = 4;
    37 const TInt KMaxGBAUsageLength = 4;
    37 const TInt KMaxVerLength = 4;
    38 const TInt KMaxVerLength = 4;
    38 //const TInt KMaxNewPasswordLength =  8;
    39 //const TInt KMaxNewPasswordLength =  8;
    39 const TInt KMaxNewPasswordLength = 16;
    40 const TInt KMaxNewPasswordLength = 16;
    40 const TInt KMaxPskKeyLength = 256;
    41 const TInt KMaxPskKeyLength = 256;
   317                 KTraceFileName, __LINE__);
   318                 KTraceFileName, __LINE__);
   318         }
   319         }
   319     // Cancel Any outstanding request
   320     // Cancel Any outstanding request
   320     Cancel();
   321     Cancel();
   321 
   322 
   322     iTrace->Trace(_L("CSuplConnection::Destructor...Deleting Socket Reader"),
   323     if (iTrace)
   323             KTraceFileName, __LINE__);
   324         iTrace->Trace(_L(
       
   325                 "CSuplConnection::Destructor...Deleting Socket Reader"),
       
   326                 KTraceFileName, __LINE__);
   324     //Delete the Socket Reader
   327     //Delete the Socket Reader
   325     delete iSocketReader;
   328     delete iSocketReader;
   326 
   329 
   327     // Close the resolver if required
   330     // Close the resolver if required
   328     if (iState == ELookingUp)
   331     if (iState == ELookingUp)
   965     // Check if Connect() is started.  If started, add status to Q
   968     // Check if Connect() is started.  If started, add status to Q
   966     //if (iConnectStarted)
   969     //if (iConnectStarted)
   967         {
   970         {
   968         aStatus = KRequestPending;
   971         aStatus = KRequestPending;
   969         TRequestStatus *reqStatus = &aStatus;
   972         TRequestStatus *reqStatus = &aStatus;
   970         iConnArray.Append(reqStatus);
   973         TInt error = iConnArray.Append(reqStatus);
       
   974         if (error != KErrNone)
       
   975             {
       
   976             User::RequestComplete(reqStatus, error);
       
   977             return;
       
   978             }
   971         }
   979         }
   972 
   980 
   973     if (!iConnectStarted)
   981     if (!iConnectStarted)
   974         {
   982         {
   975         iTrace->Trace(
   983         iTrace->Trace(
   981             iTrace->Trace(_L("CSuplConnection::Connect : ENotConnected"),
   989             iTrace->Trace(_L("CSuplConnection::Connect : ENotConnected"),
   982                     KTraceFileName, __LINE__);
   990                     KTraceFileName, __LINE__);
   983             iConnectStarted = ETrue;
   991             iConnectStarted = ETrue;
   984 
   992 
   985 #ifndef __WINS__
   993 #ifndef __WINS__
   986             TCommDbConnPref prefs;
   994             TExtendedConnPref OCCPrefs;
   987             prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
   995             TConnPrefList prefList;
   988             prefs.SetDirection(ECommDbConnectionDirectionOutgoing);
   996 
   989             prefs.SetIapId(iIAPId);
   997             OCCPrefs.SetForcedRoaming(EFalse); //do not switch networks during an ongoing connection            
       
   998             OCCPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourDefault);
       
   999 
       
  1000             if(iIAPId != -1) //if a IAP was configured
       
  1001 
       
  1002                 {
       
  1003                 iTrace->Trace(_L("CSuplConnection::Connect : IAP configured"), KTraceFileName, __LINE__);
       
  1004                 OCCPrefs.SetIapId(iIAPId);
       
  1005                 // since IAP Id is set SNAP purpose should not be set - set to unknown
       
  1006                 OCCPrefs.SetSnapPurpose(CMManager::ESnapPurposeUnknown);
       
  1007                 OCCPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerUnknown);
       
  1008                 }
       
  1009             else
       
  1010                 {
       
  1011                 OCCPrefs.SetSnapPurpose(CMManager::ESnapPurposeInternet);
       
  1012                 //WLAN and Cellular Networks allowed for connection
       
  1013                 OCCPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerWLAN | TExtendedConnPref::EExtendedConnBearerCellular);
       
  1014 
       
  1015                 //if SNAP purpose is set IAP Id should be zero - zero by default not explicitly set
       
  1016                 iTrace->Trace(_L("CSuplConnection::Connect : IAP not configured"), KTraceFileName, __LINE__);
       
  1017                 }
       
  1018 
       
  1019             TRAP_IGNORE(prefList.AppendL(&OCCPrefs));
   990 
  1020 
   991             TInt ret = iConnection.Open(iSocketServ);
  1021             TInt ret = iConnection.Open(iSocketServ);
   992              if( ret != KErrNone )
  1022             if(ret != KErrNone)
   993                 {
  1023             iTrace->Trace(_L("RConnection Open returned error"), KTraceFileName, __LINE__);
   994                 TRequestStatus* statusPtr = &aStatus;
  1024 
   995                 User::RequestComplete( statusPtr,ret );
  1025             iTrace->Trace(_L("RConnection Start Called, State is ERetriveIAP"), KTraceFileName, __LINE__);
   996                 return;
       
   997                 }
       
   998             // Start an Outgoing Connection with overrides
  1026             // Start an Outgoing Connection with overrides
   999             iConnection.Start(prefs,iStatus);
  1027             iConnection.Start(prefList,iStatus);
  1000             // Set state to ERetriveIAP
  1028             // Set state to ERetriveIAP
  1001             iState = ERetriveIAP;
  1029             iState = ERetriveIAP;
  1002             SetActive();
  1030             SetActive();
  1003 #else
  1031 #else
  1004             ConnectIAP();
  1032             ConnectIAP();
  1093             TRAP_IGNORE(prefList.AppendL(&OCCPrefs));
  1121             TRAP_IGNORE(prefList.AppendL(&OCCPrefs));
  1094 
  1122 
  1095             TInt ret = iConnection.Open(iSocketServ);
  1123             TInt ret = iConnection.Open(iSocketServ);
  1096             if( ret != KErrNone )
  1124             if( ret != KErrNone )
  1097                 {
  1125                 {
  1098                 TRequestStatus* statusPtr = &iStatus;
  1126                 TRequestStatus* statusPtr = &aStatus;
  1099                 User::RequestComplete( statusPtr,ret );
  1127                 User::RequestComplete( statusPtr,ret );
  1100                 return;
  1128                 return;
  1101                 }
  1129                 }
  1102             // Start an Outgoing Connection with overrides
  1130             // Start an Outgoing Connection with overrides
  1103             iConnection.Start(prefList,iStatus);
  1131             iConnection.Start(prefList,iStatus);
  1197         {
  1225         {
  1198         TInt err = KErrNone;
  1226         TInt err = KErrNone;
  1199         aStatus = KRequestPending;
  1227         aStatus = KRequestPending;
  1200         CSuplPacketInfo *packetInfo = NULL;
  1228         CSuplPacketInfo *packetInfo = NULL;
  1201 
  1229 
  1202         TRAP(err, packetInfo = CSuplPacketInfo::NewL(aPacket, aStatus));
  1230         TRAP(err, packetInfo = CSuplPacketInfo::NewL(aPacket, aStatus);
       
  1231                 iPktArray.AppendL(packetInfo));
  1203         if (err != KErrNone)
  1232         if (err != KErrNone)
  1204             {
  1233             {
  1205             TRequestStatus *reqStatus = &aStatus;
  1234             TRequestStatus *reqStatus = &aStatus;
  1206             User::RequestComplete(reqStatus, err);
  1235             User::RequestComplete(reqStatus, err);
  1207             return;
  1236             return;
  1208             }
  1237             }
  1209         iPktArray.Append(packetInfo);
       
  1210         }
  1238         }
  1211 
  1239 
  1212     else
  1240     else
  1213         {
  1241         {
  1214         TInt err = KErrNone;
  1242         TInt err = KErrNone;
  1335     if (!IsActive())
  1363     if (!IsActive())
  1336         {
  1364         {
  1337         SetActive();
  1365         SetActive();
  1338         }
  1366         }
  1339     }
  1367     }
       
  1368 
  1340 // -----------------------------------------------------------------------------
  1369 // -----------------------------------------------------------------------------
  1341 // CSuplConnection::ConnectIAP
  1370 // CSuplConnection::ConnectIAP
  1342 // Makes a socket connection to Network
  1371 // Makes a socket connection to Network
  1343 // (other items were commented in a header).
  1372 // (other items were commented in a header).
  1344 // -----------------------------------------------------------------------------
  1373 // -----------------------------------------------------------------------------