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 |
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 } |