supl/locationsuplfw/protocolhandlerapi/src/epos_csuplconnection.cpp
branchRCL_3
changeset 55 ea98413ce11f
parent 49 10852b179f64
equal deleted inserted replaced
49:10852b179f64 55:ea98413ce11f
    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"
   123 CSuplConnection::CSuplConnection(RSocketServ &aSocketServ) :
   123 CSuplConnection::CSuplConnection(RSocketServ &aSocketServ) :
   124     CActive(EPriorityStandard), iSocketServ(aSocketServ), iRefCount(0),
   124     CActive(EPriorityStandard), iSocketServ(aSocketServ), iRefCount(0),
   125             iState(ENotConnected), iPacket(0, 0), iVariantEnabled(ETrue),
   125             iState(ENotConnected), iPacket(0, 0), iVariantEnabled(ETrue),
   126             iPskTLSUsage(EFalse), iStartedListen(EFalse), iConnectStarted(
   126             iPskTLSUsage(EFalse), iStartedListen(EFalse), iConnectStarted(
   127                     EFalse), iSendInProgress(EFalse), iFirstPkt(EFalse),
   127                     EFalse), iSendInProgress(EFalse), iFirstPkt(EFalse),
   128             iListenCount(0), iPrompt(EFalse), iWlanOnly(EFalse)
   128             iListenCount(0)
   129     {
   129     {
   130     iHostAddress.Zero();
   130     iHostAddress.Zero();
   131     CActiveScheduler::Add(this);
   131     CActiveScheduler::Add(this);
   132     }
   132     }
   133 
   133 
   317                 KTraceFileName, __LINE__);
   317                 KTraceFileName, __LINE__);
   318         }
   318         }
   319     // Cancel Any outstanding request
   319     // Cancel Any outstanding request
   320     Cancel();
   320     Cancel();
   321 
   321 
   322     if (iTrace)
   322     iTrace->Trace(_L("CSuplConnection::Destructor...Deleting Socket Reader"),
   323         iTrace->Trace(_L(
   323             KTraceFileName, __LINE__);
   324                 "CSuplConnection::Destructor...Deleting Socket Reader"),
       
   325                 KTraceFileName, __LINE__);
       
   326     //Delete the Socket Reader
   324     //Delete the Socket Reader
   327     delete iSocketReader;
   325     delete iSocketReader;
   328 
   326 
   329     // Close the resolver if required
   327     // Close the resolver if required
   330     if (iState == ELookingUp)
   328     if (iState == ELookingUp)
   967     // Check if Connect() is started.  If started, add status to Q
   965     // Check if Connect() is started.  If started, add status to Q
   968     //if (iConnectStarted)
   966     //if (iConnectStarted)
   969         {
   967         {
   970         aStatus = KRequestPending;
   968         aStatus = KRequestPending;
   971         TRequestStatus *reqStatus = &aStatus;
   969         TRequestStatus *reqStatus = &aStatus;
   972         TInt error = iConnArray.Append(reqStatus);
   970         iConnArray.Append(reqStatus);
   973         if (error != KErrNone)
       
   974             {
       
   975             User::RequestComplete(reqStatus, error);
       
   976             return;
       
   977             }
       
   978         }
   971         }
   979 
   972 
   980     if (!iConnectStarted)
   973     if (!iConnectStarted)
   981         {
   974         {
   982         iTrace->Trace(
   975         iTrace->Trace(
   988             iTrace->Trace(_L("CSuplConnection::Connect : ENotConnected"),
   981             iTrace->Trace(_L("CSuplConnection::Connect : ENotConnected"),
   989                     KTraceFileName, __LINE__);
   982                     KTraceFileName, __LINE__);
   990             iConnectStarted = ETrue;
   983             iConnectStarted = ETrue;
   991 
   984 
   992 #ifndef __WINS__
   985 #ifndef __WINS__
   993             TExtendedConnPref OCCPrefs;
   986             TCommDbConnPref prefs;
   994             TConnPrefList prefList;
   987             prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
   995 
   988             prefs.SetDirection(ECommDbConnectionDirectionOutgoing);
   996             OCCPrefs.SetForcedRoaming(EFalse); //do not switch networks during an ongoing connection            
   989             prefs.SetIapId(iIAPId);
   997             OCCPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourDefault);
       
   998 
       
   999             if(iIAPId != -1) //if a IAP was configured
       
  1000 
       
  1001                 {
       
  1002                 iTrace->Trace(_L("CSuplConnection::Connect : IAP configured"), KTraceFileName, __LINE__);
       
  1003                 OCCPrefs.SetIapId(iIAPId);
       
  1004                 // since IAP Id is set SNAP purpose should not be set - set to unknown
       
  1005                 OCCPrefs.SetSnapPurpose(CMManager::ESnapPurposeUnknown);
       
  1006                 OCCPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerUnknown);
       
  1007                 }
       
  1008             else
       
  1009                 {
       
  1010                 OCCPrefs.SetSnapPurpose(CMManager::ESnapPurposeInternet);
       
  1011                 //WLAN and Cellular Networks allowed for connection
       
  1012                 OCCPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerWLAN | TExtendedConnPref::EExtendedConnBearerCellular);
       
  1013 
       
  1014                 //if SNAP purpose is set IAP Id should be zero - zero by default not explicitly set
       
  1015                 iTrace->Trace(_L("CSuplConnection::Connect : IAP not configured"), KTraceFileName, __LINE__);
       
  1016                 }
       
  1017 
       
  1018             TRAP_IGNORE(prefList.AppendL(&OCCPrefs));
       
  1019 
   990 
  1020             TInt ret = iConnection.Open(iSocketServ);
   991             TInt ret = iConnection.Open(iSocketServ);
  1021             if(ret != KErrNone)
       
  1022             iTrace->Trace(_L("RConnection Open returned error"), KTraceFileName, __LINE__);
       
  1023 
       
  1024             iTrace->Trace(_L("RConnection Start Called, State is ERetriveIAP"), KTraceFileName, __LINE__);
       
  1025             // Start an Outgoing Connection with overrides
   992             // Start an Outgoing Connection with overrides
  1026             iConnection.Start(prefList,iStatus);
   993             iConnection.Start(prefs,iStatus);
  1027             // Set state to ERetriveIAP
   994             // Set state to ERetriveIAP
  1028             iState = ERetriveIAP;
   995             iState = ERetriveIAP;
  1029             SetActive();
   996             SetActive();
  1030 #else
       
  1031             ConnectIAP();
       
  1032 #endif
       
  1033             }
       
  1034         }
       
  1035     else
       
  1036         iTrace->Trace(
       
  1037                 _L(
       
  1038                         "CSuplConnection::Connect : Conn in progress, request queued"),
       
  1039                 KTraceFileName, __LINE__);
       
  1040     // Log
       
  1041     iTrace->Trace(_L("CSuplConnection::Connect:Exit"), KTraceFileName,
       
  1042             __LINE__);
       
  1043     }
       
  1044 
       
  1045 // -----------------------------------------------------------------------------
       
  1046 // CSuplConnection::Connect
       
  1047 // Makes a secure connection to Network
       
  1048 // (other items were commented in a header).
       
  1049 // -----------------------------------------------------------------------------
       
  1050 //
       
  1051 
       
  1052 EXPORT_C void CSuplConnection::Connect(TRequestStatus &aStatus,
       
  1053         TBool aPrompt, TBool aWlanOnly)
       
  1054     {
       
  1055 
       
  1056     // Log
       
  1057     iTrace->Trace(_L("CSuplConnection::Connect"), KTraceFileName, __LINE__);
       
  1058     iPrompt = aPrompt;
       
  1059     iWlanOnly = aWlanOnly;
       
  1060 
       
  1061     aStatus = KRequestPending;
       
  1062     TRequestStatus *reqStatus = &aStatus;
       
  1063 
       
  1064     if (iState == EConnected)
       
  1065         {
       
  1066         User::RequestComplete(reqStatus, KErrNone);
       
  1067         iConnectClients++;
       
  1068         return;
       
  1069         }
       
  1070 
       
  1071     TInt error = iConnArray.Append(reqStatus);
       
  1072     if (error != KErrNone)
       
  1073         {
       
  1074         User::RequestComplete(reqStatus, error);
       
  1075         return;
       
  1076         }
       
  1077 
       
  1078     if (!iConnectStarted)
       
  1079         {
       
  1080         iTrace->Trace(
       
  1081                 _L("CSuplConnection::Connect : Connection not started"),
       
  1082                 KTraceFileName, __LINE__);
       
  1083         // Connect only if not already connected
       
  1084         if (iState == ENotConnected || iState == EFailure)
       
  1085             {
       
  1086             iTrace->Trace(_L("CSuplConnection::Connect : ENotConnected"),
       
  1087                     KTraceFileName, __LINE__);
       
  1088             iConnectStarted = ETrue;
       
  1089 
       
  1090 #ifndef __WINS__
       
  1091 
       
  1092             iTrace->Trace(_L("CSuplConnection::Connect ExtendedConnPref"), KTraceFileName, __LINE__);
       
  1093 
       
  1094             TExtendedConnPref OCCPrefs;
       
  1095             TConnPrefList prefList;
       
  1096 
       
  1097             if(iWlanOnly)
       
  1098                 {
       
  1099                 iTrace->Trace(_L("CSuplConnection::Connect : iWLANOnly used"), KTraceFileName, __LINE__);
       
  1100                 OCCPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerWLAN);
       
  1101                 }
       
  1102             else
       
  1103                 {
       
  1104                 iTrace->Trace(_L("CSuplConnection::Connect OCC GPRS Connection.."), KTraceFileName, __LINE__);
       
  1105                 OCCPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerCellular);
       
  1106                 }
       
  1107             OCCPrefs.SetSnapPurpose(CMManager::ESnapPurposeInternet);
       
  1108 
       
  1109             if(!iPrompt)
       
  1110                 {
       
  1111                 iTrace->Trace(_L("CSuplConnection::Connect : silent connection"), KTraceFileName, __LINE__);
       
  1112                 OCCPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent);
       
  1113                 }
       
  1114             else
       
  1115                 {
       
  1116                 iTrace->Trace(_L("CSuplConnection::Connect : Dialog prompt"), KTraceFileName, __LINE__);
       
  1117                 OCCPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourDefault);
       
  1118                 }
       
  1119 
       
  1120             TRAP_IGNORE(prefList.AppendL(&OCCPrefs));
       
  1121 
       
  1122             TInt ret = iConnection.Open(iSocketServ);
       
  1123             if( ret != KErrNone )
       
  1124                 {
       
  1125                 TRequestStatus* statusPtr = &aStatus;
       
  1126                 User::RequestComplete( statusPtr,ret );
       
  1127                 return;
       
  1128                 }
       
  1129             // Start an Outgoing Connection with overrides
       
  1130             iConnection.Start(prefList,iStatus);
       
  1131             // Set state to ERetriveIAP
       
  1132             iState = ERetriveIAP;
       
  1133             SetActive();
       
  1134 
       
  1135 #else
   997 #else
  1136             ConnectIAP();
   998             ConnectIAP();
  1137 #endif
   999 #endif
  1138             }
  1000             }
  1139         }
  1001         }
  1362     if (!IsActive())
  1224     if (!IsActive())
  1363         {
  1225         {
  1364         SetActive();
  1226         SetActive();
  1365         }
  1227         }
  1366     }
  1228     }
  1367 
       
  1368 // -----------------------------------------------------------------------------
  1229 // -----------------------------------------------------------------------------
  1369 // CSuplConnection::ConnectIAP
  1230 // CSuplConnection::ConnectIAP
  1370 // Makes a socket connection to Network
  1231 // Makes a socket connection to Network
  1371 // (other items were commented in a header).
  1232 // (other items were commented in a header).
  1372 // -----------------------------------------------------------------------------
  1233 // -----------------------------------------------------------------------------